aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicklistview/data/sectionpropertychange.qml')
-rw-r--r--tests/auto/quick/qquicklistview/data/sectionpropertychange.qml92
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
new file mode 100644
index 0000000000..f4679b5af0
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
@@ -0,0 +1,92 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 320; height: 480
+
+ Rectangle {
+ id: groupButtons
+ width: 300; height: 30
+ color: "yellow"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: "swap"
+ }
+ anchors {
+ top: parent.top
+ horizontalCenter: parent.horizontalCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: switchGroups()
+ }
+ }
+
+ function switchGroups() {
+ if ("title" === myListView.groupBy)
+ myListView.groupBy = "genre"
+ else
+ myListView.groupBy = "title"
+ }
+
+ Component.onCompleted: {
+ myListView.model = generateModel(myListView)
+ }
+
+ ListView {
+ id: myListView
+ objectName: "list"
+
+ clip: true
+ property string groupBy: "title"
+
+ anchors {
+ top: groupButtons.bottom
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+
+ delegate: Item {
+ objectName: "wrapper"
+ height: 50
+ width: 320
+ Text { id: t; text: model.title }
+ Text { text: model.author; font.pixelSize: 10; anchors.top: t.bottom }
+ Text { text: parent.y; anchors.right: parent.right }
+ }
+
+ onGroupByChanged: {
+ model.move(0,1,1)
+ section.property = groupBy
+ }
+
+ section {
+ criteria: ViewSection.FullString
+ delegate: Rectangle { width: 320; height: 25; color: "lightblue"
+ objectName: "sect"
+ Text {text: section }
+ Text { text: parent.y; anchors.right: parent.right }
+ }
+ property: "title"
+ }
+ }
+
+ function generateModel(theParent)
+ {
+ var books = [
+ { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" },
+ { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" }
+ ];
+
+ var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent);
+
+ for (var i = 0; i < books.length; ++i) {
+ var book = books[i];
+ model.append(book);
+ }
+ return model;
+ }
+
+}
+