Merge lp:~macslow/unity-notifications/modal-snap-decisions into lp:unity-notifications

Proposed by Mirco Müller
Status: Merged
Approved by: Michał Sawicz
Approved revision: 210
Merged at revision: 203
Proposed branch: lp:~macslow/unity-notifications/modal-snap-decisions
Merge into: lp:unity-notifications
Diff against target: 195 lines (+37/-38)
5 files modified
debian/control (+2/-2)
include/NotificationModel.h (+0/-14)
src/CMakeLists.txt (+4/-0)
src/NotificationModel.cpp (+27/-22)
src/NotificationPlugin.cpp (+4/-0)
To merge this branch: bzr merge lp:~macslow/unity-notifications/modal-snap-decisions
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Albert Astals Cid (community) Approve
Michael Zanetti (community) Needs Information
Review via email: mp+212483@code.launchpad.net

Commit message

Make the Roles enum available to QML.

Description of the change

Make the Roles enum available to QML.

This is needed for the MR https://code.launchpad.net/~macslow/unity8/modal-snap-decisions/+merge/210988 to work with.

* Are there any related MPs required for this MP to build/function as expected? Please list.
Yes. https://code.launchpad.net/~macslow/unity-api/version-bump-to-0.1.3/+merge/216122 needs to land before this one will work.

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Yes.

* If you changed the UI, has there been a design review?
Not applicable.

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Hmm... I think this should rather be defined in lp:unity-api and teted for its existence here in tst_NotificaitonInterface.qml, no?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Yeah, please submit a similar thing to lp:unity-api, even though this is not using it yet (it should!), let's keep it as close as possible.

Revision history for this message
Mirco Müller (macslow) wrote :

Just working on that.

Revision history for this message
Mirco Müller (macslow) wrote :
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Even though this model doesn't inherit the one from unity-api yet, I'm wondering if it wouldn't make sense to already now use the enums in there. Without having tested it, do you think we could just drop the enum definition in here and use ModelInterface::Roles everywhere in here already? Otherwise I see it drifting apart again.

review: Needs Information
Revision history for this message
Mirco Müller (macslow) wrote :

Ill will make sure we can use the enum from unity-api as drop-in here and see that it will still work (or make it work) with https://code.launchpad.net/~macslow/unity8/modal-snap-decisions/+merge/210988

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Q_ENUMS(Roles) seems like it should go away

review: Needs Fixing
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 :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, still works

* Did CI run pass? If not, please explain why.
Yes.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

This needs a bump in unity-notifications-impl provided, to go with a bump in a .pc file bump in unity-api.

See https://code.launchpad.net/~macslow/unity8/modal-snap-decisions/+merge/210988/comments/512330 for details.

review: Needs Fixing
206. By Mirco Müller

Make unity-notifications require at least unity-api 0.1.3 and thus also bump the Provides to unity-notifications-impl-3.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

You're right, in a sense, that this implements both v2 and v3 of the Notifications API, but I don't think we're at the point where we care. Just drop the -impl-2 and replace with -impl-3 please.

The whole idea is like so:
unity-api defines the API by providing headers, for each group of interfaces (application, notifications etc.), there's a pkg-config file (i.e. unity-notifications.pc), which in the Version field defines the version of the API implemented. Right now it's manual, but we'll make it automagic, that unity-notifications-impl-$version will be generated from this .pc file.

Then, any consumer of this API (unity8 in our case) depends on $default-implementation-real-package | unity-$interface-impl, unity-$interface-impl-$version. We wouldn't need the first bit, but dpkg would choke on only-virtual dependency like that.

On top of that, the unity-api tests will be ran against the actual implementation to verify the expected API.

Makes some sense now? The idea is to ensure shell-facing API stability and allow for easy drop-in replacements, as long as they implement the same interfaces.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

This needs to build-depend on libunity-api-dev >= 7.80.7.

review: Needs Fixing
207. By Mirco Müller

Make sure to depend on the new upstream-version of libunity-api-dev

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

18 + unity-notifications-impl-2,
19 + unity-notifications-impl-3

See my previous comment - replace, don't add.

=====

54 +pkg_check_modules(NOTIFICATIONS_API REQUIRED unity-shell-notifications=1)

This version should be the same as -impl, so 3.

=====

76 +/* check if unity-api >= 0.1.3 */
77 +#include <unity/api/Version.h>
78 +#if UNITY_API_VERSION_MAJOR > 0 || \
79 + (UNITY_API_VERSION_MAJOR == 0 && (UNITY_API_VERSION_MINOR > 1 || \
80 + (UNITY_API_VERSION_MINOR == 1 && \
81 + UNITY_API_VERSION_MICRO < 3)))
82 + #error Unity-API needs to be at least 0.1.3
83 +#endif

You're not using that part of unity-api at all, so all that is not needed.

review: Needs Fixing
208. By Mirco Müller

Just bump the required unity-notification version on the packaging-side of things.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

See https://code.launchpad.net/~macslow/unity-api/version-bump-to-0.1.3/+merge/217882/comments/518636, bump the build-depends to (>= 7.80.8).

Also, parentheses are required in dependencies!

You might want to run `wrap-and-sort -atv` to make sure of all the formatting in debian/ is good.

review: Needs Fixing
209. By Mirco Müller

Addes missing parentheses.

210. By Mirco Müller

Another version-bump in the dependency was needed, because another branch was merged to trunk before.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Yup.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-01-27 16:05:06 +0000
3+++ debian/control 2014-05-05 08:08:03 +0000
4@@ -7,7 +7,7 @@
5 pkg-config,
6 qtdeclarative5-dev,
7 qtbase5-dev-tools,
8- libunity-api-dev,
9+ libunity-api-dev (>= 7.80.8),
10 # For Qml tests
11 qtchooser,
12 qt5-default,
13@@ -18,7 +18,7 @@
14
15 Package: qtdeclarative5-unity-notifications-plugin
16 Provides: unity-notifications-impl,
17- unity-notifications-impl-2
18+ unity-notifications-impl-3
19 Architecture: any
20 Multi-Arch: same
21 Pre-Depends: ${misc:Pre-Depends}
22
23=== modified file 'include/NotificationModel.h'
24--- include/NotificationModel.h 2013-12-04 17:38:52 +0000
25+++ include/NotificationModel.h 2014-05-05 08:08:03 +0000
26@@ -30,20 +30,6 @@
27
28 struct NotificationModelPrivate;
29
30-enum Roles {
31- RoleType = Qt::UserRole + 1,
32- RoleUrgency = Qt::UserRole + 2,
33- RoleId = Qt::UserRole + 3,
34- RoleSummary = Qt::UserRole + 4,
35- RoleBody = Qt::UserRole + 5,
36- RoleValue = Qt::UserRole + 6,
37- RoleIcon = Qt::UserRole + 7,
38- RoleSecondaryIcon = Qt::UserRole + 8,
39- RoleActions = Qt::UserRole + 9,
40- RoleHints = Qt::UserRole + 10,
41- RoleNotification = Qt::UserRole + 11
42-};
43-
44 class NotificationModel : public QAbstractListModel {
45 Q_OBJECT
46
47
48=== modified file 'src/CMakeLists.txt'
49--- src/CMakeLists.txt 2013-11-29 10:55:54 +0000
50+++ src/CMakeLists.txt 2014-05-05 08:08:03 +0000
51@@ -1,3 +1,6 @@
52+include(FindPkgConfig)
53+pkg_check_modules(NOTIFICATIONS_API REQUIRED unity-shell-notifications=3)
54+
55 set(CORE_SRCS
56 ActionModel.cpp
57 ../include/ActionModel.h
58@@ -9,6 +12,7 @@
59 ../include/NotificationServer.h
60 NotificationClient.cpp
61 ../include/NotificationClient.h
62+${NOTIFICATIONS_API_INCLUDEDIR}/unity/shell/notifications/ModelInterface.h
63 )
64
65 # Build everything twice. Since we have only a few
66
67=== modified file 'src/NotificationModel.cpp'
68--- src/NotificationModel.cpp 2014-02-18 14:51:44 +0000
69+++ src/NotificationModel.cpp 2014-05-05 08:08:03 +0000
70@@ -19,6 +19,9 @@
71
72 #include "NotificationModel.h"
73 #include "Notification.h"
74+
75+#include <unity/shell/notifications/ModelInterface.h>
76+
77 #include <QTimer>
78 #include <QList>
79 #include <QVector>
80@@ -26,6 +29,8 @@
81 #include <QStringListModel>
82 #include <QQmlEngine>
83
84+using namespace unity::shell::notifications;
85+
86 struct NotificationModelPrivate {
87 QList<QSharedPointer<Notification> > displayedNotifications;
88 QTimer timer;
89@@ -71,37 +76,37 @@
90 return QVariant();
91
92 switch(role) {
93- case RoleType:
94+ case ModelInterface::RoleType:
95 return QVariant(p->displayedNotifications[index.row()]->getType());
96
97- case RoleUrgency:
98+ case ModelInterface::RoleUrgency:
99 return QVariant(p->displayedNotifications[index.row()]->getUrgency());
100
101- case RoleId:
102+ case ModelInterface::RoleId:
103 return QVariant(p->displayedNotifications[index.row()]->getID());
104
105- case RoleSummary:
106+ case ModelInterface::RoleSummary:
107 return QVariant(p->displayedNotifications[index.row()]->getSummary());
108
109- case RoleBody:
110+ case ModelInterface::RoleBody:
111 return QVariant(p->displayedNotifications[index.row()]->getBody());
112
113- case RoleValue:
114+ case ModelInterface::RoleValue:
115 return QVariant(p->displayedNotifications[index.row()]->getValue());
116
117- case RoleIcon:
118+ case ModelInterface::RoleIcon:
119 return QVariant(p->displayedNotifications[index.row()]->getIcon());
120
121- case RoleSecondaryIcon:
122+ case ModelInterface::RoleSecondaryIcon:
123 return QVariant(p->displayedNotifications[index.row()]->getSecondaryIcon());
124
125- case RoleActions:
126+ case ModelInterface::RoleActions:
127 return QVariant::fromValue(p->displayedNotifications[index.row()]->getActions());
128
129- case RoleHints:
130+ case ModelInterface::RoleHints:
131 return QVariant(p->displayedNotifications[index.row()]->getHints());
132
133- case RoleNotification:
134+ case ModelInterface::RoleNotification:
135 return QVariant(p->displayedNotifications[index.row()]);
136
137 default:
138@@ -543,17 +548,17 @@
139 QHash<int, QByteArray> NotificationModel::roleNames() const {
140 QHash<int, QByteArray> roles;
141
142- roles.insert(RoleType, "type");
143- roles.insert(RoleUrgency, "urgency");
144- roles.insert(RoleId, "id");
145- roles.insert(RoleSummary, "summary");
146- roles.insert(RoleBody, "body");
147- roles.insert(RoleValue, "value");
148- roles.insert(RoleIcon, "icon");
149- roles.insert(RoleSecondaryIcon, "secondaryIcon");
150- roles.insert(RoleActions, "actions");
151- roles.insert(RoleHints, "hints");
152- roles.insert(RoleNotification, "notification");
153+ roles.insert(ModelInterface::RoleType, "type");
154+ roles.insert(ModelInterface::RoleUrgency, "urgency");
155+ roles.insert(ModelInterface::RoleId, "id");
156+ roles.insert(ModelInterface::RoleSummary, "summary");
157+ roles.insert(ModelInterface::RoleBody, "body");
158+ roles.insert(ModelInterface::RoleValue, "value");
159+ roles.insert(ModelInterface::RoleIcon, "icon");
160+ roles.insert(ModelInterface::RoleSecondaryIcon, "secondaryIcon");
161+ roles.insert(ModelInterface::RoleActions, "actions");
162+ roles.insert(ModelInterface::RoleHints, "hints");
163+ roles.insert(ModelInterface::RoleNotification, "notification");
164
165 return roles;
166 }
167
168=== modified file 'src/NotificationPlugin.cpp'
169--- src/NotificationPlugin.cpp 2013-10-29 03:19:47 +0000
170+++ src/NotificationPlugin.cpp 2014-05-05 08:08:03 +0000
171@@ -22,6 +22,8 @@
172 #include "NotificationModel.h"
173 #include "NotificationServer.h"
174
175+#include <unity/shell/notifications/ModelInterface.h>
176+
177 #include <qqml.h>
178
179 #include <QtDBus>
180@@ -33,6 +35,7 @@
181 static NotificationModel *m = NULL;
182 static NotificationServer *s = NULL;
183
184+using namespace unity::shell::notifications;
185
186 static QObject* modelProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
187 {
188@@ -41,6 +44,7 @@
189
190 void NotificationPlugin::registerTypes(const char *uri) {
191 // @uri Unity.Notifications
192+ qmlRegisterUncreatableType<ModelInterface>(uri, 1, 0, "ModelInterface", "Abstract Interface. Cannot be instantiated.");
193 qmlRegisterSingletonType<NotificationModel>(uri, 1, 0, "Model", modelProvider);
194 qmlRegisterUncreatableType<Notification>(uri, 1, 0, "Notification", "Notification objects can only be created by the plugin");
195 }

Subscribers

People subscribed via source and target branches

to all changes: