aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml')
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml b/tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml
new file mode 100644
index 0000000000..d72ca51d7f
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/data/filterGroupForDelegate.qml
@@ -0,0 +1,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
+ }
+}