on xenial help sign in
Update m_firstVisibleIndex if there's no visible items anymore

Also remove the check for m_visibleItems.isEmpty() on insert, the m_firstVisibleIndex == 0 already protects us against that. Approved by Michael Zanetti, PS Jenkins bot.

commitfa506069423ce4eaf9b8815e40114971807d77f5 authorAlbert Astals <albert.astals@canonical.com> dateThu 25 Jul 2013, 12:23 (13 years ago) parent9995d94740e437
1 file changed+9−5
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+9−5
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+9−5
@@ -785,10 +785,14 @@ void ListViewWithPageHeader::onModelUpdated(const QQuickChangeSet &changeSet, bo
785785 }
786786 if (growDown) {
787787 adjustMinYExtent();
788− } else if (remove.index <= m_firstVisibleIndex && !m_visibleItems.isEmpty()) {
789− // We removed the first item that is the one that positions the rest
790− // position the new first item correctly
791− m_visibleItems.first()->setY(oldFirstValidIndexPos);
788+ } else if (remove.index <= m_firstVisibleIndex) {
789+ if (!m_visibleItems.isEmpty()) {
790+ // We removed the first item that is the one that positions the rest
791+ // position the new first item correctly
792+ m_visibleItems.first()->setY(oldFirstValidIndexPos);
793+ } else {
794+ m_firstVisibleIndex = -1;
795+ }
792796 }
793797 } else if (remove.index + remove.count <= m_firstVisibleIndex) {
794798 m_firstVisibleIndex -= remove.count;
@@ -806,7 +810,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQuickChangeSet &changeSet, bo
806810 Q_FOREACH(const QQuickChangeSet::Insert &insert, changeSet.inserts()) {
807811// qDebug() << "ListViewWithPageHeader::onModelUpdated Insert" << insert.index << insert.count;
808812 const bool insertingInValidIndexes = insert.index > m_firstVisibleIndex && insert.index < m_firstVisibleIndex + m_visibleItems.count();
809− const bool firstItemWithViewOnTop = insert.index == 0 && m_firstVisibleIndex == 0 && !m_visibleItems.isEmpty() && m_visibleItems.first()->y() + m_clipItem->y() > contentY();
813+ const bool firstItemWithViewOnTop = insert.index == 0 && m_firstVisibleIndex == 0 && m_visibleItems.first()->y() + m_clipItem->y() > contentY();
810814 if (insertingInValidIndexes || firstItemWithViewOnTop)
811815 {
812816 // If the items we are adding won't be really visible