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 . Approved by PS Jenkins bot, Michael Zanetti.

commit1fbfcd71fd74cf9bf84b9198906e5ed39e02298c authorAlbert Astals <albert.astals@canonical.com> dateFri 2 Aug 2013, 08:52 (13 years ago) parent6dccd0ead92746
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
@@ -280,7 +280,7 @@ void ListViewWithPageHeader::setSectionDelegate(QQmlComponent *delegate)
280280
281281 m_sectionDelegate = delegate;
282282
283− m_topSectionItem = getSectionItem(QString());
283+ m_topSectionItem = getSectionItem(-1, QString());
284284 m_topSectionItem->setZ(3);
285285 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
286286
@@ -599,16 +599,17 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
599599 }
600600 }
601601
602− return getSectionItem(section);
602+ return getSectionItem(modelIndex, section);
603603}
604604
605−QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText)
605+QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, const QString &sectionText)
606606{
607607 QQuickItem *sectionItem = nullptr;
608608
609609 QQmlContext *creationContext = m_sectionDelegate->creationContext();
610610 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
611611 context->setContextProperty(QLatin1String("section"), sectionText);
612+ context->setContextProperty(QLatin1String("delegateIndex"), modelIndex);
612613 QObject *nobj = m_sectionDelegate->beginCreate(context);
613614 if (nobj) {
614615 QQml_setParent_noEvent(context, nobj);
@@ -932,6 +933,14 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
932933 adjustMinYExtent();
933934 }
934935
936+ for (int i = 0; i < m_visibleItems.count(); ++i) {
937+ ListItem *item = m_visibleItems[i];
938+ if (item->m_sectionItem) {
939+ QQmlContext *context = QQmlEngine::contextForObject(item->m_sectionItem)->parentContext();
940+ context->setContextProperty(QLatin1String("delegateIndex"), m_firstVisibleIndex + i);
941+ }
942+ }
943+
935944 layout();
936945 polish();
937946 m_contentHeightDirty = true;
@@ -1060,6 +1069,15 @@ void ListViewWithPageHeader::layout()
10601069
10611070 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
10621071 m_topSectionItem->setY(topSectionStickPos);
1072+ int delegateIndex = modelIndex;
1073+ // Look for the first index with this section text
1074+ while (delegateIndex > 0) {
1075+ const QString prevSection = m_delegateModel->stringValue(delegateIndex - 1, m_sectionProperty);
1076+ if (prevSection != section)
1077+ break;
1078+ delegateIndex--;
1079+ }
1080+ context->setContextProperty(QLatin1String("delegateIndex"), delegateIndex);
10631081 if (item->m_sectionItem) {
10641082 QQuickItemPrivate::get(item->m_sectionItem)->setCulled(true);
10651083 }
plugins/ListViewWithPageHeader/listviewwithpageheader.h+1−1
@@ -152,7 +152,7 @@ private:
152152 void reallyReleaseItem(ListItem *item);
153153 void updateWatchedRoles();
154154 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
155− QQuickItem *getSectionItem(const QString &sectionText);
155+ QQuickItem *getSectionItem(int modelIndex, const QString &sectionText);
156156
157157#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
158158 QQuickVisualDataModel *m_delegateModel;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+51−2
@@ -45,6 +45,7 @@ private:
4545 QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), sectionHeader);
4646 if (!sectionHeader.isNull()) {
4747 QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_sectionItem)->culled, sectionHeaderCulled);
48+ QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), lvwph->m_firstVisibleIndex + visibleIndex);
4849 }
4950 }
5051
@@ -116,6 +117,11 @@ private:
116117 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString();
117118 }
118119
120+ int sectionDelegateIndex(QQuickItem *item)
121+ {
122+ return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1;
123+ }
124+
119125private Q_SLOTS:
120126
121127 void initTestCase()
@@ -220,6 +226,7 @@ private Q_SLOTS:
220226 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
221227 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
222228 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
229+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
223230 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
224231 }
225232
@@ -241,6 +248,7 @@ private Q_SLOTS:
241248 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
242249 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
243250 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
251+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
244252 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
245253 }
246254
@@ -262,6 +270,7 @@ private Q_SLOTS:
262270 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
263271 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
264272 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
273+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
265274 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
266275
267276 changeContentY(-30);
@@ -280,6 +289,7 @@ private Q_SLOTS:
280289 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
281290 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
282291 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
292+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
283293 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
284294 }
285295
@@ -335,6 +345,7 @@ private Q_SLOTS:
335345 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
336346 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
337347 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
348+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
338349 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
339350
340351 lvwph->positionAtBeginning();
@@ -360,6 +371,7 @@ private Q_SLOTS:
360371 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
361372 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
362373 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
374+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
363375 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
364376
365377 lvwph->positionAtBeginning();
@@ -404,6 +416,7 @@ private Q_SLOTS:
404416 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
405417 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
406418 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
419+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
407420 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
408421
409422 model->setProperty(0, "size", 400);
@@ -423,6 +436,7 @@ private Q_SLOTS:
423436 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
424437 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
425438 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
439+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
426440 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
427441
428442 scrollToTop();
@@ -476,6 +490,7 @@ private Q_SLOTS:
476490 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
477491 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
478492 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
493+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
479494 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
480495
481496 model->setProperty(0, "size", 400);
@@ -495,6 +510,7 @@ private Q_SLOTS:
495510 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
496511 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
497512 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
513+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
498514 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
499515
500516 scrollToTop();
@@ -531,6 +547,7 @@ private Q_SLOTS:
531547 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
532548 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
533549 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
550+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
534551 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
535552
536553 changeContentY(-30);
@@ -548,6 +565,7 @@ private Q_SLOTS:
548565 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
549566 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
550567 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
568+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
551569 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
552570
553571 changeContentY(30);
@@ -565,6 +583,7 @@ private Q_SLOTS:
565583 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
566584 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
567585 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
586+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
568587 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
569588
570589 changeContentY(-30);
@@ -582,6 +601,7 @@ private Q_SLOTS:
582601 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
583602 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
584603 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
604+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
585605 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
586606 }
587607
@@ -602,6 +622,7 @@ private Q_SLOTS:
602622 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
603623 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
604624 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
625+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
605626 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
606627
607628 lvwph->setDelegate(otherDelegate);
@@ -660,6 +681,7 @@ private Q_SLOTS:
660681 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
661682 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
662683 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
684+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
663685 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
664686
665687 scrollToTop();
@@ -698,6 +720,7 @@ private Q_SLOTS:
698720 QTRY_VERIFY(lvwph->isAtYEnd());
699721 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
700722 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
723+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
701724 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
702725
703726 scrollToTop();
@@ -734,6 +757,7 @@ private Q_SLOTS:
734757 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
735758 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
736759 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
760+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
737761 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
738762 }
739763
@@ -818,6 +842,7 @@ private Q_SLOTS:
818842 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
819843 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
820844 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
845+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
821846 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
822847
823848 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -838,6 +863,7 @@ private Q_SLOTS:
838863 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
839864 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
840865 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
866+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
841867 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
842868
843869 scrollToTop();
@@ -878,6 +904,7 @@ private Q_SLOTS:
878904 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
879905 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
880906 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
907+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
881908 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
882909
883910 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 3), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -898,6 +925,7 @@ private Q_SLOTS:
898925 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
899926 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
900927 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
928+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
901929 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
902930 }
903931
@@ -920,6 +948,7 @@ private Q_SLOTS:
920948 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
921949 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
922950 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
951+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
923952 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
924953
925954 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -940,6 +969,7 @@ private Q_SLOTS:
940969 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
941970 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
942971 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
972+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
943973 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
944974 }
945975
@@ -962,6 +992,7 @@ private Q_SLOTS:
962992 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
963993 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
964994 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
995+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
965996 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
966997
967998 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -982,6 +1013,7 @@ private Q_SLOTS:
9821013 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
9831014 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
9841015 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1016+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
9851017 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
9861018
9871019 scrollToTop();
@@ -1029,6 +1061,7 @@ private Q_SLOTS:
10291061 QVERIFY(!lvwph->isAtYEnd());
10301062 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10311063 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1064+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
10321065 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10331066
10341067 scrollToBottom();
@@ -1049,6 +1082,7 @@ private Q_SLOTS:
10491082 QVERIFY(lvwph->isAtYEnd());
10501083 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10511084 QCOMPARE(section(lvwph->m_topSectionItem), QString("Lazy"));
1085+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 5);
10521086 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10531087 }
10541088
@@ -1102,6 +1136,7 @@ private Q_SLOTS:
11021136 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
11031137 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11041138 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1139+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 13);
11051140 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
11061141
11071142 changeContentY(-1700);
@@ -1126,6 +1161,7 @@ private Q_SLOTS:
11261161 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
11271162 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11281163 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1164+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
11291165 QCOMPARE(lvwph->m_topSectionItem->y(), -23.);
11301166 }
11311167
@@ -1187,6 +1223,7 @@ private Q_SLOTS:
11871223 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
11881224 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11891225 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1226+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
11901227 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
11911228 }
11921229
@@ -1210,6 +1247,7 @@ private Q_SLOTS:
12101247 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12111248 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12121249 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1250+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12131251 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12141252 }
12151253
@@ -1232,6 +1270,7 @@ private Q_SLOTS:
12321270 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12331271 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12341272 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1273+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12351274 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12361275
12371276 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 1));
@@ -1251,6 +1290,7 @@ private Q_SLOTS:
12511290 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12521291 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12531292 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1293+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
12541294 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12551295 }
12561296
@@ -1273,6 +1313,7 @@ private Q_SLOTS:
12731313 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12741314 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12751315 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1316+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12761317 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12771318
12781319 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 3), Q_ARG(QVariant, 1));
@@ -1292,6 +1333,7 @@ private Q_SLOTS:
12921333 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12931334 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12941335 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1336+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
12951337 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12961338 }
12971339
@@ -1371,6 +1413,7 @@ private Q_SLOTS:
13711413 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
13721414 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13731415 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1416+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
13741417 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13751418
13761419 QMetaObject::invokeMethod(model, "moveItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 5), Q_ARG(QVariant, 1));
@@ -1391,6 +1434,7 @@ private Q_SLOTS:
13911434 QVERIFY(!lvwph->isAtYEnd());
13921435 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13931436 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1437+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
13941438 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13951439 }
13961440
@@ -1414,6 +1458,7 @@ private Q_SLOTS:
14141458 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14151459 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14161460 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1461+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
14171462 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14181463
14191464 model->setProperty(1, "size", 100);
@@ -1434,6 +1479,7 @@ private Q_SLOTS:
14341479 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14351480 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14361481 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1482+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
14371483 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14381484 }
14391485
@@ -1455,7 +1501,7 @@ private Q_SLOTS:
14551501 QCOMPARE(lvwph->m_headerItem->y(), 0.);
14561502 QCOMPARE(lvwph->m_headerItem->height(), 50.);
14571503 QCOMPARE(lvwph->contentY(), 20.);
1458− QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1504+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14591505 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14601506
14611507 lvwph->showHeader();
@@ -1475,6 +1521,7 @@ private Q_SLOTS:
14751521 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
14761522 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14771523 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1524+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
14781525 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14791526
14801527 scrollToTop();
@@ -1510,9 +1557,10 @@ private Q_SLOTS:
15101557 QCOMPARE(lvwph->m_headerItem->y(), 0.);
15111558 QCOMPARE(lvwph->m_headerItem->height(), 50.);
15121559 QCOMPARE(lvwph->contentY(), 375.);
1513− QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1560+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
15141561 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15151562 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1563+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
15161564 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15171565
15181566 lvwph->showHeader();
@@ -1533,6 +1581,7 @@ private Q_SLOTS:
15331581 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
15341582 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15351583 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1584+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
15361585 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15371586
15381587 scrollToTop();