aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-06-26 09:13:52 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-26 08:08:32 +0200
commit4089c2bbc51717a642f17c76c17c9ca73e180f00 (patch)
tree8b829f1f61c1c76f6594457b4b1a9f9418f25d20 /tests
parent058a9ca9a25c4ea5679c741e1a19fe996e23a932 (diff)
Position section headers correctly when section property changes.
Schedule a new layout after the section property is changed to correct item positions if section headers are added or removed. Task-number: QTBUG-24900 Change-Id: I7e46ec6dc00e5a810029396a4c5ca4e87ee1d94d Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklistview/data/sectionpropertychange.qml19
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp20
2 files changed, 31 insertions, 8 deletions
diff --git a/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
index f4679b5af0..feb22404d0 100644
--- a/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
+++ b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
@@ -23,12 +23,20 @@ Rectangle {
}
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)
}
@@ -56,11 +64,6 @@ Rectangle {
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"
@@ -68,15 +71,15 @@ Rectangle {
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);
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index f051e5baca..c6a72306f9 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -2408,6 +2408,26 @@ void tst_QQuickListView::sectionPropertyChange()
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;
}