aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-11-10 16:08:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-11 20:29:45 +0000
commit7894b7551b5f74127cddf455c76260aa98239375 (patch)
tree08535f927ced6b76219f5142f342a18f62521a81 /src
parent1a6a7b312123b6c407a5594b0a1df12248557296 (diff)
QQuickTableView: detect if syncView topLeft has changed
It can happen that the top left cell in syncView changes after a normal relayout. This is especially prone to happen if the cells used to be large, but are suddenly made much smaller, such that the top left cell ends up outside the viewport. This patch will detect this case, and ensure that the top left is being recalculated when they are no longer in sync. Change-Id: I80cad2859a35e0f3bc58f101696112be7c084175 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit f15528407033057fb5c6e6ba5bbe8e5936fe346b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquicktableview.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 2483b5781b..8aaf00c775 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -3720,6 +3720,13 @@ void QQuickTableViewPrivate::syncSyncView()
q->setLeftMargin(syncView->leftMargin());
q->setRightMargin(syncView->rightMargin());
updateContentWidth();
+
+ if (syncView->leftColumn() != q->leftColumn()) {
+ // The left column is no longer the same as the left
+ // column in syncView. This requires a rebuild.
+ scheduledRebuildOptions |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftColumn;
+ scheduledRebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ }
}
if (syncVertically) {
@@ -3728,6 +3735,13 @@ void QQuickTableViewPrivate::syncSyncView()
q->setTopMargin(syncView->topMargin());
q->setBottomMargin(syncView->bottomMargin());
updateContentHeight();
+
+ if (syncView->topRow() != q->topRow()) {
+ // The top row is no longer the same as the top
+ // row in syncView. This requires a rebuild.
+ scheduledRebuildOptions |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow;
+ scheduledRebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ }
}
if (syncView && loadedItems.isEmpty() && !tableSize.isEmpty()) {