diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-11-15 07:35:12 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-11-15 07:35:12 (GMT) |
commit | 153991a45647755c0186f985da255caa09444ff4 (patch) | |
tree | 09d486e4a12b20b4891d7e71951bbfb2a0f754eb /tests | |
parent | cb25091049daf3f94445c6165d924f49f94325ab (diff) | |
download | Qt-153991a45647755c0186f985da255caa09444ff4.zip Qt-153991a45647755c0186f985da255caa09444ff4.tar.gz Qt-153991a45647755c0186f985da255caa09444ff4.tar.bz2 |
ListView: items with size < 1.0 were layed out incorrectly.
If the size of an item was less than one its endPosition() was less
than its position(), which caused incorrect layout (overlapping items).
Task-number: QTBUG-15242
Reviewed-by: Yann Bodson
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml | 26 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 36 |
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml b/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml new file mode 100644 index 0000000..77bfef8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 0.5 + width: 240 + color: ((index % 2) == 1 ? "red" : "blue") + } + } + ListView { + id: list + objectName: "list" + focus: true + width: 240 + height: 320 + model: testModel + delegate: myDelegate + } +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 79fef7a..a4b4f21 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -100,6 +100,7 @@ private slots: void QTBUG_11105(); void footer(); void resizeView(); + void sizeLessThan1(); private: template <class T> void items(); @@ -1732,6 +1733,41 @@ void tst_QDeclarativeListView::resizeView() QCOMPARE(heightRatio.toReal(), 0.25); } +void tst_QDeclarativeListView::sizeLessThan1() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/sizelessthan1.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // Confirm items positioned correctly + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*0.5); + } + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); |