on xenial help sign in
Merge lp:~aacid/unity8/lvwph_maximizeVisibleArea
commita3e77fa143bce78b75317e8afc2b392f9865dc8b authorAlbert Astals <albert.astals@canonical.com> dateTue 6 Aug 2013, 13:22 (13 years ago) parent203cf69ba83189
5 files changed+408−12
debian/changelog+33 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−11 plugins/ListViewWithPageHeader/listviewwithpageheader.h+5−1 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+164 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+185
debian/changelog+33
@@ -1,3 +1,36 @@
1+unity8 (7.81.3+13.10.20130805-0ubuntu1) saucy; urgency=low
2+
3+ [ Michael Terry ]
4+ * Fixes the lockscreen and swiping on the greeter still being possible
5+ even when in tablet mode. (LP: #1204984)
6+ * Watch powerd signals to notice a sleep and unfocus current app when
7+ that happens.
8+
9+ [ Michael Zanetti ]
10+ * make findChild also find invisible childs This considerably
11+ increases the amount of items to be searched up to a level where
12+ testShell didn't finish any more with searching. Hence this commit
13+ also changes findChild to do a breadth-first instead of a depth-
14+ first search.
15+ * Read background from GSettings or fallback to default_background.
16+
17+ [ Andrea Cimitan ]
18+ * Read background from GSettings or fallback to default_background.
19+
20+ [ Albert Astals ]
21+ * Make LVWPH provide a delegateIndex for sectionHeaders This way we
22+ can match the sectionHeader to the model easier in the qml/js side .
23+ * Fix tryCompare call The 4th parameter of tryCompare is timeout not
24+ message .
25+
26+ [ Daniel d'Andrada ]
27+ * Read background from GSettings or fallback to default_background.
28+
29+ [ Ubuntu daily release ]
30+ * Automatic snapshot from revision 162
31+
32+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 05 Aug 2013 02:32:05 +0000
33+
134unity8 (7.81.3+13.10.20130802-0ubuntu1) saucy; urgency=low
235
336 [ Michael Terry ]
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−11
@@ -375,7 +375,7 @@ void ListViewWithPageHeader::showHeader()
375375 }
376376 }
377377 m_contentYAnimation->setTo(to);
378− contentYAnimationIsShownHeader = true;
378+ contentYAnimationType = ContentYAnimationShowHeader;
379379 m_contentYAnimation->start();
380380 }
381381}
@@ -394,10 +394,18 @@ void ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
394394 ListItem *listItem = itemAtIndex(modelIndex);
395395 if (listItem)
396396 {
397− // Check if we can scroll the list up to show more stuff
398− if (m_clipItem->y() + listItem->y() > contentY() && m_clipItem->y() + listItem->y() + listItem->height() > contentY() + height()) {
399− m_contentYAnimation->setTo(m_clipItem->y() + listItem->y());
400− contentYAnimationIsShownHeader = false;
397+ const auto listItemY = m_clipItem->y() + listItem->y();
398+ if (listItemY > contentY() && listItemY + listItem->height() > contentY() + height()) {
399+ // we can scroll the list up to show more stuff
400+ const auto to = qMin(listItemY, listItemY + listItem->height() - height());
401+ m_contentYAnimation->setTo(to);
402+ contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
403+ m_contentYAnimation->start();
404+ } else if (listItemY < contentY() && listItemY + listItem->height() < contentY() + height()) {
405+ // we can scroll the list down to show more stuff
406+ const auto to = qMax(listItemY, listItemY + listItem->height() - height());
407+ m_contentYAnimation->setTo(to);
408+ contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
401409 m_contentYAnimation->start();
402410 }
403411 }
@@ -424,6 +432,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
424432 QQuickFlickable::viewportMoved(orient);
425433// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
426434 qreal diff = m_previousContentY - contentY();
435+ const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
427436 if (m_headerItem) {
428437 auto oldHeaderItemShownHeight = m_headerItemShownHeight;
429438 if (contentY() < -m_minYExtent) {
@@ -434,15 +443,16 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
434443 m_headerItem->setHeight(m_headerItem->implicitHeight());
435444 // We are going down (but it's not because of the rebound at the end)
436445 // (but the header was not shown by it's own position)
437− // or the header is partially shown
446+ // or the header is partially shown and we are not doing a maximizeVisibleArea either
438447 const bool scrolledUp = m_previousContentY > contentY();
439448 const bool notRebounding = contentY() + height() < contentHeight();
440449 const bool notShownByItsOwn = contentY() + diff > m_headerItem->y() + m_headerItem->height();
450+ const bool maximizeVisibleAreaRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationMaximizeVisibleArea;
441451
442452 if (!scrolledUp && contentY() == -m_minYExtent) {
443453 m_headerItemShownHeight = 0;
444454 m_headerItem->setY(contentY());
445− } else if ((scrolledUp && notRebounding && notShownByItsOwn) || (m_headerItemShownHeight > 0)) {
455+ } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0)) {
446456 m_headerItemShownHeight += diff;
447457 if (contentY() == -m_minYExtent) {
448458 m_headerItemShownHeight = 0;
@@ -459,7 +469,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
459469 // We will be changing the clip item, need to accomadate for it
460470 // otherwise we move the firstItem down/up twice (unless the
461471 // show header animation is running, where we want to keep the viewport stable)
462− if (!(m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader)) {
472+ if (!showHeaderAnimationRunning) {
463473 diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
464474 } else {
465475 diff = -diff;
@@ -469,7 +479,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
469479 updateClipItem();
470480 ListItem *firstItem = m_visibleItems.first();
471481 firstItem->setY(firstItem->y() + diff);
472− if (m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader) {
482+ if (showHeaderAnimationRunning) {
473483 adjustMinYExtent();
474484 }
475485 }
@@ -758,7 +768,7 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
758768 releaseItem(listItem);
759769 listItem = nullptr;
760770 } else {
761− listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() < contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
771+ listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() <= contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
762772 if (m_visibleItems.isEmpty()) {
763773 m_visibleItems << listItem;
764774 } else {
@@ -1064,7 +1074,7 @@ void ListViewWithPageHeader::layout()
10641074 int firstReallyVisibleItem = -1;
10651075 int modelIndex = m_firstVisibleIndex;
10661076 Q_FOREACH(ListItem *item, m_visibleItems) {
1067− const bool cull = pos + item->height() < visibleFrom || pos >= visibleTo;
1077+ const bool cull = pos + item->height() <= visibleFrom || pos >= visibleTo;
10681078 item->setCulled(cull);
10691079 item->setY(pos);
10701080 if (!cull && firstReallyVisibleItem == -1) {
plugins/ListViewWithPageHeader/listviewwithpageheader.h+5−1
@@ -91,6 +91,9 @@ public:
9191 Q_INVOKABLE QQuickItem *item(int modelIndex) const;
9292 Q_INVOKABLE void maximizeVisibleArea(int modelIndex);
9393
94+ // The index has to be visible for this to try to do something
95+ Q_INVOKABLE void maximizeVisibleArea(int modelIndex);
96+
9497Q_SIGNALS:
9598 void modelChanged();
9699 void delegateChanged();
@@ -184,7 +187,8 @@ private:
184187 qreal m_previousContentY;
185188 qreal m_headerItemShownHeight; // The height of header shown when the header is shown outside its topmost position
186189 // i.e. it's being shown after dragging down in the middle of the list
187− bool contentYAnimationIsShownHeader;
190+ enum ContentYAnimationType { ContentYAnimationShowHeader, ContentYAnimationMaximizeVisibleArea };
191+ ContentYAnimationType contentYAnimationType;
188192 QQuickNumberAnimation *m_contentYAnimation;
189193
190194 QQmlComponent *m_sectionDelegate;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+164
@@ -1390,6 +1390,170 @@ 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+
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+
13931557private:
13941558 QQuickView *view;
13951559 ListViewWithPageHeader *lvwph;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+185
@@ -1691,6 +1691,191 @@ 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+
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+
16941879private:
16951880 QQuickView *view;
16961881 ListViewWithPageHeader *lvwph;