aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-03-05 18:06:33 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-13 02:02:49 +0100
commit52d3d361a0db4b0cfdf795b7998733f61ca3082d (patch)
treefee6e5378568a9246ae28aa52c3195240d715e9b /tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
parentfb1ce5ed0dc037ba6cd66b34321a43a82de6bd0e (diff)
Displaced items were moving unnecessarily
They should only move if they actually change from the last set position, and not if they are simply changing from their current item position, as that is wrong during an animation. This also cleans up some code for resetting the transition data. Task-number: QTBUG-24586 Change-Id: I0a6635903975ebc40d5cf8398b943a9de92d4493 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicklistview/data/multipleDisplaced.qml')
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleDisplaced.qml78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml b/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
new file mode 100644
index 0000000000..e315270360
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
@@ -0,0 +1,78 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+
+ ListView {
+ id: list
+
+ property var displaceTransitionsStarted: new Object()
+ property bool displaceTransitionsDone: false
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ displaced: Transition {
+ id: transition
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ var name = transition.ViewTransition.item.nameData
+ if (list.displaceTransitionsStarted[name] == undefined)
+ list.displaceTransitionsStarted[name] = 0
+ list.displaceTransitionsStarted[name] += 1
+ }
+ }
+ NumberAnimation {
+ properties: "x,y"
+ duration: root.duration
+ easing.type: Easing.OutBounce
+ easing.amplitude: 10.0 // longer-lasting bounce to trigger bug
+ }
+ PropertyAction { target: list; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+