blob: d72ca51d7fb4fcb89552a8c8db0602eea8d8c067 (
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
|
import QtQml.Models 2.12
import Qt.labs.qmlmodels 1.0
import QtQuick 2.12
Item {
id: root
width: 200
height: 320
property int numChanges: 0
property bool ok: true
DelegateModel {
id: theModel
model: ListModel {
ListElement { role: "section" }
ListElement { role: "item" }
ListElement { role: "section" }
ListElement { role: "item" }
ListElement { role: "section" }
ListElement { role: "item" }
ListElement { role: "item" }
ListElement { role: "item" }
}
filterOnGroup: "expanded"
groups: DelegateModelGroup {
name: "expanded"
}
delegate: DelegateChooser {
role: "role"
DelegateChoice {
roleValue: "section"
Text {
text: "+ Section " + index
Timer {
interval: (index + 10)
repeat: true
running: true
onTriggered: {
++ root.numChanges;
if (model.role !== "section") {
root.ok = false;
console.warn("wrong!", root.numChanges);
}
let i = parent.DelegateModel.itemsIndex + 1;
for (; i < theModel.items.count; ++i) {
let item = theModel.items.get(i);
if (item.model.role === "section")
break;
item.inExpanded = !item.inExpanded;
}
}
}
}
}
DelegateChoice {
roleValue: "item"
Text {
text: "Item " + index
}
}
}
Component.onCompleted: items.addGroups(0, items.count, ["expanded"])
}
ListView {
anchors.fill: parent
model: theModel
}
}
|