diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 26 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 47c9d76318..6e91b78bd9 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -777,6 +777,28 @@ int QQuickTableViewPrivate::nextVisibleEdgeIndex(Qt::Edge edge, int startIndex) return foundIndex; } +bool QQuickTableViewPrivate::allColumnsLoaded() +{ + // Returns true if all the columns in the model (that are not + // hidden by the columnWidthProvider) are currently loaded and visible. + const bool firstColumnLoaded = nextVisibleEdgeIndexAroundLoadedTable(Qt::LeftEdge) == kEdgeIndexAtEnd; + if (!firstColumnLoaded) + return false; + bool lastColumnLoaded = nextVisibleEdgeIndexAroundLoadedTable(Qt::RightEdge) == kEdgeIndexAtEnd; + return lastColumnLoaded; +} + +bool QQuickTableViewPrivate::allRowsLoaded() +{ + // Returns true if all the rows in the model (that are not hidden + // by the columnWidthProvider) are currently loaded and visible. + const bool firstColumnLoaded = nextVisibleEdgeIndexAroundLoadedTable(Qt::TopEdge) == kEdgeIndexAtEnd; + if (!firstColumnLoaded) + return false; + bool lastColumnLoaded = nextVisibleEdgeIndexAroundLoadedTable(Qt::BottomEdge) == kEdgeIndexAtEnd; + return lastColumnLoaded; +} + void QQuickTableViewPrivate::updateContentWidth() { // Note that we actually never really know what the content size / size of the full table will @@ -2136,12 +2158,12 @@ void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() relayoutTableItems(); syncLoadedTableRectFromLoadedTable(); - if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentWidth)) { + if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentWidth) || allColumnsLoaded()) { updateAverageColumnWidth(); updateContentWidth(); } - if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentHeight)) { + if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentHeight) || allRowsLoaded()) { updateAverageRowHeight(); updateContentHeight(); } diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index ef408be668..b01fe3cf93 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -385,6 +385,8 @@ public: int nextVisibleEdgeIndex(Qt::Edge edge, int startIndex); int nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge); + bool allColumnsLoaded(); + bool allRowsLoaded(); inline int edgeToArrayIndex(Qt::Edge edge); void clearEdgeSizeCache(); |