diff options
Diffstat (limited to 'tests/auto/quick/qquicklistview/data')
3 files changed, 248 insertions, 1 deletions
diff --git a/tests/auto/quick/qquicklistview/data/displacedTransitions.qml b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml new file mode 100644 index 0000000000..cc7892e930 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml @@ -0,0 +1,128 @@ +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" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == displaced_transitionVia) + model_displaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == addDisplaced_transitionVia) + model_addDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == moveDisplaced_transitionVia) + model_moveDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == removeDisplaced_transitionVia) + model_removeDisplaced_transitionVia.addItem(name, "") + } + } + } + + ListView { + id: list + + property int targetTransitionsDone + property int displaceTransitionsDone + + objectName: "list" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + displaced: useDisplaced ? displaced : null + addDisplaced: useAddDisplaced ? addDisplaced : null + moveDisplaced: useMoveDisplaced ? moveDisplaced : null + removeDisplaced: useRemoveDisplaced ? removeDisplaced : null + + Transition { + id: displaced + enabled: displacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: addDisplaced + enabled: addDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: moveDisplaced + enabled: moveDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: removeDisplaced + enabled: removeDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + } + + Rectangle { + anchors.fill: list + color: "lightsteelblue" + opacity: 0.2 + } +} + diff --git a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml index 50ffbc53c3..8264b42b64 100644 --- a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml +++ b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml @@ -10,7 +10,7 @@ Rectangle { // interrupting transitions will still produce the correct result) property int timeBetweenActions: duration / 2 - property int duration: 100 + property int duration: 300 property int count: list.count @@ -45,6 +45,8 @@ Rectangle { property bool runningAddDisplaced: false property bool runningMoveTargets: false property bool runningMoveDisplaced: false + property bool runningRemoveTargets: false + property bool runningRemoveDisplaced: false objectName: "list" focus: true @@ -70,6 +72,7 @@ Rectangle { id: addDisplaced SequentialAnimation { ScriptAction { script: list.runningAddDisplaced = true } + PauseAnimation { duration: rippleAddDisplaced ? addDisplaced.ViewTransition.index * root.duration/10 : 0 } ParallelAnimation { NumberAnimation { properties: "x"; from: addDisplaced_transitionFrom.x; duration: root.duration } NumberAnimation { properties: "y"; from: addDisplaced_transitionFrom.y; duration: root.duration } @@ -101,6 +104,30 @@ Rectangle { ScriptAction { script: list.runningMoveDisplaced = false } } } + + remove: Transition { + id: removeTargets + SequentialAnimation { + ScriptAction { script: list.runningRemoveTargets = true } + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveTargets = false } + } + } + + removeDisplaced: Transition { + id: removeDisplaced + SequentialAnimation { + ScriptAction { script: list.runningRemoveDisplaced = true } + ParallelAnimation { + NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration } + NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveDisplaced = false } + } + } } Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml new file mode 100644 index 0000000000..f4679b5af0 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml @@ -0,0 +1,92 @@ +import QtQuick 2.0 + +Rectangle { + width: 320; height: 480 + + Rectangle { + id: groupButtons + width: 300; height: 30 + color: "yellow" + border.width: 1 + Text { + anchors.centerIn: parent + text: "swap" + } + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + } + MouseArea { + anchors.fill: parent + onClicked: switchGroups() + } + } + + function switchGroups() { + if ("title" === myListView.groupBy) + myListView.groupBy = "genre" + else + myListView.groupBy = "title" + } + + Component.onCompleted: { + myListView.model = generateModel(myListView) + } + + ListView { + id: myListView + objectName: "list" + + clip: true + property string groupBy: "title" + + anchors { + top: groupButtons.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + + delegate: Item { + objectName: "wrapper" + height: 50 + width: 320 + Text { id: t; text: model.title } + Text { text: model.author; font.pixelSize: 10; anchors.top: t.bottom } + Text { text: parent.y; anchors.right: parent.right } + } + + onGroupByChanged: { + model.move(0,1,1) + section.property = groupBy + } + + section { + criteria: ViewSection.FullString + delegate: Rectangle { width: 320; height: 25; color: "lightblue" + objectName: "sect" + Text {text: section } + Text { text: parent.y; anchors.right: parent.right } + } + property: "title" + } + } + + function generateModel(theParent) + { + var books = [ + { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" }, + { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" } + ]; + + var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent); + + for (var i = 0; i < books.length; ++i) { + var book = books[i]; + model.append(book); + } + return model; + } + +} + |