aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-11 16:55:09 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-14 14:58:23 +0000
commitbdeaef727230b6e820b202828e06503dac8096d6 (patch)
tree207b690898395a6924a8c9ff785848ae018430be /src/quick/items/qquicktableview_p_p.h
parentec6b67a0e15ca271032689bfe94619c298a0a9bf (diff)
QQuickTableView: preload one extra row and column at start-up
When a TableView initially loads as many rows and columns it can fit inside the viewport, it will always be one less than the number it will show while flicking. The reason is that, as soon as you flick half a column out on the left, half a column will move in on the right. And this will increase the number of visible columns by 1 (but without reusing any items from the pool, since the first column is not out). Since this is always the case, it makes sense to preload one extra row and column at start-up, so that they're ready when the flicking starts. Note that this doesn't load more items in the background than what we need (like the cache buffer would). The viewport will fit _all_ the loaded items into the viewport once you start flicking. But the extra items loaded at start-up will instead be moved direcly to the pool for reuse, and the application will be informed about it (using the onPooled signal). Change-Id: Icea85c1d44f74ab54f1b96325489e8d6d1c0889e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p_p.h')
-rw-r--r--src/quick/items/qquicktableview_p_p.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 936d8b8207..53fd936195 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -163,6 +163,18 @@ public:
}
};
+ enum class RebuildState {
+ NotStarted = 0,
+ LoadInitalTable,
+ VerifyTable,
+ LayoutTable,
+ LoadAndUnloadAfterLayout,
+ PreloadColumns,
+ PreloadRows,
+ MovePreloadedItemsToPool,
+ Done
+ };
+
public:
QQuickTableViewPrivate();
~QQuickTableViewPrivate() override;
@@ -196,6 +208,7 @@ public:
QSize tableSize;
+ RebuildState rebuildState = RebuildState::NotStarted;
TableEdgeLoadRequest loadRequest;
QPoint contentSizeBenchMarkPoint = QPoint(-1, -1);
@@ -205,8 +218,6 @@ public:
QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable;
bool blockItemCreatedCallback = false;
- bool tableInvalid = false;
- bool tableRebuilding = false;
bool columnRowPositionsInvalid = false;
bool layoutWarningIssued = false;
bool polishing = false;
@@ -289,8 +300,11 @@ public:
void drainReusePoolAfterLoadRequest();
void cancelLoadRequest();
void processLoadRequest();
+
+ void processRebuildTable();
+ bool moveToNextRebuildState();
void beginRebuildTable();
- void endRebuildTable();
+ void layoutAfterLoadingInitialTable();
void invalidateTable();
void invalidateColumnRowPositions();