blob: bc354a9e8343aa1d21af218c982fea9d6521556c (
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
|
import Qt 4.6
Rectangle {
id: listselector
width: parent.width; height: parent.height
color: "Black"
property string text: "ListSelector"
property string value: ""
property string itemId: "0"
signal changed
function startup() {
console.log("model is: "+listModel);
}
Component.onCompleted: startup();
Component {
id: delegate
Item {
id: wrapper
width: list.width; height: 20
Column {
x: 5; y: 5
Text { text: itemName; color: "White" }
}
MouseRegion {
id:delegateMouse
anchors.fill: parent
onClicked: { list.currentIndex=itemId; listselector.value=itemName; listselector.changed() }
}
}
}
Component {
id: highlight
Rectangle {
color: "lightsteelblue"
radius: 5
}
}
Text {
id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 14;
anchors.horizontalCenter: list.horizontalCenter
anchors.verticalCenter: listselector.top
}
ListView {
id: list;
width: listselector.width*0.8; height: listselector.height
anchors.top: labelTxt.bottom;
anchors.left: listselector.left
model: listModel
delegate: delegate
highlight: highlight
focus: true
clip: true
highlightFollowsCurrentItem: true
keyNavigationWraps: true
overShoot: false
currentIndex: listselector.itemId;
}
Rectangle {
id: listScroller
opacity: 0.5; anchors.left: list.right; anchors.leftMargin: 4; width: 6
y: (list.visibleArea.yPosition * list.height)+(list.visibleArea.heightRatio * list.height/4)
height: list.visibleArea.heightRatio * list.height
}
}
|