Merge lp:~stolowski/unity-api/single-preview into lp:unity-api

Proposed by Paweł Stołowski
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 211
Merged at revision: 212
Proposed branch: lp:~stolowski/unity-api/single-preview
Merge into: lp:unity-api
Prerequisite: lp:~stolowski/unity-api/activation-progress
Diff against target: 427 lines (+16/-283)
10 files modified
debian/changelog (+7/-0)
include/unity/shell/scopes/PreviewStackInterface.h (+0/-99)
include/unity/shell/scopes/ScopeInterface.h (+3/-3)
test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt (+0/-2)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.cpp (+0/-63)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.h (+0/-47)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp (+3/-3)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h (+1/-1)
test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp (+1/-3)
test/qmltest/unity/shell/scopes/tst_Scopes.qml (+1/-62)
To merge this branch: bzr merge lp:~stolowski/unity-api/single-preview
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Unity8 CI Bot continuous-integration Needs Fixing
Review via email: mp+286527@code.launchpad.net

This proposal supersedes a proposal from 2016-02-17.

Commit message

Removed PreviewStackInterface. Changed ScopeInterface to return single preview.

Description of the change

Removed PreviewStackInterface. Changed ScopeInterface to return single preview.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-02-11 23:53:29 +0000
3+++ debian/changelog 2016-02-18 15:48:23 +0000
4@@ -1,3 +1,10 @@
5+unity-api (7.107) UNRELEASED; urgency=medium
6+
7+ * Removed PreviewStackInterface, modified ScopeInterface to return
8+ PreviewModelInterface on preview().
9+
10+ -- Pawel Stolowski <pawel.stolowski@canonical.com> Wed, 17 Feb 2016 17:46:13 +0100
11+
12 unity-api (7.106+16.04.20160211.1-0ubuntu1) xenial; urgency=medium
13
14 [ Daniel d'Andrada ]
15
16=== removed file 'include/unity/shell/scopes/PreviewStackInterface.h'
17--- include/unity/shell/scopes/PreviewStackInterface.h 2014-05-19 09:24:42 +0000
18+++ include/unity/shell/scopes/PreviewStackInterface.h 1970-01-01 00:00:00 +0000
19@@ -1,99 +0,0 @@
20-/*
21- * Copyright (C) 2014 Canonical, Ltd.
22- *
23- * This program is free software; you can redistribute it and/or modify
24- * it under the terms of the GNU General Public License as published by
25- * the Free Software Foundation; version 3.
26- *
27- * This program is distributed in the hope that it will be useful,
28- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30- * GNU General Public License for more details.
31- *
32- * You should have received a copy of the GNU General Public License
33- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34- */
35-
36-#ifndef UNITY_SHELL_SCOPES_PREVIEWSTACKINTERFACE_H
37-#define UNITY_SHELL_SCOPES_PREVIEWSTACKINTERFACE_H
38-
39-#include <unity/SymbolExport.h>
40-
41-#include <QAbstractListModel>
42-
43-namespace unity
44-{
45-namespace shell
46-{
47-namespace scopes
48-{
49-
50-class PreviewModelInterface;
51-
52-/**
53- * @brief A master model for previews.
54- *
55- * Each item in this model represents an individual preview, where each is stacked
56- * on top of the previous one. Item on index 0 is always the one on the very bottom
57- * of the stack.
58- */
59-class UNITY_API PreviewStackInterface : public QAbstractListModel
60-{
61- Q_OBJECT
62-
63- Q_ENUMS(Roles)
64-
65- /**
66- * @brief Number of columns the individual previews should expose.
67- *
68- * Previews can be laid out in a different number of columns - for example the number
69- * of desired columns can change when changing orientation of the display and
70- * therefore there's more horizontal space available.
71- */
72- Q_PROPERTY(int widgetColumnCount READ widgetColumnCount WRITE setWidgetColumnCount NOTIFY widgetColumnCountChanged)
73-
74-protected:
75- /// @cond
76- explicit PreviewStackInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
77- /// @endcond
78-
79-public:
80- /**
81- * @brief The roles supported by this model.
82- */
83- enum Roles {
84- RolePreviewModel
85- };
86-
87- /**
88- * @brief Get preview model at a particular index.
89- *
90- * Return PreviewModelInterface instance at a particular index or nullptr
91- * if the index is out of bounds.
92- */
93- Q_INVOKABLE virtual unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const = 0;
94-
95- // @cond
96- virtual void setWidgetColumnCount(int columnCount) = 0;
97- virtual int widgetColumnCount() const = 0;
98- QHash<int, QByteArray> roleNames() const override
99- {
100- QHash<int, QByteArray> roles;
101- roles[RolePreviewModel] = "previewModel";
102- return roles;
103- }
104- // @endcond
105-
106-Q_SIGNALS:
107- // @cond
108- void widgetColumnCountChanged();
109- // @endcond
110-};
111-
112-}
113-}
114-}
115-
116-Q_DECLARE_METATYPE(unity::shell::scopes::PreviewStackInterface*)
117-
118-#endif
119
120=== modified file 'include/unity/shell/scopes/ScopeInterface.h'
121--- include/unity/shell/scopes/ScopeInterface.h 2016-02-18 15:48:23 +0000
122+++ include/unity/shell/scopes/ScopeInterface.h 2016-02-18 15:48:23 +0000
123@@ -30,7 +30,7 @@
124 {
125
126 class CategoriesInterface;
127-class PreviewStackInterface;
128+class PreviewModelInterface;
129 class NavigationInterface;
130 class SettingsModelInterface;
131
132@@ -209,10 +209,10 @@
133 /**
134 * @brief Method used to preview a result.
135 *
136- * Returns a new PreviewStackInterface instance. It's caller's responsibility
137+ * Returns a new PreviewModelInterface instance. It's caller's responsibility
138 * to free it.
139 */
140- Q_INVOKABLE virtual unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result, QString const& categoryId) = 0;
141+ Q_INVOKABLE virtual unity::shell::scopes::PreviewModelInterface* preview(QVariant const& result, QString const& categoryId) = 0;
142
143 /**
144 * @brief Cancels the current activation.
145
146=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt'
147--- test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2014-07-25 15:17:40 +0000
148+++ test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2016-02-18 15:48:23 +0000
149@@ -15,7 +15,6 @@
150 Mocks/MockDepartment.cpp
151 Mocks/MockResultsModel.cpp
152 Mocks/MockPreviewModel.cpp
153- Mocks/MockPreviewStack.cpp
154 Mocks/MockPreviewWidgetModel.cpp
155 Mocks/MockScope.cpp
156 Mocks/MockScopes.cpp
157@@ -25,7 +24,6 @@
158 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h
159 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h
160 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewWidgetModelInterface.h
161- ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewStackInterface.h
162 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ScopeInterface.h
163 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ScopesInterface.h
164 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/SettingsModelInterface.h
165
166=== removed file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.cpp'
167--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.cpp 2014-05-19 11:45:10 +0000
168+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.cpp 1970-01-01 00:00:00 +0000
169@@ -1,63 +0,0 @@
170-/*
171- * Copyright (C) 2014 Canonical, Ltd.
172- *
173- * This program is free software; you can redistribute it and/or modify
174- * it under the terms of the GNU General Public License as published by
175- * the Free Software Foundation; version 3.
176- *
177- * This program is distributed in the hope that it will be useful,
178- * but WITHOUT ANY WARRANTY; without even the implied warranty of
179- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
180- * GNU General Public License for more details.
181- *
182- * You should have received a copy of the GNU General Public License
183- * along with this program. If not, see <http://www.gnu.org/licenses/>.
184- */
185-
186-// self
187-#include "MockPreviewStack.h"
188-
189-// local
190-#include "MockPreviewModel.h"
191-
192-MockPreviewStack::MockPreviewStack(QObject* parent)
193- : unity::shell::scopes::PreviewStackInterface(parent)
194-{
195- m_previews << new MockPreviewModel(this);
196-}
197-
198-void MockPreviewStack::setWidgetColumnCount(int columnCount)
199-{
200- if (columnCount != 1) {
201- qFatal("MockPreviewStack::setWidgetColumnCount != 1 not implemented");
202- }
203-}
204-
205-int MockPreviewStack::widgetColumnCount() const
206-{
207- return 1;
208-}
209-
210-int MockPreviewStack::rowCount(const QModelIndex&) const
211-{
212- return m_previews.size();
213-}
214-
215-unity::shell::scopes::PreviewModelInterface* MockPreviewStack::getPreviewModel(int index) const
216-{
217- if (index >= m_previews.size()) {
218- return nullptr;
219- }
220-
221- return m_previews.at(index);
222-}
223-
224-QVariant MockPreviewStack::data(const QModelIndex& index, int role) const
225-{
226- switch (role) {
227- case RolePreviewModel:
228- return QVariant::fromValue(m_previews.at(index.row()));
229- default:
230- return QVariant();
231- }
232-}
233
234=== removed file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.h'
235--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.h 2014-05-19 11:45:10 +0000
236+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockPreviewStack.h 1970-01-01 00:00:00 +0000
237@@ -1,47 +0,0 @@
238-/*
239- * Copyright (C) 2014 Canonical, Ltd.
240- *
241- * This program is free software; you can redistribute it and/or modify
242- * it under the terms of the GNU General Public License as published by
243- * the Free Software Foundation; version 3.
244- *
245- * This program is distributed in the hope that it will be useful,
246- * but WITHOUT ANY WARRANTY; without even the implied warranty of
247- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
248- * GNU General Public License for more details.
249- *
250- * You should have received a copy of the GNU General Public License
251- * along with this program. If not, see <http://www.gnu.org/licenses/>.
252- */
253-
254-
255-#ifndef MOCKPREVIEWSTACK_H
256-#define MOCKPREVIEWSTACK_H
257-
258-#include <unity/shell/scopes/PreviewStackInterface.h>
259-
260-#include <QSharedPointer>
261-#include <QVariantMap>
262-
263-class MockPreviewModel;
264-
265-class MockPreviewStack : public unity::shell::scopes::PreviewStackInterface
266-{
267- Q_OBJECT
268-
269-public:
270- explicit MockPreviewStack (QObject* parent = 0);
271-
272- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
273- int rowCount(const QModelIndex& parent = QModelIndex()) const override;
274-
275- Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
276-
277- void setWidgetColumnCount(int columnCount) override;
278- int widgetColumnCount() const override;
279-
280-private:
281- QList<MockPreviewModel*> m_previews;
282-};
283-
284-#endif
285
286=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp'
287--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2016-02-18 15:48:23 +0000
288+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2016-02-18 15:48:23 +0000
289@@ -16,7 +16,7 @@
290
291 #include "MockScope.h"
292 #include "MockCategories.h"
293-#include "MockPreviewStack.h"
294+#include "MockPreviewModel.h"
295 #include "MockDepartment.h"
296 #include "MockSettingsModel.h"
297
298@@ -176,14 +176,14 @@
299 Q_UNUSED(actionId);
300 }
301
302-unity::shell::scopes::PreviewStackInterface* MockScope::preview(QVariant const& result, QString const& categoryId)
303+unity::shell::scopes::PreviewModelInterface* MockScope::preview(QVariant const& result, QString const& categoryId)
304 {
305 Q_UNUSED(result);
306 Q_UNUSED(categoryId);
307
308 // This probably leaks, do we don't care
309 // it's a test after all
310- return new MockPreviewStack;
311+ return new MockPreviewModel;
312 }
313
314 unity::shell::scopes::NavigationInterface* MockScope::getNavigation(QString const& navigationId)
315
316=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
317--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-02-18 15:48:23 +0000
318+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-02-18 15:48:23 +0000
319@@ -60,7 +60,7 @@
320
321 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
322 Q_INVOKABLE void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) override;
323- Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result, QString const& categoryId) override;
324+ Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* preview(QVariant const& result, QString const& categoryId) override;
325 Q_INVOKABLE void cancelActivation() override;
326 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
327 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;
328
329=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp'
330--- test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2014-07-25 15:17:40 +0000
331+++ test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2016-02-18 15:48:23 +0000
332@@ -24,7 +24,6 @@
333 #include "ResultsModelInterface.h"
334 #include "PreviewModelInterface.h"
335 #include "PreviewWidgetModelInterface.h"
336-#include "PreviewStackInterface.h"
337 #include "SettingsModelInterface.h"
338 #include "Mocks/MockScopes.h"
339 #include "Mocks/MockScope.h"
340@@ -36,8 +35,7 @@
341 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML. Get them from Scope instance.");
342 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML. Get them from Scope instance.");
343 qmlRegisterUncreatableType<unity::shell::scopes::ResultsModelInterface>(uri, 0, 2, "ResultsModel", "Can't create new ResultsModel in QML. Get them from Categories instance.");
344- qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
345+ qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
346 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
347- qmlRegisterUncreatableType<unity::shell::scopes::PreviewStackInterface>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
348 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");
349 }
350
351=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
352--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2015-10-09 08:30:31 +0000
353+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2016-02-18 15:48:23 +0000
354@@ -343,72 +343,11 @@
355 }
356
357 Verifier {
358- id: previewStackVerifier
359-
360- Repeater {
361- id: previewStackRepeater
362- model: preview
363- delegate: Item {
364- property var roles: model
365- }
366- }
367-
368- function test_previewStack_data() {
369- return [
370- { tag: "PreviewStack[object]", type: "object" },
371- { tag: "PreviewStack[PreviewStackInterface]", type: "unity::shell::scopes::PreviewStackInterface" },
372- ];
373- }
374-
375- function test_previewStack(data) {
376- object = previewStackRepeater.model;
377- name = "PreviewStack";
378- verifyData(data);
379- }
380-
381- function test_previewStack_roles_data() {
382- return [
383- { tag: "Model.roles[previewModel]", role: "previewModel", type: "object" }
384- ];
385- }
386-
387- function test_previewStack_roles(data) {
388- object = previewStackRepeater.itemAt(0).roles;
389- name = "PreviewStack";
390- verifyData(data);
391- }
392-
393- function test_previewStack_properties_data() {
394- return [
395- { tag: "Item.properties[widgetColumnCount]", constant: "widgetColumnCount", type: "number" }
396- ];
397- }
398-
399- function test_previewStack_properties(data) {
400- object = previewStackRepeater.model;
401- name = "PreviewStack";
402- verifyData(data);
403- }
404-
405- function test_previewStack_methods_data() {
406- return [
407- { tag: "Model.methods[get]", method: "getPreviewModel" }
408- ];
409- }
410-
411- function test_previewStack_methods(data) {
412- object = previewStackRepeater.model;
413- name = "PreviewStack"
414- verifyData(data);
415- }
416- }
417-
418- Verifier {
419 id: previewModelVerifier
420
421 Repeater {
422 id: previewModelRepeater
423- model: preview.getPreviewModel(0)
424+ model: preview
425 delegate: Item {
426 property var roles: model
427 property var columnModel: model.columnModel

Subscribers

People subscribed via source and target branches

to all changes: