on xenial help sign in
Fix off by one in the culling condition

If you are on 0 and your height is 1 and viewport starts at 1 you have to be culled since you are not visible

commit36a8fb088f182b7552fa9a6fa3760ecfb6cad82e authorAlbert Astals <albert.astals@canonical.com> dateTue 6 Aug 2013, 10:26 (13 years ago) parent030b3c9
3 files changed+41−2
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+2−2 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+19 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+20
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+2−2
@@ -734,7 +734,7 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
734734 releaseItem(listItem);
735735 listItem = nullptr;
736736 } else {
737− listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() < contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
737+ listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() <= contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
738738 if (m_visibleItems.isEmpty()) {
739739 m_visibleItems << listItem;
740740 } else {
@@ -1040,7 +1040,7 @@ void ListViewWithPageHeader::layout()
10401040 int firstReallyVisibleItem = -1;
10411041 int modelIndex = m_firstVisibleIndex;
10421042 Q_FOREACH(ListItem *item, m_visibleItems) {
1043− const bool cull = pos + item->height() < visibleFrom || pos >= visibleTo;
1043+ const bool cull = pos + item->height() <= visibleFrom || pos >= visibleTo;
10441044 item->setCulled(cull);
10451045 item->setY(pos);
10461046 if (!cull && firstReallyVisibleItem == -1) {
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+19
@@ -1390,6 +1390,25 @@ private Q_SLOTS:
13901390 lvwph->showHeader();
13911391 }
13921392
1393+ void testCullOnBottomEdge()
1394+ {
1395+ changeContentY(200);
1396+
1397+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1398+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1399+ verifyItem(0, -150., 150., true);
1400+ verifyItem(1, 0., 200., false);
1401+ verifyItem(2, 200., 350., false);
1402+ verifyItem(3, 550., 350., true);
1403+ QCOMPARE(lvwph->m_minYExtent, 0.);
1404+ QCOMPARE(lvwph->m_clipItem->y(), 200.);
1405+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1406+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1407+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1408+ QCOMPARE(lvwph->contentY(), 200.);
1409+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1410+ }
1411+
13931412private:
13941413 QQuickView *view;
13951414 ListViewWithPageHeader *lvwph;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+20
@@ -1691,6 +1691,26 @@ private Q_SLOTS:
16911691 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
16921692 }
16931693
1694+ void testCullOnBottomEdge()
1695+ {
1696+ changeContentY(240);
1697+
1698+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1699+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1700+ verifyItem(0, -190., 190., true, "Agressive", true);
1701+ verifyItem(1, 0., 240., false, "Regular", false);
1702+ verifyItem(2, 240., 390., false, "Mild", false);
1703+ verifyItem(3, 630., 390., true, "Bold", true);
1704+ QCOMPARE(lvwph->m_minYExtent, 0.);
1705+ QCOMPARE(lvwph->m_clipItem->y(), 240.);
1706+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1707+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1708+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1709+ QCOMPARE(lvwph->contentY(), 240.);
1710+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1711+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1712+ }
1713+
16941714private:
16951715 QQuickView *view;
16961716 ListViewWithPageHeader *lvwph;