diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-11-15 10:19:33 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-11-15 10:19:33 (GMT) |
commit | 6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4 (patch) | |
tree | 61f8e9b589e6ab6db1a1e59676dc9f5ca91e890f | |
parent | 1150f994464719000071f7ef5836c9e1dd695c65 (diff) | |
parent | 153991a45647755c0186f985da255caa09444ff4 (diff) | |
download | Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.zip Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.tar.gz Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
3 files changed, 65 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index c7b027d..6be49ba 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -124,8 +124,8 @@ public: } qreal endPosition() const { return (view->orientation() == QDeclarativeListView::Vertical - ? item->y() + (item->height() > 0 ? item->height() : 1) - : item->x() + (item->width() > 0 ? item->width() : 1)) - 1; + ? item->y() + (item->height() >= 1.0 ? item->height() : 1) + : item->x() + (item->width() >= 1.0 ? item->width() : 1)) - 1; } void setPosition(qreal pos) { if (view->orientation() == QDeclarativeListView::Vertical) { @@ -736,7 +736,7 @@ void QDeclarativeListViewPrivate::layout() } if (!visibleItems.isEmpty()) { qreal oldEnd = visibleItems.last()->endPosition(); - qreal pos = visibleItems.first()->endPosition() + spacing + 1; + qreal pos = visibleItems.first()->position() + visibleItems.first()->size() + spacing; for (int i=1; i < visibleItems.count(); ++i) { FxListItem *item = visibleItems.at(i); item->setPosition(pos); 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>(); |