Merge lp:~stolowski/unity-api/scope-activate-action into lp:unity-api

Proposed by Paweł Stołowski
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 181
Merged at revision: 195
Proposed branch: lp:~stolowski/unity-api/scope-activate-action
Merge into: lp:unity-api
Diff against target: 324 lines (+58/-136)
10 files modified
debian/changelog (+6/-0)
include/unity/shell/scopes/CMakeLists.txt (+1/-1)
include/unity/shell/scopes/CategoriesInterface.h (+0/-10)
include/unity/shell/scopes/ResultsModelInterface.h (+2/-0)
include/unity/shell/scopes/ScopeInterface.h (+5/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.cpp (+35/-109)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.h (+0/-14)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp (+7/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h (+1/-0)
test/qmltest/unity/shell/scopes/tst_Scopes.qml (+1/-2)
To merge this branch: bzr merge lp:~stolowski/unity-api/scope-activate-action
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+273557@code.launchpad.net

Commit message

New method for in-card actions. Remove obsolete special categories.

Description of the change

New method for in-card actions. Remove obsolete special categories.

To post a comment you must log in.
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
182. By Paweł Stołowski

Bump

183. By Paweł Stołowski

Merged trunk

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 2015-10-21 11:48:38 +0000
3+++ debian/changelog 2015-11-02 10:10:49 +0000
4@@ -1,3 +1,9 @@
5+unity-api (7.102-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * New method for in-card actions.
8+
9+ -- Pawel Stolowski <pawel.stolowski@canonical.com> Tue, 06 Oct 2015 18:06:37 +0200
10+
11 unity-api (7.101+15.10.20151021-0ubuntu1) wily; urgency=medium
12
13 [ Daniel d'Andrada ]
14
15=== modified file 'include/unity/shell/scopes/CMakeLists.txt'
16--- include/unity/shell/scopes/CMakeLists.txt 2015-09-15 09:15:11 +0000
17+++ include/unity/shell/scopes/CMakeLists.txt 2015-11-02 10:10:49 +0000
18@@ -7,7 +7,7 @@
19
20 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
21
22-set(VERSION 7)
23+set(VERSION 8)
24 set(PKGCONFIG_NAME "unity-shell-scopes")
25 set(PKGCONFIG_DESCRIPTION "Unity shell Scopes APIs")
26 set(PKGCONFIG_REQUIRES "Qt5Core")
27
28=== modified file 'include/unity/shell/scopes/CategoriesInterface.h'
29--- include/unity/shell/scopes/CategoriesInterface.h 2014-07-08 11:02:23 +0000
30+++ include/unity/shell/scopes/CategoriesInterface.h 2015-11-02 10:10:49 +0000
31@@ -69,16 +69,6 @@
32 */
33 Q_INVOKABLE virtual bool overrideCategoryJson(QString const& categoryId, QString const& json) = 0;
34
35- /**
36- * @brief Allows the shell to define a special category that isn't provided by
37- * the scope.
38- *
39- * Allows the shell to use specialized renderers for certain categories.
40- * The plugin implementation should prepend the category before any others
41- * provided by the scope.
42- */
43- Q_INVOKABLE virtual void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject) = 0;
44-
45 // @cond
46 QHash<int, QByteArray> roleNames() const override
47 {
48
49=== modified file 'include/unity/shell/scopes/ResultsModelInterface.h'
50--- include/unity/shell/scopes/ResultsModelInterface.h 2014-07-18 12:15:05 +0000
51+++ include/unity/shell/scopes/ResultsModelInterface.h 2015-11-02 10:10:49 +0000
52@@ -61,6 +61,7 @@
53 RoleCategoryId,
54 RoleDndUri,
55 RoleResult,
56+ RoleQuickPreviewData, ///< Data for UI quick previewing. In case of audio should contain uri and duration
57 // card components
58 RoleTitle,
59 RoleArt,
60@@ -84,6 +85,7 @@
61 roles[RoleUri] = "uri";
62 roles[RoleCategoryId] = "categoryId";
63 roles[RoleDndUri] = "dndUri";
64+ roles[RoleQuickPreviewData] = "quickPreviewData";
65 roles[RoleResult] = "result";
66 roles[RoleTitle] = "title";
67 roles[RoleArt] = "art";
68
69=== modified file 'include/unity/shell/scopes/ScopeInterface.h'
70--- include/unity/shell/scopes/ScopeInterface.h 2015-09-15 09:15:11 +0000
71+++ include/unity/shell/scopes/ScopeInterface.h 2015-11-02 10:10:49 +0000
72@@ -243,6 +243,11 @@
73 */
74 Q_INVOKABLE virtual void refresh() = 0;
75
76+ /**
77+ * @brief Method used to activate an action of a result.
78+ */
79+ Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;
80+
81 Q_SIGNALS:
82 // @cond
83 void idChanged();
84
85=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.cpp'
86--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.cpp 2014-07-08 11:02:23 +0000
87+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.cpp 2015-11-02 10:10:49 +0000
88@@ -29,25 +29,7 @@
89
90 int MockCategories::rowCount(const QModelIndex& /*parent*/) const
91 {
92- return m_category_count + m_specialCategories.count();
93-}
94-
95-void MockCategories::addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject)
96-{
97- CategoryData catData;
98- catData.categoryId = categoryId;
99- catData.name = name;
100- catData.icon = icon;
101- catData.rawTemplate = rawTemplate;
102- catData.countObject = countObject;
103-
104- beginInsertRows(QModelIndex(), 0, 0);
105- m_specialCategories.prepend(catData);
106- endInsertRows();
107-
108- if (countObject) {
109- connect(countObject, SIGNAL(countChanged()), this, SLOT(countChanged()));
110- }
111+ return m_category_count;
112 }
113
114 bool MockCategories::overrideCategoryJson(QString const& , QString const& )
115@@ -56,23 +38,6 @@
116 return false;
117 }
118
119-void MockCategories::countChanged()
120-{
121- QObject* countObject = sender();
122-
123- for (int i = 0; i < m_specialCategories.count(); ++i) {
124- const CategoryData &catData = m_specialCategories.at(i);
125- if (catData.countObject == countObject) {
126- QVector<int> roles;
127- roles.append(RoleCount);
128-
129- QModelIndex changedIndex(index(i));
130- dataChanged(changedIndex, changedIndex, roles);
131- break;
132- }
133- }
134-}
135-
136 QVariant
137 MockCategories::data(const QModelIndex& index, int role) const
138 {
139@@ -85,78 +50,39 @@
140 resultsModel = new MockResultsModel(15, index.row());
141 m_resultsModels[index.row()] = resultsModel;
142 }
143- if (index.row() < m_specialCategories.count()) {
144- const CategoryData &catData = m_specialCategories.at(index.row());
145- switch (role) {
146- case RoleCategoryId:
147- return catData.categoryId;
148- case RoleName:
149- return catData.name;
150- case RoleIcon:
151- return catData.icon;
152- case RoleRawRendererTemplate:
153- return catData.rawTemplate;
154- case RoleRenderer:
155- {
156- QVariantMap map;
157- map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
158- map["card-size"] = "small";
159- return map;
160- }
161- case RoleComponents:
162- {
163- QVariantMap map, artMap;
164- artMap["aspect-ratio"] = "1.0";
165- artMap["field"] = "art";
166- map["art"] = artMap;
167- map["title"] = "HOLA";
168- return map;
169- }
170- case RoleHeaderLink:
171- return QString();
172- case RoleResults:
173- return QVariant();
174- case RoleCount:
175- return catData.countObject->property("count");
176- default:
177- qFatal("Using un-implemented Categories role");
178- return QVariant();
179- }
180- } else {
181- switch (role) {
182- case RoleCategoryId:
183- return QString("%1").arg(index.row());
184- case RoleName:
185- return QString("Category %1").arg(index.row());
186- case RoleIcon:
187- return "gtk-apply";
188- case RoleRawRendererTemplate:
189- return QString();
190- case RoleRenderer:
191- {
192- QVariantMap map;
193- map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
194- map["card-size"] = "small";
195- return map;
196- }
197- case RoleComponents:
198- {
199- QVariantMap map, artMap;
200- artMap["aspect-ratio"] = "1.0";
201- artMap["field"] = "art";
202- map["art"] = artMap;
203- map["title"] = "HOLA";
204- return map;
205- }
206- case RoleHeaderLink:
207- return QString();
208- case RoleResults:
209- return QVariant::fromValue(resultsModel);
210- case RoleCount:
211- return resultsModel->rowCount();
212- default:
213- qFatal("Using un-implemented Categories role");
214- return QVariant();
215- }
216+ switch (role) {
217+ case RoleCategoryId:
218+ return QString("%1").arg(index.row());
219+ case RoleName:
220+ return QString("Category %1").arg(index.row());
221+ case RoleIcon:
222+ return "gtk-apply";
223+ case RoleRawRendererTemplate:
224+ return QString();
225+ case RoleRenderer:
226+ {
227+ QVariantMap map;
228+ map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
229+ map["card-size"] = "small";
230+ return map;
231+ }
232+ case RoleComponents:
233+ {
234+ QVariantMap map, artMap;
235+ artMap["aspect-ratio"] = "1.0";
236+ artMap["field"] = "art";
237+ map["art"] = artMap;
238+ map["title"] = "HOLA";
239+ return map;
240+ }
241+ case RoleHeaderLink:
242+ return QString();
243+ case RoleResults:
244+ return QVariant::fromValue(resultsModel);
245+ case RoleCount:
246+ return resultsModel->rowCount();
247+ default:
248+ qFatal("Using un-implemented Categories role");
249+ return QVariant();
250 }
251 }
252
253=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.h'
254--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.h 2014-05-13 13:52:12 +0000
255+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockCategories.h 2015-11-02 10:10:49 +0000
256@@ -34,25 +34,11 @@
257 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
258 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
259
260- Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject) override;
261 Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
262
263-private Q_SLOTS:
264- void countChanged();
265-
266 private:
267 mutable QHash<int, MockResultsModel*> m_resultsModels;
268 int m_category_count;
269-
270- struct CategoryData {
271- QString categoryId;
272- QString name;
273- QString icon;
274- QString rawTemplate;
275- QObject* countObject;
276- };
277-
278- QList<CategoryData> m_specialCategories;
279 };
280
281 #endif
282
283=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp'
284--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2015-09-15 09:15:11 +0000
285+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2015-11-02 10:10:49 +0000
286@@ -165,6 +165,13 @@
287 Q_UNUSED(categoryId);
288 }
289
290+void MockScope::activateAction(QVariant const& result, QString const& categoryId, QString const& actionId)
291+{
292+ Q_UNUSED(result);
293+ Q_UNUSED(categoryId);
294+ Q_UNUSED(actionId);
295+}
296+
297 unity::shell::scopes::PreviewStackInterface* MockScope::preview(QVariant const& result, QString const& categoryId)
298 {
299 Q_UNUSED(result);
300
301=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
302--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2015-09-15 09:15:11 +0000
303+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2015-11-02 10:10:49 +0000
304@@ -58,6 +58,7 @@
305 void setFavorite(const bool) override;
306
307 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
308+ Q_INVOKABLE void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) override;
309 Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result, QString const& categoryId) override;
310 Q_INVOKABLE void cancelActivation() override;
311 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
312
313=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
314--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2015-09-15 09:15:11 +0000
315+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2015-11-02 10:10:49 +0000
316@@ -215,8 +215,7 @@
317
318 function test_categories_methods_data() {
319 return [
320- { tag: "Model.methods[overrideCategoryJson]", method: "overrideCategoryJson" },
321- { tag: "Model.methods[addSpecialCategory]", method: "addSpecialCategory" }
322+ { tag: "Model.methods[overrideCategoryJson]", method: "overrideCategoryJson" }
323 ];
324 }
325

Subscribers

People subscribed via source and target branches

to all changes: