From 1061c7e5cfae88a336f1327cc20b2d8a0a3c6015 Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Mon, 7 Oct 2013 11:55:12 +0200 Subject: Make GridView/ListView attached "view" property available to all delegate types This is useful for accessing the view (e.g. "width", "cellWidth", ... properties) from within section (ListView only), header, footer and highlight delegate components. A typical usecase are components that are used in multiple views and therefore cannot use the views's id for access. The only attached property valid for those non-item delegates is "view". This has been added to the documentation. Change-Id: I33d976da778be23ed531a3b193ceee95ed9800d2 Task-number: QTBUG-32836 Reviewed-by: Alan Alpert --- .../quick/qquicklistview/tst_qquicklistview.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp') diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 7d0b76ad63..5651806a33 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -172,6 +172,7 @@ private slots: void onAdd_data(); void onRemove(); void onRemove_data(); + void attachedProperties_QTBUG_32836(); void rightToLeft(); void test_mirroring(); void margins(); @@ -5440,6 +5441,40 @@ void tst_QQuickListView::snapOneItem() releaseView(window); } +void tst_QQuickListView::attachedProperties_QTBUG_32836() +{ + QQuickView *window = createView(); + + window->setSource(testFileUrl("attachedProperties.qml")); + window->show(); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(window->rootObject()); + QVERIFY(listview != 0); + + QQuickItem *header = listview->headerItem(); + QVERIFY(header); + QCOMPARE(header->width(), listview->width()); + + QQuickItem *footer = listview->footerItem(); + QVERIFY(footer); + QCOMPARE(footer->width(), listview->width()); + + QQuickItem *highlight = listview->highlightItem(); + QVERIFY(highlight); + QCOMPARE(highlight->width(), listview->width()); + + QQuickItem *currentItem = listview->currentItem(); + QVERIFY(currentItem); + QCOMPARE(currentItem->width(), listview->width()); + + QQuickItem *sectionItem = findItem(window->rootObject(), "sectionItem"); + QVERIFY(sectionItem); + QCOMPARE(sectionItem->width(), listview->width()); + + delete window; +} + void tst_QQuickListView::unrequestedVisibility() { QaimModel model; -- cgit v1.2.3