blob: 1e9ccd900ae66551799921f1f1c91528dcf6c54b (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
//![import]
import Qt 4.7
//![import]
Item {
//![classdocs simple]
ListView {
width: 180; height: 200
model: ContactModel {}
delegate: Text {
text: name + ": " + number
}
}
//![classdocs simple]
//![classdocs advanced]
Rectangle {
width: 180; height: 200
Component {
id: contactDelegate
Item {
width: 180; height: 40
Column {
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
}
}
}
ListView {
anchors.fill: parent
model: ContactModel {}
delegate: contactDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
}
}
//![classdocs advanced]
//![delayRemove]
Component {
id: delegate
Item {
ListView.onRemove: SequentialAnimation {
PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
}
}
}
//![delayRemove]
//![highlightFollowsCurrentItem]
Component {
id: highlight
Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
SpringFollow on y {
to: list.currentItem.y
spring: 3
damping: 0.2
}
}
}
ListView {
id: list
width: 180; height: 200
model: ContactModel {}
delegate: Text { text: name }
highlight: highlight
highlightFollowsCurrentItem: false
focus: true
}
//![highlightFollowsCurrentItem]
//![isCurrentItem]
ListView {
width: 180; height: 200
Component {
id: contactsDelegate
Text {
id: contactInfo
text: name + ": " + number
color: contactInfo.ListView.isCurrentItem ? "red" : "black"
}
}
model: ContactModel {}
delegate: contactsDelegate
focus: true
}
//![isCurrentItem]
}
|