summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-05-19 14:14:48 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-05-19 14:14:48 (GMT)
commit7bb43814f4eb919b330b29eef52efbaf92c698b0 (patch)
tree362966596016eb20f7e1f6bb1a24ae0f0f11c215 /doc/src/snippets
parent03eae0610376bec9a3b85f8fb9abc0a789322e37 (diff)
parente758b6fcbda482d1482c2a7258413711801bd746 (diff)
downloadQt-7bb43814f4eb919b330b29eef52efbaf92c698b0.zip
Qt-7bb43814f4eb919b330b29eef52efbaf92c698b0.tar.gz
Qt-7bb43814f4eb919b330b29eef52efbaf92c698b0.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
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/ContactModel.qml (renamed from doc/src/snippets/declarative/listview/dummydata/ContactModel.qml)3
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml2
-rw-r--r--doc/src/snippets/declarative/listview/listview.qml116
5 files changed, 105 insertions, 35 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/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/ContactModel.qml
index 20687cf..b930c06 100644
--- a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
+++ b/doc/src/snippets/declarative/listview/ContactModel.qml
@@ -1,7 +1,7 @@
+//![0]
import Qt 4.7
ListModel {
- id: contactModel
ListElement {
name: "Bill Smith"
number: "555 3264"
@@ -15,3 +15,4 @@ ListModel {
number: "555 0473"
}
}
+//![0]
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
index 1282f8d..794b3f2 100644
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -4,7 +4,7 @@ Rectangle {
width: 180; height: 200; 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/listview.qml b/doc/src/snippets/declarative/listview/listview.qml
index 44f0540..1e9ccd9 100644
--- a/doc/src/snippets/declarative/listview/listview.qml
+++ b/doc/src/snippets/declarative/listview/listview.qml
@@ -1,49 +1,101 @@
+//![import]
import Qt 4.7
+//![import]
-//! [3]
-Rectangle {
- width: 180; height: 200; color: "white"
+Item {
+
+//![classdocs simple]
+ListView {
+ width: 180; height: 200
+
+ model: ContactModel {}
+ delegate: Text {
+ text: name + ": " + number
+ }
+}
+//![classdocs simple]
- // ContactModel model is defined in dummydata/ContactModel.qml
- // The launcher automatically loads files in dummydata/* to assist
- // development without a real data source.
+//![classdocs advanced]
+Rectangle {
+ width: 180; height: 200
- // Define a delegate component. A component will be
- // instantiated for each visible item in the list.
-//! [0]
Component {
- id: delegate
+ id: contactDelegate
Item {
- id: wrapper
width: 180; height: 40
Column {
- x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
}
}
}
-//! [0]
- // Define a highlight component. Just one of these will be instantiated
- // by each ListView and placed behind the current item.
-//! [1]
- Component {
- id: highlight
- Rectangle {
- color: "lightsteelblue"
- radius: 5
- }
- }
-//! [1]
- // The actual list
-//! [2]
+
ListView {
- width: parent.width; height: parent.height
- model: ContactModel
- delegate: delegate
- highlight: highlight
+ anchors.fill: parent
+ model: ContactModel {}
+ delegate: contactDelegate
+ highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
}
-//! [2]
}
-//! [3]
+//![classdocs advanced]
+
+//![delayRemove]
+Component {
+ id: delegate
+ Item {
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+ }
+ }
+}
+//![delayRemove]
+
+//![highlightFollowsCurrentItem]
+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: 180; height: 200
+ model: ContactModel {}
+ delegate: Text { text: name }
+
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+}
+//![highlightFollowsCurrentItem]
+
+//![isCurrentItem]
+ListView {
+ width: 180; height: 200
+
+ Component {
+ id: contactsDelegate
+ Text {
+ id: contactInfo
+ text: name + ": " + number
+ color: contactInfo.ListView.isCurrentItem ? "red" : "black"
+ }
+ }
+
+ model: ContactModel {}
+ delegate: contactsDelegate
+ focus: true
+}
+//![isCurrentItem]
+
+}