@@ -477,6 +477,11 @@ void ListViewWithPageHeader::componentComplete()
477 polish();
477 polish();
480+static inline bool uFuzzyCompare(qreal r1, qreal r2)
482+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
485void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
482 // Check we are not being taken down and don't paint anything
487 // Check we are not being taken down and don't paint anything
@@ -491,11 +496,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
491 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
496 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
492 if (m_headerItem) {
497 if (m_headerItem) {
493 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
498 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
494− if (contentY() < -m_minYExtent) {
499+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
495− // Stick the header item to the top when dragging down
496− m_headerItem->setY(contentY());
497− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
499 m_headerItem->setHeight(m_headerItem->implicitHeight());
500 m_headerItem->setHeight(m_headerItem->implicitHeight());
500 // We are going down (but it's not because of the rebound at the end)
501 // We are going down (but it's not because of the rebound at the end)
501 // (but the header was not shown by it's own position)
502 // (but the header was not shown by it's own position)
@@ -509,21 +510,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
509 m_headerItemShownHeight = 0;
510 m_headerItemShownHeight = 0;
510 m_headerItem->setY(-m_minYExtent);
511 m_headerItem->setY(-m_minYExtent);
511 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
512 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
513+ if (maximizeVisibleAreaRunning && diff > 0) {
512− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
514+ // If we are maximizing and the header was shown, make sure we hide it
513 m_headerItemShownHeight -= diff;
515 m_headerItemShownHeight -= diff;
515 m_headerItemShownHeight += diff;
517 m_headerItemShownHeight += diff;
516− if (contentY() == -m_minYExtent) {
519+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
517 m_headerItemShownHeight = 0;
520 m_headerItemShownHeight = 0;
519 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
522 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
521 if (m_headerItemShownHeight > 0) {
524 if (m_headerItemShownHeight > 0) {
525+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
526+ m_headerItem->setY(contentY());
527+ m_headerItemShownHeight = m_headerItem->height();
522− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
529+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
524 m_headerItem->setY(-m_minYExtent);
532 m_headerItem->setY(-m_minYExtent);
536+ // Stick the header item to the top when dragging down
537+ m_headerItem->setY(contentY());
538+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
528 // We will be changing the clip item, need to accomadate for it
540 // We will be changing the clip item, need to accomadate for it
529 // otherwise we move the firstItem down/up twice (unless the
541 // otherwise we move the firstItem down/up twice (unless the
@@ -1264,6 +1276,11 @@ void ListViewWithPageHeader::updatePolish()
1264 refill();
1276 refill();
1266 if (m_contentHeightDirty) {
1278 if (m_contentHeightDirty) {
1279+ // We need to make sure all bindings have updated otherwise
1280+ // we may end up with bindings updating when we call setContentHeight
1281+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1282+ qApp->processEvents();
1267 qreal contentHeight;
1284 qreal contentHeight;
1268 if (m_visibleItems.isEmpty()) {
1285 if (m_visibleItems.isEmpty()) {
1269 contentHeight = m_headerItem ? m_headerItem->height() : 0;
1286 contentHeight = m_headerItem ? m_headerItem->height() : 0;