Merge lp:~mardy/unity8/lp1433442 into lp:unity8

Proposed by Alberto Mardegan on 2015-08-14
Status: Superseded
Proposed branch: lp:~mardy/unity8/lp1433442
Merge into: lp:unity8
Diff against target: 120 lines (+37/-21)
2 files modified
qml/Dash/GenericScopeView.qml (+21/-15)
qml/Dash/PreviewListView.qml (+16/-6)
To merge this branch: bzr merge lp:~mardy/unity8/lp1433442
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) 2015-08-14 Approve on 2015-08-17
PS Jenkins bot continuous-integration Needs Fixing on 2015-08-14
Review via email: mp+268068@code.launchpad.net

This proposal has been superseded by a proposal from 2015-08-17.

Commit Message

Set currentIndex after the model change is completed

When setting the model, the list view will first emit the countChanged signal, then will change the currentIndex to 0 (see QtDeclarative git commit 22c6873 and https://bugreports.qt.io/browse/QTBUG-26604), and finally will emit the modelChanged signal.
If we set the currentIndex in the onCountChanged handler (as we were doing
before), the currentIndex would be reset to 0 shortly afterwards.

For some mysterious reason, the desired delegate was anyway shown until the bugfix for bug 1433442 was introduced; with that bugfix, the listview is more consistent and shows the delegate corresponding to the currentIndex.

Description of the Change

Set currentIndex after the model change is completed

When setting the model, the list view will first emit the countChanged signal, then will change the currentIndex to 0 (see QtDeclarative git commit 22c6873 and https://bugreports.qt.io/browse/QTBUG-26604), and finally will emit the modelChanged signal.
If we set the currentIndex in the onCountChanged handler (as we were doing
before), the currentIndex would be reset to 0 shortly afterwards.

For some mysterious reason, the desired delegate was anyway shown until the bugfix for bug 1433442 was introduced; with that bugfix, the listview is more consistent and shows the delegate corresponding to the currentIndex.

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

No, although this change is mostly relevant when using libqt5quick5 from silo 29 (because without this change, that silo would cause a regression).

 * 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?

It isn't.

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

No visible UI changes.

To post a comment you must log in.
Albert Astals Cid (aacid) wrote :

This is actually regressing (without the silo 29).

Is silo 29 ready/testable already?

review: Needs Fixing
lp:~mardy/unity8/lp1433442 updated on 2015-08-14
1918. By Alberto Mardegan on 2015-08-14

Change index via positionViewAtIndex()

Albert Astals Cid (aacid) wrote :

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

 * Did CI run pass?
It's kaboomed

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

review: Approve
lp:~mardy/unity8/lp1433442 updated on 2015-08-17
1919. By Alberto Mardegan on 2015-08-17

Merge previews-in-order

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Dash/GenericScopeView.qml'
2--- qml/Dash/GenericScopeView.qml 2015-08-06 10:46:10 +0000
3+++ qml/Dash/GenericScopeView.qml 2015-08-17 11:32:22 +0000
4@@ -99,23 +99,25 @@
5 function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
6 clearMaybePreviewData();
7
8- if (scope.preview(result, categoryId)) {
9- openPreview(index, resultsModel, limitedCategoryItemCount, categoryId);
10- }
11+ openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId);
12 }
13
14- function openPreview(index, resultsModel, limitedCategoryItemCount, categoryId) {
15- if (limitedCategoryItemCount > 0) {
16- previewLimitModel.model = resultsModel;
17- previewLimitModel.limit = limitedCategoryItemCount;
18- subPageLoader.model = previewLimitModel;
19- } else {
20- subPageLoader.model = resultsModel;
21+ function openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId) {
22+ var previewStack = scope.preview(result, categoryId);
23+ if (previewStack) {
24+ if (limitedCategoryItemCount > 0) {
25+ previewLimitModel.model = resultsModel;
26+ previewLimitModel.limit = limitedCategoryItemCount;
27+ subPageLoader.model = previewLimitModel;
28+ } else {
29+ subPageLoader.model = resultsModel;
30+ }
31+ subPageLoader.initialIndex = -1;
32+ subPageLoader.initialIndex = index;
33+ subPageLoader.categoryId = categoryId;
34+ subPageLoader.previewStack = previewStack;
35+ subPageLoader.openSubPage("preview");
36 }
37- subPageLoader.initialIndex = -1;
38- subPageLoader.initialIndex = index;
39- subPageLoader.categoryId = categoryId;
40- subPageLoader.openSubPage("preview");
41 }
42
43 Binding {
44@@ -163,7 +165,8 @@
45 onHideDash: subPageLoader.closeSubPage()
46 onPreviewRequested: { // (QVariant const& result)
47 if (result === scopeView.maybePreviewResult) {
48- openPreview(scopeView.maybePreviewIndex,
49+ openPreview(result,
50+ scopeView.maybePreviewIndex,
51 scopeView.maybePreviewResultsModel,
52 scopeView.maybePreviewLimitedCategoryItemCount,
53 scopeView.maybePreviewCategoryId);
54@@ -758,6 +761,7 @@
55 property var scope: scopeView.scope
56 property var scopeStyle: scopeView.scopeStyle
57 property int initialIndex: -1
58+ property var previewStack;
59 property string categoryId
60 property var model: null
61
62@@ -791,6 +795,8 @@
63 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
64 item.model = Qt.binding(function() { return subPageLoader.model; } )
65 item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
66+ item.initialIndexPreviewStack = subPageLoader.previewStack;
67+ subPageLoader.previewStack = null;
68 }
69 open = true;
70 }
71
72=== modified file 'qml/Dash/PreviewListView.qml'
73--- qml/Dash/PreviewListView.qml 2015-07-07 15:52:19 +0000
74+++ qml/Dash/PreviewListView.qml 2015-08-17 11:32:22 +0000
75@@ -24,9 +24,11 @@
76 id: root
77
78 property int initialIndex: -1
79+ property var initialIndexPreviewStack: null
80 property var scope: null
81 property var scopeStyle: null
82 property string categoryId
83+ property bool usedInitialIndex: false
84
85 property alias showSignatureLine: header.showSignatureLine
86
87@@ -84,10 +86,10 @@
88 }
89 }
90
91- onCountChanged: {
92- if (count > 0 && initialIndex >= 0) {
93- currentIndex = initialIndex;
94- initialIndex = -1;
95+ onModelChanged: {
96+ if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
97+ usedInitialIndex = true;
98+ previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
99 }
100 }
101
102@@ -100,8 +102,16 @@
103 isCurrent: ListView.isCurrentItem
104
105 previewModel: {
106- var previewStack = root.scope.preview(result, root.categoryId);
107- return previewStack.getPreviewModel(0);
108+ if (root.open) {
109+ if (index === root.initialIndex) {
110+ return root.initialIndexPreviewStack.getPreviewModel(0);
111+ } else {
112+ var previewStack = root.scope.preview(result, root.categoryId);
113+ return previewStack.getPreviewModel(0);
114+ }
115+ } else {
116+ return null;
117+ }
118 }
119 scopeStyle: root.scopeStyle
120 }

Subscribers

People subscribed via source and target branches