on xenial help sign in
Updated the Preview view to use a single PreviewModel instead old PreviewStack, using a Loader instead ListView Fixes: #1541967

Approved by: Albert Astals Cid

commit05b99f2eba6f4f2825a070b7e5321cd726f8e549 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 1 Mar 2016, 10:28 (11 years ago) parent1189f50dbe8861
20 files changed+152−419
debian/control+1−1 qml/Dash/GenericScopeView.qml+13−41 qml/Dash/PreviewListView.qml−140 qml/Dash/PreviewView.qml+76 qml/Dash/Previews/Preview.qml−4 qml/Dash/Previews/PreviewExpandable.qml−1 qml/Dash/Previews/PreviewRatingDisplay.qml−1 qml/Dash/Previews/PreviewRatingEdit.qml−1 qml/Dash/Previews/PreviewWidget.qml−3 qml/Dash/Previews/PreviewWidgetFactory.qml−4 tests/mocks/Unity/CMakeLists.txt−2 tests/mocks/Unity/Unity.qmltypes+33−50 tests/mocks/Unity/fake_previewstack.cpp−68 tests/mocks/Unity/fake_previewstack.h−52 tests/mocks/Unity/fake_scope.cpp+2−2 tests/mocks/Unity/fake_scope.h+2−2 tests/mocks/Unity/fake_unity_plugin.cpp+1−2 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml−28 tests/qmltests/Dash/tst_PreviewListView.qml → tests/qmltests/Dash/tst_PreviewView.qml+23−16
debian/control+1−1
@@ -29,7 +29,7 @@ Build-Depends: cmake,
2929 libqt5xmlpatterns5-dev,
3030 libsystemsettings-dev,
3131 libudev-dev,
32− libunity-api-dev (>= 7.106),
32+ libunity-api-dev (>= 7.107),
3333 libusermetricsoutput1-dev,
3434# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
3535 libx11-dev[!armhf],
qml/Dash/GenericScopeView.qml+13−41
@@ -73,49 +73,30 @@ FocusScope {
7373 }
7474
7575 property var maybePreviewResult;
76− property int maybePreviewIndex;
77− property var maybePreviewResultsModel;
78− property int maybePreviewLimitedCategoryItemCount;
7976 property string maybePreviewCategoryId;
8077
8178 function clearMaybePreviewData() {
8279 scopeView.maybePreviewResult = undefined;
83− scopeView.maybePreviewIndex = -1;
84− scopeView.maybePreviewResultsModel = undefined;
85− scopeView.maybePreviewLimitedCategoryItemCount = -1;
8680 scopeView.maybePreviewCategoryId = "";
8781 }
8882
89− function itemClicked(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
83+ function itemClicked(result, categoryId) {
9084 scopeView.maybePreviewResult = result;
91− scopeView.maybePreviewIndex = index;
92− scopeView.maybePreviewResultsModel = resultsModel;
93− scopeView.maybePreviewLimitedCategoryItemCount = limitedCategoryItemCount;
9485 scopeView.maybePreviewCategoryId = categoryId;
9586
9687 scope.activate(result, categoryId);
9788 }
9889
99− function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
90+ function itemPressedAndHeld(result, categoryId) {
10091 clearMaybePreviewData();
10192
102− openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId);
93+ openPreview(result, categoryId);
10394 }
10495
105− function openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId) {
106− var previewStack = scope.preview(result, categoryId);
107− if (previewStack) {
108− if (limitedCategoryItemCount > 0) {
109− previewLimitModel.model = resultsModel;
110− previewLimitModel.limit = limitedCategoryItemCount;
111− subPageLoader.model = previewLimitModel;
112− } else {
113− subPageLoader.model = resultsModel;
114− }
115− subPageLoader.initialIndex = -1;
116− subPageLoader.initialIndex = index;
117− subPageLoader.categoryId = categoryId;
118− subPageLoader.previewStack = previewStack;
96+ function openPreview(result, categoryId) {
97+ var previewModel = scope.preview(result, categoryId);
98+ if (previewModel) {
99+ subPageLoader.previewModel = previewModel;
119100 subPageLoader.openSubPage("preview");
120101 }
121102 }
@@ -166,9 +147,6 @@ FocusScope {
166147 onPreviewRequested: { // (QVariant const& result)
167148 if (result === scopeView.maybePreviewResult) {
168149 openPreview(result,
169− scopeView.maybePreviewIndex,
170− scopeView.maybePreviewResultsModel,
171− scopeView.maybePreviewLimitedCategoryItemCount,
172150 scopeView.maybePreviewCategoryId);
173151
174152 clearMaybePreviewData();
@@ -400,11 +378,11 @@ FocusScope {
400378 Connections {
401379 target: rendererLoader.item
402380 onClicked: { // (int index, var result, var item, var itemModel)
403− scopeView.itemClicked(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
381+ scopeView.itemClicked(result, baseItem.category);
404382 }
405383
406384 onPressAndHold: { // (int index, var result, var itemModel)
407− scopeView.itemPressedAndHeld(index, result, target.model, categoryItemCount(), baseItem.category);
385+ scopeView.itemPressedAndHeld(result, baseItem.category);
408386 }
409387
410388 function categoryItemCount() {
@@ -779,13 +757,10 @@ FocusScope {
779757 property var scope: scopeView.scope
780758 property var scopeStyle: scopeView.scopeStyle
781759 property int initialIndex: -1
782− property var previewStack;
783− property string categoryId
784− property var model: null
760+ property var previewModel;
785761
786762 readonly property bool processing: item && item.processing || false
787763 readonly property int count: item && item.count || 0
788− readonly property int currentIndex: item && item.currentIndex || 0
789764 readonly property var currentItem: item && item.currentItem || null
790765
791766 property string subPage: ""
@@ -800,7 +775,7 @@ FocusScope {
800775 }
801776
802777 source: switch(subPage) {
803− case "preview": return "PreviewListView.qml";
778+ case "preview": return "PreviewView.qml";
804779 case "settings": return "ScopeSettingsPage.qml";
805780 default: return "";
806781 }
@@ -810,11 +785,8 @@ FocusScope {
810785 item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
811786 if (subPage == "preview") {
812787 item.open = Qt.binding(function() { return subPageLoader.open; } )
813− item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
814− item.model = Qt.binding(function() { return subPageLoader.model; } )
815− item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
816− item.initialIndexPreviewStack = subPageLoader.previewStack;
817− subPageLoader.previewStack = null;
788+ item.previewModel = subPageLoader.previewModel;
789+ subPageLoader.previewModel = null;
818790 }
819791 open = true;
820792 }
qml/Dash/PreviewListView.qmldeleted−140
@@ -1,140 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Unity 0.2
20−import "../Components"
21−import "Previews" as Previews
22−
23−Item {
24− id: root
25−
26− property int initialIndex: -1
27− property var initialIndexPreviewStack: null
28− property var scope: null
29− property var scopeStyle: null
30− property string categoryId
31− property bool usedInitialIndex: false
32−
33− property alias showSignatureLine: header.showSignatureLine
34−
35− property alias open: previewListView.open
36− property alias model: previewListView.model
37− property alias currentIndex: previewListView.currentIndex
38− property alias currentItem: previewListView.currentItem
39− property alias count: previewListView.count
40−
41− readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
42− || currentItem.previewModel.processingAction)
43−
44− signal backClicked()
45−
46− DashPageHeader {
47− id: header
48− objectName: "pageHeader"
49− width: parent.width
50− title: root.scope ? root.scope.name : ""
51− showBackButton: true
52− searchEntryEnabled: false
53− scopeStyle: root.scopeStyle
54−
55− onBackClicked: root.backClicked()
56− }
57−
58− ListView {
59− id: previewListView
60− objectName: "listView"
61− anchors {
62− top: header.bottom
63− bottom: parent.bottom
64− left: parent.left
65− right: parent.right
66− }
67− orientation: ListView.Horizontal
68− highlightRangeMode: ListView.StrictlyEnforceRange
69− snapMode: ListView.SnapOneItem
70− boundsBehavior: Flickable.DragAndOvershootBounds
71− highlightMoveDuration: 250
72− flickDeceleration: units.gu(625)
73− maximumFlickVelocity: width * 5
74− cacheBuffer: 0
75−
76− property bool open: false
77−
78− onOpenChanged: {
79− if (!open) {
80− // Cancel any pending preview requests or actions
81− if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
82− previewListView.currentItem.previewData.cancelAction();
83− }
84− root.scope.cancelActivation();
85− model = undefined;
86− }
87− }
88−
89− onModelChanged: {
90− if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
91− usedInitialIndex = true;
92− previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
93− }
94− }
95−
96− delegate: Previews.Preview {
97− id: preview
98− objectName: "preview" + index
99− height: previewListView.height
100− width: previewListView.width
101−
102− isCurrent: ListView.isCurrentItem
103−
104− readonly property var previewStack: {
105− if (root.open) {
106− if (index === root.initialIndex) {
107− return root.initialIndexPreviewStack;
108− } else {
109− return root.scope.preview(result, root.categoryId);
110− }
111− } else {
112− return null;
113− }
114− }
115−
116− previewModel: {
117− if (previewStack) {
118− return previewStack.getPreviewModel(0);
119− } else {
120− return null;
121− }
122− }
123−
124− scopeStyle: root.scopeStyle
125− }
126− }
127−
128− MouseArea {
129− id: processingMouseArea
130− objectName: "processingMouseArea"
131− anchors {
132− left: parent.left
133− right: parent.right
134− top: header.bottom
135− bottom: parent.bottom
136− }
137−
138− enabled: root.processing
139− }
140−}
qml/Dash/PreviewView.qmlnew file+76
@@ -0,0 +1,76 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+import Unity 0.2
20+import "../Components"
21+import "Previews" as Previews
22+
23+Item {
24+ id: root
25+
26+ property bool open: false
27+ property var scope: null
28+ property var scopeStyle: null
29+ property alias showSignatureLine: header.showSignatureLine
30+ property alias previewModel: preview.previewModel
31+ readonly property bool processing: previewModel && (!previewModel.loaded || previewModel.processingAction)
32+
33+ signal backClicked()
34+
35+ DashPageHeader {
36+ id: header
37+ objectName: "pageHeader"
38+ width: parent.width
39+ title: root.scope ? root.scope.name : ""
40+ showBackButton: true
41+ searchEntryEnabled: false
42+ scopeStyle: root.scopeStyle
43+
44+ onBackClicked: root.backClicked()
45+ }
46+
47+ onOpenChanged: {
48+ if (!open) {
49+ root.scope.cancelActivation();
50+ }
51+ }
52+
53+ Previews.Preview {
54+ id: preview
55+ objectName: "preview"
56+ anchors {
57+ top: header.bottom
58+ bottom: parent.bottom
59+ left: parent.left
60+ right: parent.right
61+ }
62+ scopeStyle: root.scopeStyle
63+ }
64+
65+ MouseArea {
66+ id: processingMouseArea
67+ objectName: "processingMouseArea"
68+ anchors {
69+ top: header.bottom
70+ bottom: parent.bottom
71+ left: parent.left
72+ right: parent.right
73+ }
74+ enabled: root.processing
75+ }
76+}
qml/Dash/Previews/Preview.qml−4
@@ -34,9 +34,6 @@ Item {
3434 */
3535 property var previewModel
3636
37− //! \brief Should be set to true if this preview is currently displayed.
38− property bool isCurrent: false
39−
4037 //! \brief The ScopeStyle component.
4138 property var scopeStyle: null
4239
@@ -88,7 +85,6 @@ Item {
8885 widgetId: model.widgetId
8986 widgetType: model.type
9087 widgetData: model.properties
91− isCurrentPreview: root.isCurrent
9288 scopeStyle: root.scopeStyle
9389 parentFlickable: column
9490
qml/Dash/Previews/PreviewExpandable.qml−1
@@ -84,7 +84,6 @@ PreviewWidget {
8484 widgetId: model.widgetId
8585 widgetType: model.type
8686 widgetData: model.properties
87− isCurrentPreview: root.isCurrentPreview
8887 scopeStyle: root.scopeStyle
8988 anchors {
9089 left: parent.left
qml/Dash/Previews/PreviewRatingDisplay.qml−1
@@ -40,7 +40,6 @@ PreviewWidget {
4040 id: root
4141 implicitHeight: childrenRect.height
4242
43− onIsCurrentPreviewChanged: ratingsList.updateRanges();
4443 onParentFlickableChanged: ratingsList.updateRanges();
4544
4645 Connections {
qml/Dash/Previews/PreviewRatingEdit.qml−1
@@ -68,7 +68,6 @@ PreviewWidget {
6868
6969 widgetId: root.widgetId
7070 widgetData: root.widgetData
71− isCurrentPreview: root.isCurrentPreview
7271 scopeStyle: root.scopeStyle
7372
7473 ratingValue: widgetData["rating"]
qml/Dash/Previews/PreviewWidget.qml−3
@@ -19,9 +19,6 @@ import QtQuick 2.4
1919/*! Interface for preview widgets. */
2020
2121Item {
22− //! Specifies the preview widget being currently used or not
23− property bool isCurrentPreview: true
24−
2522 //! The widget identifier
2623 property string widgetId
2724
qml/Dash/Previews/PreviewWidgetFactory.qml−4
@@ -37,9 +37,6 @@ Loader {
3737 //! Should the widget show in expanded mode (For those that support it)
3838 property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
3939
40− //! Set to true if the parent preview is displayed.
41− property bool isCurrentPreview: false
42−
4340 //! Set margins width.
4441 property real widgetMargins: status === Loader.Ready ? item.widgetMargins : units.gu(1)
4542
@@ -82,7 +79,6 @@ Loader {
8279 onLoaded: {
8380 item.widgetId = Qt.binding(function() { return root.widgetId } )
8481 item.widgetData = Qt.binding(function() { return root.widgetData } )
85− item.isCurrentPreview = Qt.binding(function() { return root.isCurrentPreview } )
8682 item.expanded = Qt.binding(function() { return root.expanded } )
8783 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
8884 item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
tests/mocks/Unity/CMakeLists.txt−2
@@ -28,13 +28,11 @@ set(UnityQML_SOURCES
2828 fake_navigation.cpp
2929 fake_resultsmodel.cpp
3030 fake_previewmodel.cpp
31− fake_previewstack.cpp
3231 fake_previewwidgetmodel.cpp
3332 fake_unity_plugin.cpp
3433 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
3534 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
3635 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
37− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
3836 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
3937 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
4038 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
tests/mocks/Unity/Unity.qmltypes+33−50
@@ -1,4 +1,4 @@
1−import QtQuick.tooling 1.1
1+import QtQuick.tooling 1.2
22
33// This file describes the plugin-supplied types contained in the library.
44// It is used for QML tooling purposes only.
@@ -7,17 +7,10 @@ import QtQuick.tooling 1.1
77// 'qmlplugindump -notrelocatable Unity 0.2 tests/mocks'
88
99Module {
10+ dependencies: ["QtQuick 2.4", "Unity.Indicators 0.1"]
1011 Component {
1112 name: "Categories"
1213 prototype: "unity::shell::scopes::CategoriesInterface"
13− Method {
14− name: "addSpecialCategory"
15− Parameter { name: "categoryId"; type: "string" }
16− Parameter { name: "name"; type: "string" }
17− Parameter { name: "icon"; type: "string" }
18− Parameter { name: "rawTemplate"; type: "string" }
19− Parameter { name: "countObject"; type: "QObject"; isPointer: true }
20− }
2114 Method {
2215 name: "overrideCategoryJson"
2316 type: "bool"
@@ -60,18 +53,6 @@ Module {
6053 Parameter { type: "bool" }
6154 }
6255 }
63− Component {
64− name: "PreviewStack"
65− prototype: "unity::shell::scopes::PreviewStackInterface"
66− exports: ["Unity/PreviewStack 0.2"]
67− isCreatable: false
68− exportMetaObjectRevisions: [0]
69− Method {
70− name: "getPreviewModel"
71− type: "unity::shell::scopes::PreviewModelInterface*"
72− Parameter { name: "index"; type: "int" }
73− }
74− }
7556 Component {
7657 name: "PreviewWidgetModel"
7758 prototype: "unity::shell::scopes::PreviewWidgetModelInterface"
@@ -95,11 +76,11 @@ Module {
9576 prototype: "unity::shell::scopes::ScopeInterface"
9677 exports: ["Unity/MockScope 0.2"]
9778 exportMetaObjectRevisions: [0]
79+ Signal { name: "refreshed" }
9880 Signal {
99− name: "performQuery"
81+ name: "queryPerformed"
10082 Parameter { name: "query"; type: "string" }
10183 }
102− Signal { name: "refreshed" }
10384 Method {
10485 name: "setId"
10586 Parameter { name: "id"; type: "string" }
@@ -115,11 +96,13 @@ Module {
11596 Method {
11697 name: "activate"
11798 Parameter { name: "result"; type: "QVariant" }
99+ Parameter { name: "categoryId"; type: "string" }
118100 }
119101 Method {
120102 name: "preview"
121− type: "PreviewStack*"
103+ type: "PreviewModel*"
122104 Parameter { name: "result"; type: "QVariant" }
105+ Parameter { name: "categoryId"; type: "string" }
123106 }
124107 Method { name: "cancelActivation" }
125108 Method {
@@ -142,6 +125,12 @@ Module {
142125 Parameter { name: "isAltNavigation"; type: "bool" }
143126 }
144127 Method { name: "refresh" }
128+ Method {
129+ name: "activateAction"
130+ Parameter { name: "result"; type: "QVariant" }
131+ Parameter { name: "categoryId"; type: "string" }
132+ Parameter { name: "actionId"; type: "string" }
133+ }
145134 }
146135 Component {
147136 name: "Scopes"
@@ -181,6 +170,10 @@ Module {
181170 Parameter { name: "scopeId"; type: "string" }
182171 Parameter { name: "index"; type: "int" }
183172 }
173+ Method {
174+ name: "closeScope"
175+ Parameter { name: "scope"; type: "unity::shell::scopes::ScopeInterface"; isPointer: true }
176+ }
184177 Method {
185178 name: "getScopeFromAll"
186179 type: "Scope*"
@@ -214,14 +207,6 @@ Module {
214207 Parameter { name: "categoryId"; type: "string" }
215208 Parameter { name: "json"; type: "string" }
216209 }
217− Method {
218− name: "addSpecialCategory"
219− Parameter { name: "categoryId"; type: "string" }
220− Parameter { name: "name"; type: "string" }
221− Parameter { name: "icon"; type: "string" }
222− Parameter { name: "rawTemplate"; type: "string" }
223− Parameter { name: "countObject"; type: "QObject"; isPointer: true }
224− }
225210 }
226211 Component {
227212 name: "unity::shell::scopes::NavigationInterface"
@@ -270,22 +255,6 @@ Module {
270255 Parameter { type: "QVariantMap" }
271256 }
272257 }
273− Component {
274− name: "unity::shell::scopes::PreviewStackInterface"
275− prototype: "QAbstractListModel"
276− Enum {
277− name: "Roles"
278− values: {
279− "RolePreviewModel": 0
280− }
281− }
282− Property { name: "widgetColumnCount"; type: "int" }
283− Method {
284− name: "getPreviewModel"
285− type: "unity::shell::scopes::PreviewModelInterface*"
286− Parameter { name: "index"; type: "int" }
287− }
288− }
289258 Component {
290259 name: "unity::shell::scopes::PreviewWidgetModelInterface"
291260 prototype: "QAbstractListModel"
@@ -316,7 +285,8 @@ Module {
316285 "RoleSummary": 9,
317286 "RoleAttributes": 10,
318287 "RoleBackground": 11,
319− "RoleOverlayColor": 12
288+ "RoleOverlayColor": 12,
289+ "RoleQuickPreviewData": 13
320290 }
321291 }
322292 Property { name: "categoryId"; type: "string" }
@@ -343,6 +313,7 @@ Module {
343313 Property { name: "description"; type: "string"; isReadonly: true }
344314 Property { name: "searchHint"; type: "string"; isReadonly: true }
345315 Property { name: "searchInProgress"; type: "bool"; isReadonly: true }
316+ Property { name: "activationInProgress"; type: "bool"; isReadonly: true }
346317 Property { name: "favorite"; type: "bool" }
347318 Property { name: "shortcut"; type: "string"; isReadonly: true }
348319 Property {
@@ -393,11 +364,13 @@ Module {
393364 Method {
394365 name: "activate"
395366 Parameter { name: "result"; type: "QVariant" }
367+ Parameter { name: "categoryId"; type: "string" }
396368 }
397369 Method {
398370 name: "preview"
399− type: "unity::shell::scopes::PreviewStackInterface*"
371+ type: "unity::shell::scopes::PreviewModelInterface*"
400372 Parameter { name: "result"; type: "QVariant" }
373+ Parameter { name: "categoryId"; type: "string" }
401374 }
402375 Method { name: "cancelActivation" }
403376 Method {
@@ -424,6 +397,12 @@ Module {
424397 Parameter { name: "cannedQuery"; type: "string" }
425398 }
426399 Method { name: "refresh" }
400+ Method {
401+ name: "activateAction"
402+ Parameter { name: "result"; type: "QVariant" }
403+ Parameter { name: "categoryId"; type: "string" }
404+ Parameter { name: "actionId"; type: "string" }
405+ }
427406 }
428407 Component {
429408 name: "unity::shell::scopes::ScopesInterface"
@@ -464,6 +443,10 @@ Module {
464443 Parameter { name: "scopeId"; type: "string" }
465444 Parameter { name: "index"; type: "int" }
466445 }
446+ Method {
447+ name: "closeScope"
448+ Parameter { name: "scope"; type: "unity::shell::scopes::ScopeInterface"; isPointer: true }
449+ }
467450 }
468451 Component {
469452 name: "unity::shell::scopes::SettingsModelInterface"
tests/mocks/Unity/fake_previewstack.cppdeleted−68
@@ -1,68 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−// self
18−#include "fake_previewstack.h"
19−
20−// local
21−#include "fake_previewmodel.h"
22−#include "fake_scope.h"
23−
24−PreviewStack::PreviewStack(Scope *scope)
25− : unity::shell::scopes::PreviewStackInterface(nullptr)
26−{
27− m_previews << new PreviewModel(this, scope);
28−}
29−
30−PreviewStack::~PreviewStack()
31−{
32−}
33−
34−void PreviewStack::setWidgetColumnCount(int columnCount)
35−{
36− if (columnCount != 1) {
37− qFatal("PreviewStack::setWidgetColumnCount != 1 not implemented");
38− }
39−}
40−
41−int PreviewStack::widgetColumnCount() const
42−{
43− return 1;
44−}
45−
46−int PreviewStack::rowCount(const QModelIndex&) const
47−{
48− return m_previews.size();
49−}
50−
51−unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
52−{
53− if (index >= m_previews.size()) {
54− return nullptr;
55− }
56−
57− return m_previews.at(index);
58−}
59−
60−QVariant PreviewStack::data(const QModelIndex& index, int role) const
61−{
62− switch (role) {
63− case RolePreviewModel:
64− return QVariant::fromValue(m_previews.at(index.row()));
65− default:
66− return QVariant();
67− }
68−}
tests/mocks/Unity/fake_previewstack.hdeleted−52
@@ -1,52 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−
18−#ifndef FAKE_PREVIEWSTACK_H
19−#define FAKE_PREVIEWSTACK_H
20−
21−#include <unity/shell/scopes/PreviewStackInterface.h>
22−
23−#include <QSharedPointer>
24−#include <QVariantMap>
25−
26−class PreviewModel;
27−
28−class Scope;
29−
30−class PreviewStack : public unity::shell::scopes::PreviewStackInterface
31−{
32− Q_OBJECT
33−
34−public:
35− explicit PreviewStack(Scope* scope = 0);
36− virtual ~PreviewStack();
37−
38− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
39− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
40−
41− Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
42−
43− void setWidgetColumnCount(int columnCount) override;
44− int widgetColumnCount() const override;
45−
46−private:
47− QList<PreviewModel*> m_previews;
48−};
49−
50−Q_DECLARE_METATYPE(PreviewStack*)
51−
52−#endif // FAKE_PREVIEWSTACK_H
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -199,14 +199,14 @@ void Scope::activate(QVariant const& result, QString const& categoryId)
199199 }
200200}
201201
202−PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
202+PreviewModel* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
203203{
204204 Q_UNUSED(result);
205205
206206 if (m_returnNullPreview) {
207207 return nullptr;
208208 } else {
209− return new PreviewStack(this);
209+ return new PreviewModel(this, this);
210210 }
211211}
212212
tests/mocks/Unity/fake_scope.h+2−2
@@ -20,7 +20,7 @@
2020#include <unity/shell/scopes/ScopeInterface.h>
2121
2222#include "fake_categories.h"
23−#include "fake_previewstack.h"
23+#include "fake_previewmodel.h"
2424
2525#include <QTimer>
2626
@@ -62,7 +62,7 @@ public:
6262 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
6363
6464 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
65− Q_INVOKABLE PreviewStack* preview(QVariant const& result, QString const& categoryId) override;
65+ Q_INVOKABLE PreviewModel* preview(QVariant const& result, QString const& categoryId) override;
6666 Q_INVOKABLE void cancelActivation() override;
6767 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
6868
tests/mocks/Unity/fake_unity_plugin.cpp+1−2
@@ -47,10 +47,9 @@ void FakeUnityPlugin::registerTypes(const char *uri)
4747 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
4848 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
4949 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
50− qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
50+ qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
5151 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
5252 qmlRegisterType<ResultsModel>(uri, 0, 2, "FakeResultsModel");
5353 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
5454 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
55− qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
5655}
tests/qmltests/CMakeLists.txt+1−1
@@ -29,7 +29,7 @@ add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
2929add_unity8_qmltest(Dash CardTool)
3030add_unity8_qmltest(Dash GenericScopeView)
3131add_unity8_qmltest(Dash DashPageHeader)
32−add_unity8_qmltest(Dash PreviewListView)
32+add_unity8_qmltest(Dash PreviewView)
3333add_unity8_qmltest(Dash/Previews Preview)
3434add_unity8_qmltest(Dash/Previews PreviewActions)
3535add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
tests/qmltests/Dash/tst_GenericScopeView.qml−28
@@ -236,12 +236,6 @@ Item {
236236 verify(seeAll, "Can't find the seeAll element");
237237
238238 compare(seeAll.height, 0, "SeeAll should be 0-height.");
239−
240− openPreview(4, 0);
241−
242− compare(testCase.subPageLoader.count, 16, "There should only be 16 items in preview.");
243−
244− closePreview();
245239 }
246240
247241 function test_narrow_delegate_ranges_expand() {
@@ -404,28 +398,6 @@ Item {
404398 closePreview();
405399 }
406400
407− function test_previewCycle() {
408− var categoryListView = findChild(genericScopeView, "categoryListView");
409− categoryListView.positionAtBeginning();
410−
411− tryCompare(testCase.subPageLoader, "open", false);
412−
413− openPreview();
414− var previewListViewList = findChild(subPageLoader.item, "listView");
415−
416− // flick to the next previews
417− tryCompare(testCase.subPageLoader, "count", 25);
418− for (var i = 1; i < testCase.subPageLoader.count; ++i) {
419− mouseFlick(testCase.subPageLoader.item, testCase.subPageLoader.width - units.gu(1),
420− testCase.subPageLoader.height / 2,
421− units.gu(2),
422− testCase.subPageLoader.height / 2);
423− tryCompare(previewListViewList, "moving", false);
424− tryCompare(testCase.subPageLoader.currentItem, "objectName", "preview" + i);
425− }
426− closePreview();
427− }
428−
429401 function test_settingsOpenClose() {
430402 waitForRendering(genericScopeView);
431403 verify(header, "Could not find the header.");
tests/qmltests/Dash/tst_PreviewListView.qml → tests/qmltests/Dash/tst_PreviewView.qmlrenamed+23−16
@@ -36,8 +36,8 @@ Rectangle {
3636 id: mockResultsModel
3737 }
3838
39− PreviewListView {
40− id: listView
39+ PreviewView {
40+ id: view
4141 anchors.fill: parent
4242 scope: mockScope
4343 scopeStyle: ScopeStyle {
@@ -45,12 +45,22 @@ Rectangle {
4545 }
4646 }
4747
48+ Item {
49+ Repeater {
50+ id: repeater
51+ model: mockResultsModel
52+ Item {
53+ property var previewModel: mockScope.preview(model.result, model.categoryId);
54+ }
55+ }
56+ }
57+
4858 UT.UnityTestCase {
4959 id: testCase
50− name: "PreviewListView"
60+ name: "PreviewView"
5161 when: windowShown
5262
53− property MouseArea mouseArea: findChild(listView, "processingMouseArea")
63+ property MouseArea mouseArea: findChild(view, "processingMouseArea")
5464
5565 SignalSpy {
5666 id: clickedSpy
@@ -59,43 +69,40 @@ Rectangle {
5969 }
6070
6171 function init() {
62− listView.model = mockResultsModel;
63− listView.currentIndex = 1;
64− listView.open = true;
72+ view.open = true;
73+ view.previewModel = repeater.itemAt(0).previewModel
6574 verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
6675 }
6776
6877 function cleanup() {
69− listView.open = false;
70− listView.model = null;
78+ view.open = false;
7179 clickedSpy.clear();
7280 }
7381
7482 function test_notProcessing() {
7583 expectFail("", "processingMouseArea should not receive the click.");
76− mouseClick(listView);
84+ mouseClick(view);
7785 clickedSpy.wait();
7886 }
7987
8088 function test_processing() {
81− verify(listView.currentItem, "currentItem is not ready yet");
82− listView.currentItem.previewModel.setLoaded(false);
89+ view.previewModel.setLoaded(false);
8390
84− tryCompare(listView, "processing", true);
91+ tryCompare(view, "processing", true);
8592
86− mouseClick(listView);
93+ mouseClick(view);
8794 clickedSpy.wait();
8895 }
8996
9097 function test_title() {
91− var header = findChild(listView, "innerPageHeader");
98+ var header = findChild(view, "innerPageHeader");
9299 verify(header, "Could not find the preview header");
93100
94101 compare(header.config.title, "Mock Scope");
95102 }
96103
97104 function test_header_style() {
98− var header = findChild(listView, "pageHeader");
105+ var header = findChild(view, "pageHeader");
99106 verify(header, "Could not find the header");
100107
101108 var innerHeader = findChild(header, "innerPageHeader");