diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-12-19 17:49:16 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-18 13:40:18 +0000 |
commit | 88187a07139dbbe7797baf66db2ecc6d38435c5d (patch) | |
tree | 78c98363521ae7f3a7e4661a4f41560c64b74d73 | |
parent | 9d01d183fdddcae7cab11c2c346203c95952ee43 (diff) |
Fix content position of table view control
The estimated width in the table view has been used to layout
and accordingly, edges of the table be loaded. This estimated
width will be passed to flickable to adjust its parameters and
width/position of scroll bar. This in turn change geometry of
table view with respect to view port.
In some scenarios, this estimated width during layout causes
table view to be misaligned. This can be avoided by calculating
and updating latest content width of the table view once after
loading the edges of table.
Fixes: QTBUG-108664
Change-Id: I47c3325bc9e51f75c87564a2ec1de4522e4a7e60
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 19b35008e2b2bebef10a9d52c8389920df1e1953)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 25 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 3 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 3a37f86717..f95e652746 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -3228,19 +3228,20 @@ void QQuickTableViewPrivate::processRebuildTable() if (rebuildState == RebuildState::LayoutTable) { layoutAfterLoadingInitialTable(); + loadAndUnloadVisibleEdges(); if (!moveToNextRebuildState()) return; } - if (rebuildState == RebuildState::LoadAndUnloadAfterLayout) { + if (rebuildState == RebuildState::CancelOvershoot) { + cancelOvershootAfterLayout(); loadAndUnloadVisibleEdges(); if (!moveToNextRebuildState()) return; } - if (rebuildState == RebuildState::CancelOvershoot) { - cancelOvershootAfterLayout(); - loadAndUnloadVisibleEdges(); + if (rebuildState == RebuildState::UpdateContentSize) { + updateContentSize(); if (!moveToNextRebuildState()) return; } @@ -3511,12 +3512,8 @@ void QQuickTableViewPrivate::loadInitialTable() loadAndUnloadVisibleEdges(); } -void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() +void QQuickTableViewPrivate::updateContentSize() { - clearEdgeSizeCache(); - relayoutTableItems(); - syncLoadedTableRectFromLoadedTable(); - const bool allColumnsLoaded = atTableEnd(Qt::LeftEdge) && atTableEnd(Qt::RightEdge); if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentWidth) || allColumnsLoaded) { updateAverageColumnWidth(); @@ -3530,6 +3527,16 @@ void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() } updateExtents(); +} + +void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() +{ + clearEdgeSizeCache(); + relayoutTableItems(); + syncLoadedTableRectFromLoadedTable(); + + updateContentSize(); + adjustViewportXAccordingToAlignment(); adjustViewportYAccordingToAlignment(); } diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index d53a7f5162..a8b1409773 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -216,8 +216,8 @@ public: LoadInitalTable, VerifyTable, LayoutTable, - LoadAndUnloadAfterLayout, CancelOvershoot, + UpdateContentSize, PreloadColumns, PreloadRows, MovePreloadedItemsToPool, @@ -485,6 +485,7 @@ public: void updateCursor(); #endif void updateEditItem(); + void updateContentSize(); QTypeRevision resolveImportVersion(); void createWrapperModel(); |