on xenial help sign in
Make LVWPH provide a delegateIndex for sectionHeaders

This way we can match the sectionHeader to the model easier in the qml/js side

commitad9274611058fe3377e9c295575a2d3135e48907 authorAlbert Astals <albert.astals@canonical.com> dateThu 1 Aug 2013, 17:13 (13 years ago) parentba5eb2f
3 files changed+73−6
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−3 plugins/ListViewWithPageHeader/listviewwithpageheader.h+1−1 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+51−2
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−3
@@ -269,7 +269,7 @@ void ListViewWithPageHeader::setSectionDelegate(QQmlComponent *delegate)
269269
270270 m_sectionDelegate = delegate;
271271
272− m_topSectionItem = getSectionItem(QString());
272+ m_topSectionItem = getSectionItem(-1, QString());
273273 m_topSectionItem->setZ(3);
274274 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
275275
@@ -578,16 +578,17 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
578578 }
579579 }
580580
581− return getSectionItem(section);
581+ return getSectionItem(modelIndex, section);
582582}
583583
584−QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText)
584+QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, const QString &sectionText)
585585{
586586 QQuickItem *sectionItem = nullptr;
587587
588588 QQmlContext *creationContext = m_sectionDelegate->creationContext();
589589 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
590590 context->setContextProperty(QLatin1String("section"), sectionText);
591+ context->setContextProperty(QLatin1String("delegateIndex"), modelIndex);
591592 QObject *nobj = m_sectionDelegate->beginCreate(context);
592593 if (nobj) {
593594 QQml_setParent_noEvent(context, nobj);
@@ -870,6 +871,14 @@ void ListViewWithPageHeader::onModelUpdated(const QQuickChangeSet &changeSet, bo
870871 adjustMinYExtent();
871872 }
872873
874+ for (int i = 0; i < m_visibleItems.count(); ++i) {
875+ ListItem *item = m_visibleItems[i];
876+ if (item->m_sectionItem) {
877+ QQmlContext *context = QQmlEngine::contextForObject(item->m_sectionItem)->parentContext();
878+ context->setContextProperty(QLatin1String("delegateIndex"), m_firstVisibleIndex + i);
879+ }
880+ }
881+
873882 layout();
874883 polish();
875884 m_contentHeightDirty = true;
@@ -998,6 +1007,15 @@ void ListViewWithPageHeader::layout()
9981007 } else {
9991008 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
10001009 m_topSectionItem->setY(topSectionStickPos);
1010+ int delegateIndex = modelIndex;
1011+ // Look for the first index with this section text
1012+ while (delegateIndex > 0) {
1013+ const QString prevSection = m_delegateModel->stringValue(delegateIndex - 1, m_sectionProperty);
1014+ if (prevSection != section)
1015+ break;
1016+ delegateIndex--;
1017+ }
1018+ context->setContextProperty(QLatin1String("delegateIndex"), delegateIndex);
10011019 if (item->m_sectionItem) {
10021020 QQuickItemPrivate::get(item->m_sectionItem)->setCulled(true);
10031021 }
plugins/ListViewWithPageHeader/listviewwithpageheader.h+1−1
@@ -139,7 +139,7 @@ private:
139139 void reallyReleaseItem(ListItem *item);
140140 void updateWatchedRoles();
141141 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
142− QQuickItem *getSectionItem(const QString &sectionText);
142+ QQuickItem *getSectionItem(int modelIndex, const QString &sectionText);
143143
144144 QQuickVisualDataModel *m_delegateModel;
145145
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+51−2
@@ -41,6 +41,7 @@ private:
4141 QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), sectionHeader);
4242 if (!sectionHeader.isNull()) {
4343 QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_sectionItem)->culled, sectionHeaderCulled);
44+ QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), lvwph->m_firstVisibleIndex + visibleIndex);
4445 }
4546 }
4647
@@ -112,6 +113,11 @@ private:
112113 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString();
113114 }
114115
116+ int sectionDelegateIndex(QQuickItem *item)
117+ {
118+ return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1;
119+ }
120+
115121private Q_SLOTS:
116122
117123 void initTestCase()
@@ -212,6 +218,7 @@ private Q_SLOTS:
212218 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
213219 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
214220 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
221+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
215222 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
216223 }
217224
@@ -233,6 +240,7 @@ private Q_SLOTS:
233240 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
234241 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
235242 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
243+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
236244 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
237245 }
238246
@@ -254,6 +262,7 @@ private Q_SLOTS:
254262 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
255263 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
256264 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
265+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
257266 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
258267
259268 changeContentY(-30);
@@ -272,6 +281,7 @@ private Q_SLOTS:
272281 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
273282 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
274283 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
284+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
275285 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
276286 }
277287
@@ -327,6 +337,7 @@ private Q_SLOTS:
327337 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
328338 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
329339 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
340+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
330341 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
331342
332343 lvwph->positionAtBeginning();
@@ -352,6 +363,7 @@ private Q_SLOTS:
352363 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
353364 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
354365 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
366+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
355367 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
356368
357369 lvwph->positionAtBeginning();
@@ -396,6 +408,7 @@ private Q_SLOTS:
396408 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
397409 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
398410 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
411+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
399412 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
400413
401414 model->setProperty(0, "size", 400);
@@ -415,6 +428,7 @@ private Q_SLOTS:
415428 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
416429 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
417430 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
431+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
418432 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
419433
420434 scrollToTop();
@@ -468,6 +482,7 @@ private Q_SLOTS:
468482 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
469483 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
470484 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
485+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
471486 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
472487
473488 model->setProperty(0, "size", 400);
@@ -487,6 +502,7 @@ private Q_SLOTS:
487502 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
488503 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
489504 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
505+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
490506 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
491507
492508 scrollToTop();
@@ -523,6 +539,7 @@ private Q_SLOTS:
523539 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
524540 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
525541 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
542+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
526543 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
527544
528545 changeContentY(-30);
@@ -540,6 +557,7 @@ private Q_SLOTS:
540557 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
541558 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
542559 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
560+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
543561 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
544562
545563 changeContentY(30);
@@ -557,6 +575,7 @@ private Q_SLOTS:
557575 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
558576 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
559577 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
578+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
560579 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
561580
562581 changeContentY(-30);
@@ -574,6 +593,7 @@ private Q_SLOTS:
574593 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
575594 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
576595 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
596+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
577597 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
578598 }
579599
@@ -594,6 +614,7 @@ private Q_SLOTS:
594614 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
595615 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
596616 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
617+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
597618 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
598619
599620 lvwph->setDelegate(otherDelegate);
@@ -652,6 +673,7 @@ private Q_SLOTS:
652673 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
653674 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
654675 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
676+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
655677 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
656678
657679 scrollToTop();
@@ -690,6 +712,7 @@ private Q_SLOTS:
690712 QTRY_VERIFY(lvwph->isAtYEnd());
691713 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
692714 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
715+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
693716 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
694717
695718 scrollToTop();
@@ -726,6 +749,7 @@ private Q_SLOTS:
726749 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
727750 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
728751 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
752+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
729753 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
730754 }
731755
@@ -810,6 +834,7 @@ private Q_SLOTS:
810834 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
811835 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
812836 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
837+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
813838 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
814839
815840 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -830,6 +855,7 @@ private Q_SLOTS:
830855 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
831856 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
832857 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
858+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
833859 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
834860
835861 scrollToTop();
@@ -870,6 +896,7 @@ private Q_SLOTS:
870896 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
871897 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
872898 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
899+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
873900 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
874901
875902 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 3), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -890,6 +917,7 @@ private Q_SLOTS:
890917 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
891918 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
892919 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
920+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
893921 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
894922 }
895923
@@ -912,6 +940,7 @@ private Q_SLOTS:
912940 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
913941 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
914942 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
943+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
915944 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
916945
917946 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -932,6 +961,7 @@ private Q_SLOTS:
932961 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
933962 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
934963 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
964+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
935965 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
936966 }
937967
@@ -954,6 +984,7 @@ private Q_SLOTS:
954984 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
955985 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
956986 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
987+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
957988 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
958989
959990 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -974,6 +1005,7 @@ private Q_SLOTS:
9741005 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
9751006 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
9761007 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1008+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
9771009 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
9781010
9791011 scrollToTop();
@@ -1021,6 +1053,7 @@ private Q_SLOTS:
10211053 QVERIFY(!lvwph->isAtYEnd());
10221054 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10231055 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1056+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
10241057 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10251058
10261059 scrollToBottom();
@@ -1041,6 +1074,7 @@ private Q_SLOTS:
10411074 QVERIFY(lvwph->isAtYEnd());
10421075 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10431076 QCOMPARE(section(lvwph->m_topSectionItem), QString("Lazy"));
1077+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 5);
10441078 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10451079 }
10461080
@@ -1094,6 +1128,7 @@ private Q_SLOTS:
10941128 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
10951129 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10961130 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1131+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 13);
10971132 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10981133
10991134 changeContentY(-1700);
@@ -1118,6 +1153,7 @@ private Q_SLOTS:
11181153 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
11191154 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11201155 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1156+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
11211157 QCOMPARE(lvwph->m_topSectionItem->y(), -23.);
11221158 }
11231159
@@ -1179,6 +1215,7 @@ private Q_SLOTS:
11791215 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
11801216 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11811217 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1218+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
11821219 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
11831220 }
11841221
@@ -1202,6 +1239,7 @@ private Q_SLOTS:
12021239 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12031240 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12041241 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1242+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12051243 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12061244 }
12071245
@@ -1224,6 +1262,7 @@ private Q_SLOTS:
12241262 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12251263 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12261264 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1265+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12271266 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12281267
12291268 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 1));
@@ -1243,6 +1282,7 @@ private Q_SLOTS:
12431282 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12441283 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12451284 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1285+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
12461286 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12471287 }
12481288
@@ -1265,6 +1305,7 @@ private Q_SLOTS:
12651305 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12661306 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12671307 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1308+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12681309 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12691310
12701311 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 3), Q_ARG(QVariant, 1));
@@ -1284,6 +1325,7 @@ private Q_SLOTS:
12841325 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12851326 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12861327 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1328+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12871329 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12881330 }
12891331
@@ -1363,6 +1405,7 @@ private Q_SLOTS:
13631405 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
13641406 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13651407 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1408+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
13661409 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13671410
13681411 QMetaObject::invokeMethod(model, "moveItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 5), Q_ARG(QVariant, 1));
@@ -1383,6 +1426,7 @@ private Q_SLOTS:
13831426 QVERIFY(!lvwph->isAtYEnd());
13841427 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13851428 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1429+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
13861430 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13871431 }
13881432
@@ -1406,6 +1450,7 @@ private Q_SLOTS:
14061450 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14071451 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14081452 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1453+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
14091454 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14101455
14111456 model->setProperty(1, "size", 100);
@@ -1426,6 +1471,7 @@ private Q_SLOTS:
14261471 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14271472 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14281473 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1474+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
14291475 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14301476 }
14311477
@@ -1447,7 +1493,7 @@ private Q_SLOTS:
14471493 QCOMPARE(lvwph->m_headerItem->y(), 0.);
14481494 QCOMPARE(lvwph->m_headerItem->height(), 50.);
14491495 QCOMPARE(lvwph->contentY(), 20.);
1450− QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1496+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14511497 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14521498
14531499 lvwph->showHeader();
@@ -1467,6 +1513,7 @@ private Q_SLOTS:
14671513 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
14681514 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14691515 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1516+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
14701517 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14711518
14721519 scrollToTop();
@@ -1502,9 +1549,10 @@ private Q_SLOTS:
15021549 QCOMPARE(lvwph->m_headerItem->y(), 0.);
15031550 QCOMPARE(lvwph->m_headerItem->height(), 50.);
15041551 QCOMPARE(lvwph->contentY(), 375.);
1505− QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1552+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
15061553 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15071554 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1555+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
15081556 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15091557
15101558 lvwph->showHeader();
@@ -1525,6 +1573,7 @@ private Q_SLOTS:
15251573 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
15261574 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15271575 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1576+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
15281577 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15291578
15301579 scrollToTop();