Revert "Remove properties related to highlight speed"
[profile/ivi/qtdeclarative.git] / tests / auto / quick / qquicklistview / data / listviewtest-package.qml
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 (visualModel.model != testModel) {
20             console.log("model property incorrect");
21             testObject.error = true;
22         }
23         if (!testObject.animate && visualModel.delegate != myDelegate) {
24             console.log("delegate property incorrect - expected myDelegate");
25             testObject.error = true;
26         }
27         if (testObject.animate && visualModel.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             Package {
44                 Rectangle {
45                     id: wrapper
46                     objectName: "wrapper"
47                     height: 20
48                     width: 240
49                     Package.name: "package"
50                     Text {
51                         text: index
52                     }
53                     Text {
54                         x: 30
55                         id: textName
56                         objectName: "textName"
57                         text: name
58                     }
59                     Text {
60                         x: 120
61                         id: textNumber
62                         objectName: "textNumber"
63                         text: number
64                     }
65                     Text {
66                         x: 200
67                         text: wrapper.y
68                     }
69                     color: ListView.isCurrentItem ? "lightsteelblue" : "white"
70                 }
71             }
72         },
73         Component {
74             id: animatedDelegate
75             Package {
76                 Rectangle {
77                     id: wrapper
78                     objectName: "wrapper"
79                     height: 20
80                     width: 240
81                     Package.name: "package"
82                     Text {
83                         text: index
84                     }
85                     Text {
86                         x: 30
87                         id: textName
88                         objectName: "textName"
89                         text: name
90                     }
91                     Text {
92                         x: 120
93                         id: textNumber
94                         objectName: "textNumber"
95                         text: number
96                     }
97                     Text {
98                         x: 200
99                         text: wrapper.y
100                     }
101                     color: ListView.isCurrentItem ? "lightsteelblue" : "white"
102                     ListView.onRemove: SequentialAnimation {
103                         PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
104                         NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
105                         PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
106
107                     }
108                 }
109             }
110         },
111         Component {
112             id: myHighlight
113             Rectangle { color: "green" }
114         },
115         Component {
116             id: invalidHl
117             SmoothedAnimation {}
118         },
119         Component {
120             id: headerFooter
121             Rectangle { height: 30; width: 240; color: "blue" }
122         },
123         VisualDataModel {
124            id: visualModel
125
126            model: testModel
127            delegate: testObject.animate ? animatedDelegate : myDelegate
128         }
129
130     ]
131     ListView {
132         id: list
133         objectName: "list"
134         focus: true
135         width: 240
136         height: 320
137         model: visualModel.parts.package
138         highlight: testObject.invalidHighlight ? invalidHl : myHighlight
139         highlightMoveSpeed: 1000
140         highlightResizeSpeed: 1000
141         cacheBuffer: testObject.cacheBuffer
142         header: root.showHeader ? headerFooter : null
143         footer: root.showFooter ? headerFooter : null
144     }
145 }