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

« back to all changes in this revision

Viewing changes to tests/auto/quick/qquicklistview/data/multipleTransitions.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
    // time to pause between each add, remove, etc.
 
9
    // (obviously, must be less than 'duration' value to actually test that
 
10
    // interrupting transitions will still produce the correct result)
 
11
    property int timeBetweenActions: duration / 2
 
12
 
 
13
    property int duration: 100
 
14
 
 
15
    property int count: list.count
 
16
 
 
17
    Component {
 
18
        id: myDelegate
 
19
        Rectangle {
 
20
            id: wrapper
 
21
            objectName: "wrapper"
 
22
            height: 20
 
23
            width: 240
 
24
            Text { text: index }
 
25
            Text {
 
26
                x: 30
 
27
                id: textName
 
28
                objectName: "textName"
 
29
                text: name
 
30
            }
 
31
            Text {
 
32
                x: 200
 
33
                text: wrapper.y
 
34
            }
 
35
            color: ListView.isCurrentItem ? "lightsteelblue" : "white"
 
36
        }
 
37
    }
 
38
 
 
39
    ListView {
 
40
        id: list
 
41
 
 
42
        property bool populateDone
 
43
 
 
44
        property bool runningAddTargets: false
 
45
        property bool runningAddDisplaced: false
 
46
        property bool runningMoveTargets: false
 
47
        property bool runningMoveDisplaced: false
 
48
        property bool runningRemoveTargets: false
 
49
        property bool runningRemoveDisplaced: false
 
50
 
 
51
        objectName: "list"
 
52
        focus: true
 
53
        anchors.centerIn: parent
 
54
        width: 240
 
55
        height: 320
 
56
        model: testModel
 
57
        delegate: myDelegate
 
58
 
 
59
        add: Transition {
 
60
            id: addTargets
 
61
            enabled: enableAddTransitions
 
62
            SequentialAnimation {
 
63
                ScriptAction { script: list.runningAddTargets = true }
 
64
                ParallelAnimation {
 
65
                    NumberAnimation { properties: "x"; from: addTargets_transitionFrom.x; duration: root.duration }
 
66
                    NumberAnimation { properties: "y"; from: addTargets_transitionFrom.y; duration: root.duration }
 
67
                }
 
68
                ScriptAction { script: list.runningAddTargets = false }
 
69
            }
 
70
        }
 
71
 
 
72
        addDisplaced: Transition {
 
73
            id: addDisplaced
 
74
            enabled: enableAddTransitions
 
75
            SequentialAnimation {
 
76
                ScriptAction { script: list.runningAddDisplaced = true }
 
77
                PauseAnimation { duration: rippleAddDisplaced ? addDisplaced.ViewTransition.index * root.duration/10 : 0 }
 
78
                ParallelAnimation {
 
79
                    NumberAnimation { properties: "x"; from: addDisplaced_transitionFrom.x; duration: root.duration }
 
80
                    NumberAnimation { properties: "y"; from: addDisplaced_transitionFrom.y; duration: root.duration }
 
81
                }
 
82
                ScriptAction { script: list.runningAddDisplaced = false }
 
83
            }
 
84
        }
 
85
 
 
86
        move: Transition {
 
87
            id: moveTargets
 
88
            enabled: enableMoveTransitions
 
89
            SequentialAnimation {
 
90
                ScriptAction { script: list.runningMoveTargets = true }
 
91
                ParallelAnimation {
 
92
                    NumberAnimation { properties: "x"; from: moveTargets_transitionFrom.x; duration: root.duration }
 
93
                    NumberAnimation { properties: "y"; from: moveTargets_transitionFrom.y; duration: root.duration }
 
94
                }
 
95
                ScriptAction { script: list.runningMoveTargets = false }
 
96
            }
 
97
        }
 
98
 
 
99
        moveDisplaced: Transition {
 
100
            id: moveDisplaced
 
101
            enabled: enableMoveTransitions
 
102
            SequentialAnimation {
 
103
                ScriptAction { script: list.runningMoveDisplaced = true }
 
104
                ParallelAnimation {
 
105
                    NumberAnimation { properties: "x"; from: moveDisplaced_transitionFrom.x; duration: root.duration }
 
106
                    NumberAnimation { properties: "y"; from: moveDisplaced_transitionFrom.y; duration: root.duration }
 
107
                }
 
108
                ScriptAction { script: list.runningMoveDisplaced = false }
 
109
            }
 
110
        }
 
111
 
 
112
        remove: Transition {
 
113
            id: removeTargets
 
114
            enabled: enableRemoveTransitions
 
115
            SequentialAnimation {
 
116
                ScriptAction { script: list.runningRemoveTargets = true }
 
117
                ParallelAnimation {
 
118
                    NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration }
 
119
                    NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration }
 
120
                }
 
121
                ScriptAction { script: list.runningRemoveTargets = false }
 
122
            }
 
123
        }
 
124
 
 
125
        removeDisplaced: Transition {
 
126
            id: removeDisplaced
 
127
            enabled: enableRemoveTransitions
 
128
            SequentialAnimation {
 
129
                ScriptAction { script: list.runningRemoveDisplaced = true }
 
130
                ParallelAnimation {
 
131
                    NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration }
 
132
                    NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration }
 
133
                }
 
134
                ScriptAction { script: list.runningRemoveDisplaced = false }
 
135
            }
 
136
        }
 
137
    }
 
138
 
 
139
    Rectangle {
 
140
        anchors.fill: list
 
141
        color: "lightsteelblue"
 
142
        opacity: 0.2
 
143
    }
 
144
 
 
145
    Rectangle {
 
146
        anchors.bottom: parent.bottom
 
147
        width: 20; height: 20
 
148
        color: "white"
 
149
        NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
 
150
    }
 
151
}
 
152
 
 
153
 
 
154