aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanthosh Kumar <santhosh.kumar.selvaraj@qt.io>2022-12-19 17:49:16 +0100
committerSanthosh Kumar <santhosh.kumar.selvaraj@qt.io>2023-01-23 10:37:31 +0100
commit0efc4ea6bf2d06d3ff402263698dec750c3e341f (patch)
tree72b0c8ad3529c1e0ab22ca86993c9f1cc529d93e
parente3ff385caacfd2aff4a2f68662bdcab04fafc2c1 (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)
-rw-r--r--src/quick/items/qquicktableview.cpp25
-rw-r--r--src/quick/items/qquicktableview_p_p.h3
2 files changed, 18 insertions, 10 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 1225f51900..78994b9de0 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -2762,19 +2762,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;
}
@@ -3036,12 +3037,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();
@@ -3055,6 +3052,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 d189669f94..e3eea18bca 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -168,8 +168,8 @@ public:
LoadInitalTable,
VerifyTable,
LayoutTable,
- LoadAndUnloadAfterLayout,
CancelOvershoot,
+ UpdateContentSize,
PreloadColumns,
PreloadRows,
MovePreloadedItemsToPool,
@@ -416,6 +416,7 @@ public:
void adjustViewportXAccordingToAlignment();
void adjustViewportYAccordingToAlignment();
void cancelOvershootAfterLayout();
+ void updateContentSize();
void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);