1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332 | === modified file 'qml/Dash/GenericScopeView.qml'
--- qml/Dash/GenericScopeView.qml 2016-01-28 10:49:33 +0000
+++ qml/Dash/GenericScopeView.qml 2016-02-09 11:57:28 +0000
@@ -785,7 +785,6 @@
readonly property bool processing: item && item.processing || false
readonly property int count: item && item.count || 0
- readonly property int currentIndex: item && item.currentIndex || 0
readonly property var currentItem: item && item.currentItem || null
property string subPage: ""
@@ -800,7 +799,7 @@
}
source: switch(subPage) {
- case "preview": return "PreviewListView.qml";
+ case "preview": return "PreviewView.qml";
case "settings": return "ScopeSettingsPage.qml";
default: return "";
}
=== renamed file 'qml/Dash/PreviewListView.qml' => 'qml/Dash/PreviewView.qml'
--- qml/Dash/PreviewListView.qml 2016-02-08 12:24:45 +0000
+++ qml/Dash/PreviewView.qml 2016-02-09 16:01:55 +0000
@@ -23,6 +23,7 @@
Item {
id: root
+ property bool open: false
property int initialIndex: -1
property var initialIndexPreviewStack: null
property var scope: null
@@ -32,11 +33,9 @@
property alias showSignatureLine: header.showSignatureLine
- property alias open: previewListView.open
- property alias model: previewListView.model
- property alias currentIndex: previewListView.currentIndex
- property alias currentItem: previewListView.currentItem
- property alias count: previewListView.count
+ property var model
+ property alias currentIndex: previewLoader.index
+ property alias currentItem: previewLoader.item
readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
|| currentItem.previewModel.processingAction)
@@ -55,60 +54,49 @@
onBackClicked: root.backClicked()
}
- ListView {
- id: previewListView
- objectName: "listView"
+ onOpenChanged: {
+ if (!open) {
+ // Cancel any pending preview requests or actions
+ if (currentItem && currentItem.previewData !== undefined) {
+ currentItem.previewData.cancelAction();
+ }
+ root.scope.cancelActivation();
+ model = undefined;
+ }
+ }
+
+ onModelChanged: {
+ if (previewLoader.active && initialIndex >= 0 && !usedInitialIndex) {
+ usedInitialIndex = true;
+ previewLoader.index = initialIndex;
+ }
+ }
+
+ Loader {
+ id: previewLoader
+ objectName: "loader"
anchors {
top: header.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
- orientation: ListView.Horizontal
- highlightRangeMode: ListView.StrictlyEnforceRange
- snapMode: ListView.SnapOneItem
- boundsBehavior: Flickable.DragAndOvershootBounds
- highlightMoveDuration: 250
- flickDeceleration: units.gu(625)
- maximumFlickVelocity: width * 5
- interactive: false
- cacheBuffer: 0
-
- property bool open: false
-
- onOpenChanged: {
- if (!open) {
- // Cancel any pending preview requests or actions
- if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
- previewListView.currentItem.previewData.cancelAction();
- }
- root.scope.cancelActivation();
- model = undefined;
- }
- }
-
- onModelChanged: {
- if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
- usedInitialIndex = true;
- previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
- }
- }
-
- delegate: Previews.Preview {
+ active: count > 0
+
+ property int index: 0
+ readonly property int count: root.model && root.model.count || 0
+
+ sourceComponent: Previews.Preview {
id: preview
objectName: "preview" + index
- height: previewListView.height
- width: previewListView.width
+ height: previewLoader.height
+ width: previewLoader.width
- isCurrent: ListView.isCurrentItem
+ property int index: 0
readonly property var previewStack: {
- if (root.open) {
- if (index === root.initialIndex) {
- return root.initialIndexPreviewStack;
- } else {
- return root.scope.preview(result, root.categoryId);
- }
+ if (root.open && index === root.initialIndex) {
+ return root.initialIndexPreviewStack;
} else {
return null;
}
@@ -121,8 +109,11 @@
return null;
}
}
+ }
- scopeStyle: root.scopeStyle
+ onLoaded: {
+ item.index = Qt.binding(function() { return index; });
+ item.scopeStyle = Qt.binding(function() { return root.scopeStyle; });
}
}
=== modified file 'qml/Dash/Previews/Preview.qml'
--- qml/Dash/Previews/Preview.qml 2015-11-26 16:36:41 +0000
+++ qml/Dash/Previews/Preview.qml 2016-02-09 13:09:18 +0000
@@ -34,9 +34,6 @@
*/
property var previewModel
- //! \brief Should be set to true if this preview is currently displayed.
- property bool isCurrent: false
-
//! \brief The ScopeStyle component.
property var scopeStyle: null
@@ -68,8 +65,8 @@
id: column
objectName: "previewListRow" + index
anchors {
- top: parent.top
- bottom: parent.bottom
+ top: parent ? parent.top : undefined
+ bottom: parent ? parent.bottom : undefined
}
width: row.columnWidth
spacing: row.spacing
@@ -88,7 +85,6 @@
widgetId: model.widgetId
widgetType: model.type
widgetData: model.properties
- isCurrentPreview: root.isCurrent
scopeStyle: root.scopeStyle
parentFlickable: column
=== modified file 'qml/Dash/Previews/PreviewExpandable.qml'
--- qml/Dash/Previews/PreviewExpandable.qml 2015-09-18 07:43:38 +0000
+++ qml/Dash/Previews/PreviewExpandable.qml 2016-02-09 11:30:56 +0000
@@ -84,7 +84,6 @@
widgetId: model.widgetId
widgetType: model.type
widgetData: model.properties
- isCurrentPreview: root.isCurrentPreview
scopeStyle: root.scopeStyle
anchors {
left: parent.left
=== modified file 'qml/Dash/Previews/PreviewRatingEdit.qml'
--- qml/Dash/Previews/PreviewRatingEdit.qml 2015-06-18 09:30:17 +0000
+++ qml/Dash/Previews/PreviewRatingEdit.qml 2016-02-09 11:29:53 +0000
@@ -68,7 +68,6 @@
widgetId: root.widgetId
widgetData: root.widgetData
- isCurrentPreview: root.isCurrentPreview
scopeStyle: root.scopeStyle
ratingValue: widgetData["rating"]
=== modified file 'qml/Dash/Previews/PreviewWidget.qml'
--- qml/Dash/Previews/PreviewWidget.qml 2015-11-26 16:36:41 +0000
+++ qml/Dash/Previews/PreviewWidget.qml 2016-02-09 11:29:39 +0000
@@ -19,9 +19,6 @@
/*! Interface for preview widgets. */
Item {
- //! Specifies the preview widget being currently used or not
- property bool isCurrentPreview: true
-
//! The widget identifier
property string widgetId
=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
--- qml/Dash/Previews/PreviewWidgetFactory.qml 2015-11-26 16:36:41 +0000
+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2016-02-09 11:30:44 +0000
@@ -37,9 +37,6 @@
//! Should the widget show in expanded mode (For those that support it)
property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
- //! Set to true if the parent preview is displayed.
- property bool isCurrentPreview: false
-
//! Set margins width.
property real widgetMargins: status === Loader.Ready ? item.widgetMargins : units.gu(1)
@@ -82,7 +79,6 @@
onLoaded: {
item.widgetId = Qt.binding(function() { return root.widgetId } )
item.widgetData = Qt.binding(function() { return root.widgetData } )
- item.isCurrentPreview = Qt.binding(function() { return root.isCurrentPreview } )
item.expanded = Qt.binding(function() { return root.expanded } )
item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
=== modified file 'tests/qmltests/Dash/tst_PreviewListView.qml'
--- tests/qmltests/Dash/tst_PreviewListView.qml 2015-08-24 07:45:32 +0000
+++ tests/qmltests/Dash/tst_PreviewListView.qml 2016-02-09 11:56:26 +0000
@@ -36,8 +36,8 @@
id: mockResultsModel
}
- PreviewListView {
- id: listView
+ PreviewView {
+ id: view
anchors.fill: parent
scope: mockScope
scopeStyle: ScopeStyle {
@@ -47,10 +47,10 @@
UT.UnityTestCase {
id: testCase
- name: "PreviewListView"
+ name: "PreviewView"
when: windowShown
- property MouseArea mouseArea: findChild(listView, "processingMouseArea")
+ property MouseArea mouseArea: findChild(view, "processingMouseArea")
SignalSpy {
id: clickedSpy
@@ -59,43 +59,43 @@
}
function init() {
- listView.model = mockResultsModel;
- listView.currentIndex = 1;
- listView.open = true;
+ view.model = mockResultsModel;
+ view.currentIndex = 1;
+ view.open = true;
verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
}
function cleanup() {
- listView.open = false;
- listView.model = null;
+ view.open = false;
+ view.model = null;
clickedSpy.clear();
}
function test_notProcessing() {
expectFail("", "processingMouseArea should not receive the click.");
- mouseClick(listView);
+ mouseClick(view);
clickedSpy.wait();
}
function test_processing() {
- verify(listView.currentItem, "currentItem is not ready yet");
- listView.currentItem.previewModel.setLoaded(false);
-
- tryCompare(listView, "processing", true);
-
- mouseClick(listView);
+ verify(view.currentItem, "currentItem is not ready yet");
+ view.currentItem.previewModel.setLoaded(false);
+
+ tryCompare(view, "processing", true);
+
+ mouseClick(view);
clickedSpy.wait();
}
function test_title() {
- var header = findChild(listView, "innerPageHeader");
+ var header = findChild(view, "innerPageHeader");
verify(header, "Could not find the preview header");
compare(header.config.title, "Mock Scope");
}
function test_header_style() {
- var header = findChild(listView, "pageHeader");
+ var header = findChild(view, "pageHeader");
verify(header, "Could not find the header");
var innerHeader = findChild(header, "innerPageHeader");
|