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

Proposed by Albert Astals Cid on 2015-08-05
Status: Merged
Approved by: Andrea Cimitan on 2015-08-14
Approved revision: 1858
Merged at revision: 1922
Proposed branch: lp:~aacid/unity8/previews_in_order
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/dash_activation_no_special_casing
Diff against target: 117 lines (+35/-19)
2 files modified
qml/Dash/GenericScopeView.qml (+21/-15)
qml/Dash/PreviewListView.qml (+14/-4)
To merge this branch: bzr merge lp:~aacid/unity8/previews_in_order
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) 2015-08-05 Approve on 2015-08-13
PS Jenkins bot continuous-integration Needs Fixing on 2015-08-05
Review via email: mp+267058@code.launchpad.net

Commit Message

Optimize scope.preview() calls

Don't call it in PreviewListView if we're still not open (i.e the list is being constructed)
Also reuse the call we do in GenericScopeView and pass it down for PreviewListView to use

Description of the Change

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

 * 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.
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
y
 * Did CI run pass? If not, please explain why.
unrelated
 * Did you make sure that the branch does not contain spurious tags?
y

review: Approve

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-05 15:39:58 +0000
3+++ qml/Dash/GenericScopeView.qml 2015-08-05 15:39:58 +0000
4@@ -95,23 +95,25 @@
5 scopeView.maybePreviewLimitedCategoryItemCount = undefined;
6 scopeView.maybePreviewCategoryId = "";
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@@ -159,7 +161,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-08-05 15:39:58 +0000
74+++ qml/Dash/PreviewListView.qml 2015-08-05 15:39:58 +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@@ -85,9 +87,9 @@
88 }
89
90 onCountChanged: {
91- if (count > 0 && initialIndex >= 0) {
92+ if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
93+ usedInitialIndex = true;
94 currentIndex = initialIndex;
95- initialIndex = -1;
96 }
97 }
98
99@@ -100,8 +102,16 @@
100 isCurrent: ListView.isCurrentItem
101
102 previewModel: {
103- var previewStack = root.scope.preview(result, root.categoryId);
104- return previewStack.getPreviewModel(0);
105+ if (root.open) {
106+ if (index === root.initialIndex) {
107+ return root.initialIndexPreviewStack.getPreviewModel(0);
108+ } else {
109+ var previewStack = root.scope.preview(result, root.categoryId);
110+ return previewStack.getPreviewModel(0);
111+ }
112+ } else {
113+ return null;
114+ }
115 }
116 scopeStyle: root.scopeStyle
117 }

Subscribers

People subscribed via source and target branches