~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to tests/auto/quick/qquicklistview/data/addTransitions.qml

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
 
 
3
Rectangle {
 
4
    id: root
 
5
    width: 500
 
6
    height: 600
 
7
 
 
8
    property int duration: 10
 
9
    property int count: list.count
 
10
 
 
11
    Component {
 
12
        id: myDelegate
 
13
        Rectangle {
 
14
            id: wrapper
 
15
 
 
16
            property string nameData: name
 
17
 
 
18
            objectName: "wrapper"
 
19
            height: 20
 
20
            width: 240
 
21
            Text { text: index }
 
22
            Text {
 
23
                x: 30
 
24
                id: textName
 
25
                objectName: "textName"
 
26
                text: name
 
27
            }
 
28
            Text {
 
29
                x: 200
 
30
                text: wrapper.y
 
31
            }
 
32
            color: ListView.isCurrentItem ? "lightsteelblue" : "white"
 
33
 
 
34
            onXChanged: checkPos()
 
35
            onYChanged: checkPos()
 
36
 
 
37
            function checkPos() {
 
38
                if (Qt.point(x, y) == targetItems_transitionFrom)
 
39
                    model_targetItems_transitionFrom.addItem(name, "")
 
40
                if (Qt.point(x, y) == displacedItems_transitionVia)
 
41
                    model_displacedItems_transitionVia.addItem(name, "")
 
42
            }
 
43
        }
 
44
    }
 
45
 
 
46
    ListView {
 
47
        id: list
 
48
 
 
49
        property int targetTransitionsDone
 
50
        property int displaceTransitionsDone
 
51
 
 
52
        property var targetTrans_items: new Object()
 
53
        property var targetTrans_targetIndexes: new Array()
 
54
        property var targetTrans_targetItems: new Array()
 
55
 
 
56
        property var displacedTrans_items: new Object()
 
57
        property var displacedTrans_targetIndexes: new Array()
 
58
        property var displacedTrans_targetItems: new Array()
 
59
 
 
60
        objectName: "list"
 
61
        focus: true
 
62
        anchors.centerIn: parent
 
63
        width: 240
 
64
        height: 320
 
65
        model: testModel
 
66
        delegate: myDelegate
 
67
 
 
68
        // for QQmlListProperty types
 
69
        function copyList(propList) {
 
70
            var temp = new Array()
 
71
            for (var i=0; i<propList.length; i++)
 
72
                temp.push(propList[i])
 
73
            return temp
 
74
        }
 
75
 
 
76
        add: Transition {
 
77
            id: targetTransition
 
78
 
 
79
            SequentialAnimation {
 
80
                ScriptAction {
 
81
                    script: {
 
82
                        list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
 
83
                        list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
 
84
                        list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
 
85
                    }
 
86
                }
 
87
                ParallelAnimation {
 
88
                    NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
 
89
                    NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
 
90
                }
 
91
 
 
92
                ScriptAction { script: list.targetTransitionsDone += 1 }
 
93
            }
 
94
        }
 
95
 
 
96
        addDisplaced: Transition {
 
97
            id: displaced
 
98
 
 
99
            SequentialAnimation {
 
100
                ScriptAction {
 
101
                    script: {
 
102
                        list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
 
103
                        list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
 
104
                        list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
 
105
                    }
 
106
                }
 
107
                ParallelAnimation {
 
108
                    NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
 
109
                    NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
 
110
                }
 
111
                NumberAnimation { properties: "x,y"; duration: root.duration }
 
112
 
 
113
                ScriptAction { script: list.displaceTransitionsDone += 1 }
 
114
            }
 
115
 
 
116
        }
 
117
    }
 
118
 
 
119
    Rectangle {
 
120
        anchors.fill: list
 
121
        color: "lightsteelblue"
 
122
        opacity: 0.2
 
123
    }
 
124
 
 
125
    // XXX will it pass without these if I just wait for polish?
 
126
    // check all of these tests - if not, then mark this bit with the bug number!
 
127
    Rectangle {
 
128
        anchors.bottom: parent.bottom
 
129
        width: 20; height: 20
 
130
        color: "white"
 
131
        NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
 
132
    }
 
133
}
 
134