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

Proposed by Albert Astals Cid on 2015-03-17
Status: Merged
Approved by: Michael Zanetti on 2015-03-18
Approved revision: 1661
Merged at revision: 1691
Proposed branch: lp:~aacid/unity8/lvwph_firstVisibleIndex_remove
Merge into: lp:unity8
Diff against target: 47 lines (+18/-8)
2 files modified
plugins/Dash/listviewwithpageheader.cpp (+7/-8)
tests/plugins/Dash/listviewwithpageheadertest.cpp (+11/-0)
To merge this branch: bzr merge lp:~aacid/unity8/lvwph_firstVisibleIndex_remove
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-03-19
Michael Zanetti (community) 2015-03-17 Approve on 2015-03-18
Review via email: mp+253236@code.launchpad.net

Commit Message

Make sure m_firstVisibleIndex is correctly set after processing changeSet.removes

There are two fixes:
* Decouple the code that sets the m_firstVisibleIndex that was only done when !growDown
* Set m_firstVisibleIndex correctly when the list is not empty

Description of the Change

* Are there any related MPs required for this MP to build/function as expected?
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* Did you make sure that your branch does not contain spurious tags?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Michael Zanetti (mzanetti) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?

yes

 * Did CI run pass? If not, please explain why.

No. :( Qmltest failures are not related to this branch. It's a bit odd that this branch seems to have failed all AP tests. I've triggered a rebuild now, but I think there's some general mir restarting instability going on atm.

 * Did you make sure that the branch does not contain spurious tags?

yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Dash/listviewwithpageheader.cpp'
2--- plugins/Dash/listviewwithpageheader.cpp 2014-12-03 10:28:53 +0000
3+++ plugins/Dash/listviewwithpageheader.cpp 2015-03-17 16:03:51 +0000
4@@ -973,14 +973,13 @@
5 }
6 if (growDown) {
7 adjustMinYExtent();
8- } else if (remove.index <= m_firstVisibleIndex) {
9- if (!m_visibleItems.isEmpty()) {
10- // We removed the first item that is the one that positions the rest
11- // position the new first item correctly
12- m_visibleItems.first()->setY(oldFirstValidIndexPos);
13- } else {
14- m_firstVisibleIndex = -1;
15- }
16+ } else if (remove.index <= m_firstVisibleIndex && !m_visibleItems.isEmpty()) {
17+ m_visibleItems.first()->setY(oldFirstValidIndexPos);
18+ }
19+ if (m_visibleItems.isEmpty()) {
20+ m_firstVisibleIndex = -1;
21+ } else {
22+ m_firstVisibleIndex -= qMax(0, m_firstVisibleIndex - remove.index);
23 }
24 } else if (remove.index + remove.count <= m_firstVisibleIndex) {
25 m_firstVisibleIndex -= remove.count;
26
27=== modified file 'tests/plugins/Dash/listviewwithpageheadertest.cpp'
28--- tests/plugins/Dash/listviewwithpageheadertest.cpp 2014-12-03 11:06:10 +0000
29+++ tests/plugins/Dash/listviewwithpageheadertest.cpp 2015-03-17 16:03:51 +0000
30@@ -1938,6 +1938,17 @@
31 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
32 }
33
34+ void testFirstVisibleIndexRemove()
35+ {
36+ changeContentY(520);
37+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
38+ QCOMPARE(lvwph->m_firstVisibleIndex, 1);
39+
40+ // Remove 0 and 1, the previously visible index 2 will be 0 and visible
41+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 0), Q_ARG(QVariant, 2));
42+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
43+ }
44+
45 private:
46 QQuickView *view;
47 ListViewWithPageHeader *lvwph;

Subscribers

People subscribed via source and target branches