diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-02-25 03:07:04 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-02-25 03:26:18 (GMT) |
commit | eeea1dd085d4712ce78166bdf8769e4270e2d831 (patch) | |
tree | dfca5db9f306b400ed7a25a210a453e8dee91a72 /tests/auto/declarative/qdeclarativelistview | |
parent | fbf73dec65df9c27a3a09ca9b436f5f8cb9f1b0e (diff) | |
download | Qt-eeea1dd085d4712ce78166bdf8769e4270e2d831.zip Qt-eeea1dd085d4712ce78166bdf8769e4270e2d831.tar.gz Qt-eeea1dd085d4712ce78166bdf8769e4270e2d831.tar.bz2 |
Ensure layout is updated when section property changes.
When the section property changed the sections were recalculated,
but the items were not relayouted.
Also avoid 'Unable to assign undefined value' warning by setting
section item parent before component is completed.
Change-Id: I7bd8eb369877a6faf72b32b80b45a68366c95772
Task-number: QTBUG-17759
Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistview')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml | 3 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml index 9d9cda8..b2d9213 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml @@ -1,6 +1,7 @@ import QtQuick 1.0 Rectangle { + property string sectionProperty: "number" width: 240 height: 320 color: "#ffffff" @@ -56,7 +57,7 @@ Rectangle { height: 320 model: testModel delegate: myDelegate - section.property: "number" + section.property: sectionProperty section.delegate: Rectangle { objectName: "sect_" + section color: "#99bb99" diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index c7f90da..e8b6028 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1091,6 +1091,28 @@ void tst_QDeclarativeListView::sectionsDelegate() QList<QDeclarativeItem*> items = findItems<QDeclarativeItem>(contentItem, "sect_1"); QCOMPARE(items.count(), 1); + // QTBUG-17759 + model.modifyItem(0, "One", "aaa"); + model.modifyItem(1, "One", "aaa"); + model.modifyItem(2, "One", "aaa"); + model.modifyItem(3, "Four", "aaa"); + model.modifyItem(4, "Four", "aaa"); + model.modifyItem(5, "Four", "aaa"); + model.modifyItem(6, "Five", "aaa"); + model.modifyItem(7, "Five", "aaa"); + model.modifyItem(8, "Five", "aaa"); + model.modifyItem(9, "Two", "aaa"); + model.modifyItem(10, "Two", "aaa"); + model.modifyItem(11, "Two", "aaa"); + QTest::qWait(100); + canvas->rootObject()->setProperty("sectionProperty", "name"); + for (int i = 0; i < 4; ++i) { + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, + "sect_" + model.name(i*3)); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*4)); + } + delete canvas; } |