diff options
Diffstat (limited to 'framework')
26 files changed, 134 insertions, 554 deletions
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 4fecaf14..95be342d 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt | |||
@@ -41,7 +41,5 @@ add_subdirectory(actions) | |||
41 | add_subdirectory(settings) | 41 | add_subdirectory(settings) |
42 | # Domain specific domain logic | 42 | # Domain specific domain logic |
43 | add_subdirectory(domain) | 43 | add_subdirectory(domain) |
44 | # Theme specfic things like colors | ||
45 | add_subdirectory(theme) | ||
46 | 44 | ||
47 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) | 45 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) |
diff --git a/framework/actions/actionhandler.cpp b/framework/actions/actionhandler.cpp index 4ae8d0a9..9d58f464 100644 --- a/framework/actions/actionhandler.cpp +++ b/framework/actions/actionhandler.cpp | |||
@@ -106,14 +106,12 @@ ActionResult ActionHandlerHelper::execute(Context *context) | |||
106 | handlerFunction(context); | 106 | handlerFunction(context); |
107 | result.setDone(); | 107 | result.setDone(); |
108 | } else { | 108 | } else { |
109 | jobHandlerFunction(context).then<void>([=]() { | 109 | jobHandlerFunction(context).syncThen<void>([=](const KAsync::Error &error) { |
110 | auto modifyableResult = result; | 110 | auto modifyableResult = result; |
111 | modifyableResult.setDone(); | 111 | if (error) { |
112 | }, | 112 | qWarning() << "Job failed: " << error.errorCode << error.errorMessage; |
113 | [=](int errorCode, const QString &string) { | 113 | modifyableResult.setError(1); |
114 | qWarning() << "Job failed: " << errorCode << string; | 114 | } |
115 | auto modifyableResult = result; | ||
116 | modifyableResult.setError(1); | ||
117 | modifyableResult.setDone(); | 115 | modifyableResult.setDone(); |
118 | }).exec(); | 116 | }).exec(); |
119 | } | 117 | } |
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp index 10f01f65..182a0a1d 100644 --- a/framework/domain/accountfactory.cpp +++ b/framework/domain/accountfactory.cpp | |||
@@ -43,8 +43,8 @@ QString AccountFactory::name() const | |||
43 | void AccountFactory::setAccountId(const QString &accountId) | 43 | void AccountFactory::setAccountId(const QString &accountId) |
44 | { | 44 | { |
45 | mAccountId = accountId; | 45 | mAccountId = accountId; |
46 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(accountId.toUtf8())) | 46 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query().filter(accountId.toUtf8())) |
47 | .then<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | 47 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { |
48 | mAccountType = account.getProperty("type").toByteArray(); | 48 | mAccountType = account.getProperty("type").toByteArray(); |
49 | loadPackage(); | 49 | loadPackage(); |
50 | }).exec(); | 50 | }).exec(); |
diff --git a/framework/domain/accountscontroller.cpp b/framework/domain/accountscontroller.cpp index 2f47fa03..5cb60d0c 100644 --- a/framework/domain/accountscontroller.cpp +++ b/framework/domain/accountscontroller.cpp | |||
@@ -34,9 +34,9 @@ void AccountsController::createAccount(const QString &accountType) | |||
34 | { | 34 | { |
35 | auto account = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkAccount>(); | 35 | auto account = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkAccount>(); |
36 | account.setProperty("type", accountType); | 36 | account.setProperty("type", accountType); |
37 | Sink::Store::create(account).then<void>([]() {}, | 37 | Sink::Store::create(account).syncThen<void>([](const KAsync::Error &error) { |
38 | [](int errorCode, const QString &errorMessage) { | 38 | if (error) { |
39 | qWarning() << "Error while creating account: " << errorMessage; | 39 | qWarning() << "Error while creating account: " << error.errorMessage; |
40 | }) | 40 | } |
41 | .exec(); | 41 | }).exec(); |
42 | } | 42 | } |
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 921fe748..cc8d324e 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -28,20 +28,22 @@ | |||
28 | SINK_DEBUG_AREA("sinkactions") | 28 | SINK_DEBUG_AREA("sinkactions") |
29 | 29 | ||
30 | using namespace Kube; | 30 | using namespace Kube; |
31 | using namespace Sink; | ||
32 | using namespace Sink::ApplicationDomain; | ||
31 | 33 | ||
32 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", | 34 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", |
33 | [](Context *context) -> bool { | 35 | [](Context *context) -> bool { |
34 | return context->property("mail").isValid(); | 36 | return context->property("mail").isValid(); |
35 | }, | 37 | }, |
36 | [](Context *context) { | 38 | [](Context *context) { |
37 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 39 | auto mail = context->property("mail").value<Mail::Ptr>(); |
38 | if (!mail) { | 40 | if (!mail) { |
39 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 41 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
40 | return; | 42 | return; |
41 | } | 43 | } |
42 | mail->setProperty("unread", false); | 44 | mail->setProperty("unread", false); |
43 | SinkLog() << "Mark as read " << mail->identifier(); | 45 | SinkLog() << "Mark as read " << mail->identifier(); |
44 | Sink::Store::modify(*mail).exec(); | 46 | Store::modify(*mail).exec(); |
45 | } | 47 | } |
46 | ); | 48 | ); |
47 | 49 | ||
@@ -50,14 +52,14 @@ static ActionHandlerHelper moveToTrashHandler("org.kde.kube.actions.move-to-tras | |||
50 | return context->property("mail").isValid(); | 52 | return context->property("mail").isValid(); |
51 | }, | 53 | }, |
52 | [](Context *context) { | 54 | [](Context *context) { |
53 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 55 | auto mail = context->property("mail").value<Mail::Ptr>(); |
54 | if (!mail) { | 56 | if (!mail) { |
55 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 57 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
56 | return; | 58 | return; |
57 | } | 59 | } |
58 | mail->setTrash(true); | 60 | mail->setTrash(true); |
59 | SinkLog() << "Move to trash " << mail->identifier(); | 61 | SinkLog() << "Move to trash " << mail->identifier(); |
60 | Sink::Store::modify(*mail).exec(); | 62 | Store::modify(*mail).exec(); |
61 | } | 63 | } |
62 | ); | 64 | ); |
63 | 65 | ||
@@ -66,13 +68,13 @@ static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete", | |||
66 | return context->property("mail").isValid(); | 68 | return context->property("mail").isValid(); |
67 | }, | 69 | }, |
68 | [](Context *context) { | 70 | [](Context *context) { |
69 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 71 | auto mail = context->property("mail").value<Mail::Ptr>(); |
70 | if (!mail) { | 72 | if (!mail) { |
71 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 73 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
72 | return; | 74 | return; |
73 | } | 75 | } |
74 | SinkLog() << "Remove " << mail->identifier(); | 76 | SinkLog() << "Remove " << mail->identifier(); |
75 | Sink::Store::remove(*mail).exec(); | 77 | Store::remove(*mail).exec(); |
76 | } | 78 | } |
77 | ); | 79 | ); |
78 | 80 | ||
@@ -81,12 +83,12 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" | |||
81 | return true; | 83 | return true; |
82 | }, | 84 | }, |
83 | [](Context *context) { | 85 | [](Context *context) { |
84 | if (auto folder = context->property("folder").value<Sink::ApplicationDomain::Folder::Ptr>()) { | 86 | if (auto folder = context->property("folder").value<Folder::Ptr>()) { |
85 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); | 87 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); |
86 | Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); | 88 | Store::synchronize(Query().resourceFilter(folder->resourceInstanceIdentifier())).exec(); |
87 | } else { | 89 | } else { |
88 | SinkLog() << "Synchronizing all"; | 90 | SinkLog() << "Synchronizing all"; |
89 | Sink::Store::synchronize(Sink::Query()).exec(); | 91 | Store::synchronize(Query()).exec(); |
90 | } | 92 | } |
91 | } | 93 | } |
92 | ); | 94 | ); |
@@ -102,17 +104,17 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
102 | auto message = context->property("message").value<KMime::Message::Ptr>(); | 104 | auto message = context->property("message").value<KMime::Message::Ptr>(); |
103 | SinkLog() << "Sending a mail: "; | 105 | SinkLog() << "Sending a mail: "; |
104 | 106 | ||
105 | Sink::Query query; | 107 | Query query; |
106 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport); | 108 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); |
107 | query += Sink::Query::AccountFilter(accountId); | 109 | query.filter<SinkResource::Account>(accountId); |
108 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(query) | 110 | Store::fetchAll<ApplicationDomain::SinkResource>(query) |
109 | .then<void, KAsync::Job<void>, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { | 111 | .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { |
110 | if (!resources.isEmpty()) { | 112 | if (!resources.isEmpty()) { |
111 | auto resourceId = resources[0]->identifier(); | 113 | auto resourceId = resources[0]->identifier(); |
112 | SinkTrace() << "Sending message via resource: " << resourceId; | 114 | SinkTrace() << "Sending message via resource: " << resourceId; |
113 | Sink::ApplicationDomain::Mail mail(resourceId); | 115 | Mail mail(resourceId); |
114 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 116 | mail.setBlobProperty("mimeMessage", message->encodedContent()); |
115 | return Sink::Store::create(mail); | 117 | return Store::create(mail); |
116 | } | 118 | } |
117 | SinkWarning() << "Failed to find a mailtransport resource"; | 119 | SinkWarning() << "Failed to find a mailtransport resource"; |
118 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); | 120 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); |
@@ -127,30 +129,30 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
127 | return !accountId.isEmpty() && message; | 129 | return !accountId.isEmpty() && message; |
128 | }, | 130 | }, |
129 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { | 131 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { |
130 | SinkWarning() << "executing save as draft"; | 132 | SinkLog() << "Executing the save-as-draft action"; |
131 | const auto accountId = context->property("accountId").value<QByteArray>(); | 133 | const auto accountId = context->property("accountId").value<QByteArray>(); |
132 | const auto message = context->property("message").value<KMime::Message::Ptr>(); | 134 | const auto message = context->property("message").value<KMime::Message::Ptr>(); |
133 | auto existingMail = context->property("existingMail").value<Sink::ApplicationDomain::Mail>(); | 135 | auto existingMail = context->property("existingMail").value<Mail>(); |
134 | if (!message) { | 136 | if (!message) { |
135 | SinkWarning() << "Failed to get the mail: " << context->property("mail"); | 137 | SinkWarning() << "Failed to get the mail: " << context->property("mail"); |
136 | return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString()); | 138 | return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString()); |
137 | } | 139 | } |
138 | 140 | ||
139 | if (existingMail.identifier().isEmpty()) { | 141 | if (existingMail.identifier().isEmpty()) { |
140 | Sink::Query query; | 142 | Query query; |
141 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::drafts); | 143 | query.containsFilter<SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::drafts); |
142 | query += Sink::Query::AccountFilter(accountId); | 144 | query.filter<SinkResource::Account>(accountId); |
143 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) | 145 | return Store::fetchOne<SinkResource>(query) |
144 | .then<void, KAsync::Job<void>, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { | 146 | .then<void, SinkResource>([=](const SinkResource &resource) -> KAsync::Job<void> { |
145 | Sink::ApplicationDomain::Mail mail(resource.identifier()); | 147 | Mail mail(resource.identifier()); |
146 | mail.setProperty("draft", true); | 148 | mail.setDraft(true); |
147 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 149 | mail.setMimeMessage(message->encodedContent()); |
148 | return Sink::Store::create(mail); | 150 | return Store::create(mail); |
149 | }); | 151 | }); |
150 | } else { | 152 | } else { |
151 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); | 153 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); |
152 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); | 154 | existingMail.setMimeMessage(message->encodedContent()); |
153 | return Sink::Store::modify(existingMail); | 155 | return Store::modify(existingMail); |
154 | } | 156 | } |
155 | }) | 157 | }) |
156 | ); | 158 | ); |
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index 2dcf1bb1..b2ad7ecc 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -133,7 +133,7 @@ void ComposerController::loadMessage(const QVariant &message, bool loadAsDraft) | |||
133 | { | 133 | { |
134 | Sink::Query query(*message.value<Sink::ApplicationDomain::Mail::Ptr>()); | 134 | Sink::Query query(*message.value<Sink::ApplicationDomain::Mail::Ptr>()); |
135 | query.request<Sink::ApplicationDomain::Mail::MimeMessage>(); | 135 | query.request<Sink::ApplicationDomain::Mail::MimeMessage>(); |
136 | Sink::Store::fetchOne<Sink::ApplicationDomain::Mail>(query).then<void, Sink::ApplicationDomain::Mail>([this, loadAsDraft](const Sink::ApplicationDomain::Mail &mail) { | 136 | Sink::Store::fetchOne<Sink::ApplicationDomain::Mail>(query).syncThen<void, Sink::ApplicationDomain::Mail>([this, loadAsDraft](const Sink::ApplicationDomain::Mail &mail) { |
137 | m_existingMail = mail; | 137 | m_existingMail = mail; |
138 | const auto mailData = KMime::CRLFtoLF(mail.getMimeMessage()); | 138 | const auto mailData = KMime::CRLFtoLF(mail.getMimeMessage()); |
139 | if (!mailData.isEmpty()) { | 139 | if (!mailData.isEmpty()) { |
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index 14d3d5a7..7cf5ad5d 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -22,11 +22,14 @@ | |||
22 | #include <sink/store.h> | 22 | #include <sink/store.h> |
23 | #include <settings/settings.h> | 23 | #include <settings/settings.h> |
24 | 24 | ||
25 | using namespace Sink; | ||
26 | using namespace Sink::ApplicationDomain; | ||
27 | |||
25 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | 28 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() |
26 | { | 29 | { |
27 | Sink::Query query; | 30 | Query query; |
28 | query.liveQuery = true; | 31 | query.liveQuery = true; |
29 | query.requestedProperties << "name" << "icon" << "parent"; | 32 | query.request<Folder::Name>().request<Folder::Icon>().request<Folder::Parent>(); |
30 | query.parentProperty = "parent"; | 33 | query.parentProperty = "parent"; |
31 | runQuery(query); | 34 | runQuery(query); |
32 | } | 35 | } |
@@ -57,34 +60,32 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const | |||
57 | case Icon: | 60 | case Icon: |
58 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); | 61 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); |
59 | case Id: | 62 | case Id: |
60 | return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | 63 | return srcIdx.data(Store::DomainObjectBaseRole).value<ApplicationDomainType::Ptr>()->identifier(); |
61 | case DomainObject: | 64 | case DomainObject: |
62 | return srcIdx.data(Sink::Store::DomainObjectRole); | 65 | return srcIdx.data(Store::DomainObjectRole); |
63 | } | 66 | } |
64 | return QIdentityProxyModel::data(idx, role); | 67 | return QIdentityProxyModel::data(idx, role); |
65 | } | 68 | } |
66 | 69 | ||
67 | void FolderListModel::runQuery(const Sink::Query &query) | 70 | void FolderListModel::runQuery(const Query &query) |
68 | { | 71 | { |
69 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 72 | mModel = Store::loadModel<Folder>(query); |
70 | setSourceModel(mModel.data()); | 73 | setSourceModel(mModel.data()); |
71 | } | 74 | } |
72 | 75 | ||
73 | void FolderListModel::setAccountId(const QVariant &accountId) | 76 | void FolderListModel::setAccountId(const QVariant &accountId) |
74 | { | 77 | { |
75 | const auto account = accountId.toString().toUtf8(); | 78 | const auto account = accountId.toString().toUtf8(); |
76 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(account))) | 79 | |
77 | .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([this, account](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 80 | //Get all folders of an account |
78 | Sink::Query query; | 81 | auto query = Query(); |
79 | query.liveQuery = true; | 82 | query.resourceFilter<SinkResource::Account>(account); |
80 | query.requestedProperties << "name" << "icon" << "parent"; | 83 | query.liveQuery = true; |
81 | query.parentProperty = "parent"; | 84 | query.request<Folder::Name>() |
82 | for (const auto &r : resources) { | 85 | .request<Folder::Icon>() |
83 | qDebug() << "Found resources for account: " << r->identifier() << account; | 86 | .request<Folder::Parent>(); |
84 | query.resources << r->identifier(); | 87 | query.parentProperty = Folder::Parent::name; |
85 | } | 88 | runQuery(query); |
86 | runQuery(query); | ||
87 | }).exec(); | ||
88 | } | 89 | } |
89 | 90 | ||
90 | QVariant FolderListModel::accountId() const | 91 | QVariant FolderListModel::accountId() const |
diff --git a/framework/domain/identitiesmodel.cpp b/framework/domain/identitiesmodel.cpp index adb5d625..1958d2f5 100644 --- a/framework/domain/identitiesmodel.cpp +++ b/framework/domain/identitiesmodel.cpp | |||
@@ -83,7 +83,7 @@ void IdentitiesModel::runQuery(const Sink::Query &query) | |||
83 | setSourceModel(mModel.data()); | 83 | setSourceModel(mModel.data()); |
84 | 84 | ||
85 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkAccount>(Sink::Query()) | 85 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkAccount>(Sink::Query()) |
86 | .then<void, QList<Sink::ApplicationDomain::SinkAccount::Ptr> >([this](const QList<Sink::ApplicationDomain::SinkAccount::Ptr> &accounts) { | 86 | .syncThen<void, QList<Sink::ApplicationDomain::SinkAccount::Ptr> >([this](const QList<Sink::ApplicationDomain::SinkAccount::Ptr> &accounts) { |
87 | for (const auto &account : accounts) { | 87 | for (const auto &account : accounts) { |
88 | mAccountNames.insert(account->identifier(), account->getProperty("name").toString()); | 88 | mAccountNames.insert(account->identifier(), account->getProperty("name").toString()); |
89 | mAccountIcons.insert(account->identifier(), account->getProperty("icon").toString()); | 89 | mAccountIcons.insert(account->identifier(), account->getProperty("icon").toString()); |
diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index e3f555c4..9afb6408 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp | |||
@@ -107,7 +107,7 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) | |||
107 | } | 107 | } |
108 | Sink::Query query; | 108 | Sink::Query query; |
109 | query.liveQuery = true; | 109 | query.liveQuery = true; |
110 | query.resources << folder->resourceInstanceIdentifier(); | 110 | query.resourceFilter(folder->resourceInstanceIdentifier()); |
111 | query.sort<Mail::Date>(); | 111 | query.sort<Mail::Date>(); |
112 | query.limit = 100; | 112 | query.limit = 100; |
113 | query.request<Mail::Subject>(); | 113 | query.request<Mail::Subject>(); |
diff --git a/framework/domain/messageparser.cpp b/framework/domain/messageparser.cpp index 262be0b7..febd1363 100644 --- a/framework/domain/messageparser.cpp +++ b/framework/domain/messageparser.cpp | |||
@@ -101,7 +101,8 @@ QVariant PartModel::data(const QModelIndex &index, int role) const | |||
101 | case Type: | 101 | case Type: |
102 | return part->metaObject()->className(); | 102 | return part->metaObject()->className(); |
103 | case IsHidden: | 103 | case IsHidden: |
104 | return part->property("isHidden").toBool(); | 104 | return false; |
105 | //return part->property("isHidden").toBool(); | ||
105 | 106 | ||
106 | } | 107 | } |
107 | } | 108 | } |
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index cf348f39..ea798a73 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <QDir> | 23 | #include <QDir> |
24 | #include <QUrl> | 24 | #include <QUrl> |
25 | 25 | ||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
26 | AccountSettings::AccountSettings(QObject *parent) | 29 | AccountSettings::AccountSettings(QObject *parent) |
27 | : QObject(parent) | 30 | : QObject(parent) |
28 | { | 31 | { |
@@ -130,87 +133,83 @@ void AccountSettings::saveAccount() | |||
130 | { | 133 | { |
131 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; | 134 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; |
132 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 135 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
133 | Sink::ApplicationDomain::SinkAccount account(mAccountIdentifier); | 136 | SinkAccount account(mAccountIdentifier); |
134 | account.setProperty("type", "imap"); | 137 | account.setAccountType("imap"); |
135 | account.setProperty("name", mName); | 138 | account.setName(mName); |
136 | account.setProperty("icon", mIcon); | 139 | account.setIcon(mIcon); |
137 | Q_ASSERT(!account.identifier().isEmpty()); | 140 | Q_ASSERT(!account.identifier().isEmpty()); |
138 | Sink::Store::modify(account).then<void>([]() {}, | 141 | Store::modify(account) |
139 | [](int errorCode, const QString &errorMessage) { | 142 | .onError([](const KAsync::Error &error) { |
140 | qWarning() << "Error while creating account: " << errorMessage; | 143 | qWarning() << "Error while creating account: " << error.errorMessage;; |
141 | }) | 144 | }) |
142 | .exec(); | 145 | .exec(); |
143 | } | 146 | } |
144 | 147 | ||
145 | void AccountSettings::loadAccount() | 148 | void AccountSettings::loadAccount() |
146 | { | 149 | { |
147 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 150 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
148 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(mAccountIdentifier)) | 151 | Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier)) |
149 | .then<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | 152 | .syncThen<void, SinkAccount>([this](const SinkAccount &account) { |
150 | mIcon = account.getProperty("icon").toString(); | 153 | mIcon = account.getIcon(); |
151 | mName = account.getProperty("name").toString(); | 154 | mName = account.getName(); |
152 | emit changed(); | 155 | emit changed(); |
153 | }).exec(); | 156 | }).exec(); |
154 | } | 157 | } |
155 | 158 | ||
156 | void AccountSettings::loadImapResource() | 159 | void AccountSettings::loadImapResource() |
157 | { | 160 | { |
158 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 161 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
159 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 162 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
160 | mImapIdentifier = resource.identifier(); | 163 | mImapIdentifier = resource.identifier(); |
161 | mImapServer = resource.getProperty("server").toString(); | 164 | mImapServer = resource.getProperty("server").toString(); |
162 | mImapUsername = resource.getProperty("username").toString(); | 165 | mImapUsername = resource.getProperty("username").toString(); |
163 | mImapPassword = resource.getProperty("password").toString(); | 166 | mImapPassword = resource.getProperty("password").toString(); |
164 | emit imapResourceChanged(); | 167 | emit imapResourceChanged(); |
165 | }, | 168 | }).onError([](const KAsync::Error &error) { |
166 | [](int errorCode, const QString &errorMessage) { | 169 | qWarning() << "Failed to find the imap resource: " << error.errorMessage; |
167 | qWarning() << "Failed to find the imap resource: " << errorMessage; | ||
168 | }).exec(); | 170 | }).exec(); |
169 | } | 171 | } |
170 | 172 | ||
171 | void AccountSettings::loadMaildirResource() | 173 | void AccountSettings::loadMaildirResource() |
172 | { | 174 | { |
173 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 175 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
174 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 176 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
175 | mMaildirIdentifier = resource.identifier(); | 177 | mMaildirIdentifier = resource.identifier(); |
176 | auto path = resource.getProperty("path").toString(); | 178 | auto path = resource.getProperty("path").toString(); |
177 | if (mPath != path) { | 179 | if (mPath != path) { |
178 | mPath = path; | 180 | mPath = path; |
179 | emit pathChanged(); | 181 | emit pathChanged(); |
180 | } | 182 | } |
181 | }, | 183 | }).onError([](const KAsync::Error &error) { |
182 | [](int errorCode, const QString &errorMessage) { | 184 | qWarning() << "Failed to find the maildir resource: " << error.errorMessage; |
183 | qWarning() << "Failed to find the maildir resource: " << errorMessage; | ||
184 | }).exec(); | 185 | }).exec(); |
185 | } | 186 | } |
186 | 187 | ||
187 | void AccountSettings::loadMailtransportResource() | 188 | void AccountSettings::loadMailtransportResource() |
188 | { | 189 | { |
189 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport)) | 190 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport)) |
190 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 191 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
191 | mMailtransportIdentifier = resource.identifier(); | 192 | mMailtransportIdentifier = resource.identifier(); |
192 | mSmtpServer = resource.getProperty("server").toString(); | 193 | mSmtpServer = resource.getProperty("server").toString(); |
193 | mSmtpUsername = resource.getProperty("username").toString(); | 194 | mSmtpUsername = resource.getProperty("username").toString(); |
194 | mSmtpPassword = resource.getProperty("password").toString(); | 195 | mSmtpPassword = resource.getProperty("password").toString(); |
195 | emit smtpResourceChanged(); | 196 | emit smtpResourceChanged(); |
196 | }, | 197 | }).onError([](const KAsync::Error &error) { |
197 | [](int errorCode, const QString &errorMessage) { | 198 | qWarning() << "Failed to find the smtp resource: " << error.errorMessage; |
198 | qWarning() << "Failed to find the smtp resource: " << errorMessage; | ||
199 | }).exec(); | 199 | }).exec(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void AccountSettings::loadIdentity() | 202 | void AccountSettings::loadIdentity() |
203 | { | 203 | { |
204 | //FIXME this assumes that we only ever have one identity per account | 204 | //FIXME this assumes that we only ever have one identity per account |
205 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query::AccountFilter(mAccountIdentifier)) | 205 | Store::fetchOne<Identity>(Query().filter<Identity::Account>(mAccountIdentifier)) |
206 | .then<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { | 206 | .syncThen<void, Identity>([this](const Identity &identity) { |
207 | mIdentityIdentifier = identity.identifier(); | 207 | mIdentityIdentifier = identity.identifier(); |
208 | mUsername = identity.getProperty("username").toString(); | 208 | mUsername = identity.getProperty("username").toString(); |
209 | mEmailAddress = identity.getProperty("address").toString(); | 209 | mEmailAddress = identity.getProperty("address").toString(); |
210 | emit identityChanged(); | 210 | emit identityChanged(); |
211 | }, | 211 | }).onError([](const KAsync::Error &error) { |
212 | [](int errorCode, const QString &errorMessage) { | 212 | qWarning() << "Failed to find the identity resource: " << error.errorMessage; |
213 | qWarning() << "Failed to find the identity resource: " << errorMessage; | ||
214 | }).exec(); | 213 | }).exec(); |
215 | } | 214 | } |
216 | 215 | ||
@@ -220,25 +219,26 @@ template<typename ResourceType> | |||
220 | static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteArray &identifier, const std::map<QByteArray, QVariant> &properties) | 219 | static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteArray &identifier, const std::map<QByteArray, QVariant> &properties) |
221 | { | 220 | { |
222 | if (!identifier.isEmpty()) { | 221 | if (!identifier.isEmpty()) { |
223 | Sink::ApplicationDomain::SinkResource resource(identifier); | 222 | SinkResource resource(identifier); |
224 | for (const auto &pair : properties) { | 223 | for (const auto &pair : properties) { |
225 | resource.setProperty(pair.first, pair.second); | 224 | resource.setProperty(pair.first, pair.second); |
226 | } | 225 | } |
227 | Sink::Store::modify(resource).then<void>([](){}, [](int errorCode, const QString &errorMessage) { | 226 | Store::modify(resource) |
228 | qWarning() << "Error while modifying resource: " << errorMessage; | 227 | .onError([](const KAsync::Error &error) { |
229 | }) | 228 | qWarning() << "Error while modifying resource: " << error.errorMessage; |
230 | .exec(); | 229 | }) |
230 | .exec(); | ||
231 | } else { | 231 | } else { |
232 | auto resource = ResourceType::create(accountIdentifier); | 232 | auto resource = ResourceType::create(accountIdentifier); |
233 | auto newIdentifier = resource.identifier(); | 233 | auto newIdentifier = resource.identifier(); |
234 | for (const auto &pair : properties) { | 234 | for (const auto &pair : properties) { |
235 | resource.setProperty(pair.first, pair.second); | 235 | resource.setProperty(pair.first, pair.second); |
236 | } | 236 | } |
237 | Sink::Store::create(resource).template then<void>([]() {}, | 237 | Store::create(resource) |
238 | [](int errorCode, const QString &errorMessage) { | 238 | .onError([](const KAsync::Error &error) { |
239 | qWarning() << "Error while creating resource: " << errorMessage; | 239 | qWarning() << "Error while creating resource: " << error.errorMessage; |
240 | }) | 240 | }) |
241 | .exec(); | 241 | .exec(); |
242 | return newIdentifier; | 242 | return newIdentifier; |
243 | } | 243 | } |
244 | return identifier; | 244 | return identifier; |
@@ -246,7 +246,7 @@ static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteA | |||
246 | 246 | ||
247 | void AccountSettings::saveImapResource() | 247 | void AccountSettings::saveImapResource() |
248 | { | 248 | { |
249 | mImapIdentifier = saveResource<Sink::ApplicationDomain::ImapResource>(mAccountIdentifier, mImapIdentifier, { | 249 | mImapIdentifier = saveResource<ImapResource>(mAccountIdentifier, mImapIdentifier, { |
250 | {"server", mImapServer}, | 250 | {"server", mImapServer}, |
251 | {"username", mImapUsername}, | 251 | {"username", mImapUsername}, |
252 | {"password", mImapPassword}, | 252 | {"password", mImapPassword}, |
@@ -255,14 +255,14 @@ void AccountSettings::saveImapResource() | |||
255 | 255 | ||
256 | void AccountSettings::saveMaildirResource() | 256 | void AccountSettings::saveMaildirResource() |
257 | { | 257 | { |
258 | mMaildirIdentifier = saveResource<Sink::ApplicationDomain::MaildirResource>(mAccountIdentifier, mMaildirIdentifier, { | 258 | mMaildirIdentifier = saveResource<MaildirResource>(mAccountIdentifier, mMaildirIdentifier, { |
259 | {"path", mPath}, | 259 | {"path", mPath}, |
260 | }); | 260 | }); |
261 | } | 261 | } |
262 | 262 | ||
263 | void AccountSettings::saveMailtransportResource() | 263 | void AccountSettings::saveMailtransportResource() |
264 | { | 264 | { |
265 | mMailtransportIdentifier = saveResource<Sink::ApplicationDomain::MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, { | 265 | mMailtransportIdentifier = saveResource<MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, { |
266 | {"server", mSmtpServer}, | 266 | {"server", mSmtpServer}, |
267 | {"username", mSmtpUsername}, | 267 | {"username", mSmtpUsername}, |
268 | {"password", mSmtpPassword}, | 268 | {"password", mSmtpPassword}, |
@@ -272,22 +272,23 @@ void AccountSettings::saveMailtransportResource() | |||
272 | void AccountSettings::saveIdentity() | 272 | void AccountSettings::saveIdentity() |
273 | { | 273 | { |
274 | if (!mIdentityIdentifier.isEmpty()) { | 274 | if (!mIdentityIdentifier.isEmpty()) { |
275 | Sink::ApplicationDomain::Identity identity(mMailtransportIdentifier); | 275 | Identity identity(mMailtransportIdentifier); |
276 | identity.setProperty("username", mUsername); | 276 | identity.setProperty("username", mUsername); |
277 | identity.setProperty("address", mEmailAddress); | 277 | identity.setProperty("address", mEmailAddress); |
278 | Sink::Store::modify(identity).then<void>([](){}, [](int errorCode, const QString &errorMessage) { | 278 | Store::modify(identity) |
279 | qWarning() << "Error while modifying identity: " << errorMessage; | 279 | .onError([](const KAsync::Error &error) { |
280 | qWarning() << "Error while modifying identity: " << error.errorMessage; | ||
280 | }) | 281 | }) |
281 | .exec(); | 282 | .exec(); |
282 | } else { | 283 | } else { |
283 | auto identity = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::Identity>(); | 284 | auto identity = ApplicationDomainType::createEntity<Identity>(); |
284 | mIdentityIdentifier = identity.identifier(); | 285 | mIdentityIdentifier = identity.identifier(); |
285 | identity.setProperty("account", mAccountIdentifier); | 286 | identity.setAccount(mAccountIdentifier); |
286 | identity.setProperty("username", mUsername); | 287 | identity.setProperty("username", mUsername); |
287 | identity.setProperty("address", mEmailAddress); | 288 | identity.setProperty("address", mEmailAddress); |
288 | Sink::Store::create(identity).then<void>([]() {}, | 289 | Store::create(identity) |
289 | [](int errorCode, const QString &errorMessage) { | 290 | .onError([](const KAsync::Error &error) { |
290 | qWarning() << "Error while creating identity: " << errorMessage; | 291 | qWarning() << "Error while creating identity: " << error.errorMessage; |
291 | }) | 292 | }) |
292 | .exec(); | 293 | .exec(); |
293 | } | 294 | } |
@@ -298,10 +299,10 @@ void AccountSettings::removeResource(const QByteArray &identifier) | |||
298 | if (identifier.isEmpty()) { | 299 | if (identifier.isEmpty()) { |
299 | qWarning() << "We're missing an identifier"; | 300 | qWarning() << "We're missing an identifier"; |
300 | } else { | 301 | } else { |
301 | Sink::ApplicationDomain::SinkResource resource("", identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 302 | SinkResource resource(identifier); |
302 | Sink::Store::remove(resource).template then<void>([]() {}, | 303 | Store::remove(resource) |
303 | [](int errorCode, const QString &errorMessage) { | 304 | .onError([](const KAsync::Error &error) { |
304 | qWarning() << "Error while removing resource: " << errorMessage; | 305 | qWarning() << "Error while removing resource: " << error.errorMessage; |
305 | }) | 306 | }) |
306 | .exec(); | 307 | .exec(); |
307 | } | 308 | } |
@@ -312,10 +313,10 @@ void AccountSettings::removeAccount() | |||
312 | if (mAccountIdentifier.isEmpty()) { | 313 | if (mAccountIdentifier.isEmpty()) { |
313 | qWarning() << "We're missing an identifier"; | 314 | qWarning() << "We're missing an identifier"; |
314 | } else { | 315 | } else { |
315 | Sink::ApplicationDomain::SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 316 | SinkAccount account(mAccountIdentifier); |
316 | Sink::Store::remove(account).then<void>([]() {}, | 317 | Store::remove(account) |
317 | [](int errorCode, const QString &errorMessage) { | 318 | .onError([](const KAsync::Error &error) { |
318 | qWarning() << "Error while removing account: " << errorMessage; | 319 | qWarning() << "Error while removing account: " << error.errorMessage; |
319 | }) | 320 | }) |
320 | .exec(); | 321 | .exec(); |
321 | } | 322 | } |
@@ -326,10 +327,10 @@ void AccountSettings::removeIdentity() | |||
326 | if (mIdentityIdentifier.isEmpty()) { | 327 | if (mIdentityIdentifier.isEmpty()) { |
327 | qWarning() << "We're missing an identifier"; | 328 | qWarning() << "We're missing an identifier"; |
328 | } else { | 329 | } else { |
329 | Sink::ApplicationDomain::Identity identity("", mIdentityIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 330 | Identity identity(mIdentityIdentifier); |
330 | Sink::Store::remove(identity).then<void>([]() {}, | 331 | Store::remove(identity) |
331 | [](int errorCode, const QString &errorMessage) { | 332 | .onError([](const KAsync::Error &error) { |
332 | qWarning() << "Error while removing identity: " << errorMessage; | 333 | qWarning() << "Error while removing identity: " << error.errorMessage; |
333 | }) | 334 | }) |
334 | .exec(); | 335 | .exec(); |
335 | } | 336 | } |
diff --git a/framework/settings/CMakeLists.txt b/framework/settings/CMakeLists.txt index 9d876850..bf456138 100644 --- a/framework/settings/CMakeLists.txt +++ b/framework/settings/CMakeLists.txt | |||
@@ -1,8 +1,5 @@ | |||
1 | set(settingsplugin_SRCS | 1 | set(settingsplugin_SRCS |
2 | settingsplugin.cpp | 2 | settingsplugin.cpp |
3 | # maildir_resource.cpp | ||
4 | # resourcelistmodel.cpp | ||
5 | # resourcescontroller.cpp | ||
6 | settings.cpp | 3 | settings.cpp |
7 | ) | 4 | ) |
8 | 5 | ||
diff --git a/framework/settings/maildir_resource.cpp b/framework/settings/maildir_resource.cpp deleted file mode 100644 index cb670295..00000000 --- a/framework/settings/maildir_resource.cpp +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #include "maildir_resource.h" | ||
2 | |||
3 | MaildirResouceController::MaildirResouceController(QObject *parent) : QObject(parent) | ||
4 | { | ||
5 | |||
6 | } | ||
7 | |||
8 | QString MaildirResouceController::name() const | ||
9 | { | ||
10 | return m_name; | ||
11 | } | ||
12 | |||
13 | void MaildirResouceController::setName(const QString &name) | ||
14 | { | ||
15 | if(m_name != name) { | ||
16 | m_name = name; | ||
17 | emit nameChanged(); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | QUrl MaildirResouceController::folderUrl() const | ||
22 | { | ||
23 | return m_folderUrl; | ||
24 | } | ||
25 | |||
26 | void MaildirResouceController::setFolderUrl(const QUrl &url) | ||
27 | { | ||
28 | if(m_folderUrl != url) { | ||
29 | m_folderUrl = url; | ||
30 | emit folderUrlChanged(); | ||
31 | } | ||
32 | } | ||
diff --git a/framework/settings/maildir_resource.h b/framework/settings/maildir_resource.h deleted file mode 100644 index 1db1a1f8..00000000 --- a/framework/settings/maildir_resource.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <QObject> | ||
4 | #include <QString> | ||
5 | #include <QUrl> | ||
6 | |||
7 | class MaildirResouceController : public QObject | ||
8 | { | ||
9 | Q_OBJECT | ||
10 | Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged) | ||
11 | Q_PROPERTY (QUrl folderUrl READ folderUrl WRITE setFolderUrl NOTIFY folderUrlChanged); | ||
12 | |||
13 | public: | ||
14 | explicit MaildirResouceController(QObject *parent = Q_NULLPTR); | ||
15 | |||
16 | QString name() const; | ||
17 | void setName(const QString &name); | ||
18 | |||
19 | QUrl folderUrl() const; | ||
20 | void setFolderUrl(const QUrl &url); | ||
21 | |||
22 | signals: | ||
23 | void nameChanged(); | ||
24 | void folderUrlChanged(); | ||
25 | |||
26 | private: | ||
27 | QString m_name; | ||
28 | QUrl m_folderUrl; | ||
29 | }; \ No newline at end of file | ||
diff --git a/framework/settings/resourcelistmodel.cpp b/framework/settings/resourcelistmodel.cpp deleted file mode 100644 index 27063ebc..00000000 --- a/framework/settings/resourcelistmodel.cpp +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | #include "resourcelistmodel.h" | ||
2 | |||
3 | #include <sink/store.h> | ||
4 | |||
5 | ResourceListModel::ResourceListModel(QObject *parent) : QIdentityProxyModel() | ||
6 | { | ||
7 | Sink::Query query; | ||
8 | query.syncOnDemand = false; | ||
9 | query.processAll = false; | ||
10 | query.liveQuery = true; | ||
11 | query.requestedProperties << "type"; | ||
12 | m_model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); | ||
13 | } | ||
14 | |||
15 | ResourceListModel::~ResourceListModel() | ||
16 | { | ||
17 | |||
18 | } | ||
19 | |||
20 | QHash< int, QByteArray > ResourceListModel::roleNames() const | ||
21 | { | ||
22 | QHash<int, QByteArray> roles; | ||
23 | |||
24 | roles[Type] = "type"; | ||
25 | roles[Id] = "id"; | ||
26 | |||
27 | return roles; | ||
28 | } | ||
29 | |||
30 | QVariant ResourceListModel::data(const QModelIndex& index, int role) const | ||
31 | { | ||
32 | auto srcIdx = mapToSource(index); | ||
33 | switch (role) { | ||
34 | case Id: | ||
35 | return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | ||
36 | case Type: | ||
37 | return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); | ||
38 | } | ||
39 | |||
40 | return QIdentityProxyModel::data(index, role); | ||
41 | } | ||
42 | |||
diff --git a/framework/settings/resourcelistmodel.h b/framework/settings/resourcelistmodel.h deleted file mode 100644 index de1b5a51..00000000 --- a/framework/settings/resourcelistmodel.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <QIdentityProxyModel> | ||
4 | #include <QSharedPointer> | ||
5 | #include <QStringList> | ||
6 | |||
7 | class ResourceListModel : public QIdentityProxyModel | ||
8 | { | ||
9 | Q_OBJECT | ||
10 | |||
11 | public: | ||
12 | ResourceListModel(QObject *parent = Q_NULLPTR); | ||
13 | ~ResourceListModel(); | ||
14 | |||
15 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | ||
16 | |||
17 | enum Roles { | ||
18 | Id = Qt::UserRole + 1, | ||
19 | Type | ||
20 | }; | ||
21 | |||
22 | QHash<int, QByteArray> roleNames() const; | ||
23 | |||
24 | private: | ||
25 | QSharedPointer<QAbstractItemModel> m_model; | ||
26 | }; | ||
diff --git a/framework/settings/resourcescontroller.cpp b/framework/settings/resourcescontroller.cpp deleted file mode 100644 index 03016b67..00000000 --- a/framework/settings/resourcescontroller.cpp +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | #include "resourcescontroller.h" | ||
2 | |||
3 | ResourcesController::ResourcesController(QObject *parent) : QObject(parent), m_model(new ResourceListModel()) | ||
4 | { | ||
5 | |||
6 | } | ||
7 | |||
8 | |||
9 | ResourceListModel* ResourcesController::model() const | ||
10 | { | ||
11 | return m_model.data(); | ||
12 | } | ||
diff --git a/framework/settings/resourcescontroller.h b/framework/settings/resourcescontroller.h deleted file mode 100644 index 0e2e89de..00000000 --- a/framework/settings/resourcescontroller.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "resourcelistmodel.h" | ||
4 | |||
5 | #include <QObject> | ||
6 | #include <QScopedPointer> | ||
7 | |||
8 | class ResourcesController : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | Q_PROPERTY (ResourceListModel *model READ model CONSTANT) | ||
12 | |||
13 | public: | ||
14 | explicit ResourcesController(QObject *parent = Q_NULLPTR); | ||
15 | |||
16 | ResourceListModel *model() const; | ||
17 | |||
18 | private: | ||
19 | QScopedPointer<ResourceListModel> m_model; | ||
20 | }; | ||
diff --git a/framework/theme/CMakeLists.txt b/framework/theme/CMakeLists.txt deleted file mode 100644 index 319e3d39..00000000 --- a/framework/theme/CMakeLists.txt +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | set(themeplugin_SRCS | ||
2 | themeplugin.cpp | ||
3 | colorpalette.cpp | ||
4 | unit.cpp | ||
5 | ) | ||
6 | |||
7 | add_library(themeplugin SHARED ${themeplugin_SRCS}) | ||
8 | |||
9 | qt5_use_modules(themeplugin Core Quick Qml) | ||
10 | |||
11 | target_link_libraries(themeplugin) | ||
12 | |||
13 | install(TARGETS themeplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/theme) | ||
14 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/theme) | ||
diff --git a/framework/theme/colorpalette.cpp b/framework/theme/colorpalette.cpp deleted file mode 100644 index a321a292..00000000 --- a/framework/theme/colorpalette.cpp +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include "colorpalette.h" | ||
20 | |||
21 | ColorPalette::ColorPalette(QObject *parent) : QObject(parent), m_background("#fcfcfc"), m_selected("#3daee9"), m_read("#232629"), m_border("#232629") | ||
22 | { | ||
23 | |||
24 | } | ||
25 | |||
26 | QString ColorPalette::background() const | ||
27 | { | ||
28 | return m_background; | ||
29 | } | ||
30 | |||
31 | QString ColorPalette::read() const | ||
32 | { | ||
33 | return m_read; | ||
34 | } | ||
35 | |||
36 | QString ColorPalette::selected() const | ||
37 | { | ||
38 | return m_selected; | ||
39 | } | ||
40 | |||
41 | QString ColorPalette::border() const | ||
42 | { | ||
43 | return m_border; | ||
44 | } | ||
45 | |||
diff --git a/framework/theme/colorpalette.h b/framework/theme/colorpalette.h deleted file mode 100644 index a06783f3..00000000 --- a/framework/theme/colorpalette.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <QObject> | ||
20 | #include <QString> | ||
21 | |||
22 | class ColorPalette : public QObject | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | |||
26 | Q_PROPERTY (QString background READ background NOTIFY themeChanged) | ||
27 | Q_PROPERTY (QString selected READ background NOTIFY themeChanged) | ||
28 | Q_PROPERTY (QString read READ read NOTIFY themeChanged) | ||
29 | Q_PROPERTY (QString border READ border NOTIFY themeChanged) | ||
30 | |||
31 | public: | ||
32 | explicit ColorPalette(QObject *parent = Q_NULLPTR); | ||
33 | |||
34 | QString background() const; | ||
35 | QString selected() const; | ||
36 | QString read() const; | ||
37 | QString border() const; | ||
38 | |||
39 | signals: | ||
40 | void themeChanged(); | ||
41 | |||
42 | private: | ||
43 | QString m_background; | ||
44 | QString m_selected; | ||
45 | QString m_read; | ||
46 | QString m_border; | ||
47 | }; | ||
diff --git a/framework/theme/qmldir b/framework/theme/qmldir deleted file mode 100644 index 489a71ca..00000000 --- a/framework/theme/qmldir +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | module org.kube.framework.theme | ||
2 | |||
3 | plugin themeplugin | ||
diff --git a/framework/theme/themeplugin.cpp b/framework/theme/themeplugin.cpp deleted file mode 100644 index ad9d0e1b..00000000 --- a/framework/theme/themeplugin.cpp +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include "themeplugin.h" | ||
20 | |||
21 | #include <QtQml> | ||
22 | #include <QQmlEngine> | ||
23 | |||
24 | #include "colorpalette.h" | ||
25 | #include "unit.h" | ||
26 | |||
27 | static QObject *colorpaletteInstace(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
28 | { | ||
29 | Q_UNUSED(engine); | ||
30 | Q_UNUSED(scriptEngine); | ||
31 | |||
32 | return new ColorPalette; | ||
33 | } | ||
34 | |||
35 | static QObject *unitInstace(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
36 | { | ||
37 | Q_UNUSED(engine); | ||
38 | Q_UNUSED(scriptEngine); | ||
39 | |||
40 | return new Unit; | ||
41 | } | ||
42 | |||
43 | void ThemePlugin::registerTypes (const char *uri) | ||
44 | { | ||
45 | Q_ASSERT(uri == QLatin1String("org.kube.framework.theme")); | ||
46 | |||
47 | qmlRegisterSingletonType<ColorPalette>(uri, 1, 0, "ColorPalette", colorpaletteInstace); | ||
48 | qmlRegisterSingletonType<Unit>(uri, 1, 0, "Unit", unitInstace); | ||
49 | |||
50 | } | ||
diff --git a/framework/theme/themeplugin.h b/framework/theme/themeplugin.h deleted file mode 100644 index d8ae43c1..00000000 --- a/framework/theme/themeplugin.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #pragma once | ||
20 | |||
21 | #include <QQmlEngine> | ||
22 | #include <QQmlExtensionPlugin> | ||
23 | |||
24 | class ThemePlugin : public QQmlExtensionPlugin | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
28 | |||
29 | public: | ||
30 | virtual void registerTypes(const char *uri); | ||
31 | }; \ No newline at end of file | ||
diff --git a/framework/theme/unit.cpp b/framework/theme/unit.cpp deleted file mode 100644 index 1f3803cb..00000000 --- a/framework/theme/unit.cpp +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include "unit.h" | ||
20 | |||
21 | Unit::Unit(QObject *parent) : QObject(parent), m_size(5) | ||
22 | { | ||
23 | |||
24 | } | ||
25 | |||
26 | int Unit::size() const | ||
27 | { | ||
28 | return m_size; | ||
29 | } \ No newline at end of file | ||
diff --git a/framework/theme/unit.h b/framework/theme/unit.h deleted file mode 100644 index bd9b58f0..00000000 --- a/framework/theme/unit.h +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <QObject> | ||
20 | |||
21 | |||
22 | class Unit : public QObject | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | Q_PROPERTY (int size READ size NOTIFY unitChanged) | ||
26 | |||
27 | |||
28 | public: | ||
29 | explicit Unit(QObject *parent = Q_NULLPTR); | ||
30 | |||
31 | int size() const; | ||
32 | |||
33 | signals: | ||
34 | void unitChanged(); | ||
35 | |||
36 | private: | ||
37 | int m_size; | ||
38 | }; | ||