Merge lp:~aacid/unity8/fixShowHeaderHalfShownAtTop into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michael Zanetti
Approved revision: 92
Merged at revision: 92
Proposed branch: lp:~aacid/unity8/fixShowHeaderHalfShownAtTop
Merge into: lp:unity8
Diff against target: 157 lines (+125/-0)
3 files modified
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp (+13/-0)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp (+55/-0)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp (+57/-0)
To merge this branch: bzr merge lp:~aacid/unity8/fixShowHeaderHalfShownAtTop
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Gerry Boland (community) Approve
Michael Zanetti (community) functional Approve
Michał Sawicz functional Approve
Review via email: mp+173727@code.launchpad.net

Commit message

Fix showHeader animation when the header is half shown at top

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote :

Yup, this fixes the issue.

review: Approve (functional)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Cannot reproduce the bug any more.

review: Approve (functional)
91. By Albert Astals Cid

Fix showHeader animation when the header is half shown at top

------------- This line and the following will be ignored --------------

modified:
  plugins/ListViewWithPageHeader/listviewwithpageheader.cpp
  tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp
  tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp
pending merges:
  Albert Astals 2013-07-09 Fix showHeader animation when the header is half shown at top

92. By Albert Astals Cid

QSKPI instead of comment

Revision history for this message
Gerry Boland (gerboland) wrote :

Looks great, approving!

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

waiting for CI bot to agree before top approving

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/ListViewWithPageHeader/listviewwithpageheader.cpp'
--- plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-07-02 08:45:40 +0000
+++ plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-07-09 14:58:25 +0000
@@ -347,6 +347,19 @@
347347
348 auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);348 auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);
349 if (to != contentY()) {349 if (to != contentY()) {
350 const bool headerShownByItsOwn = contentY() < m_headerItem->y() + m_headerItem->height();
351 if (headerShownByItsOwn && m_headerItemShownHeight == 0) {
352 // We are not clipping since we are just at the top of the viewport
353 // but because of the showHeader animation we will need to, so
354 // enable the clipping without logically moving the items
355 m_headerItemShownHeight = m_headerItem->y() + m_headerItem->height() - contentY();
356 if (!m_visibleItems.isEmpty()) {
357 updateClipItem();
358 ListItem *firstItem = m_visibleItems.first();
359 firstItem->setY(firstItem->y() - m_headerItemShownHeight);
360 layout();
361 }
362 }
350 m_headerShowAnimation->setTo(to);363 m_headerShowAnimation->setTo(to);
351 m_headerShowAnimation->start();364 m_headerShowAnimation->start();
352 }365 }
353366
=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp'
--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-07-02 09:57:41 +0000
+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-07-09 14:58:25 +0000
@@ -1248,6 +1248,61 @@
1248 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);1248 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1249 }1249 }
12501250
1251 void testShowHeaderHalfShown()
1252 {
1253#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1254 QSKIP("This test is extremely unstable in 5.0.x");
1255#endif
1256 changeContentY(20);
1257
1258 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1259 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1260 verifyItem(0, 30., 150., false);
1261 verifyItem(1, 180, 200., false);
1262 verifyItem(2, 380, 350., false);
1263 verifyItem(3, 730, 350., true);
1264 QCOMPARE(lvwph->m_minYExtent, 0.);
1265 QCOMPARE(lvwph->m_clipItem->y(), 20.);
1266 QCOMPARE(lvwph->m_clipItem->clip(), false);
1267 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1268 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1269 QCOMPARE(lvwph->contentY(), 20.);
1270 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1271
1272 lvwph->showHeader();
1273
1274 QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1275 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1276 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1277 verifyItem(0, -20., 150., false);
1278 verifyItem(1, 130, 200., false);
1279 verifyItem(2, 330, 350., false);
1280 verifyItem(3, 680, 350., true);
1281 QCOMPARE(lvwph->m_minYExtent, 20.);
1282 QCOMPARE(lvwph->m_clipItem->y(), 50.);
1283 QCOMPARE(lvwph->m_clipItem->clip(), true);
1284 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1285 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1286 QCOMPARE(lvwph->contentY(), 0.);
1287 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
1288
1289 scrollToTop();
1290
1291 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1292 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1293 verifyItem(0, 50., 150., false);
1294 verifyItem(1, 200., 200., false);
1295 verifyItem(2, 400., 350., false);
1296 verifyItem(3, 750, 350., true);
1297 QCOMPARE(lvwph->m_minYExtent, 20.);
1298 QCOMPARE(lvwph->m_clipItem->y(), -20.);
1299 QCOMPARE(lvwph->m_clipItem->clip(), false);
1300 QCOMPARE(lvwph->m_headerItem->y(), -20.);
1301 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1302 QCOMPARE(lvwph->contentY(), -20.);
1303 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1304 }
1305
1251 void testShowHeaderAtBottom()1306 void testShowHeaderAtBottom()
1252 {1307 {
1253 scrollToBottom();1308 scrollToBottom();
12541309
=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp'
--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-06-28 07:40:47 +0000
+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-07-09 14:58:25 +0000
@@ -1407,6 +1407,63 @@
1407 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);1407 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1408 }1408 }
14091409
1410 void testShowHeaderHalfShown()
1411 {
1412#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1413 QSKIP("This test is extremely unstable in 5.0.x");
1414#endif
1415 changeContentY(20);
1416
1417 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1418 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1419 verifyItem(0, 30., 190., false, "Agressive", false);
1420 verifyItem(1, 220, 240., false, "Regular", false);
1421 verifyItem(2, 460, 390., false, "Mild", false);
1422 QCOMPARE(lvwph->m_minYExtent, 0.);
1423 QCOMPARE(lvwph->m_clipItem->y(), 20.);
1424 QCOMPARE(lvwph->m_clipItem->clip(), false);
1425 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1426 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1427 QCOMPARE(lvwph->contentY(), 20.);
1428 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1429 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1430
1431 lvwph->showHeader();
1432
1433 QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1434 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1435 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1436 verifyItem(0, -20., 190., false, "Agressive", true);
1437 verifyItem(1, 170, 240., false, "Regular", false);
1438 verifyItem(2, 410, 390., false, "Mild", false);
1439 QCOMPARE(lvwph->m_minYExtent, 20.);
1440 QCOMPARE(lvwph->m_clipItem->y(), 50.);
1441 QCOMPARE(lvwph->m_clipItem->clip(), true);
1442 QCOMPARE(lvwph->m_headerItem->y(), 0.);
1443 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1444 QCOMPARE(lvwph->contentY(), 0.);
1445 QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
1446 QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1447 QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1448 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1449
1450 scrollToTop();
1451
1452 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1453 QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1454 verifyItem(0, 50., 190., false, "Agressive", false);
1455 verifyItem(1, 240., 240., false, "Regular", false);
1456 verifyItem(2, 480., 390., false, "Mild", false);
1457 QCOMPARE(lvwph->m_minYExtent, 20.);
1458 QCOMPARE(lvwph->m_clipItem->y(), -20.);
1459 QCOMPARE(lvwph->m_clipItem->clip(), false);
1460 QCOMPARE(lvwph->m_headerItem->y(), -20.);
1461 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1462 QCOMPARE(lvwph->contentY(), -20.);
1463 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1464 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1465 }
1466
1410 void testShowHeaderCloseToTheTop()1467 void testShowHeaderCloseToTheTop()
1411 {1468 {
1412 changeContentY(375);1469 changeContentY(375);

Subscribers

People subscribed via source and target branches