on xenial help sign in
Fix resizing of items before the viewport that are not the first item moving the viewport
commit5de03b084971803fc187a7f0cfcb704edcf48bf3 authorAlbert Astals <albert.astals@canonical.com> dateMon 10 Jun 2013, 11:35 (13 years ago) parent1a82fd6
2 files changed+40−4
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+3−4 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+37
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+3−4
@@ -507,10 +507,9 @@ void ListViewWithPageHeader::itemGeometryChanged(QQuickItem *item, const QRectF
507507 headerHeightChanged(newGeometry.height(), oldGeometry.height(), oldGeometry.y());
508508 } else {
509509 if (oldGeometry.y() + oldGeometry.height() + m_clipItem->y() < contentY() && !m_visibleItems.isEmpty()) {
510− item->setY(item->y() - heightDiff);
511− if (m_visibleItems.first() == item) {
512− adjustMinYExtent();
513− }
510+ QQuickItem *firstItem = m_visibleItems.first();
511+ firstItem->setY(firstItem->y() - heightDiff);
512+ adjustMinYExtent();
514513 }
515514 }
516515 polish();
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+37
@@ -1416,6 +1416,43 @@ private Q_SLOTS:
14161416 QVERIFY(!lvwph->isAtYEnd());
14171417 }
14181418
1419+ void changeSizeVisibleItemNotOnViewport()
1420+ {
1421+ changeContentY(440);
1422+
1423+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 5);
1424+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1425+ verifyItem(0, -390., 150., true);
1426+ verifyItem(1, -240., 200., true);
1427+ verifyItem(2, -40, 350., false);
1428+ verifyItem(3, 310, 350., false);
1429+ verifyItem(4, 660, 350., true);
1430+ QCOMPARE(lvwph->m_minYExtent, 0.);
1431+ QCOMPARE(lvwph->m_clipItem->y(), 440.);
1432+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1433+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1434+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1435+ QCOMPARE(lvwph->contentY(), 440.);
1436+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1437+
1438+ model->setProperty(1, "size", 100);
1439+
1440+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 5);
1441+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1442+ verifyItem(0, -290., 150., true);
1443+ verifyItem(1, -140., 100., true);
1444+ verifyItem(2, -40, 350., false);
1445+ verifyItem(3, 310, 350., false);
1446+ verifyItem(4, 660, 350., true);
1447+ QCOMPARE(lvwph->m_minYExtent, -100.);
1448+ QCOMPARE(lvwph->m_clipItem->y(), 440.);
1449+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1450+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1451+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1452+ QCOMPARE(lvwph->contentY(), 440.);
1453+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1454+ }
1455+
14191456private:
14201457 QQuickView *view;
14211458 ListViewWithPageHeader *lvwph;