diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-12-05 14:53:55 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-12-09 14:16:07 +0100 |
commit | e1cc06972a42e2bae51b027737919445d0e675f7 (patch) | |
tree | 086634c598fa5e4ed5cac28c9f05c446d173601e /src/quick/items/qquicktableview.cpp | |
parent | f60f2aaa5176ca703fa01fbaf01059fe989c0029 (diff) |
QQuickTableView: set empty content size when table is empty
From before we would bail out early from the rebuild process if we
detected an empty table. A result from this is that we left
both contentWidth and contentHeight unchanged.
This patch will set an empty content size when the table is
empty. The effect will be that the user cannot flick the view
around based on the old size.
Fixes: QTBUG-80505
Change-Id: I3ac080476269fd5906ce79fa007eabb59b5ff4b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview.cpp')
-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 ab57a8ea0b..4b34e3b2c1 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -628,6 +628,12 @@ void QQuickTableViewPrivate::updateContentWidth() return; } + if (loadedItems.isEmpty()) { + QBoolBlocker fixupGuard(inUpdateContentSize, true); + q->QQuickFlickable::setContentWidth(0); + return; + } + const int nextColumn = nextVisibleEdgeIndexAroundLoadedTable(Qt::RightEdge); const int columnsRemaining = nextColumn == kEdgeIndexAtEnd ? 0 : tableSize.width() - nextColumn; const qreal remainingColumnWidths = columnsRemaining * averageEdgeSize.width(); @@ -655,6 +661,12 @@ void QQuickTableViewPrivate::updateContentHeight() return; } + if (loadedItems.isEmpty()) { + QBoolBlocker fixupGuard(inUpdateContentSize, true); + q->QQuickFlickable::setContentHeight(0); + return; + } + const int nextRow = nextVisibleEdgeIndexAroundLoadedTable(Qt::BottomEdge); const int rowsRemaining = nextRow == kEdgeIndexAtEnd ? 0 : tableSize.height() - nextRow; const qreal remainingRowHeights = rowsRemaining * averageEdgeSize.height(); @@ -1614,6 +1626,8 @@ void QQuickTableViewPrivate::processRebuildTable() if (rebuildState == RebuildState::VerifyTable) { if (loadedItems.isEmpty()) { qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded!"; + updateContentWidth(); + updateContentHeight(); rebuildState = RebuildState::Done; } else if (!moveToNextRebuildState()) { return; |