on xenial help sign in
Fix case in which header was shown incorrectly

Making the list smaller did not move the header so it ended up being in view

commit67c0fdb109d4829e2dd5ec2dcf83ca9bee292f62 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 3 Aug 2016, 18:04 (10 years ago) parentd406bd8
2 files changed+19−1
plugins/Dash/listviewwithpageheader.cpp+5−1 tests/plugins/Dash/listviewwithpageheadertest.cpp+14
plugins/Dash/listviewwithpageheader.cpp+5−1
@@ -587,6 +587,10 @@ void ListViewWithPageHeader::adjustHeader(qreal diff)
587587 } else {
588588 m_headerItem->setY(-m_minYExtent);
589589 }
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);
590594 }
591595 Q_EMIT headerItemShownHeightChanged();
592596 } else {
@@ -1027,7 +1031,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
10271031 m_firstVisibleIndex = -1;
10281032 } else {
10291033 m_firstVisibleIndex -= qMax(0, m_firstVisibleIndex - remove.index);
1030− }
1034+ }
10311035 } else if (remove.index + remove.count <= m_firstVisibleIndex) {
10321036 m_firstVisibleIndex -= remove.count;
10331037 }
tests/plugins/Dash/listviewwithpageheadertest.cpp+14
@@ -1994,6 +1994,20 @@ private Q_SLOTS:
19941994 verifyItem(2, 400., 350., false);
19951995 }
19961996
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+
19972011private:
19982012 QQuickView *view;
19992013 ListViewWithPageHeader *lvwph;