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

Making the list smaller did not move the header so it ended up being in view Approved by: Josh Arenson

commit9c327b6ca2e9ccd74735fccfbb30aab244ade3b1 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 13 Sep 2016, 06:48 (10 years ago) parent27bfea66be603d
2 files changed+18
plugins/Dash/listviewwithpageheader.cpp+4 tests/plugins/Dash/listviewwithpageheadertest.cpp+14
plugins/Dash/listviewwithpageheader.cpp+4
@@ -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's visible
592+ // make sure it isn't
593+ m_headerItem->setY(-m_minYExtent);
590594 }
591595 Q_EMIT headerItemShownHeightChanged();
592596 } else {
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;