Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/noDoCleanup into lp:ubuntu-ui-toolkit/staging

Proposed by Christian Dywan on 2015-07-07
Status: Merged
Approved by: Zsombor Egri on 2015-07-13
Approved revision: 1553
Merged at revision: 1557
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/noDoCleanup
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 479 lines (+70/-158)
6 files modified
components.api (+10/-10)
modules/Ubuntu/Components/plugin/ucactioncontext.cpp (+16/-35)
modules/Ubuntu/Components/plugin/ucactioncontext.h (+7/-7)
modules/Ubuntu/Components/plugin/ucactionmanager.cpp (+23/-60)
modules/Ubuntu/Components/plugin/ucactionmanager.h (+14/-14)
tests/unit/tst_components/tst_action.qml (+0/-32)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/noDoCleanup
Reviewer Review Type Date Requested Status
Zsombor Egri (community) 2015-07-07 Approve on 2015-07-13
PS Jenkins bot continuous-integration Approve on 2015-07-10
Review via email: mp+264053@code.launchpad.net

Commit Message

Remove "do cleanup" comments

To post a comment you must log in.
Zsombor Egri (zsombi) wrote :

There is slightly more to do when fixing this: you should make sure the list properties are list<UCAction> not as list<QObject>.

review: Needs Fixing
1552. By Christian Dywan on 2015-07-09

Move to strict UCAction(Context) type usage

Zsombor Egri (zsombi) wrote :

Small issue, API file ;)

review: Needs Fixing
1553. By Christian Dywan on 2015-07-10

Update components.api

Zsombor Egri (zsombi) wrote :

Looks good to go now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-07-10 13:05:26 +0000
3+++ components.api 2015-07-10 13:53:01 +0000
4@@ -34,10 +34,10 @@
5 readonly property Action actions
6 property int numberOfSlots
7 Ubuntu.Components.ActionContext 1.0 0.1: QtObject
8- default readonly property QtObject actions
9+ default readonly property Action actions
10 property bool active
11- function addAction(QtObject action)
12- function removeAction(QtObject action)
13+ function addAction(Action action)
14+ function removeAction(Action action)
15 Ubuntu.Components.ActionItem 1.0 0.1: StyledItem
16 property Action action
17 property string iconName
18@@ -59,14 +59,14 @@
19 readonly property Action actions
20 default readonly property Action children
21 Ubuntu.Components.ActionManager 1.0 0.1: QtObject
22- default readonly property QtObject actions
23+ default readonly property Action actions
24 readonly property ActionContext globalContext
25- readonly property QtObject localContexts
26+ readonly property ActionContext localContexts
27 signal quit()
28- function addAction(QtObject action)
29- function removeAction(QtObject action)
30- function addLocalContext(QtObject context)
31- function removeLocalContext(QtObject context)
32+ function addAction(Action action)
33+ function removeAction(Action action)
34+ function addLocalContext(ActionContext context)
35+ function removeLocalContext(ActionContext context)
36 Ubuntu.Components.Popups.ActionSelectionPopover 1.0 0.1: Popover
37 property var actions
38 property Component delegate
39@@ -581,7 +581,7 @@
40 readonly property bool rotating
41 property bool transitionEnabled
42 Ubuntu.Components.Page 1.0 0.1: PageTreeNode
43- readonly property QtObject actions
44+ readonly property Action actions
45 property Flickable flickable
46 property string title
47 property Item tools
48
49=== modified file 'modules/Ubuntu/Components/plugin/ucactioncontext.cpp'
50--- modules/Ubuntu/Components/plugin/ucactioncontext.cpp 2014-09-16 15:54:35 +0000
51+++ modules/Ubuntu/Components/plugin/ucactioncontext.cpp 2015-07-10 13:53:01 +0000
52@@ -53,40 +53,33 @@
53 }
54 }
55
56-
57 /*!
58 * \qmlproperty list<Action> ActionContext::actions
59 * \default
60 * List of Actions in this ActionContext.
61 */
62-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
63-QQmlListProperty<QObject> UCActionContext::actions()
64+QQmlListProperty<UCAction> UCActionContext::actions()
65 {
66- return QQmlListProperty<QObject>(this, 0, UCActionContext::append, UCActionContext::count, 0, UCActionContext::clear);
67+ return QQmlListProperty<UCAction>(this, 0, UCActionContext::append, UCActionContext::count, 0, UCActionContext::clear);
68 }
69-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
70-void UCActionContext::append(QQmlListProperty<QObject> *list, QObject *action)
71+
72+void UCActionContext::append(QQmlListProperty<UCAction> *list, UCAction *action)
73 {
74 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
75 if (context) {
76- UCAction *toolkitAction = qobject_cast<UCAction*>(action);
77- if (toolkitAction) {
78- context->m_actions.insert(toolkitAction);
79- } else {
80- qmlInfo(action) << "Invalid Action. Please use Action from Ubuntu.Components.";
81- }
82+ context->m_actions.insert(action);
83 }
84 }
85-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
86-void UCActionContext::clear(QQmlListProperty<QObject> *list)
87+
88+void UCActionContext::clear(QQmlListProperty<UCAction> *list)
89 {
90 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
91 if (context) {
92 context->m_actions.clear();
93 }
94 }
95-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
96-int UCActionContext::count(QQmlListProperty<QObject> *list)
97+
98+int UCActionContext::count(QQmlListProperty<UCAction> *list)
99 {
100 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
101 if (context) {
102@@ -129,18 +122,12 @@
103 * \deprecated
104 * Adds an Action to the context programatically.
105 */
106-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
107-void UCActionContext::addAction(QObject *action)
108+void UCActionContext::addAction(UCAction *action)
109 {
110- UCAction *toolkitAction = qobject_cast<UCAction*>(action);
111- if (!toolkitAction) {
112- qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
113- return;
114- }
115- if (m_actions.contains(toolkitAction)) {
116- return;
117- }
118- m_actions.insert(toolkitAction);
119+ if (m_actions.contains(action)) {
120+ return;
121+ }
122+ m_actions.insert(action);
123 }
124
125 /*!
126@@ -148,16 +135,10 @@
127 * \deprecated
128 * Removes an action from the context programatically.
129 */
130-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
131-void UCActionContext::removeAction(QObject *action)
132+void UCActionContext::removeAction(UCAction *action)
133 {
134 if (!action) {
135 return;
136 }
137- UCAction *toolkitAction = qobject_cast<UCAction*>(action);
138- if (!toolkitAction) {
139- qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
140- return;
141- }
142- m_actions.remove(toolkitAction);
143+ m_actions.remove(action);
144 }
145
146=== modified file 'modules/Ubuntu/Components/plugin/ucactioncontext.h'
147--- modules/Ubuntu/Components/plugin/ucactioncontext.h 2014-10-08 19:08:08 +0000
148+++ modules/Ubuntu/Components/plugin/ucactioncontext.h 2015-07-10 13:53:01 +0000
149@@ -28,7 +28,7 @@
150 {
151 Q_OBJECT
152 Q_INTERFACES(QQmlParserStatus)
153- Q_PROPERTY(QQmlListProperty<QObject> actions READ actions)
154+ Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions)
155 Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged)
156 Q_CLASSINFO("DefaultProperty", "actions")
157 public:
158@@ -39,7 +39,7 @@
159 void componentComplete();
160 void markActionsPublished(bool mark);
161
162- QQmlListProperty<QObject> actions();
163+ QQmlListProperty<UCAction> actions();
164
165 void setActive(bool active);
166
167@@ -47,17 +47,17 @@
168 void activeChanged(bool);
169
170 public Q_SLOTS:
171- void addAction(QObject *action);
172- void removeAction(QObject *action);
173+ void addAction(UCAction *action);
174+ void removeAction(UCAction *action);
175
176 private:
177 bool m_active;
178 QSet<UCAction*> m_actions;
179 friend class UCActionManager;
180
181- static void append(QQmlListProperty<QObject> *list, QObject *action);
182- static void clear(QQmlListProperty<QObject> *list);
183- static int count(QQmlListProperty<QObject> *list);
184+ static void append(QQmlListProperty<UCAction> *list, UCAction *action);
185+ static void clear(QQmlListProperty<UCAction> *list);
186+ static int count(QQmlListProperty<UCAction> *list);
187 };
188
189 QML_DECLARE_TYPE(UCActionContext)
190
191=== modified file 'modules/Ubuntu/Components/plugin/ucactionmanager.cpp'
192--- modules/Ubuntu/Components/plugin/ucactionmanager.cpp 2014-09-16 15:54:35 +0000
193+++ modules/Ubuntu/Components/plugin/ucactionmanager.cpp 2015-07-10 13:53:01 +0000
194@@ -50,33 +50,25 @@
195 * \default
196 * A list of actions in the global context.
197 */
198-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
199-QQmlListProperty<QObject> UCActionManager::actions()
200+QQmlListProperty<UCAction> UCActionManager::actions()
201 {
202- return QQmlListProperty<QObject>(this, 0, actionAppend, actionCount, 0, actionClear);
203+ return QQmlListProperty<UCAction>(this, 0, actionAppend, actionCount, 0, actionClear);
204 }
205-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
206-void UCActionManager::actionAppend(QQmlListProperty<QObject> *list, QObject *action)
207+
208+void UCActionManager::actionAppend(QQmlListProperty<UCAction> *list, UCAction *action)
209 {
210 Q_UNUSED(list);
211- UCAction *toolkitAction = qobject_cast<UCAction*>(action);
212- if (!toolkitAction) {
213- qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
214- return;
215- }
216- ActionProxy::instance().globalContext->m_actions.insert(toolkitAction);
217+ ActionProxy::instance().globalContext->m_actions.insert(action);
218 }
219
220-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
221-void UCActionManager::actionClear(QQmlListProperty<QObject> *list)
222+void UCActionManager::actionClear(QQmlListProperty<UCAction> *list)
223 {
224 Q_UNUSED(list);
225 UCActionContext *context = ActionProxy::instance().globalContext;
226 context->m_actions.clear();
227 }
228
229-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
230-int UCActionManager::actionCount(QQmlListProperty<QObject> *list)
231+int UCActionManager::actionCount(QQmlListProperty<UCAction> *list)
232 {
233 Q_UNUSED(list);
234 return ActionProxy::instance().globalContext->m_actions.count();
235@@ -86,32 +78,26 @@
236 * \qmlproperty list<ActionContext> ActionManager::localContexts
237 * List of local contexts.
238 */
239-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
240-QQmlListProperty<QObject> UCActionManager::localContexts()
241+QQmlListProperty<UCActionContext> UCActionManager::localContexts()
242 {
243- return QQmlListProperty<QObject>(this, 0, contextAppend, contextCount, 0, contextClear);
244+ return QQmlListProperty<UCActionContext>(this, 0, contextAppend, contextCount, 0, contextClear);
245 }
246-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
247-void UCActionManager::contextAppend(QQmlListProperty<QObject> *list, QObject *context)
248+
249+void UCActionManager::contextAppend(QQmlListProperty<UCActionContext> *list, UCActionContext *context)
250 {
251 Q_UNUSED(list);
252- UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
253- if (!toolkitContext) {
254- qmlInfo(context) << "Unity.Action deprecatedContext. Please use ActionContext from Ubuntu.Components.";
255- return;
256- }
257- ActionProxy::addContext(toolkitContext);
258+ ActionProxy::addContext(context);
259 }
260-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
261-void UCActionManager::contextClear(QQmlListProperty<QObject> *list)
262+
263+void UCActionManager::contextClear(QQmlListProperty<UCActionContext> *list)
264 {
265 Q_UNUSED(list);
266 Q_FOREACH(UCActionContext *context, ActionProxy::instance().localContexts().toList()) {
267 ActionProxy::removeContext(context);
268 }
269 }
270-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
271-int UCActionManager::contextCount(QQmlListProperty<QObject> *list)
272+
273+int UCActionManager::contextCount(QQmlListProperty<UCActionContext> *list)
274 {
275 Q_UNUSED(list);
276 return ActionProxy::instance().localContexts().count();
277@@ -132,16 +118,11 @@
278 * \deprecated
279 * This is a shorthand for \c ActionManager.globalContext.addAction(action) call.
280 */
281-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
282-void UCActionManager::addAction(QObject *action)
283+void UCActionManager::addAction(UCAction *action)
284 {
285 if (!action) {
286 return;
287 }
288- if (!qobject_cast<UCAction*>(action)) {
289- qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
290- return;
291- }
292 ActionProxy::instance().globalContext->addAction(action);
293 }
294
295@@ -150,18 +131,12 @@
296 * \deprecated
297 * This is a shorthand for \c ActionManager.globalContext.removeAction(action) call.
298 */
299-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
300-void UCActionManager::removeAction(QObject *action)
301+void UCActionManager::removeAction(UCAction *action)
302 {
303 if (!action) {
304 return;
305 }
306- UCAction *toolkitAction = qobject_cast<UCAction*>(action);
307- if (!toolkitAction) {
308- qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
309- return;
310- }
311- ActionProxy::instance().globalContext->removeAction(toolkitAction);
312+ ActionProxy::instance().globalContext->removeAction(action);
313 }
314
315 /*!
316@@ -172,18 +147,12 @@
317 * This is deprecated. ActionContext instances are added autimatically to the
318 * action management stystem when declared and removed when destroyed.
319 */
320-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
321-void UCActionManager::addLocalContext(QObject *context)
322+void UCActionManager::addLocalContext(UCActionContext *context)
323 {
324 if (!context) {
325 return;
326 }
327- UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
328- if (!toolkitContext) {
329- qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components.";
330- return;
331- }
332- ActionProxy::addContext(toolkitContext);
333+ ActionProxy::addContext(context);
334 }
335
336 /*!
337@@ -194,16 +163,10 @@
338 * This is deprecated. ActionContext instances are added autimatically to the
339 * action management stystem when declared and removed when destroyed.
340 */
341-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
342-void UCActionManager::removeLocalContext(QObject *context)
343+void UCActionManager::removeLocalContext(UCActionContext *context)
344 {
345 if (!context) {
346 return;
347 }
348- UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
349- if (!toolkitContext) {
350- qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components.";
351- return;
352- }
353- ActionProxy::removeContext(toolkitContext);
354+ ActionProxy::removeContext(context);
355 }
356
357=== modified file 'modules/Ubuntu/Components/plugin/ucactionmanager.h'
358--- modules/Ubuntu/Components/plugin/ucactionmanager.h 2014-10-08 19:08:08 +0000
359+++ modules/Ubuntu/Components/plugin/ucactionmanager.h 2015-07-10 13:53:01 +0000
360@@ -27,8 +27,8 @@
361 {
362 Q_OBJECT
363 Q_INTERFACES(QQmlParserStatus)
364- Q_PROPERTY(QQmlListProperty<QObject> actions READ actions)
365- Q_PROPERTY(QQmlListProperty<QObject> localContexts READ localContexts)
366+ Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions)
367+ Q_PROPERTY(QQmlListProperty<UCActionContext> localContexts READ localContexts)
368 Q_PROPERTY(UCActionContext *globalContext READ globalContext CONSTANT)
369 Q_CLASSINFO("DefaultProperty", "actions")
370 public:
371@@ -37,27 +37,27 @@
372 void classBegin() {}
373 void componentComplete();
374
375- QQmlListProperty<QObject> actions();
376- QQmlListProperty<QObject> localContexts();
377+ QQmlListProperty<UCAction> actions();
378+ QQmlListProperty<UCActionContext> localContexts();
379 UCActionContext *globalContext() const;
380
381 Q_SIGNALS:
382 void quit();
383
384 public Q_SLOTS:
385- void addAction(QObject *action);
386- void removeAction(QObject *action);
387- void addLocalContext(QObject *context);
388- void removeLocalContext(QObject *context);
389+ void addAction(UCAction *action);
390+ void removeAction(UCAction *action);
391+ void addLocalContext(UCActionContext *context);
392+ void removeLocalContext(UCActionContext *context);
393
394 private:
395- static void contextAppend(QQmlListProperty<QObject> *list, QObject *context);
396- static void contextClear(QQmlListProperty<QObject> *list);
397- static int contextCount(QQmlListProperty<QObject> *list);
398+ static void contextAppend(QQmlListProperty<UCActionContext> *list, UCActionContext *context);
399+ static void contextClear(QQmlListProperty<UCActionContext> *list);
400+ static int contextCount(QQmlListProperty<UCActionContext> *list);
401
402- static void actionAppend(QQmlListProperty<QObject> *list, QObject *action);
403- static void actionClear(QQmlListProperty<QObject> *list);
404- static int actionCount(QQmlListProperty<QObject> *list);
405+ static void actionAppend(QQmlListProperty<UCAction> *list, UCAction *action);
406+ static void actionClear(QQmlListProperty<UCAction> *list);
407+ static int actionCount(QQmlListProperty<UCAction> *list);
408 };
409
410 #endif // UCACTIONMANAGER_H
411
412=== modified file 'tests/unit/tst_components/tst_action.qml'
413--- tests/unit/tst_components/tst_action.qml 2015-03-03 13:20:06 +0000
414+++ tests/unit/tst_components/tst_action.qml 2015-07-10 13:53:01 +0000
415@@ -17,8 +17,6 @@
416 import QtQuick 2.0
417 import QtTest 1.0
418 import Ubuntu.Components 1.1
419-// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
420-import Ubuntu.Unity.Action 1.1 as Unity
421
422 TestCase {
423 name: "ActionAPI"
424@@ -121,27 +119,6 @@
425 ignoreWarning(util.callerFile() + message);
426 }
427
428- function test_add_unity_actioncontext_failure() {
429- ignoreQMLWarning(':217:6: QML ActionContext: Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components.');
430- manager.addLocalContext(unityContext);
431- verify(!contains(manager.localContexts, unityContext), "Unity ActionContext cannot be added");
432- }
433-
434- function test_unity_action_not_in_context() {
435- verify(!contains(manager.globalContext.actions, unityAction, "Unity Action cannot be registered"));
436- }
437-
438- function test_0_cannot_add_unity_action_to_global_context() {
439- ignoreQMLWarning(':166:6: QML Action: Unity.Action deprecated. Please use Action from Ubuntu.Components.');
440- manager.globalContext.addAction(stockUnityAction);
441- verify(!contains(manager.globalContext.actions, stockUnityAction, "Unity Action cannot be registered"));
442- }
443-
444- function test_1_cannot_add_unity_action_to_local_context() {
445- ignoreQMLWarning(':166:6: QML Action: Unity.Action deprecated. Please use Action from Ubuntu.Components.');
446- context1.addAction(stockUnityAction);
447- verify(!contains(context1.actions, stockUnityAction, "Unity Action cannot be registered"));
448- }
449 function test_activate_contexts_data() {
450 return [
451 {tag: "Activate context1", active: context1, inactive: context2},
452@@ -163,9 +140,6 @@
453 property var parameter
454 onTriggered: parameter = value
455 }
456- Unity.Action {
457- id: stockUnityAction
458- }
459
460 QtObject {
461 id: object
462@@ -202,9 +176,6 @@
463 }
464 Action {
465 }
466- Unity.Action {
467- id: unityAction
468- }
469 }
470
471 ActionContext {
472@@ -214,7 +185,4 @@
473 id: context2
474 }
475
476- Unity.ActionContext {
477- id: unityContext
478- }
479 }

Subscribers

People subscribed via source and target branches