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

« back to all changes in this revision

Viewing changes to tests/auto/quick/qquicklistview/data/listviewtest.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: 240
 
6
    height: 320
 
7
    color: "#ffffff"
 
8
 
 
9
    property int count: list.count
 
10
    property bool showHeader: false
 
11
    property bool showFooter: false
 
12
    property real hr: list.visibleArea.heightRatio
 
13
    function heightRatio() {
 
14
        return list.visibleArea.heightRatio
 
15
    }
 
16
 
 
17
    function checkProperties() {
 
18
        testObject.error = false;
 
19
        if (list.model != testModel) {
 
20
            console.log("model property incorrect");
 
21
            testObject.error = true;
 
22
        }
 
23
        if (!testObject.animate && list.delegate != myDelegate) {
 
24
            console.log("delegate property incorrect - expected myDelegate");
 
25
            testObject.error = true;
 
26
        }
 
27
        if (testObject.animate && list.delegate != animatedDelegate) {
 
28
            console.log("delegate property incorrect - expected animatedDelegate");
 
29
            testObject.error = true;
 
30
        }
 
31
        if (testObject.invalidHighlight && list.highlight != invalidHl) {
 
32
            console.log("highlight property incorrect - expected invalidHl");
 
33
            testObject.error = true;
 
34
        }
 
35
        if (!testObject.invalidHighlight && list.highlight != myHighlight) {
 
36
            console.log("highlight property incorrect - expected myHighlight");
 
37
            testObject.error = true;
 
38
        }
 
39
    }
 
40
    resources: [
 
41
        Component {
 
42
            id: myDelegate
 
43
            Rectangle {
 
44
                id: wrapper
 
45
                objectName: "wrapper"
 
46
                height: 20
 
47
                width: 240
 
48
                Text {
 
49
                    text: index
 
50
                }
 
51
                Text {
 
52
                    x: 30
 
53
                    id: textName
 
54
                    objectName: "textName"
 
55
                    text: name
 
56
                }
 
57
                Text {
 
58
                    x: 120
 
59
                    id: textNumber
 
60
                    objectName: "textNumber"
 
61
                    text: number
 
62
                }
 
63
                Text {
 
64
                    x: 200
 
65
                    text: wrapper.y
 
66
                }
 
67
                color: ListView.isCurrentItem ? "lightsteelblue" : "#EEEEEE"
 
68
            }
 
69
        },
 
70
        Component {
 
71
            id: animatedDelegate
 
72
            Rectangle {
 
73
                id: wrapper
 
74
                objectName: "wrapper"
 
75
                height: 20
 
76
                width: 240
 
77
                Text {
 
78
                    text: index
 
79
                }
 
80
                Text {
 
81
                    x: 30
 
82
                    id: textName
 
83
                    objectName: "textName"
 
84
                    text: name
 
85
                }
 
86
                Text {
 
87
                    x: 120
 
88
                    id: textNumber
 
89
                    objectName: "textNumber"
 
90
                    text: number
 
91
                }
 
92
                Text {
 
93
                    x: 200
 
94
                    text: wrapper.y
 
95
                }
 
96
                color: ListView.isCurrentItem ? "lightsteelblue" : "white"
 
97
                ListView.onRemove: SequentialAnimation {
 
98
                    PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
 
99
                    NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
 
100
                    PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
 
101
 
 
102
                }
 
103
            }
 
104
        },
 
105
        Component {
 
106
            id: myHighlight
 
107
            Rectangle { color: "green" }
 
108
        },
 
109
        Component {
 
110
            id: invalidHl
 
111
            SmoothedAnimation {}
 
112
        },
 
113
        Component {
 
114
            id: headerFooter
 
115
            Rectangle { height: 30; width: 240; color: "blue" }
 
116
        }
 
117
    ]
 
118
    ListView {
 
119
        id: list
 
120
        objectName: "list"
 
121
        focus: true
 
122
        width: 240
 
123
        height: 320
 
124
        model: testModel
 
125
        delegate: testObject.animate ? animatedDelegate : myDelegate
 
126
        highlight: testObject.invalidHighlight ? invalidHl : myHighlight
 
127
        highlightMoveSpeed: 1000
 
128
        highlightResizeSpeed: 1000
 
129
        cacheBuffer: testObject.cacheBuffer
 
130
        header: root.showHeader ? headerFooter : null
 
131
        footer: root.showFooter ? headerFooter : null
 
132
    }
 
133
}