QQuickTableView: only preload to pool if reuseItems is true
We move preloaded items into the pool. But this is pointless if we're not reusing items in the first place. Change-Id: I2274b0d29c98162da5fa4859c810c42093875836 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
bf13637952
commit
9fa76b8a05
|
@ -889,15 +889,17 @@ void QQuickTableViewPrivate::processRebuildTable()
|
|||
return;
|
||||
}
|
||||
|
||||
const bool preload = (reusableFlag == QQmlTableInstanceModel::Reusable);
|
||||
|
||||
if (rebuildState == RebuildState::PreloadColumns) {
|
||||
if (loadedTable.right() < tableSize.width() - 1)
|
||||
if (preload && loadedTable.right() < tableSize.width() - 1)
|
||||
loadEdge(Qt::RightEdge, QQmlIncubator::AsynchronousIfNested);
|
||||
if (!moveToNextRebuildState())
|
||||
return;
|
||||
}
|
||||
|
||||
if (rebuildState == RebuildState::PreloadRows) {
|
||||
if (loadedTable.bottom() < tableSize.height() - 1)
|
||||
if (preload && loadedTable.bottom() < tableSize.height() - 1)
|
||||
loadEdge(Qt::BottomEdge, QQmlIncubator::AsynchronousIfNested);
|
||||
if (!moveToNextRebuildState())
|
||||
return;
|
||||
|
|
|
@ -85,6 +85,7 @@ private slots:
|
|||
void setAndGetModel();
|
||||
void emptyModel_data();
|
||||
void emptyModel();
|
||||
void checkPreload_data();
|
||||
void checkPreload();
|
||||
void checkZeroSizedDelegate();
|
||||
void checkImplicitSizeDelegate();
|
||||
|
@ -195,20 +196,34 @@ void tst_QQuickTableView::emptyModel()
|
|||
QCOMPARE(tableViewPrivate->loadedItems.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QQuickTableView::checkPreload_data()
|
||||
{
|
||||
QTest::addColumn<bool>("reuseItems");
|
||||
|
||||
QTest::newRow("reuse") << true;
|
||||
QTest::newRow("not reuse") << false;
|
||||
}
|
||||
|
||||
void tst_QQuickTableView::checkPreload()
|
||||
{
|
||||
// Check that the reuse pool is filled up with one extra row and
|
||||
// column (pluss corner) after rebuilding the table.
|
||||
// column (pluss corner) after rebuilding the table, but only if we reuse items.
|
||||
QFETCH(bool, reuseItems);
|
||||
LOAD_TABLEVIEW("plaintableview.qml");
|
||||
|
||||
auto model = TestModelAsVariant(100, 100);
|
||||
tableView->setModel(model);
|
||||
tableView->setReuseItems(reuseItems);
|
||||
|
||||
WAIT_UNTIL_POLISHED;
|
||||
|
||||
QSize visibleTableSize = tableViewPrivate->loadedTable.size();
|
||||
int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
|
||||
QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
|
||||
if (reuseItems) {
|
||||
QSize visibleTableSize = tableViewPrivate->loadedTable.size();
|
||||
int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
|
||||
QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
|
||||
} else {
|
||||
QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QQuickTableView::checkZeroSizedDelegate()
|
||||
|
|
Loading…
Reference in New Issue