blob: 66b76191a5b91295d6b54cac4e4aa2b2f3a4e818 (
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
|
import QtQuick 2.0
import Qt.location 5.0
Item {
id: root
property variant model
signal categorySelected(variant category)
ListView {
id: categoriesList
anchors.top: parent.top
anchors.bottom: toolbar.top
anchors.bottomMargin: 5
anchors.left: parent.left
anchors.right: parent.right
model: VisualDataModel {
id: categoryListModel
model: root.model
delegate: CategoryDelegate {
category: model.category
hasSubCategories: model.hasModelChildren
onClicked: categorySelected(category)
onDisplaySubCategories: categoryListModel.rootIndex = categoryListModel.modelIndex(index)
}
}
clip: true
snapMode: ListView.SnapToItem
}
Row {
id: toolbar
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
height: root.model.hierarchical ? childrenRect.height : 0
visible: root.model.hierarchical
Button {
text: qsTr("Back")
onClicked: categoryListModel.rootIndex = categoryListModel.parentModelIndex()
}
}
}
|