on xenial help sign in
Fix off by one in the culling condition
4e99cb2Albert Astals
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+2−2
@@ -734,7 +734,7 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
734 releaseItem(listItem);
734 releaseItem(listItem);
735 listItem = nullptr;
735 listItem = nullptr;
736 } else {
736 } 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());
738 if (m_visibleItems.isEmpty()) {
738 if (m_visibleItems.isEmpty()) {
739 m_visibleItems << listItem;
739 m_visibleItems << listItem;
740 } else {
740 } else {
@@ -1040,7 +1040,7 @@ void ListViewWithPageHeader::layout()
1040 int firstReallyVisibleItem = -1;
1040 int firstReallyVisibleItem = -1;
1041 int modelIndex = m_firstVisibleIndex;
1041 int modelIndex = m_firstVisibleIndex;
1042 Q_FOREACH(ListItem *item, m_visibleItems) {
1042 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;
1044 item->setCulled(cull);
1044 item->setCulled(cull);
1045 item->setY(pos);
1045 item->setY(pos);
1046 if (!cull && firstReallyVisibleItem == -1) {
1046 if (!cull && firstReallyVisibleItem == -1) {
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+19
@@ -1390,6 +1390,25 @@ private Q_SLOTS:
1390 lvwph->showHeader();
1390 lvwph->showHeader();
1391 }
1391 }
1392
1392
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+
1393private:
1412private:
1394 QQuickView *view;
1413 QQuickView *view;
1395 ListViewWithPageHeader *lvwph;
1414 ListViewWithPageHeader *lvwph;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+20
@@ -1691,6 +1691,26 @@ private Q_SLOTS:
1691 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1691 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1692 }
1692 }
1693
1693
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+
1694private:
1714private:
1695 QQuickView *view;
1715 QQuickView *view;
1696 ListViewWithPageHeader *lvwph;
1716 ListViewWithPageHeader *lvwph;