aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-11 15:35:07 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-14 11:51:09 +0000
commitee35b2da3921704c0eac5617687db74f46892632 (patch)
tree45a0e71cc5e20eb8b7c1e9db9a030c78e5d2ba55 /src/quick/items/qquicktableview.cpp
parentdea5b8b611e4f1a385e9fe4bee5991fc9adcd888 (diff)
QQuickTableView: remove cacheBuffer from the implementation
After we removed cacheBuffer from the public API, giving the users no way to switch if off, the safest thing is to also remove it from the implementation. The cache buffer can easily load add a lot of hidden items to the view, and the user now has no way to tweak or hinder it. As an example, lets say that you in a ListView can fit 10 items on screen. And then you have a cache buffer set that loads two more items, both on top and below. You then end up with 14 items added to the view. Now, lets consider the same case for TableView, where you show 10x10 items on screen. With the same cache buffer, you end up loading 2x10 items in the background on all sides of the table (pluss 4 items in each corners). This sums up to 96 extra items. This is really bad and unacceptable. It's more performant to just switch the caching off completely. Change-Id: Iddbd78ef1d7c7197eb4a847ec5067184149fe9a0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview.cpp')
-rw-r--r--src/quick/items/qquicktableview.cpp61
1 files changed, 1 insertions, 60 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 3925fe95cf..627eb5db71 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -59,7 +59,6 @@ Q_LOGGING_CATEGORY(lcTableViewDelegateLifecycle, "qt.quick.tableview.lifecycle")
#define Q_TABLEVIEW_ASSERT(cond, output) Q_ASSERT((cond) || [&](){ dumpTable(); qWarning() << "output:" << output; return false;}())
static const Qt::Edge allTableEdges[] = { Qt::LeftEdge, Qt::RightEdge, Qt::TopEdge, Qt::BottomEdge };
-static const int kBufferTimerInterval = 300;
static QLine rectangleEdge(const QRect &rect, Qt::Edge tableEdge)
{
@@ -99,8 +98,6 @@ const QPoint QQuickTableViewPrivate::kDown = QPoint(0, 1);
QQuickTableViewPrivate::QQuickTableViewPrivate()
: QQuickFlickablePrivate()
{
- cacheBufferDelayTimer.setSingleShot(true);
- QObject::connect(&cacheBufferDelayTimer, &QTimer::timeout, [=]{ loadBuffer(); });
}
QQuickTableViewPrivate::~QQuickTableViewPrivate()
@@ -958,13 +955,12 @@ void QQuickTableViewPrivate::loadAndUnloadVisibleEdges()
return;
}
- const QRectF unloadRect = hasBufferedItems ? bufferRect() : viewportRect;
bool tableModified;
do {
tableModified = false;
- if (Qt::Edge edge = nextEdgeToUnload(unloadRect)) {
+ if (Qt::Edge edge = nextEdgeToUnload(viewportRect)) {
tableModified = true;
unloadEdge(edge);
}
@@ -1023,44 +1019,6 @@ void QQuickTableViewPrivate::drainReusePoolAfterLoadRequest()
tableModel->drainReusableItemsPool(maxTime);
}
-void QQuickTableViewPrivate::loadBuffer()
-{
- // Rather than making sure to stop the timer from all locations that can
- // violate the "buffering allowed" state, we just check that we're in the
- // right state here before we start buffering.
- if (cacheBuffer <= 0 || loadRequest.isActive() || loadedItems.isEmpty())
- return;
-
- qCDebug(lcTableViewDelegateLifecycle());
- const QRectF loadRect = bufferRect();
- while (Qt::Edge edge = nextEdgeToLoad(loadRect)) {
- loadEdge(edge, QQmlIncubator::Asynchronous);
- if (loadRequest.isActive())
- break;
- }
-
- hasBufferedItems = true;
-}
-
-void QQuickTableViewPrivate::unloadBuffer()
-{
- if (!hasBufferedItems)
- return;
-
- qCDebug(lcTableViewDelegateLifecycle());
- hasBufferedItems = false;
- cacheBufferDelayTimer.stop();
- if (loadRequest.isActive())
- cancelLoadRequest();
- while (Qt::Edge edge = nextEdgeToUnload(viewportRect))
- unloadEdge(edge);
-}
-
-QRectF QQuickTableViewPrivate::bufferRect()
-{
- return viewportRect.adjusted(-cacheBuffer, -cacheBuffer, cacheBuffer, cacheBuffer);
-}
-
void QQuickTableViewPrivate::invalidateTable() {
tableInvalid = true;
if (loadRequest.isActive())
@@ -1115,24 +1073,7 @@ void QQuickTableViewPrivate::updatePolish()
if (columnRowPositionsInvalid)
relayoutTable();
- if (hasBufferedItems && nextEdgeToLoad(viewportRect)) {
- // We are about to load more edges, so trim down the table as much
- // as possible to avoid loading cells that are outside the viewport.
- unloadBuffer();
- }
-
loadAndUnloadVisibleEdges();
-
- if (loadRequest.isActive())
- return;
-
- if (cacheBuffer > 0) {
- // When polish hasn't been called for a while (which means that the viewport
- // rect hasn't changed), we start buffering items. We delay this operation by
- // using a timer to increase performance (by not loading hidden items) while
- // the user is flicking.
- cacheBufferDelayTimer.start(kBufferTimerInterval);
- }
}
void QQuickTableViewPrivate::createWrapperModel()