diff options
author | Christiaan Janssen <christiaan.janssen@digia.com> | 2012-11-22 17:54:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-23 11:14:41 +0100 |
commit | cef169a9eb12a860b3c0ccb1bf50b2c8cfaff9f8 (patch) | |
tree | 910311b23627dca4bfe7b78df9c04a9458c98b97 | |
parent | 543f6d4c4510c6cbf79b98abde8651d98562a834 (diff) |
QtDeclarative: fixed modelviews example
Change-Id: I3d31beb6a23b7c74061cf66d3c13616911cda7c6
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r-- | examples/quick/modelviews/listview/highlight.qml | 1 | ||||
-rw-r--r-- | examples/quick/modelviews/listview/highlightranges.qml | 41 |
2 files changed, 27 insertions, 15 deletions
diff --git a/examples/quick/modelviews/listview/highlight.qml b/examples/quick/modelviews/listview/highlight.qml index ec33cda722..bf6c9028c5 100644 --- a/examples/quick/modelviews/listview/highlight.qml +++ b/examples/quick/modelviews/listview/highlight.qml @@ -91,6 +91,7 @@ Rectangle { ListView { id: listView width: 200; height: parent.height + x: 30 model: PetsModel {} delegate: petDelegate diff --git a/examples/quick/modelviews/listview/highlightranges.qml b/examples/quick/modelviews/listview/highlightranges.qml index 815890f89b..f0cc1421f0 100644 --- a/examples/quick/modelviews/listview/highlightranges.qml +++ b/examples/quick/modelviews/listview/highlightranges.qml @@ -45,25 +45,36 @@ import "content" Rectangle { id: root property int current: 0 + property bool increasing: true // Example index automation for convenience, disabled on click or tap - SequentialAnimation on current { + SequentialAnimation { id: anim loops: -1 - NumberAnimation { - duration: 5000 - to: aModel.count - 1 - } - NumberAnimation { - duration: 5000 - to: 0 + running: true + ScriptAction { + script: if (increasing) { + current++; + if (current >= aModel.count -1) { + current = aModel.count - 1; + increasing = !increasing; + } + } else { + current--; + if (current <= 0) { + current = 0; + increasing = !increasing; + } + } } + + PauseAnimation { duration: 500 } } //! [0] MouseArea{ id: ma z: 1 anchors.fill: parent - onClicked: {ma.enabled = false; anim.running = false;} + onClicked: { z = 1 - z; if (anim.running) anim.stop(); else anim.restart();} } width: 320; height: 480 @@ -94,7 +105,7 @@ Rectangle { //! [1] ListView { id: list1 - height: 160; width: parent.width + height: 50; width: parent.width model: PetsModel {id: aModel} delegate: petDelegate orientation: ListView.Horizontal @@ -107,8 +118,8 @@ Rectangle { ListView { id: list2 - y: list1.height - height: 160; width: parent.width + y: 160 + height: 50; width: parent.width model: PetsModel {} delegate: petDelegate orientation: ListView.Horizontal @@ -121,8 +132,8 @@ Rectangle { ListView { id: list3 - y: list1.height + list2.height - height: 160; width: parent.width + y: 320 + height: 50; width: parent.width model: PetsModel {} delegate: petDelegate orientation: ListView.Horizontal @@ -149,7 +160,7 @@ Rectangle { MouseArea { anchors.fill: parent - onClicked: wrapper.ListView.view.currentIndex = index + onClicked: root.current = index } } } |