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
=== modified file 'debian/changelog'
--- debian/changelog 2014-03-17 16:41:50 +0000
+++ debian/changelog 2014-05-12 08:03:03 +0000
@@ -1,3 +1,9 @@
1accounts-qml-module (0.4+14.04.20140512-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Merge from upstream: add filter on application to AccountServiceModel.
4
5 -- Alberto Mardegan <alberto.mardegan@canonical.com> Mon, 12 May 2014 10:58:53 +0300
6
1accounts-qml-module (0.4+14.04.20140317-0ubuntu1) trusty; urgency=low7accounts-qml-module (0.4+14.04.20140317-0ubuntu1) trusty; urgency=low
28
3 [ Colin Watson ]9 [ Colin Watson ]
410
=== modified file 'src/account-service-model.cpp'
--- src/account-service-model.cpp 2014-01-30 13:25:22 +0000
+++ src/account-service-model.cpp 2014-05-12 08:03:03 +0000
@@ -22,6 +22,7 @@
2222
23#include <Accounts/Account>23#include <Accounts/Account>
24#include <Accounts/AccountService>24#include <Accounts/AccountService>
25#include <Accounts/Application>
25#include <Accounts/Manager>26#include <Accounts/Manager>
26#include <QPointer>27#include <QPointer>
2728
@@ -84,12 +85,14 @@
84 bool updateQueued;85 bool updateQueued;
85 bool accountIdChanged;86 bool accountIdChanged;
86 bool accountChanged;87 bool accountChanged;
88 bool applicationIdChanged;
87 bool providerChanged;89 bool providerChanged;
88 bool serviceTypeChanged;90 bool serviceTypeChanged;
89 bool serviceChanged;91 bool serviceChanged;
90 bool includeDisabled;92 bool includeDisabled;
91 Accounts::AccountId accountId;93 Accounts::AccountId accountId;
92 QPointer<Accounts::Account> account;94 QPointer<Accounts::Account> account;
95 Accounts::Application application;
93 QString providerId;96 QString providerId;
94 QString serviceTypeId;97 QString serviceTypeId;
95 QString serviceId;98 QString serviceId;
@@ -146,6 +149,8 @@
146 } else {149 } else {
147 foreach (Accounts::Service service, account->services()) {150 foreach (Accounts::Service service, account->services()) {
148 if (!serviceId.isEmpty() && service.name() != serviceId) continue;151 if (!serviceId.isEmpty() && service.name() != serviceId) continue;
152 if (application.isValid() &&
153 application.serviceUsage(service).isEmpty()) continue;
149 ret.append(new Accounts::AccountService(account, service));154 ret.append(new Accounts::AccountService(account, service));
150 }155 }
151 }156 }
@@ -634,6 +639,34 @@
634}639}
635640
636/*!641/*!
642 * \qmlproperty string AccountServiceModel::applicationId
643 * If set, the model will only show those account services which are relevant
644 * for the given \a applicationId. This means that an account service will only
645 * be shown if it can be used by the application, as described in the
646 * application's manifest file.
647 */
648void AccountServiceModel::setApplicationId(const QString &applicationId)
649{
650 Q_D(AccountServiceModel);
651
652 if (applicationId == d->application.name()) return;
653 if (applicationId.isEmpty()) {
654 d->application = Accounts::Application();
655 } else {
656 d->application = SharedManager::instance()->application(applicationId);
657 }
658 d->applicationIdChanged = true;
659 d->queueUpdate();
660 Q_EMIT applicationIdChanged();
661}
662
663QString AccountServiceModel::applicationId() const
664{
665 Q_D(const AccountServiceModel);
666 return d->application.name();
667}
668
669/*!
637 * \qmlproperty string AccountServiceModel::provider670 * \qmlproperty string AccountServiceModel::provider
638 * If set, the model will list only those accounts services provided by this provider.671 * If set, the model will list only those accounts services provided by this provider.
639 */672 */
640673
=== modified file 'src/account-service-model.h'
--- src/account-service-model.h 2013-06-24 09:12:35 +0000
+++ src/account-service-model.h 2014-05-12 08:03:03 +0000
@@ -38,6 +38,8 @@
38 NOTIFY accountIdChanged)38 NOTIFY accountIdChanged)
39 Q_PROPERTY(QObject *account READ account WRITE setAccount \39 Q_PROPERTY(QObject *account READ account WRITE setAccount \
40 NOTIFY accountChanged)40 NOTIFY accountChanged)
41 Q_PROPERTY(QString applicationId READ applicationId \
42 WRITE setApplicationId NOTIFY applicationIdChanged)
41 Q_PROPERTY(QString provider READ provider WRITE setProvider \43 Q_PROPERTY(QString provider READ provider WRITE setProvider \
42 NOTIFY providerChanged)44 NOTIFY providerChanged)
43 Q_PROPERTY(QString serviceType READ serviceType WRITE setServiceType \45 Q_PROPERTY(QString serviceType READ serviceType WRITE setServiceType \
@@ -70,6 +72,9 @@
70 void setAccount(QObject *account);72 void setAccount(QObject *account);
71 QObject *account() const;73 QObject *account() const;
7274
75 void setApplicationId(const QString &applicationId);
76 QString applicationId() const;
77
73 void setProvider(const QString &providerId);78 void setProvider(const QString &providerId);
74 QString provider() const;79 QString provider() const;
7580
@@ -94,6 +99,7 @@
94 void includeDisabledChanged();99 void includeDisabledChanged();
95 void accountIdChanged();100 void accountIdChanged();
96 void accountChanged();101 void accountChanged();
102 void applicationIdChanged();
97 void providerChanged();103 void providerChanged();
98 void serviceTypeChanged();104 void serviceTypeChanged();
99 void serviceChanged();105 void serviceChanged();
100106
=== modified file 'tests/tst_plugin.cpp'
--- tests/tst_plugin.cpp 2014-01-30 13:25:22 +0000
+++ tests/tst_plugin.cpp 2014-05-12 08:03:03 +0000
@@ -261,6 +261,21 @@
261 QCOMPARE(model->property("account").value<QObject*>(), account2);261 QCOMPARE(model->property("account").value<QObject*>(), account2);
262 model->setProperty("account", QVariant::fromValue<QObject*>(0));262 model->setProperty("account", QVariant::fromValue<QObject*>(0));
263263
264 /* Test the application filter */
265 model->setProperty("applicationId", QString("mailer"));
266 QCOMPARE(model->property("applicationId").toString(), QString("mailer"));
267 QTest::qWait(10);
268 QCOMPARE(model->rowCount(), 2);
269 QSet<QString> services;
270 services.insert(get(model, 0, "serviceName").toString());
271 services.insert(get(model, 1, "serviceName").toString());
272 QSet<QString> expectedServices;
273 expectedServices.insert("Cool Mail");
274 expectedServices.insert("Bad Mail");
275 QCOMPARE(services, expectedServices);
276 /* Reset the application filter */
277 model->setProperty("applicationId", QString());
278
264 /* Test the provider filter */279 /* Test the provider filter */
265 model->setProperty("provider", QString("bad"));280 model->setProperty("provider", QString("bad"));
266 QCOMPARE(model->property("provider").toString(), QString("bad"));281 QCOMPARE(model->property("provider").toString(), QString("bad"));

Subscribers

People subscribed via source and target branches