@@ -91,6 +91,7 @@
92#include "listviewwithpageheader.h"
92#include "listviewwithpageheader.h"
94+#include <QCoreApplication>
94#include <QDebug>
95#include <QDebug>
95#include <qqmlinfo.h>
96#include <qqmlinfo.h>
96#include <qqmlengine.h>
97#include <qqmlengine.h>
@@ -484,6 +485,11 @@ void ListViewWithPageHeader::componentComplete()
484 polish();
485 polish();
488+static inline bool uFuzzyCompare(qreal r1, qreal r2)
490+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
487void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
493void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
489 // Check we are not being taken down and don't paint anything
495 // Check we are not being taken down and don't paint anything
@@ -498,11 +504,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
498 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
504 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
499 if (m_headerItem) {
505 if (m_headerItem) {
500 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
506 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
501− if (contentY() < -m_minYExtent) {
507+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
502− // Stick the header item to the top when dragging down
503− m_headerItem->setY(contentY());
504− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
506 m_headerItem->setHeight(m_headerItem->implicitHeight());
508 m_headerItem->setHeight(m_headerItem->implicitHeight());
507 // We are going down (but it's not because of the rebound at the end)
509 // We are going down (but it's not because of the rebound at the end)
508 // (but the header was not shown by it's own position)
510 // (but the header was not shown by it's own position)
@@ -516,21 +518,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
516 m_headerItemShownHeight = 0;
518 m_headerItemShownHeight = 0;
517 m_headerItem->setY(-m_minYExtent);
519 m_headerItem->setY(-m_minYExtent);
518 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
520 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
521+ if (maximizeVisibleAreaRunning && diff > 0) {
519− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
522+ // If we are maximizing and the header was shown, make sure we hide it
520 m_headerItemShownHeight -= diff;
523 m_headerItemShownHeight -= diff;
522 m_headerItemShownHeight += diff;
525 m_headerItemShownHeight += diff;
523− if (contentY() == -m_minYExtent) {
527+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
524 m_headerItemShownHeight = 0;
528 m_headerItemShownHeight = 0;
526 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
530 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
528 if (m_headerItemShownHeight > 0) {
532 if (m_headerItemShownHeight > 0) {
533+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
534+ m_headerItem->setY(contentY());
535+ m_headerItemShownHeight = m_headerItem->height();
529− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
537+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
531 m_headerItem->setY(-m_minYExtent);
540 m_headerItem->setY(-m_minYExtent);
544+ // Stick the header item to the top when dragging down
545+ m_headerItem->setY(contentY());
546+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
535 // We will be changing the clip item, need to accomadate for it
548 // We will be changing the clip item, need to accomadate for it
536 // otherwise we move the firstItem down/up twice (unless the
549 // otherwise we move the firstItem down/up twice (unless the
@@ -1271,6 +1284,11 @@ void ListViewWithPageHeader::updatePolish()
1271 refill();
1284 refill();
1273 if (m_contentHeightDirty) {
1286 if (m_contentHeightDirty) {
1287+ // We need to make sure all bindings have updated otherwise
1288+ // we may end up with bindings updating when we call setContentHeight
1289+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1290+ QCoreApplication::instance()->processEvents();
1274 qreal contentHeight;
1292 qreal contentHeight;
1275 if (m_visibleItems.isEmpty()) {
1293 if (m_visibleItems.isEmpty()) {
1276 contentHeight = m_headerItem ? m_headerItem->height() : 0;
1294 contentHeight = m_headerItem ? m_headerItem->height() : 0;