diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-18 13:59:33 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-23 20:22:28 +0000 |
commit | 8db3e76960241bebaf82b2a7a4186190c93f7660 (patch) | |
tree | d23aa20d6300a78806262de4c36d940f3a8fc27f /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 5f23a667ef493f4dbaf7054bfda341b7a7d79609 (diff) |
TableView: fall back to use default column/row size
If we cannot determine the size of a row or column, we need
to fall back to some size other than 0 while layouting. The
reason for this is that we fill up with as many rows and
columns that fits inside the viewport. But if e.g the width
of column is zero, we will never make any progress, and
therefore just keep loading and loading columns.
Change-Id: I96ea410dc5a75831e44c2924172254634598b680
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 16a13707d2..4c9cfacd2d 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -85,6 +85,7 @@ private slots: void setAndGetModel(); void emptyModel_data(); void emptyModel(); + void checkZeroSizedDelegate(); void countDelegateItems_data(); void countDelegateItems(); void checkLayoutOfEqualSizedDelegateItems_data(); @@ -181,6 +182,31 @@ void tst_QQuickTableView::emptyModel() QCOMPARE(tableViewPrivate->loadedItems.count(), 0); } +void tst_QQuickTableView::checkZeroSizedDelegate() +{ + // Check that if we assign a delegate with empty width and height, we + // fall back to use kDefaultColumnWidth and kDefaultRowHeight as + // column/row sizes. + LOAD_TABLEVIEW("plaintableview.qml"); + + auto model = TestModelAsVariant(100, 100); + tableView->setModel(model); + + view->rootObject()->setProperty("delegateWidth", 0); + view->rootObject()->setProperty("delegateHeight", 0); + + WAIT_UNTIL_POLISHED; + + auto items = tableViewPrivate->loadedItems; + QVERIFY(!items.isEmpty()); + + for (auto fxItem : tableViewPrivate->loadedItems) { + auto item = fxItem->item; + QCOMPARE(item->width(), kDefaultColumnWidth); + QCOMPARE(item->height(), kDefaultRowHeight); + } +} + void tst_QQuickTableView::countDelegateItems_data() { QTest::addColumn<QVariant>("model"); |