on xenial help sign in
Fix case in which header was shown incorrectly
67c0fdbAlbert Astals Cid
plugins/Dash/listviewwithpageheader.cpp+5−1
@@ -587,6 +587,10 @@ void ListViewWithPageHeader::adjustHeader(qreal diff)
587 } else {
587 } else {
588 m_headerItem->setY(-m_minYExtent);
588 m_headerItem->setY(-m_minYExtent);
589 }
589 }
590+ } else if (m_headerItemShownHeight == 0 && m_previousContentY > m_headerItem->y() && contentY() < m_headerItem->y()) {
591+ // The header was hidden but now that we've moved up (e.g. because of item removed) it'd visible
592+ // make sure it isn't
593+ m_headerItem->setY(-m_minYExtent);
590 }
594 }
591 Q_EMIT headerItemShownHeightChanged();
595 Q_EMIT headerItemShownHeightChanged();
592 } else {
596 } else {
@@ -1027,7 +1031,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
1027 m_firstVisibleIndex = -1;
1031 m_firstVisibleIndex = -1;
1028 } else {
1032 } else {
1029 m_firstVisibleIndex -= qMax(0, m_firstVisibleIndex - remove.index);
1033 m_firstVisibleIndex -= qMax(0, m_firstVisibleIndex - remove.index);
1030− }
1034+ }
1031 } else if (remove.index + remove.count <= m_firstVisibleIndex) {
1035 } else if (remove.index + remove.count <= m_firstVisibleIndex) {
1032 m_firstVisibleIndex -= remove.count;
1036 m_firstVisibleIndex -= remove.count;
1033 }
1037 }
tests/plugins/Dash/listviewwithpageheadertest.cpp+14
@@ -1994,6 +1994,20 @@ private Q_SLOTS:
1994 verifyItem(2, 400., 350., false);
1994 verifyItem(2, 400., 350., false);
1995 }
1995 }
1996
1996
1997+ void testRemoveItemNotShowHeader()
1998+ {
1999+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 6));
2000+ QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 0), Q_ARG(QVariant, 90));
2001+ QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 600));
2002+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
2003+ scrollToBottom();
2004+ QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 2000));
2005+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
2006+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 2), Q_ARG(QVariant, 1));
2007+ QTRY_COMPARE(lvwph->m_headerItem->y(), -610.);
2008+ QTRY_COMPARE(lvwph->m_minYExtent, 610.);
2009+ }
2010+
1997private:
2011private:
1998 QQuickView *view;
2012 QQuickView *view;
1999 ListViewWithPageHeader *lvwph;
2013 ListViewWithPageHeader *lvwph;