}
function switchGroups() {
+ myListView.model.move(0,1,1)
if ("title" === myListView.groupBy)
myListView.groupBy = "genre"
else
myListView.groupBy = "title"
}
+ function switchGrouped() {
+ if ("pageCount" === myListView.groupBy)
+ myListView.groupBy = "genre"
+ else
+ myListView.groupBy = "pageCount"
+ }
+
Component.onCompleted: {
myListView.model = generateModel(myListView)
}
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"
Text {text: section }
Text { text: parent.y; anchors.right: parent.right }
}
- property: "title"
+ property: myListView.groupBy
}
}
function generateModel(theParent)
{
var books = [
- { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" },
- { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" }
+ { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love", "pageCount": 80 },
+ { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs", "pageCount": 80 }
];
var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent);
QTRY_COMPARE(item->y(), qreal(25. + i*75.));
}
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGrouped");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*50.));
+ }
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGrouped");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
delete canvas;
}