summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/gridview
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-06-01 06:27:59 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-06-02 00:07:33 (GMT)
commit9cb0802cede5f9fd91ca303bcec5ae869acae951 (patch)
treef90d5fed5004dfa7e526783d81f94f04444313e4 /doc/src/snippets/declarative/gridview
parent2e904930ede28a59710ef6f898419aba7ede7c06 (diff)
downloadQt-9cb0802cede5f9fd91ca303bcec5ae869acae951.zip
Qt-9cb0802cede5f9fd91ca303bcec5ae869acae951.tar.gz
Qt-9cb0802cede5f9fd91ca303bcec5ae869acae951.tar.bz2
Doc fixes and improvements - fix some example code, link to
examples from class docs and improve assorted docs
Diffstat (limited to 'doc/src/snippets/declarative/gridview')
-rw-r--r--doc/src/snippets/declarative/gridview/ContactModel.qml (renamed from doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml)14
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml110
2 files changed, 85 insertions, 39 deletions
diff --git a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/gridview/ContactModel.qml
index 1e79030..2da4660 100644
--- a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
+++ b/doc/src/snippets/declarative/gridview/ContactModel.qml
@@ -39,28 +39,26 @@
**
****************************************************************************/
+//![0]
import Qt 4.7
ListModel {
- id: contactModel
+
ListElement {
- name: "Bill Smith"
- number: "555 3264"
+ name: "Jim Williams"
portrait: "pics/portrait.png"
}
ListElement {
- name: "Jim Williams"
- number: "555 5673"
+ name: "John Brown"
portrait: "pics/portrait.png"
}
ListElement {
- name: "John Brown"
- number: "555 8426"
+ name: "Bill Smyth"
portrait: "pics/portrait.png"
}
ListElement {
name: "Sam Wise"
- number: "555 0473"
portrait: "pics/portrait.png"
}
}
+//![0]
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
index 3c205bc..0b3bbf3 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -39,50 +39,98 @@
**
****************************************************************************/
+//![import]
import Qt 4.7
+//![import]
-//! [3]
Rectangle {
- width: 240; height: 180; 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]
+ width: childrenRect.width; height: childrenRect.height
+
+Row {
+
+//![classdocs simple]
+GridView {
+ width: 300; height: 200
+
+ model: ContactModel {}
+ delegate: Column {
+ Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
+ Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
+ }
+}
+//![classdocs simple]
+
+
+//![classdocs advanced]
+Rectangle {
+ width: 300; height: 200
+
Component {
- id: delegate
+ id: contactDelegate
Item {
- id: wrapper
- width: 80; height: 78
+ width: grid.cellWidth; height: grid.cellHeight
Column {
+ anchors.fill: parent
Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
}
}
}
-//! [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 grid
-//! [2]
+
GridView {
- width: parent.width; height: parent.height
- model: ContactModel; delegate: delegate
+ id: grid
+ anchors.fill: parent
cellWidth: 80; cellHeight: 80
- highlight: highlight
+
+ model: ContactModel {}
+ delegate: contactDelegate
+ highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
}
-//! [2]
}
-//! [3]
+//![classdocs advanced]
+
+//![delayRemove]
+Component {
+ id: delegate
+ Item {
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
+ PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false }
+ }
+ }
+}
+//![delayRemove]
+
+//![highlightFollowsCurrentItem]
+Component {
+ id: highlight
+ Rectangle {
+ width: view.cellWidth; height: view.cellHeight
+ color: "lightsteelblue"; radius: 5
+ SpringFollow on x { to: view.currentItem.x; spring: 3; damping: 0.2 }
+ SpringFollow on y { to: view.currentItem.y; spring: 3; damping: 0.2 }
+ }
+}
+
+GridView {
+ id: view
+ width: 300; height: 200
+ cellWidth: 80; cellHeight: 80
+
+ model: ContactModel {}
+ delegate: Column {
+ Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
+ Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
+ }
+
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+}
+//![highlightFollowsCurrentItem]
+
+}
+
+}