aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-03-19 17:41:46 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-24 07:44:22 +0000
commit92d1cf4db7f1c03db0ffa1a380ff7955d162cd65 (patch)
treea4c6d3f3c8283a557280d2ea845d7c3a92ffc711 /src
parentde89e772395608dac79d8bb755fb267ec74afbaf (diff)
QQuickTableView: forceLayout() should work, even when no items are loaded
As it stood, we would return early from forceLayout if no items were loaded. This made sense, since when no items are loaded, there would be no items to lay out. But after we changed the logic so that an application can show or hide rows and columns by returning an empty size from the size providers, we now always need to do a layout to check if some rows or columns should become visible. Fixes: QTBUG-92076 Change-Id: I2a07bf8e62cfeebcbe36c01aa92eca3ed8227cd3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 9ba9336ec4515d157a1207fad1dcd2de311527ac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquicktableview.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 0d66f81b24..9bdf18cd87 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -1074,6 +1074,15 @@ void QQuickTableViewPrivate::shiftLoadedTableRect(const QPointF newPosition)
QQuickTableViewPrivate::RebuildOptions QQuickTableViewPrivate::checkForVisibilityChanges()
{
+ // This function will check if there are any visibility changes among
+ // the _already loaded_ rows and columns. Note that there can be rows
+ // and columns to the bottom or right that was not loaded, but should
+ // now become visible (in case there is free space around the table).
+ if (loadedItems.isEmpty()) {
+ // Report no changes
+ return RebuildOption::None;
+ }
+
// Go through all columns from first to last, find the columns that used
// to be hidden and not loaded, and check if they should become visible
// (and vice versa). If there is a change, we need to rebuild.
@@ -1118,9 +1127,6 @@ QQuickTableViewPrivate::RebuildOptions QQuickTableViewPrivate::checkForVisibilit
void QQuickTableViewPrivate::forceLayout()
{
- if (loadedItems.isEmpty())
- return;
-
clearEdgeSizeCache();
RebuildOptions rebuildOptions = RebuildOption::None;