diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-11-10 16:08:26 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-11-11 17:33:11 +0100 |
commit | f15528407033057fb5c6e6ba5bbe8e5936fe346b (patch) | |
tree | 3334766e0725e00d4ca5681f4f14de346fda0386 /src | |
parent | 259aec7cb4c031e14771d8eabbdea7866f03d698 (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.
Pick-to: 6.4 6.2
Change-Id: I80cad2859a35e0f3bc58f101696112be7c084175
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index b32a8e3462..0ddd69e2ed 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -3908,6 +3908,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) { @@ -3916,6 +3923,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()) { |