summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-19 07:10:14 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-19 07:10:14 (GMT)
commitd395903e4d061a30117f7b925bdad41771a29067 (patch)
treee7e2e2d09afc77af51197f5d4954249b21ee9a44 /doc/src/snippets
parent8238ef5d6648ca8fde2c709d6125772cac6a11a5 (diff)
parentf5588a2177452de29804e67ae8cd45c50f6dfdba (diff)
downloadQt-d395903e4d061a30117f7b925bdad41771a29067.zip
Qt-d395903e4d061a30117f7b925bdad41771a29067.tar.gz
Qt-d395903e4d061a30117f7b925bdad41771a29067.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts: doc/src/snippets/declarative/listview/highlight.qml doc/src/snippets/declarative/listview/listview.qml
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/declarative/folderlistmodel.qml17
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml2
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml63
3 files changed, 81 insertions, 1 deletions
diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/declarative/folderlistmodel.qml
new file mode 100644
index 0000000..e90f9fd
--- /dev/null
+++ b/doc/src/snippets/declarative/folderlistmodel.qml
@@ -0,0 +1,17 @@
+//![0]
+import Qt 4.7
+import Qt.labs.folderlistmodel 1.0
+
+ListView {
+ FolderListModel {
+ id: foldermodel
+ nameFilters: ["*.qml"]
+ }
+ Component {
+ id: filedelegate
+ Text { text: fileName }
+ }
+ model: foldermodel
+ delegate: filedelegate
+}
+//![0]
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
index cf345aa..1d3df97 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -4,7 +4,7 @@ import Qt 4.7
Rectangle {
width: 240; height: 180; color: "white"
// ContactModel model is defined in dummydata/ContactModel.qml
- // The launcher automatically loads files in dummydata/* to assist
+ // The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
// Define a delegate component. A component will be
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
new file mode 100644
index 0000000..794b3f2
--- /dev/null
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -0,0 +1,63 @@
+import Qt 4.7
+
+Rectangle {
+ width: 180; height: 200; color: "white"
+
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ // Use the ListView.isCurrentItem attached property to
+ // indent the item if it is the current item.
+ states: [
+ State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 10 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x"; duration: 200 } }
+ ]
+ }
+ }
+//! [0]
+ // Specify a highlight with custom movement. Note that autoHighlight
+ // is set to false in the ListView so that we can control how the
+ // highlight moves to the current item.
+//! [1]
+ Component {
+ id: highlight
+ Rectangle {
+ width: 180; height: 40
+ color: "lightsteelblue"; radius: 5
+ SpringFollow on y {
+ to: list.currentItem.y
+ spring: 3
+ damping: 0.2
+ }
+ }
+ }
+ ListView {
+ id: list
+ width: parent.height; height: parent.height
+ model: ContactModel; delegate: delegate
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+ }
+//! [1]
+}