diff options
author | Robin Burchell <robin.burchell@theqtcompany.com> | 2015-09-28 22:31:06 +0200 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2015-09-28 22:08:14 +0000 |
commit | ff1264cd6f48cd2bbf61e04a454c7ccccefa40d9 (patch) | |
tree | c30737975e0705d90bdb71c44e210e70e3c71976 /src/quick | |
parent | d7dcc3afc6df48bc63f6d1e4466e3da65b38d16a (diff) |
QQuickListView: Make sticky headers & footers work with no list items.
Overlay headers are supposed to be fixed in position. This worked for "usual"
cases, but flicking a list with an empty model allowed the header & footer to
move.
Two fixes were required:
* viewportMoved needs to call updateHeader and updateFooter if there are no
items if sticky headers are enabled
* updateHeader and updatefooter need to always fix the position of the header &
footer.
Change-Id: I77519d91f587458777c6c8f4863270cf762ac286
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquicklistview.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index ccc036b2b0..6a2de58318 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -1319,10 +1319,10 @@ void QQuickListViewPrivate::updateFooter() } FxListItemSG *listItem = static_cast<FxListItemSG*>(footer); - if (visibleItems.count()) { - if (footerPositioning == QQuickListView::OverlayFooter) { - listItem->setPosition(isContentFlowReversed() ? -position() - footerSize() : position() + size() - footerSize()); - } else if (footerPositioning == QQuickListView::PullBackFooter) { + if (footerPositioning == QQuickListView::OverlayFooter) { + listItem->setPosition(isContentFlowReversed() ? -position() - footerSize() : position() + size() - footerSize()); + } else if (visibleItems.count()) { + if (footerPositioning == QQuickListView::PullBackFooter) { qreal viewPos = isContentFlowReversed() ? -position() : position() + size(); qreal clampedPos = qBound(originPosition() - footerSize() + size(), listItem->position(), lastPosition()); listItem->setPosition(qBound(viewPos - footerSize(), clampedPos, viewPos)); @@ -1358,10 +1358,10 @@ void QQuickListViewPrivate::updateHeader() } FxListItemSG *listItem = static_cast<FxListItemSG*>(header); - if (visibleItems.count()) { - if (headerPositioning == QQuickListView::OverlayHeader) { - listItem->setPosition(isContentFlowReversed() ? -position() - size() : position()); - } else if (headerPositioning == QQuickListView::PullBackHeader) { + if (headerPositioning == QQuickListView::OverlayHeader) { + listItem->setPosition(isContentFlowReversed() ? -position() - size() : position()); + } else if (visibleItems.count()) { + if (headerPositioning == QQuickListView::PullBackHeader) { qreal viewPos = isContentFlowReversed() ? -position() - size() : position(); qreal clampedPos = qBound(originPosition() - headerSize(), listItem->position(), lastPosition() - headerSize() - size()); listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos)); @@ -2838,8 +2838,15 @@ void QQuickListView::viewportMoved(Qt::Orientations orient) { Q_D(QQuickListView); QQuickItemView::viewportMoved(orient); - if (!d->itemCount) + + if (!d->itemCount) { + if (d->hasStickyHeader()) + d->updateHeader(); + if (d->hasStickyFooter()) + d->updateFooter(); return; + } + // Recursion can occur due to refill changing the content size. if (d->inViewportMoved) return; |