on xenial help sign in
Improve LVWPH <-> GenericScopeView interaction

Send up directly the delegate instead of the delegateIndex and then asking back for the delegate Saves "time" and also if the delegateIndex is the same number but the delegate different the delegate won't be updated because QML doesn't know it's different

commitc8be7b65aa975c813ea0a28e3ab3fcb8d1dbc4b3 authorAlbert Astals Cid <albert.astals@canonical.com> dateThu 6 Oct 2016, 09:50 (10 years ago) parentc898524
5 files changed+62−81
plugins/Dash/listviewwithpageheader.cpp+4−21 plugins/Dash/listviewwithpageheader.h−1 qml/Dash/GenericScopeView.qml+1−2 tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp+3−3 tests/plugins/Dash/listviewwithpageheadersectiontest.cpp+54−54
plugins/Dash/listviewwithpageheader.cpp+4−21
@@ -442,15 +442,6 @@ int ListViewWithPageHeader::createdItemCount() const
442442 return m_visibleItems.count();
443443}
444444
445−QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
446−{
447− ListItem *item = itemAtIndex(modelIndex);
448− if (item)
449− return item->m_item;
450− else
451− return nullptr;
452−}
453−
454445bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
455446{
456447 ListItem *listItem = itemAtIndex(modelIndex);
@@ -772,7 +763,7 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText, b
772763 delete nobj;
773764 } else {
774765 sectionItem->setProperty("text", sectionText);
775− sectionItem->setProperty("delegateIndex", -1);
766+ sectionItem->setProperty("delegate", QVariant());
776767 sectionItem->setZ(2);
777768 QQml_setParent_noEvent(sectionItem, m_clipItem);
778769 sectionItem->setParentItem(m_clipItem);
@@ -929,7 +920,7 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
929920 polish();
930921 }
931922 if (listItem->sectionItem()) {
932− listItem->sectionItem()->setProperty("delegateIndex", modelIndex);
923+ listItem->sectionItem()->setProperty("delegate", QVariant::fromValue(listItem->m_item));
933924 }
934925 adjustMinYExtent();
935926 m_contentHeightDirty = true;
@@ -1123,7 +1114,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
11231114 for (int i = 0; i < m_visibleItems.count(); ++i) {
11241115 ListItem *item = m_visibleItems[i];
11251116 if (item->sectionItem()) {
1126− item->sectionItem()->setProperty("delegateIndex", m_firstVisibleIndex + i);
1117+ item->sectionItem()->setProperty("delegate", QVariant::fromValue(item->m_item));
11271118 }
11281119 }
11291120
@@ -1297,15 +1288,7 @@ void ListViewWithPageHeader::layout()
12971288
12981289 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
12991290 m_topSectionItem->setY(topSectionStickPos);
1300− int delegateIndex = modelIndex;
1301− // Look for the first index with this section text
1302− while (delegateIndex > 0) {
1303− const QString prevSection = m_delegateModel->stringValue(delegateIndex - 1, m_sectionProperty);
1304− if (prevSection != section)
1305− break;
1306− delegateIndex--;
1307− }
1308− m_topSectionItem->setProperty("delegateIndex", delegateIndex);
1291+ m_topSectionItem->setProperty("delegate", QVariant::fromValue(item->m_item));
13091292 if (item->sectionItem()) {
13101293 QQuickItemPrivate::get(item->sectionItem())->setCulled(true);
13111294 }
plugins/Dash/listviewwithpageheader.h−1
@@ -92,7 +92,6 @@ public:
9292 Q_INVOKABLE void showHeader();
9393 Q_INVOKABLE int firstCreatedIndex() const;
9494 Q_INVOKABLE int createdItemCount() const;
95− Q_INVOKABLE QQuickItem *item(int modelIndex) const;
9695
9796 // The index has to be created for this to try to do something
9897 // Created items are those visible and the precached ones
qml/Dash/GenericScopeView.qml+1−2
@@ -623,8 +623,7 @@ FocusScope {
623623 sectionProperty: "name"
624624 sectionDelegate: ListItems.Header {
625625 objectName: "dashSectionHeader" + (delegate ? delegate.category : "")
626− property int delegateIndex: -1
627− readonly property var delegate: categoryView.item(delegateIndex)
626+ property var delegate: null
628627 width: categoryView.width
629628 height: text != "" ? units.gu(5) : 0
630629 color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp+3−3
@@ -82,7 +82,7 @@ private:
8282 QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->sectionItem()), sectionHeader);
8383 if (!sectionHeader.isNull()) {
8484 QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->sectionItem())->culled, sectionHeaderCulled);
85− QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_firstVisibleIndex + visibleIndex);
85+ QCOMPARE(sectionDelegate(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_visibleItems[visibleIndex]->m_item);
8686 }
8787 }
8888
@@ -151,9 +151,9 @@ private:
151151 return item ? item->property("text").toString() : QString();
152152 }
153153
154− int sectionDelegateIndex(QQuickItem *item)
154+ QQuickItem *sectionDelegate(QQuickItem *item)
155155 {
156− return item ? item->property("delegateIndex").toInt() : -1;
156+ return item ? item->property("delegate").value<QQuickItem *>() : nullptr;
157157 }
158158
159159private Q_SLOTS:
tests/plugins/Dash/listviewwithpageheadersectiontest.cpp+54−54
@@ -39,7 +39,7 @@ private:
3939 QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->sectionItem()), sectionHeader);
4040 if (!sectionHeader.isNull()) {
4141 QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->sectionItem())->culled, sectionHeaderCulled);
42− QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_firstVisibleIndex + visibleIndex);
42+ QCOMPARE(sectionDelegate(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_visibleItems[visibleIndex]->m_item);
4343 }
4444 }
4545
@@ -116,9 +116,9 @@ private:
116116 return item ? item->property("text").toString() : QString();
117117 }
118118
119− int sectionDelegateIndex(QQuickItem *item) const
119+ QQuickItem *sectionDelegate(QQuickItem *item) const
120120 {
121− return item ? item->property("delegateIndex").toInt() : -1;
121+ return item ? item->property("delegate").value<QQuickItem *>() : nullptr;
122122 }
123123
124124private Q_SLOTS:
@@ -220,7 +220,7 @@ private Q_SLOTS:
220220 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
221221 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
222222 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
223− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
223+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
224224 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
225225 }
226226
@@ -242,7 +242,7 @@ private Q_SLOTS:
242242 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
243243 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
244244 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
245− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
245+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
246246 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
247247 }
248248
@@ -264,7 +264,7 @@ private Q_SLOTS:
264264 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
265265 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
266266 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
267− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
267+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
268268 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
269269
270270 changeContentY(-30);
@@ -283,7 +283,7 @@ private Q_SLOTS:
283283 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
284284 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
285285 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
286− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
286+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
287287 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
288288 }
289289
@@ -339,7 +339,7 @@ private Q_SLOTS:
339339 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
340340 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
341341 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
342− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
342+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
343343 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
344344
345345 lvwph->positionAtBeginning();
@@ -365,7 +365,7 @@ private Q_SLOTS:
365365 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
366366 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
367367 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
368− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
368+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
369369 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
370370
371371 lvwph->positionAtBeginning();
@@ -410,7 +410,7 @@ private Q_SLOTS:
410410 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
411411 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
412412 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
413− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
413+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
414414 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
415415
416416 model->setProperty(0, "size", 400);
@@ -430,7 +430,7 @@ private Q_SLOTS:
430430 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
431431 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
432432 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
433− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
433+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
434434 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
435435
436436 scrollToTop();
@@ -484,7 +484,7 @@ private Q_SLOTS:
484484 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
485485 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
486486 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
487− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
487+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
488488 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
489489
490490 model->setProperty(0, "size", 400);
@@ -504,7 +504,7 @@ private Q_SLOTS:
504504 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
505505 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
506506 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
507− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
507+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
508508 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
509509
510510 scrollToTop();
@@ -541,7 +541,7 @@ private Q_SLOTS:
541541 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
542542 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
543543 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
544− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
544+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
545545 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
546546
547547 changeContentY(-30);
@@ -559,7 +559,7 @@ private Q_SLOTS:
559559 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
560560 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
561561 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
562− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
562+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
563563 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
564564
565565 changeContentY(30);
@@ -577,7 +577,7 @@ private Q_SLOTS:
577577 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
578578 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
579579 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
580− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
580+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
581581 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
582582
583583 changeContentY(-30);
@@ -595,7 +595,7 @@ private Q_SLOTS:
595595 QCOMPARE(lvwph->m_headerItemShownHeight, 30.);
596596 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
597597 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
598− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
598+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
599599 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
600600 }
601601
@@ -616,7 +616,7 @@ private Q_SLOTS:
616616 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
617617 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
618618 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
619− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
619+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
620620 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
621621
622622 lvwph->setDelegate(otherDelegate);
@@ -675,7 +675,7 @@ private Q_SLOTS:
675675 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
676676 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
677677 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
678− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
678+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
679679 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
680680
681681 scrollToTop();
@@ -714,7 +714,7 @@ private Q_SLOTS:
714714 QTRY_VERIFY(lvwph->isAtYEnd());
715715 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
716716 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
717− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
717+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
718718 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
719719
720720 scrollToTop();
@@ -751,7 +751,7 @@ private Q_SLOTS:
751751 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
752752 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
753753 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
754− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
754+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
755755 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
756756 }
757757
@@ -836,7 +836,7 @@ private Q_SLOTS:
836836 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
837837 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
838838 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
839− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
839+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
840840 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
841841
842842 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -857,7 +857,7 @@ private Q_SLOTS:
857857 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
858858 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
859859 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
860− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
860+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
861861 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
862862
863863 scrollToTop();
@@ -898,7 +898,7 @@ private Q_SLOTS:
898898 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
899899 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
900900 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
901− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
901+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
902902 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
903903
904904 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 3), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -919,7 +919,7 @@ private Q_SLOTS:
919919 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
920920 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
921921 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
922− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
922+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
923923 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
924924 }
925925
@@ -942,7 +942,7 @@ private Q_SLOTS:
942942 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
943943 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
944944 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
945− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
945+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
946946 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
947947
948948 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -963,7 +963,7 @@ private Q_SLOTS:
963963 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
964964 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
965965 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
966− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
966+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
967967 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
968968 }
969969
@@ -986,7 +986,7 @@ private Q_SLOTS:
986986 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
987987 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
988988 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
989− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
989+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
990990 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
991991
992992 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 1), Q_ARG(QVariant, 100), Q_ARG(QVariant, "Agressive"));
@@ -1007,7 +1007,7 @@ private Q_SLOTS:
10071007 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
10081008 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10091009 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1010− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
1010+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
10111011 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10121012
10131013 scrollToTop();
@@ -1055,7 +1055,7 @@ private Q_SLOTS:
10551055 QVERIFY(!lvwph->isAtYEnd());
10561056 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10571057 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1058− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
1058+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
10591059 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10601060
10611061 scrollToBottom();
@@ -1076,7 +1076,7 @@ private Q_SLOTS:
10761076 QVERIFY(lvwph->isAtYEnd());
10771077 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
10781078 QCOMPARE(section(lvwph->m_topSectionItem), QString("Lazy"));
1079− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 5);
1079+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
10801080 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
10811081 }
10821082
@@ -1130,7 +1130,7 @@ private Q_SLOTS:
11301130 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
11311131 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11321132 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1133− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 13);
1133+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
11341134 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
11351135
11361136 changeContentY(-1700);
@@ -1155,7 +1155,7 @@ private Q_SLOTS:
11551155 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
11561156 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
11571157 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1158− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 4);
1158+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[3]->m_item);
11591159 QCOMPARE(lvwph->m_topSectionItem->y(), -23.);
11601160 }
11611161
@@ -1217,7 +1217,7 @@ private Q_SLOTS:
12171217 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12181218 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12191219 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1220− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1220+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
12211221 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12221222 }
12231223
@@ -1241,7 +1241,7 @@ private Q_SLOTS:
12411241 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12421242 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12431243 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1244− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1244+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
12451245 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12461246 }
12471247
@@ -1264,7 +1264,7 @@ private Q_SLOTS:
12641264 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12651265 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12661266 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1267− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1267+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
12681268 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12691269
12701270 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 1));
@@ -1284,7 +1284,7 @@ private Q_SLOTS:
12841284 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
12851285 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
12861286 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1287− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1287+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
12881288 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
12891289 }
12901290
@@ -1307,7 +1307,7 @@ private Q_SLOTS:
13071307 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
13081308 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13091309 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1310− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1310+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
13111311 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13121312
13131313 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 3), Q_ARG(QVariant, 1));
@@ -1327,7 +1327,7 @@ private Q_SLOTS:
13271327 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
13281328 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
13291329 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1330− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1330+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
13311331 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
13321332 }
13331333
@@ -1407,7 +1407,7 @@ private Q_SLOTS:
14071407 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14081408 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14091409 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1410− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 3);
1410+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
14111411 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14121412
14131413 QMetaObject::invokeMethod(model, "moveItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 5), Q_ARG(QVariant, 1));
@@ -1428,7 +1428,7 @@ private Q_SLOTS:
14281428 QVERIFY(!lvwph->isAtYEnd());
14291429 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14301430 QCOMPARE(section(lvwph->m_topSectionItem), QString("Bold"));
1431− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1431+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
14321432 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14331433 }
14341434
@@ -1452,7 +1452,7 @@ private Q_SLOTS:
14521452 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14531453 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14541454 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1455− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1455+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[2]->m_item);
14561456 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14571457
14581458 model->setProperty(1, "size", 100);
@@ -1473,7 +1473,7 @@ private Q_SLOTS:
14731473 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14741474 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
14751475 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1476− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1476+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[2]->m_item);
14771477 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
14781478 }
14791479
@@ -1512,7 +1512,7 @@ private Q_SLOTS:
15121512 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
15131513 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15141514 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1515− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
1515+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
15161516 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15171517
15181518 scrollToTop();
@@ -1551,7 +1551,7 @@ private Q_SLOTS:
15511551 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
15521552 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15531553 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1554− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1554+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
15551555 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15561556
15571557 lvwph->showHeader();
@@ -1572,7 +1572,7 @@ private Q_SLOTS:
15721572 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
15731573 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
15741574 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1575− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1575+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
15761576 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
15771577
15781578 scrollToTop();
@@ -1759,7 +1759,7 @@ private Q_SLOTS:
17591759 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
17601760 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
17611761 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1762− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
1762+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
17631763 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
17641764 }
17651765
@@ -1784,7 +1784,7 @@ private Q_SLOTS:
17841784 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
17851785 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
17861786 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1787− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1787+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
17881788 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
17891789 }
17901790
@@ -1892,7 +1892,7 @@ private Q_SLOTS:
18921892 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
18931893 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
18941894 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1895− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1895+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
18961896 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
18971897 }
18981898
@@ -1914,7 +1914,7 @@ private Q_SLOTS:
19141914 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
19151915 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
19161916 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1917− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1917+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
19181918 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
19191919
19201920 bool res = lvwph->maximizeVisibleArea(1);
@@ -1934,7 +1934,7 @@ private Q_SLOTS:
19341934 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
19351935 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
19361936 QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1937− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1937+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
19381938 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
19391939 }
19401940
@@ -1987,7 +1987,7 @@ private Q_SLOTS:
19871987 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
19881988 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
19891989 QCOMPARE(section(lvwph->m_topSectionItem), QString("Mild"));
1990− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 2);
1990+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[1]->m_item);
19911991 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
19921992 }
19931993
@@ -2014,7 +2014,7 @@ private Q_SLOTS:
20142014 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
20152015 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
20162016 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
2017− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
2017+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
20182018 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
20192019
20202020 changeContentY(20);
@@ -2037,7 +2037,7 @@ private Q_SLOTS:
20372037 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
20382038 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
20392039 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
2040− QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 0);
2040+ QCOMPARE(sectionDelegate(lvwph->m_topSectionItem), lvwph->m_visibleItems[0]->m_item);
20412041 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
20422042 }
20432043