Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qmlvisual / ListView / listview.qml
1 import QtQuick 1.0
2
3 Rectangle {
4     id: root
5     property int current: 0
6     width: 600; height: 300; color: "white"
7
8     ListModel {
9         id: myModel
10         ListElement {
11             itemColor: "red"
12         }
13         ListElement {
14             itemColor: "green"
15         }
16         ListElement {
17             itemColor: "blue"
18         }
19         ListElement {
20             itemColor: "orange"
21         }
22         ListElement {
23             itemColor: "brown"
24         }
25         ListElement {
26             itemColor: "yellow"
27         }
28         ListElement {
29             itemColor: "purple"
30         }
31         ListElement {
32             itemColor: "darkred"
33         }
34         ListElement {
35             itemColor: "darkblue"
36         }
37     }
38
39     Component {
40         id: myDelegate
41         Item {
42             width: 200; height: 50
43             Rectangle {
44                 x: 5; y : 5
45                 width: 190; height: 40
46                 opacity: 0.5
47                 color: itemColor
48             }
49         }
50     }
51
52     Component {
53         id: myHighlight
54         Rectangle { width: 200; height: 50; color: "black" }
55     }
56
57     ListView {
58         id: list1
59         width: 200; height: parent.height
60         model: myModel; delegate: myDelegate
61         highlight: myHighlight
62         currentIndex: root.current
63         onCurrentIndexChanged: root.current = currentIndex
64         focus: true
65     }
66     ListView {
67         id: list2
68         x: 200; width: 200; height: parent.height
69         model: myModel; delegate: myDelegate; highlight: myHighlight
70         preferredHighlightBegin: 80
71         preferredHighlightEnd: 220
72         highlightRangeMode: "ApplyRange"
73         currentIndex: root.current
74     }
75     ListView {
76         id: list3
77         x: 400; width: 200; height: parent.height
78         model: myModel; delegate: myDelegate; highlight: myHighlight
79         currentIndex: root.current
80         onCurrentIndexChanged: root.current = currentIndex
81         preferredHighlightBegin: 125
82         preferredHighlightEnd: 125
83         highlightRangeMode: "StrictlyEnforceRange"
84         flickDeceleration: 1000
85     }
86 }