-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.qml
84 lines (76 loc) · 2.21 KB
/
main.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
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
import SortFilterProxyModel 0.2
import QtQuick.Controls.Material 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("SFPM Showcase")
ContactModel {
id: contactModel
}
SortFilterProxyModel {
id: proxyModel
sourceModel: contactModel
sorters: [
RoleSorter { roleName: "favorite"; sortOrder: Qt.DescendingOrder },
StringSorter { roleName: "firstName" },
StringSorter { roleName: "lastName" }
]
filters: [
ValueFilter {
id: favoriteFilter
roleName: "favorite"
enabled: searchBar.filterFavorite
value: true
},
AnyOf {
RegExpFilter {
roleName: "firstName"
pattern: "^" + searchBar.text
caseSensitivity: Qt.CaseInsensitive
}
RegExpFilter {
roleName: "lastName"
pattern: "^" + searchBar.text
caseSensitivity: Qt.CaseInsensitive
}
}
]
proxyRoles: SwitchRole {
name: "sectionRole"
filters: ValueFilter {
roleName: "favorite"
value: true
SwitchRole.value: "*"
}
defaultRoleName: "firstName"
}
}
ColumnLayout {
anchors.fill: parent
spacing: 0
SearchBar {
id: searchBar
Layout.fillWidth: true
z: 1
}
ListView {
id: listView
Layout.fillWidth: true
Layout.fillHeight: true
//snapMode: ListView.SnapToItem
model: proxyModel
delegate: ContactDelegate { }
section {
property: "sectionRole"
criteria: ViewSection.FirstCharacter
labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
delegate: SectionDelegate { }
}
ScrollBar.vertical: SectionScrollBar { }
}
}
}