on xenial help sign in
sectionDelegates get the delegateIndex first as -1 and then to the correct value

This makes sense as initially their item has not been added to the internal list yet so if they try to use it that soon it will return null, now we only set the delegateIndex when the item is really there

commitf580988c37026886d2f3eff7e658ddf77ca0f46d authorAlbert Astals <albert.astals@canonical.com> dateThu 8 Aug 2013, 18:15 (13 years ago) parente72ae66
2 files changed+5−5
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+4−4 plugins/ListViewWithPageHeader/listviewwithpageheader.h+1−1
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+4−4
@@ -280,7 +280,7 @@ void ListViewWithPageHeader::setSectionDelegate(QQmlComponent *delegate)
280280
281281 m_sectionDelegate = delegate;
282282
283− m_topSectionItem = getSectionItem(-1, QString());
283+ m_topSectionItem = getSectionItem(QString());
284284 m_topSectionItem->setZ(3);
285285 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
286286
@@ -651,17 +651,17 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
651651 }
652652 }
653653
654− return getSectionItem(modelIndex, section);
654+ return getSectionItem(section);
655655}
656656
657−QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, const QString &sectionText)
657+QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText)
658658{
659659 QQuickItem *sectionItem = nullptr;
660660
661661 QQmlContext *creationContext = m_sectionDelegate->creationContext();
662662 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
663663 context->setContextProperty(QLatin1String("section"), sectionText);
664− context->setContextProperty(QLatin1String("delegateIndex"), modelIndex);
664+ context->setContextProperty(QLatin1String("delegateIndex"), -1);
665665 QObject *nobj = m_sectionDelegate->beginCreate(context);
666666 if (nobj) {
667667 QQml_setParent_noEvent(context, nobj);
plugins/ListViewWithPageHeader/listviewwithpageheader.h+1−1
@@ -158,7 +158,7 @@ private:
158158 void reallyReleaseItem(ListItem *item);
159159 void updateWatchedRoles();
160160 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
161− QQuickItem *getSectionItem(int modelIndex, const QString &sectionText);
161+ QQuickItem *getSectionItem(const QString &sectionText);
162162
163163#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
164164 QQuickVisualDataModel *m_delegateModel;