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
1=== modified file 'plugins/ListViewWithPageHeader/listviewwithpageheader.cpp'
2--- plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-07-02 08:45:40 +0000
3+++ plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-07-09 14:58:25 +0000
4@@ -347,6 +347,19 @@
5
6 auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);
7 if (to != contentY()) {
8+ const bool headerShownByItsOwn = contentY() < m_headerItem->y() + m_headerItem->height();
9+ if (headerShownByItsOwn && m_headerItemShownHeight == 0) {
10+ // We are not clipping since we are just at the top of the viewport
11+ // but because of the showHeader animation we will need to, so
12+ // enable the clipping without logically moving the items
13+ m_headerItemShownHeight = m_headerItem->y() + m_headerItem->height() - contentY();
14+ if (!m_visibleItems.isEmpty()) {
15+ updateClipItem();
16+ ListItem *firstItem = m_visibleItems.first();
17+ firstItem->setY(firstItem->y() - m_headerItemShownHeight);
18+ layout();
19+ }
20+ }
21 m_headerShowAnimation->setTo(to);
22 m_headerShowAnimation->start();
23 }
24
25=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp'
26--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-07-02 09:57:41 +0000
27+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-07-09 14:58:25 +0000
28@@ -1248,6 +1248,61 @@
29 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
30 }
31
32+ void testShowHeaderHalfShown()
33+ {
34+#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
35+ QSKIP("This test is extremely unstable in 5.0.x");
36+#endif
37+ changeContentY(20);
38+
39+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
40+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
41+ verifyItem(0, 30., 150., false);
42+ verifyItem(1, 180, 200., false);
43+ verifyItem(2, 380, 350., false);
44+ verifyItem(3, 730, 350., true);
45+ QCOMPARE(lvwph->m_minYExtent, 0.);
46+ QCOMPARE(lvwph->m_clipItem->y(), 20.);
47+ QCOMPARE(lvwph->m_clipItem->clip(), false);
48+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
49+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
50+ QCOMPARE(lvwph->contentY(), 20.);
51+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
52+
53+ lvwph->showHeader();
54+
55+ QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
56+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
57+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
58+ verifyItem(0, -20., 150., false);
59+ verifyItem(1, 130, 200., false);
60+ verifyItem(2, 330, 350., false);
61+ verifyItem(3, 680, 350., true);
62+ QCOMPARE(lvwph->m_minYExtent, 20.);
63+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
64+ QCOMPARE(lvwph->m_clipItem->clip(), true);
65+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
66+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
67+ QCOMPARE(lvwph->contentY(), 0.);
68+ QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
69+
70+ scrollToTop();
71+
72+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
73+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
74+ verifyItem(0, 50., 150., false);
75+ verifyItem(1, 200., 200., false);
76+ verifyItem(2, 400., 350., false);
77+ verifyItem(3, 750, 350., true);
78+ QCOMPARE(lvwph->m_minYExtent, 20.);
79+ QCOMPARE(lvwph->m_clipItem->y(), -20.);
80+ QCOMPARE(lvwph->m_clipItem->clip(), false);
81+ QCOMPARE(lvwph->m_headerItem->y(), -20.);
82+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
83+ QCOMPARE(lvwph->contentY(), -20.);
84+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
85+ }
86+
87 void testShowHeaderAtBottom()
88 {
89 scrollToBottom();
90
91=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp'
92--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-06-28 07:40:47 +0000
93+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-07-09 14:58:25 +0000
94@@ -1407,6 +1407,63 @@
95 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
96 }
97
98+ void testShowHeaderHalfShown()
99+ {
100+#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
101+ QSKIP("This test is extremely unstable in 5.0.x");
102+#endif
103+ changeContentY(20);
104+
105+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
106+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
107+ verifyItem(0, 30., 190., false, "Agressive", false);
108+ verifyItem(1, 220, 240., false, "Regular", false);
109+ verifyItem(2, 460, 390., false, "Mild", false);
110+ QCOMPARE(lvwph->m_minYExtent, 0.);
111+ QCOMPARE(lvwph->m_clipItem->y(), 20.);
112+ QCOMPARE(lvwph->m_clipItem->clip(), false);
113+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
114+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
115+ QCOMPARE(lvwph->contentY(), 20.);
116+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
117+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
118+
119+ lvwph->showHeader();
120+
121+ QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
122+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
123+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
124+ verifyItem(0, -20., 190., false, "Agressive", true);
125+ verifyItem(1, 170, 240., false, "Regular", false);
126+ verifyItem(2, 410, 390., false, "Mild", false);
127+ QCOMPARE(lvwph->m_minYExtent, 20.);
128+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
129+ QCOMPARE(lvwph->m_clipItem->clip(), true);
130+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
131+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
132+ QCOMPARE(lvwph->contentY(), 0.);
133+ QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
134+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
135+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
136+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
137+
138+ scrollToTop();
139+
140+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
141+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
142+ verifyItem(0, 50., 190., false, "Agressive", false);
143+ verifyItem(1, 240., 240., false, "Regular", false);
144+ verifyItem(2, 480., 390., false, "Mild", false);
145+ QCOMPARE(lvwph->m_minYExtent, 20.);
146+ QCOMPARE(lvwph->m_clipItem->y(), -20.);
147+ QCOMPARE(lvwph->m_clipItem->clip(), false);
148+ QCOMPARE(lvwph->m_headerItem->y(), -20.);
149+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
150+ QCOMPARE(lvwph->contentY(), -20.);
151+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
152+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
153+ }
154+
155 void testShowHeaderCloseToTheTop()
156 {
157 changeContentY(375);

Subscribers

People subscribed via source and target branches