on xenial help sign in
Implement+test the maximizeVisibleArea function

Tries to show as much possible of an index that is already shown on screen Will be used for the dash category expansion

commitba83189165e1572c331f3738e0e5384b215c7717 authorAlbert Astals <albert.astals@canonical.com> dateTue 6 Aug 2013, 13:01 (13 years ago) parent36a8fb0
4 files changed+359−19
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+37−12 plugins/ListViewWithPageHeader/listviewwithpageheader.h+6−1 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+148−3 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+168−3
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+37−12
@@ -160,16 +160,16 @@ ListViewWithPageHeader::ListViewWithPageHeader()
160160// m_clipItem = new QQuickRectangle(contentItem());
161161// ((QQuickRectangle*)m_clipItem)->setColor(Qt::gray);
162162
163− m_headerShowAnimation = new QQuickNumberAnimation(this);
164− m_headerShowAnimation->setEasing(QEasingCurve::OutQuad);
165− m_headerShowAnimation->setProperty("contentY");
166− m_headerShowAnimation->setDuration(200);
167− m_headerShowAnimation->setTargetObject(this);
163+ m_contentYAnimation = new QQuickNumberAnimation(this);
164+ m_contentYAnimation->setEasing(QEasingCurve::OutQuad);
165+ m_contentYAnimation->setProperty("contentY");
166+ m_contentYAnimation->setDuration(200);
167+ m_contentYAnimation->setTargetObject(this);
168168
169169 connect(this, SIGNAL(contentWidthChanged()), this, SLOT(onContentWidthChanged()));
170170 connect(this, SIGNAL(contentHeightChanged()), this, SLOT(onContentHeightChanged()));
171171 connect(this, SIGNAL(heightChanged()), this, SLOT(onHeightChanged()));
172− connect(m_headerShowAnimation, SIGNAL(stopped()), this, SLOT(onShowHeaderAnimationFinished()));
172+ connect(m_contentYAnimation, SIGNAL(stopped()), this, SLOT(onShowHeaderAnimationFinished()));
173173}
174174
175175ListViewWithPageHeader::~ListViewWithPageHeader()
@@ -374,8 +374,31 @@ void ListViewWithPageHeader::showHeader()
374374 layout();
375375 }
376376 }
377− m_headerShowAnimation->setTo(to);
378− m_headerShowAnimation->start();
377+ m_contentYAnimation->setTo(to);
378+ contentYAnimationType = ContentYAnimationShowHeader;
379+ m_contentYAnimation->start();
380+ }
381+}
382+
383+void ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
384+{
385+ ListItem *listItem = itemAtIndex(modelIndex);
386+ if (listItem)
387+ {
388+ const auto listItemY = m_clipItem->y() + listItem->y();
389+ if (listItemY > contentY() && listItemY + listItem->height() > contentY() + height()) {
390+ // we can scroll the list up to show more stuff
391+ const auto to = qMin(listItemY, listItemY + listItem->height() - height());
392+ m_contentYAnimation->setTo(to);
393+ contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
394+ m_contentYAnimation->start();
395+ } else if (listItemY < contentY() && listItemY + listItem->height() < contentY() + height()) {
396+ // we can scroll the list down to show more stuff
397+ const auto to = qMax(listItemY, listItemY + listItem->height() - height());
398+ m_contentYAnimation->setTo(to);
399+ contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
400+ m_contentYAnimation->start();
401+ }
379402 }
380403}
381404
@@ -400,6 +423,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
400423 QQuickFlickable::viewportMoved(orient);
401424// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
402425 qreal diff = m_previousContentY - contentY();
426+ const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
403427 if (m_headerItem) {
404428 auto oldHeaderItemShownHeight = m_headerItemShownHeight;
405429 if (contentY() < -m_minYExtent) {
@@ -410,15 +434,16 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
410434 m_headerItem->setHeight(m_headerItem->implicitHeight());
411435 // We are going down (but it's not because of the rebound at the end)
412436 // (but the header was not shown by it's own position)
413− // or the header is partially shown
437+ // or the header is partially shown and we are not doing a maximizeVisibleArea either
414438 const bool scrolledUp = m_previousContentY > contentY();
415439 const bool notRebounding = contentY() + height() < contentHeight();
416440 const bool notShownByItsOwn = contentY() + diff > m_headerItem->y() + m_headerItem->height();
441+ const bool maximizeVisibleAreaRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationMaximizeVisibleArea;
417442
418443 if (!scrolledUp && contentY() == -m_minYExtent) {
419444 m_headerItemShownHeight = 0;
420445 m_headerItem->setY(contentY());
421− } else if ((scrolledUp && notRebounding && notShownByItsOwn) || (m_headerItemShownHeight > 0)) {
446+ } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0)) {
422447 m_headerItemShownHeight += diff;
423448 if (contentY() == -m_minYExtent) {
424449 m_headerItemShownHeight = 0;
@@ -435,7 +460,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
435460 // We will be changing the clip item, need to accomadate for it
436461 // otherwise we move the firstItem down/up twice (unless the
437462 // show header animation is running, where we want to keep the viewport stable)
438− if (!m_headerShowAnimation->isRunning()) {
463+ if (!showHeaderAnimationRunning) {
439464 diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
440465 } else {
441466 diff = -diff;
@@ -445,7 +470,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
445470 updateClipItem();
446471 ListItem *firstItem = m_visibleItems.first();
447472 firstItem->setY(firstItem->y() + diff);
448− if (m_headerShowAnimation->isRunning()) {
473+ if (showHeaderAnimationRunning) {
449474 adjustMinYExtent();
450475 }
451476 }
plugins/ListViewWithPageHeader/listviewwithpageheader.h+6−1
@@ -89,6 +89,9 @@ public:
8989 Q_INVOKABLE void positionAtBeginning();
9090 Q_INVOKABLE void showHeader();
9191
92+ // The index has to be visible for this to try to do something
93+ Q_INVOKABLE void maximizeVisibleArea(int modelIndex);
94+
9295Q_SIGNALS:
9396 void modelChanged();
9497 void delegateChanged();
@@ -182,7 +185,9 @@ private:
182185 qreal m_previousContentY;
183186 qreal m_headerItemShownHeight; // The height of header shown when the header is shown outside its topmost position
184187 // i.e. it's being shown after dragging down in the middle of the list
185− QQuickNumberAnimation *m_headerShowAnimation;
188+ enum ContentYAnimationType { ContentYAnimationShowHeader, ContentYAnimationMaximizeVisibleArea };
189+ ContentYAnimationType contentYAnimationType;
190+ QQuickNumberAnimation *m_contentYAnimation;
186191
187192 QQmlComponent *m_sectionDelegate;
188193 QString m_sectionProperty;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+148−3
@@ -1245,7 +1245,7 @@ private Q_SLOTS:
12451245
12461246 lvwph->showHeader();
12471247
1248− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1248+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
12491249 QTRY_COMPARE(lvwph->m_visibleItems.count(), 5);
12501250 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
12511251 verifyItem(0, -375., 150., true);
@@ -1301,7 +1301,7 @@ private Q_SLOTS:
13011301
13021302 lvwph->showHeader();
13031303
1304− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1304+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
13051305 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
13061306 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
13071307 verifyItem(0, -20., 150., false);
@@ -1339,7 +1339,7 @@ private Q_SLOTS:
13391339
13401340 lvwph->showHeader();
13411341
1342− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1342+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
13431343 QTRY_VERIFY (lvwph->isAtYEnd());
13441344 }
13451345
@@ -1409,6 +1409,151 @@ private Q_SLOTS:
14091409 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
14101410 }
14111411
1412+ void testMaximizeVisibleArea()
1413+ {
1414+ lvwph->maximizeVisibleArea(2);
1415+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1416+
1417+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1418+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1419+ verifyItem(0, -158., 150., true);
1420+ verifyItem(1, -8., 200., false);
1421+ verifyItem(2, 192, 350., false);
1422+ verifyItem(3, 542, 350., true);
1423+ QCOMPARE(lvwph->m_minYExtent, 0.);
1424+ QCOMPARE(lvwph->m_clipItem->y(), 208.);
1425+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1426+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1427+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1428+ QCOMPARE(lvwph->contentY(), 208.);
1429+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1430+ }
1431+
1432+ void testMaximizeVisibleAreaVisibleItems()
1433+ {
1434+ lvwph->maximizeVisibleArea(0);
1435+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1436+
1437+ verifyInitialTopPosition();
1438+
1439+ lvwph->maximizeVisibleArea(1);
1440+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1441+
1442+ verifyInitialTopPosition();
1443+ }
1444+
1445+ void testMaximizeVisibleAreaInvalidIndexes()
1446+ {
1447+ lvwph->maximizeVisibleArea(-1);
1448+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1449+
1450+ verifyInitialTopPosition();
1451+
1452+ lvwph->maximizeVisibleArea(1000);
1453+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1454+
1455+ verifyInitialTopPosition();
1456+
1457+ lvwph->maximizeVisibleArea(4);
1458+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1459+
1460+ verifyInitialTopPosition();
1461+ }
1462+
1463+ void testMaximizeVisibleAreaBigElement()
1464+ {
1465+ model->setProperty(2, "size", 4000);
1466+ lvwph->maximizeVisibleArea(2);
1467+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1468+
1469+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1470+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1471+ verifyItem(0, -350., 150., true);
1472+ verifyItem(1, -200., 200., true);
1473+ verifyItem(2, 0, 4000., false);
1474+ QCOMPARE(lvwph->m_minYExtent, 0.);
1475+ QCOMPARE(lvwph->m_clipItem->y(), 400.);
1476+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1477+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1478+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1479+ QCOMPARE(lvwph->contentY(), 400.);
1480+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1481+ }
1482+
1483+ void testMaximizeVisibleAreaScrollDown()
1484+ {
1485+ changeContentY(250);
1486+ lvwph->maximizeVisibleArea(1);
1487+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1488+
1489+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1490+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1491+ verifyItem(0, -150., 150., true);
1492+ verifyItem(1, 0., 200., false);
1493+ verifyItem(2, 200, 350., false);
1494+ verifyItem(3, 550, 350., true);
1495+ QCOMPARE(lvwph->m_minYExtent, 0.);
1496+ QCOMPARE(lvwph->m_clipItem->y(), 200.);
1497+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1498+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1499+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1500+ QCOMPARE(lvwph->contentY(), 200.);
1501+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1502+ }
1503+
1504+ void testMaximizeVisibleAreaScrollDownBigElement()
1505+ {
1506+ model->setProperty(1, "size", 1000);
1507+ changeContentY(1150);
1508+ lvwph->maximizeVisibleArea(1);
1509+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1510+
1511+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1512+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1513+ verifyItem(0, -458., 1000., false);
1514+ verifyItem(1, 542., 350., true);
1515+ QCOMPARE(lvwph->m_minYExtent, 362.5);
1516+ QCOMPARE(lvwph->m_clipItem->y(), 658.);
1517+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1518+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1519+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1520+ QCOMPARE(lvwph->contentY(), 658.);
1521+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1522+ }
1523+
1524+ void testMaximizeVisibleAreaBigElementInTheMiddle()
1525+ {
1526+ model->setProperty(1, "size", 1000);
1527+ changeContentY(650);
1528+
1529+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1530+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1531+ verifyItem(0, -450., 1000., false);
1532+ verifyItem(1, 550., 350., true);
1533+ QCOMPARE(lvwph->m_minYExtent, 525.);
1534+ QCOMPARE(lvwph->m_clipItem->y(), 650.);
1535+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1536+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1537+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1538+ QCOMPARE(lvwph->contentY(), 650.);
1539+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1540+
1541+ lvwph->maximizeVisibleArea(1);
1542+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1543+
1544+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1545+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1546+ verifyItem(0, -450., 1000., false);
1547+ verifyItem(1, 550., 350., true);
1548+ QCOMPARE(lvwph->m_minYExtent, 525.);
1549+ QCOMPARE(lvwph->m_clipItem->y(), 650.);
1550+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1551+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1552+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1553+ QCOMPARE(lvwph->contentY(), 650.);
1554+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1555+ }
1556+
14121557private:
14131558 QQuickView *view;
14141559 ListViewWithPageHeader *lvwph;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+168−3
@@ -1506,7 +1506,7 @@ private Q_SLOTS:
15061506
15071507 lvwph->showHeader();
15081508
1509− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1509+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
15101510 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
15111511 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
15121512 verifyItem(0, -20., 190., false, "Agressive", true);
@@ -1565,7 +1565,7 @@ private Q_SLOTS:
15651565
15661566 lvwph->showHeader();
15671567
1568− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1568+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
15691569 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
15701570 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
15711571 verifyItem(0, -375., 190., true, "Agressive", true);
@@ -1607,7 +1607,7 @@ private Q_SLOTS:
16071607
16081608 lvwph->showHeader();
16091609
1610− QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1610+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
16111611 QTRY_VERIFY (lvwph->isAtYEnd());
16121612 }
16131613
@@ -1711,6 +1711,171 @@ private Q_SLOTS:
17111711 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
17121712 }
17131713
1714+ void testMaximizeVisibleArea()
1715+ {
1716+ lvwph->maximizeVisibleArea(2);
1717+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1718+
1719+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1720+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1721+ verifyItem(0, -278., 190., true, "Agressive", true);
1722+ verifyItem(1, -88., 240., false, "Regular", true);
1723+ verifyItem(2, 152, 390., false, "Mild", false);
1724+ verifyItem(3, 542, 390., true, "Bold", true);
1725+ QCOMPARE(lvwph->m_minYExtent, 0.);
1726+ QCOMPARE(lvwph->m_clipItem->y(), 328.);
1727+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1728+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1729+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1730+ QCOMPARE(lvwph->contentY(), 328.);
1731+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1732+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1733+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1734+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1735+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1736+ }
1737+
1738+ void testMaximizeVisibleAreaVisibleItems()
1739+ {
1740+ lvwph->maximizeVisibleArea(0);
1741+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1742+
1743+ verifyInitialTopPosition();
1744+
1745+ lvwph->maximizeVisibleArea(1);
1746+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1747+
1748+ verifyInitialTopPosition();
1749+ }
1750+
1751+ void testMaximizeVisibleAreaInvalidIndexes()
1752+ {
1753+ lvwph->maximizeVisibleArea(-1);
1754+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1755+
1756+ verifyInitialTopPosition();
1757+
1758+ lvwph->maximizeVisibleArea(1000);
1759+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1760+
1761+ verifyInitialTopPosition();
1762+
1763+ lvwph->maximizeVisibleArea(3);
1764+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1765+
1766+ verifyInitialTopPosition();
1767+ }
1768+
1769+ void testMaximizeVisibleAreaBigElement()
1770+ {
1771+ model->setProperty(2, "size", 4000);
1772+ verifyItem(2, 480, 4040., false, "Mild", false);
1773+
1774+ lvwph->maximizeVisibleArea(2);
1775+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1776+
1777+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1778+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1779+ verifyItem(0, -430., 190., true, "Agressive", true);
1780+ verifyItem(1, -240., 240., true, "Regular", true);
1781+ verifyItem(2, 0, 4040., false, "Mild", false);
1782+ QCOMPARE(lvwph->m_minYExtent, 0.);
1783+ QCOMPARE(lvwph->m_clipItem->y(), 480.);
1784+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1785+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1786+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1787+ QCOMPARE(lvwph->contentY(), 480.);
1788+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1789+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1790+ }
1791+
1792+ void testMaximizeVisibleAreaScrollDown()
1793+ {
1794+ changeContentY(350);
1795+ lvwph->maximizeVisibleArea(1);
1796+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1797+
1798+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1799+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1800+ verifyItem(0, -190., 190., true, "Agressive", true);
1801+ verifyItem(1, 0., 240., false, "Regular", false);
1802+ verifyItem(2, 240, 390., false, "Mild", false);
1803+ verifyItem(3, 630, 390., true, "Bold", true);
1804+ QCOMPARE(lvwph->m_minYExtent, 0.);
1805+ QCOMPARE(lvwph->m_clipItem->y(), 240.);
1806+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1807+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1808+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1809+ QCOMPARE(lvwph->contentY(), 240.);
1810+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1811+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1812+ }
1813+
1814+ void testMaximizeVisibleAreaScrollDownBigElement()
1815+ {
1816+ model->setProperty(1, "size", 1000);
1817+ changeContentY(1150);
1818+ lvwph->maximizeVisibleArea(1);
1819+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1820+
1821+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1822+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1823+ verifyItem(0, -498., 1040., false, "Regular", true);
1824+ verifyItem(1, 542., 390., true, "Mild", true);
1825+ QCOMPARE(lvwph->m_minYExtent, 1250/3.);
1826+ QCOMPARE(lvwph->m_clipItem->y(), 738.);
1827+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1828+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1829+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1830+ QCOMPARE(lvwph->contentY(), 738.);
1831+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1832+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1833+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1834+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1835+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1836+ }
1837+
1838+ void testMaximizeVisibleAreaBigElementInTheMiddle()
1839+ {
1840+ model->setProperty(1, "size", 1000);
1841+ changeContentY(650);
1842+
1843+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1844+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1845+ verifyItem(0, -410., 1040., false, "Regular", true);
1846+ verifyItem(1, 630., 390., true, "Mild", true);
1847+ QCOMPARE(lvwph->m_minYExtent, 525.);
1848+ QCOMPARE(lvwph->m_clipItem->y(), 650.);
1849+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1850+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1851+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1852+ QCOMPARE(lvwph->contentY(), 650.);
1853+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1854+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1855+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1856+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1857+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1858+
1859+ lvwph->maximizeVisibleArea(1);
1860+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1861+
1862+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 2);
1863+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
1864+ verifyItem(0, -410., 1040., false, "Regular", true);
1865+ verifyItem(1, 630., 390., true, "Mild", true);
1866+ QCOMPARE(lvwph->m_minYExtent, 525.);
1867+ QCOMPARE(lvwph->m_clipItem->y(), 650.);
1868+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1869+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1870+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1871+ QCOMPARE(lvwph->contentY(), 650.);
1872+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1873+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1874+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Regular"));
1875+ QCOMPARE(sectionDelegateIndex(lvwph->m_topSectionItem), 1);
1876+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1877+ }
1878+
17141879private:
17151880 QQuickView *view;
17161881 ListViewWithPageHeader *lvwph;