diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-03-27 11:38:53 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-04-21 08:56:21 +0000 |
commit | 053f88c3b283db0e6b75adb4df010b948903cea4 (patch) | |
tree | 8ce1be6b0e58e3c9af965c7556ab12147823b158 /src | |
parent | 0ddc5ba510938368a7368f2a5cfda6ea22217a96 (diff) |
QQuickTableView: improve checking rebuild status while rebuilding
Change-Id: I5e7b5b261d3ba28fbbf345f2fc3f086d87112a2d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 57 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 1 |
2 files changed, 39 insertions, 19 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 9bc6723cbd..1dca5bea4a 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1398,6 +1398,22 @@ void QQuickTableViewPrivate::processLoadRequest() void QQuickTableViewPrivate::processRebuildTable() { + Q_Q(QQuickTableView); + + if (rebuildState == RebuildState::Begin) { + if (Q_UNLIKELY(lcTableViewDelegateLifecycle().isDebugEnabled())) { + qCDebug(lcTableViewDelegateLifecycle()) << "begin rebuild:" << q; + if (rebuildOptions & RebuildOption::All) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::All, options:" << rebuildOptions; + else if (rebuildOptions & RebuildOption::ViewportOnly) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::ViewportOnly, options:" << rebuildOptions; + else if (rebuildOptions & RebuildOption::LayoutOnly) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::LayoutOnly, options:" << rebuildOptions; + else + Q_TABLEVIEW_UNREACHABLE(rebuildOptions); + } + } + moveToNextRebuildState(); if (rebuildState == RebuildState::LoadInitalTable) { @@ -1408,12 +1424,11 @@ void QQuickTableViewPrivate::processRebuildTable() if (rebuildState == RebuildState::VerifyTable) { if (loadedItems.isEmpty()) { - qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model, all rows or columns hidden, or no delegate"; + qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded!"; rebuildState = RebuildState::Done; + } else if (!moveToNextRebuildState()) { return; } - if (!moveToNextRebuildState()) - return; } if (rebuildState == RebuildState::LayoutTable) { @@ -1453,6 +1468,7 @@ void QQuickTableViewPrivate::processRebuildTable() } Q_TABLEVIEW_ASSERT(rebuildState == RebuildState::Done, int(rebuildState)); + qCDebug(lcTableViewDelegateLifecycle()) << "rebuild complete:" << q; } bool QQuickTableViewPrivate::moveToNextRebuildState() @@ -1532,12 +1548,30 @@ void QQuickTableViewPrivate::beginRebuildTable() loadedTableInnerRect = QRect(); clearEdgeSizeCache(); + if (!model) { + qCDebug(lcTableViewDelegateLifecycle()) << "no model found, leaving table empty"; + return; + } + + if (model->count() == 0) { + qCDebug(lcTableViewDelegateLifecycle()) << "empty model found, leaving table empty"; + return; + } + + if (tableModel && !tableModel->delegate()) { + qCDebug(lcTableViewDelegateLifecycle()) << "no delegate found, leaving table empty"; + return; + } + if (topLeft.x() == kEdgeIndexAtEnd || topLeft.y() == kEdgeIndexAtEnd) { - // No visible columns or rows, so nothing to load + qCDebug(lcTableViewDelegateLifecycle()) << "no visible rows or columns, leaving table empty"; return; } - loadInitialTopLeftItem(topLeft, topLeftPos); + // Load top-left item. After loaded, loadItemsInsideRect() will take + // care of filling out the rest of the table. + loadRequest.begin(topLeft, topLeftPos, QQmlIncubator::AsynchronousIfNested); + processLoadRequest(); loadAndUnloadVisibleEdges(); } @@ -1559,19 +1593,6 @@ void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() updateContentHeight(); } -void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos) -{ - Q_TABLEVIEW_ASSERT(loadedItems.isEmpty(), ""); - - if (tableModel && !tableModel->delegate()) - return; - - // Load top-left item. After loaded, loadItemsInsideRect() will take - // care of filling out the rest of the table. - loadRequest.begin(cell, pos, QQmlIncubator::AsynchronousIfNested); - processLoadRequest(); -} - void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge) { qCDebug(lcTableViewDelegateLifecycle) << edge; diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index acf537198b..6bbfd4e2d6 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -341,7 +341,6 @@ public: void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag); void unloadItem(const QPoint &cell); - void loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos); void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode); void unloadEdge(Qt::Edge edge); void loadAndUnloadVisibleEdges(); |