summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/gridview/gridview.qml
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-06-15 07:50:47 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-06-15 07:50:47 (GMT)
commit45d9575a8c680206cdea0519b03996b6b8085294 (patch)
treed156b7d5c2dc0633c4468dce4cae4f0daf9e0035 /doc/src/snippets/declarative/gridview/gridview.qml
parent01506a3b212d449d65df1131b49af0e174e45275 (diff)
parentc1e6d97b9476c859abc3927046144b4006fcf735 (diff)
downloadQt-45d9575a8c680206cdea0519b03996b6b8085294.zip
Qt-45d9575a8c680206cdea0519b03996b6b8085294.tar.gz
Qt-45d9575a8c680206cdea0519b03996b6b8085294.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'doc/src/snippets/declarative/gridview/gridview.qml')
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml110
1 files changed, 79 insertions, 31 deletions
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]
+
+}
+
+}