blob: b016f9af9a633f8a03bf8b868e3fa76dfbab5d00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import Qt 4.6
Rectangle {
width: 180; height: 200; color: "white"
// ContactModel model is defined in dummydata/ContactModel.qml
// The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
// Define a delegate component. A component will be
// instantiated for each visible item in the list.
//! [0]
Component {
id: delegate
Item {
id: wrapper
width: 180; height: 40
Column {
x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
}
// Use the ListView.isCurrentItem attached property to
// indent the item if it is the current item.
states: [
State {
name: "Current"
when: wrapper.ListView.isCurrentItem
PropertyChanges { target: wrapper; x: 10 }
}
]
transitions: [
Transition { NumberAnimation { matchProperties: "x"; duration: 200 } }
]
}
}
//! [0]
// Specify a highlight with custom movement. Note that autoHighlight
// is set to false in the ListView so that we can control how the
// highlight moves to the current item.
//! [1]
Component {
id: highlight
Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
y: SpringFollow {
source: list.currentItem.y
spring: 3
damping: 0.2
}
}
}
ListView {
id: list
width: parent.height; height: parent.height
model: ContactModel; delegate: delegate
highlight: highlight
highlightFollowsCurrentItem: false
focus: true
}
//! [1]
}
|