-
Notifications
You must be signed in to change notification settings - Fork 2
/
ListView.qml
102 lines (89 loc) · 2.63 KB
/
ListView.qml
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
102
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import "." as App
Item {
id: view
width: 400
height: 400
anchors.fill: parent
ListView {
id: listView
anchors.fill: parent
anchors.margins: 20
clip: true
delegate: App.Delegate { }
focus: true
header: header
highlight: Rectangle {
width: parent.width
color: "lightgray"
radius: 5
}
highlightMoveDuration: 400
model: App.Model { }
section.property: "name"
section.criteria: ViewSection.FirstCharacter
section.delegate: sectional
section.labelPositioning: ViewSection.InlineLabels
spacing: 5
Keys.onPressed: {
if (Qt.Key_A <= event.key <= Qt.Key_Z) {
for (var i = 0; i < model.count; i++) {
if (model.get(i).name.charAt(0) === event.text) {
listView.positionViewAtIndex(i, ListView.Center);
listView.currentIndex = i;
break;
}
}
}
}
}
Component {
id: header
Item {
id: headBanner
height: childrenRect.height + 10
width: ListView.view.width
Rectangle {
color: "transparent"
height: 50
radius: 15
width: parent.width
Text {
id: headText
anchors.centerIn: parent
font.bold: true
font.pixelSize: 28
text: headBanner.ListView.view.model.count + " FontAwesome Icons"
}
}
}
}
Component {
id: sectional
Item {
id: sectionBanner
height: 40
width: ListView.view.width
Rectangle {
anchors.centerIn: parent
color: "gray"
height: 30
width: parent.width / 2
radius: height / 2
Text {
anchors.centerIn: parent
font.bold: true
font.family: awesome.family
font.pixelSize: 20
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
width: parent.width
text: fa.hand_o_right + " " + section + " " + fa.hand_o_left
}
}
}
}
Keys.onPressed: App.Actions.keyPressed(event, parent);
}