aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-10-19 11:30:00 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-10-21 22:47:32 +0200
commitdac2c8aec4917742aed6e311cf542dc37da60809 (patch)
treec5e758a8df92bd41d240a6634ed7c598742196d3 /src/quick/items/qquicktableview_p_p.h
parenteae03ccd7f8574c176f386e3bfb30d4bd949ee11 (diff)
TableView: ensure we update content size upon model changes
For tables of non-trivial sizes, we usually don't know what the content size will be unless we load all rows and columns, which we simply cannot do. Because of this, we have up till now chosen a strategy where we normally just calculate a predicted content size up-front, when we table is built, and afterwards just stick to that prediction. This strategy works for big tables that fills more than one size of the viewport, and if the number of rows and column in the model stays around the same. But for tables that start off smaller than the viewport, and later expands to grow out of it, it simply fails. And the failure is such that the tableview can get stuck, with no way way for the user to flick around to see the rest of the contents. An example is TreeView that might only show the root node at start-up, but as you start to expand the tree, it will quickly add more rows than what fits inside the viewport. And in that case, the contentHeight will be totally off, and in turn, make the scrollbar be based on wrong values, and sometimes not work at all (e.g if it has the flag Flickable::StopAtBounds). This patch will change the implementation so that we recalculate the content size whenever it should logially change. That is, if e.g the model add or remove rows and columns, or if you change spacing. This still doesn't mean that contentWidth/Height reports the correct size of the table, but at least it will be a better guestimate for smaller tables, and at the same time, work together with Flickable and ScrollBars. Pick-to: 5.15 Fixes: QTBUG-87680 Change-Id: Ie2d2e7c1f1519dc7a5d5269a6d25e34cf441b3fe Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p_p.h')
-rw-r--r--src/quick/items/qquicktableview_p_p.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 876a175d87..6a8c5fa7fa 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -213,8 +213,10 @@ public:
ViewportOnly = 0x4,
CalculateNewTopLeftRow = 0x8,
CalculateNewTopLeftColumn = 0x10,
- PositionViewAtRow = 0x20,
- PositionViewAtColumn = 0x40,
+ CalculateNewContentWidth = 0x20,
+ CalculateNewContentHeight = 0x40,
+ PositionViewAtRow = 0x80,
+ PositionViewAtColumn = 0x100,
};
Q_DECLARE_FLAGS(RebuildOptions, RebuildOption)
@@ -371,7 +373,8 @@ public:
void updateContentWidth();
void updateContentHeight();
- void updateAverageEdgeSize();
+ void updateAverageColumnWidth();
+ void updateAverageRowHeight();
RebuildOptions checkForVisibilityChanges();
void forceLayout();