diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-01-05 15:17:04 +0100 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-01-05 15:17:04 +0100 |
commit | a2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce (patch) | |
tree | 3ca0df1d96c01baef1575b4d961365ed227531e1 /framework/domain | |
parent | bc7879eca0d242934ec2051af93fd58b66845461 (diff) | |
download | kube-a2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce.tar.gz kube-a2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce.zip |
move accounts related files to seperate folder
Diffstat (limited to 'framework/domain')
-rw-r--r-- | framework/domain/CMakeLists.txt | 3 | ||||
-rw-r--r-- | framework/domain/accountfactory.cpp | 65 | ||||
-rw-r--r-- | framework/domain/accountfactory.h | 51 | ||||
-rw-r--r-- | framework/domain/accountscontroller.cpp | 42 | ||||
-rw-r--r-- | framework/domain/accountscontroller.h | 33 | ||||
-rw-r--r-- | framework/domain/accountsmodel.cpp | 82 | ||||
-rw-r--r-- | framework/domain/accountsmodel.h | 56 | ||||
-rw-r--r-- | framework/domain/composercontroller.cpp | 1 | ||||
-rw-r--r-- | framework/domain/mailplugin.cpp | 6 |
9 files changed, 0 insertions, 339 deletions
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt index 00499f30..01d55de2 100644 --- a/framework/domain/CMakeLists.txt +++ b/framework/domain/CMakeLists.txt | |||
@@ -13,9 +13,6 @@ set(mailplugin_SRCS | |||
13 | mailtemplates.cpp | 13 | mailtemplates.cpp |
14 | modeltest.cpp | 14 | modeltest.cpp |
15 | retriever.cpp | 15 | retriever.cpp |
16 | accountfactory.cpp | ||
17 | accountscontroller.cpp | ||
18 | accountsmodel.cpp | ||
19 | outboxmodel.cpp | 16 | outboxmodel.cpp |
20 | identitiesmodel.cpp | 17 | identitiesmodel.cpp |
21 | recepientautocompletionmodel.cpp | 18 | recepientautocompletionmodel.cpp |
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp deleted file mode 100644 index 182a0a1d..00000000 --- a/framework/domain/accountfactory.cpp +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsystems.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "accountfactory.h" | ||
20 | |||
21 | #include <QDebug> | ||
22 | |||
23 | #include <KPackage/PackageLoader> | ||
24 | #include <KPackage/Package> | ||
25 | #include <KPluginMetaData> | ||
26 | |||
27 | #include "settings/settings.h" | ||
28 | #include <sink/store.h> | ||
29 | |||
30 | AccountFactory::AccountFactory(QObject *parent) | ||
31 | : QObject(parent) | ||
32 | { | ||
33 | } | ||
34 | |||
35 | QString AccountFactory::name() const | ||
36 | { | ||
37 | if (mName.isEmpty()) { | ||
38 | return tr("Account"); | ||
39 | } | ||
40 | return mName; | ||
41 | } | ||
42 | |||
43 | void AccountFactory::setAccountId(const QString &accountId) | ||
44 | { | ||
45 | mAccountId = accountId; | ||
46 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query().filter(accountId.toUtf8())) | ||
47 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | ||
48 | mAccountType = account.getProperty("type").toByteArray(); | ||
49 | loadPackage(); | ||
50 | }).exec(); | ||
51 | } | ||
52 | |||
53 | void AccountFactory::loadPackage() | ||
54 | { | ||
55 | auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + mAccountType); | ||
56 | if (!package.isValid()) { | ||
57 | qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType; | ||
58 | return; | ||
59 | } | ||
60 | Q_ASSERT(package.isValid()); | ||
61 | mUiPath = package.filePath("mainscript"); | ||
62 | mName = package.metadata().name(); | ||
63 | mIcon = package.metadata().iconName(); | ||
64 | emit accountLoaded(); | ||
65 | } | ||
diff --git a/framework/domain/accountfactory.h b/framework/domain/accountfactory.h deleted file mode 100644 index 047454ae..00000000 --- a/framework/domain/accountfactory.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsystems.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | #include <QVariant> | ||
24 | |||
25 | /** | ||
26 | * A factory to instantiate accountp plugins. | ||
27 | */ | ||
28 | class AccountFactory : public QObject | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | Q_PROPERTY(QString accountId MEMBER mAccountId WRITE setAccountId); | ||
32 | Q_PROPERTY(QString name MEMBER mName READ name NOTIFY accountLoaded); | ||
33 | Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded); | ||
34 | Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded); | ||
35 | public: | ||
36 | explicit AccountFactory(QObject *parent = Q_NULLPTR); | ||
37 | |||
38 | void setAccountId(const QString &); | ||
39 | QString name() const; | ||
40 | |||
41 | signals: | ||
42 | void accountLoaded(); | ||
43 | |||
44 | private: | ||
45 | void loadPackage(); | ||
46 | QString mAccountId; | ||
47 | QString mName; | ||
48 | QString mIcon; | ||
49 | QString mUiPath; | ||
50 | QByteArray mAccountType; | ||
51 | }; | ||
diff --git a/framework/domain/accountscontroller.cpp b/framework/domain/accountscontroller.cpp deleted file mode 100644 index 5cb60d0c..00000000 --- a/framework/domain/accountscontroller.cpp +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include "accountscontroller.h" | ||
22 | |||
23 | #include <settings/settings.h> | ||
24 | #include <sink/store.h> | ||
25 | |||
26 | #include <QVariant> | ||
27 | #include <QDebug> | ||
28 | |||
29 | AccountsController::AccountsController(QObject *parent) : QObject(parent) | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void AccountsController::createAccount(const QString &accountType) | ||
34 | { | ||
35 | auto account = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkAccount>(); | ||
36 | account.setProperty("type", accountType); | ||
37 | Sink::Store::create(account).syncThen<void>([](const KAsync::Error &error) { | ||
38 | if (error) { | ||
39 | qWarning() << "Error while creating account: " << error.errorMessage; | ||
40 | } | ||
41 | }).exec(); | ||
42 | } | ||
diff --git a/framework/domain/accountscontroller.h b/framework/domain/accountscontroller.h deleted file mode 100644 index a4421de8..00000000 --- a/framework/domain/accountscontroller.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | #include <QString> | ||
24 | |||
25 | class AccountsController : public QObject | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | public: | ||
29 | explicit AccountsController(QObject *parent = Q_NULLPTR); | ||
30 | |||
31 | public slots: | ||
32 | void createAccount(const QString &accountId); | ||
33 | }; | ||
diff --git a/framework/domain/accountsmodel.cpp b/framework/domain/accountsmodel.cpp deleted file mode 100644 index ea37784b..00000000 --- a/framework/domain/accountsmodel.cpp +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "accountsmodel.h" | ||
20 | #include <sink/store.h> | ||
21 | |||
22 | AccountsModel::AccountsModel(QObject *parent) : QIdentityProxyModel() | ||
23 | { | ||
24 | Sink::Query query; | ||
25 | query.setFlags(Sink::Query::LiveQuery); | ||
26 | query.request<Sink::ApplicationDomain::SinkAccount::Name>(); | ||
27 | query.request<Sink::ApplicationDomain::SinkAccount::Icon>(); | ||
28 | query.request<Sink::ApplicationDomain::SinkAccount::Status>(); | ||
29 | runQuery(query); | ||
30 | } | ||
31 | |||
32 | AccountsModel::~AccountsModel() | ||
33 | { | ||
34 | |||
35 | } | ||
36 | |||
37 | QHash< int, QByteArray > AccountsModel::roleNames() const | ||
38 | { | ||
39 | QHash<int, QByteArray> roles; | ||
40 | |||
41 | roles[Name] = "name"; | ||
42 | roles[Icon] = "icon"; | ||
43 | roles[AccountId] = "accountId"; | ||
44 | roles[Status] = "status"; | ||
45 | roles[StatusIcon] = "statusIcon"; | ||
46 | roles[ShowStatus] = "showStatus"; | ||
47 | |||
48 | return roles; | ||
49 | } | ||
50 | |||
51 | QVariant AccountsModel::data(const QModelIndex &idx, int role) const | ||
52 | { | ||
53 | auto srcIdx = mapToSource(idx); | ||
54 | auto account = srcIdx.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>(); | ||
55 | switch (role) { | ||
56 | case Name: | ||
57 | return account->getName(); | ||
58 | case Icon: | ||
59 | return account->getIcon(); | ||
60 | case AccountId: | ||
61 | return account->identifier(); | ||
62 | case Status: | ||
63 | return account->getStatus(); | ||
64 | case StatusIcon: | ||
65 | if (account->getStatus() == Sink::ApplicationDomain::ErrorStatus) { | ||
66 | return "emblem-error"; | ||
67 | } else if (account->getStatus() == Sink::ApplicationDomain::BusyStatus) { | ||
68 | return "view-refresh"; | ||
69 | } else if (account->getStatus() == Sink::ApplicationDomain::ConnectedStatus) { | ||
70 | return "checkmark"; | ||
71 | } | ||
72 | case ShowStatus: | ||
73 | return (account->getStatus() != Sink::ApplicationDomain::OfflineStatus); | ||
74 | } | ||
75 | return QIdentityProxyModel::data(idx, role); | ||
76 | } | ||
77 | |||
78 | void AccountsModel::runQuery(const Sink::Query &query) | ||
79 | { | ||
80 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query); | ||
81 | setSourceModel(mModel.data()); | ||
82 | } | ||
diff --git a/framework/domain/accountsmodel.h b/framework/domain/accountsmodel.h deleted file mode 100644 index e3c08cd4..00000000 --- a/framework/domain/accountsmodel.h +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | #include <QIdentityProxyModel> | ||
24 | #include <QSharedPointer> | ||
25 | #include <QStringList> | ||
26 | |||
27 | namespace Sink { | ||
28 | class Query; | ||
29 | } | ||
30 | |||
31 | class AccountsModel : public QIdentityProxyModel | ||
32 | { | ||
33 | Q_OBJECT | ||
34 | |||
35 | public: | ||
36 | AccountsModel(QObject *parent = Q_NULLPTR); | ||
37 | ~AccountsModel(); | ||
38 | |||
39 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | ||
40 | |||
41 | enum Roles { | ||
42 | Name = Qt::UserRole + 1, | ||
43 | Icon, | ||
44 | AccountId, | ||
45 | Status, | ||
46 | StatusIcon, | ||
47 | ShowStatus | ||
48 | }; | ||
49 | Q_ENUMS(Roles) | ||
50 | |||
51 | QHash<int, QByteArray> roleNames() const; | ||
52 | |||
53 | private: | ||
54 | void runQuery(const Sink::Query &query); | ||
55 | QSharedPointer<QAbstractItemModel> mModel; | ||
56 | }; | ||
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index e97af4c2..a4a8857f 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <sink/store.h> | 31 | #include <sink/store.h> |
32 | #include <sink/log.h> | 32 | #include <sink/log.h> |
33 | 33 | ||
34 | #include "accountsmodel.h" | ||
35 | #include "identitiesmodel.h" | 34 | #include "identitiesmodel.h" |
36 | #include "recepientautocompletionmodel.h" | 35 | #include "recepientautocompletionmodel.h" |
37 | #include "mailtemplates.h" | 36 | #include "mailtemplates.h" |
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp index f9dbe3ec..2ec73644 100644 --- a/framework/domain/mailplugin.cpp +++ b/framework/domain/mailplugin.cpp | |||
@@ -25,9 +25,6 @@ | |||
25 | #include "composercontroller.h" | 25 | #include "composercontroller.h" |
26 | #include "messageparser.h" | 26 | #include "messageparser.h" |
27 | #include "retriever.h" | 27 | #include "retriever.h" |
28 | #include "accountfactory.h" | ||
29 | #include "accountscontroller.h" | ||
30 | #include "accountsmodel.h" | ||
31 | #include "outboxmodel.h" | 28 | #include "outboxmodel.h" |
32 | #include "outboxcontroller.h" | 29 | #include "outboxcontroller.h" |
33 | #include "mailcontroller.h" | 30 | #include "mailcontroller.h" |
@@ -45,9 +42,6 @@ void MailPlugin::registerTypes (const char *uri) | |||
45 | qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController"); | 42 | qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController"); |
46 | qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser"); | 43 | qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser"); |
47 | qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); | 44 | qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); |
48 | qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); | ||
49 | qmlRegisterType<AccountsController>(uri, 1, 0, "AccountsController"); | ||
50 | qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); | ||
51 | qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController"); | 45 | qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController"); |
52 | qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); | 46 | qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); |
53 | qmlRegisterType<MailController>(uri, 1, 0, "MailController"); | 47 | qmlRegisterType<MailController>(uri, 1, 0, "MailController"); |