Merge lp:~mardy/accounts-qml-module/packaging into lp:accounts-qml-module

Proposed by Alberto Mardegan
Status: Merged
Merged at revision: 48
Proposed branch: lp:~mardy/accounts-qml-module/packaging
Merge into: lp:accounts-qml-module
Diff against target: 141 lines (+60/-0)
4 files modified
debian/changelog (+6/-0)
src/account-service-model.cpp (+33/-0)
src/account-service-model.h (+6/-0)
tests/tst_plugin.cpp (+15/-0)
To merge this branch: bzr merge lp:~mardy/accounts-qml-module/packaging
Reviewer Review Type Date Requested Status
David Barth (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+219151@code.launchpad.net

Commit message

Add filter on application to AccountServiceModel.

Description of the change

Merge from upstream: add filter on application to AccountServiceModel.

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
David Barth (dbarth) :
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 2014-03-17 16:41:50 +0000
3+++ debian/changelog 2014-05-12 08:03:03 +0000
4@@ -1,3 +1,9 @@
5+accounts-qml-module (0.4+14.04.20140512-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * Merge from upstream: add filter on application to AccountServiceModel.
8+
9+ -- Alberto Mardegan <alberto.mardegan@canonical.com> Mon, 12 May 2014 10:58:53 +0300
10+
11 accounts-qml-module (0.4+14.04.20140317-0ubuntu1) trusty; urgency=low
12
13 [ Colin Watson ]
14
15=== modified file 'src/account-service-model.cpp'
16--- src/account-service-model.cpp 2014-01-30 13:25:22 +0000
17+++ src/account-service-model.cpp 2014-05-12 08:03:03 +0000
18@@ -22,6 +22,7 @@
19
20 #include <Accounts/Account>
21 #include <Accounts/AccountService>
22+#include <Accounts/Application>
23 #include <Accounts/Manager>
24 #include <QPointer>
25
26@@ -84,12 +85,14 @@
27 bool updateQueued;
28 bool accountIdChanged;
29 bool accountChanged;
30+ bool applicationIdChanged;
31 bool providerChanged;
32 bool serviceTypeChanged;
33 bool serviceChanged;
34 bool includeDisabled;
35 Accounts::AccountId accountId;
36 QPointer<Accounts::Account> account;
37+ Accounts::Application application;
38 QString providerId;
39 QString serviceTypeId;
40 QString serviceId;
41@@ -146,6 +149,8 @@
42 } else {
43 foreach (Accounts::Service service, account->services()) {
44 if (!serviceId.isEmpty() && service.name() != serviceId) continue;
45+ if (application.isValid() &&
46+ application.serviceUsage(service).isEmpty()) continue;
47 ret.append(new Accounts::AccountService(account, service));
48 }
49 }
50@@ -634,6 +639,34 @@
51 }
52
53 /*!
54+ * \qmlproperty string AccountServiceModel::applicationId
55+ * If set, the model will only show those account services which are relevant
56+ * for the given \a applicationId. This means that an account service will only
57+ * be shown if it can be used by the application, as described in the
58+ * application's manifest file.
59+ */
60+void AccountServiceModel::setApplicationId(const QString &applicationId)
61+{
62+ Q_D(AccountServiceModel);
63+
64+ if (applicationId == d->application.name()) return;
65+ if (applicationId.isEmpty()) {
66+ d->application = Accounts::Application();
67+ } else {
68+ d->application = SharedManager::instance()->application(applicationId);
69+ }
70+ d->applicationIdChanged = true;
71+ d->queueUpdate();
72+ Q_EMIT applicationIdChanged();
73+}
74+
75+QString AccountServiceModel::applicationId() const
76+{
77+ Q_D(const AccountServiceModel);
78+ return d->application.name();
79+}
80+
81+/*!
82 * \qmlproperty string AccountServiceModel::provider
83 * If set, the model will list only those accounts services provided by this provider.
84 */
85
86=== modified file 'src/account-service-model.h'
87--- src/account-service-model.h 2013-06-24 09:12:35 +0000
88+++ src/account-service-model.h 2014-05-12 08:03:03 +0000
89@@ -38,6 +38,8 @@
90 NOTIFY accountIdChanged)
91 Q_PROPERTY(QObject *account READ account WRITE setAccount \
92 NOTIFY accountChanged)
93+ Q_PROPERTY(QString applicationId READ applicationId \
94+ WRITE setApplicationId NOTIFY applicationIdChanged)
95 Q_PROPERTY(QString provider READ provider WRITE setProvider \
96 NOTIFY providerChanged)
97 Q_PROPERTY(QString serviceType READ serviceType WRITE setServiceType \
98@@ -70,6 +72,9 @@
99 void setAccount(QObject *account);
100 QObject *account() const;
101
102+ void setApplicationId(const QString &applicationId);
103+ QString applicationId() const;
104+
105 void setProvider(const QString &providerId);
106 QString provider() const;
107
108@@ -94,6 +99,7 @@
109 void includeDisabledChanged();
110 void accountIdChanged();
111 void accountChanged();
112+ void applicationIdChanged();
113 void providerChanged();
114 void serviceTypeChanged();
115 void serviceChanged();
116
117=== modified file 'tests/tst_plugin.cpp'
118--- tests/tst_plugin.cpp 2014-01-30 13:25:22 +0000
119+++ tests/tst_plugin.cpp 2014-05-12 08:03:03 +0000
120@@ -261,6 +261,21 @@
121 QCOMPARE(model->property("account").value<QObject*>(), account2);
122 model->setProperty("account", QVariant::fromValue<QObject*>(0));
123
124+ /* Test the application filter */
125+ model->setProperty("applicationId", QString("mailer"));
126+ QCOMPARE(model->property("applicationId").toString(), QString("mailer"));
127+ QTest::qWait(10);
128+ QCOMPARE(model->rowCount(), 2);
129+ QSet<QString> services;
130+ services.insert(get(model, 0, "serviceName").toString());
131+ services.insert(get(model, 1, "serviceName").toString());
132+ QSet<QString> expectedServices;
133+ expectedServices.insert("Cool Mail");
134+ expectedServices.insert("Bad Mail");
135+ QCOMPARE(services, expectedServices);
136+ /* Reset the application filter */
137+ model->setProperty("applicationId", QString());
138+
139 /* Test the provider filter */
140 model->setProperty("provider", QString("bad"));
141 QCOMPARE(model->property("provider").toString(), QString("bad"));

Subscribers

People subscribed via source and target branches