From b3223155b178427354b44f05167d0afba0926cbd Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 24 Apr 2017 21:51:24 +0200 Subject: Another bunch of controllers gone --- framework/qml/AccountSwitcher.qml | 8 +- framework/qml/Messages.qml | 1 + framework/qml/Outbox.qml | 18 ++-- framework/src/CMakeLists.txt | 5 +- framework/src/domain/foldercontroller.cpp | 62 ------------- framework/src/domain/foldercontroller.h | 36 -------- framework/src/domain/mailcontroller.cpp | 142 ------------------------------ framework/src/domain/mailcontroller.h | 51 ----------- framework/src/domain/outboxcontroller.cpp | 60 ------------- framework/src/domain/outboxcontroller.h | 37 -------- framework/src/frameworkplugin.cpp | 6 -- framework/src/sinkfabric.cpp | 15 ++++ 12 files changed, 23 insertions(+), 418 deletions(-) delete mode 100644 framework/src/domain/foldercontroller.cpp delete mode 100644 framework/src/domain/foldercontroller.h delete mode 100644 framework/src/domain/mailcontroller.cpp delete mode 100644 framework/src/domain/mailcontroller.h delete mode 100644 framework/src/domain/outboxcontroller.cpp delete mode 100644 framework/src/domain/outboxcontroller.h (limited to 'framework') diff --git a/framework/qml/AccountSwitcher.qml b/framework/qml/AccountSwitcher.qml index 7a1e7592..a8151712 100644 --- a/framework/qml/AccountSwitcher.qml +++ b/framework/qml/AccountSwitcher.qml @@ -36,11 +36,6 @@ Controls.ToolButton { width: parent.width iconName: Kube.Icons.menu_inverted - Kube.FolderController { - id: folderController - accountId: accountId - } - Kube.AccountsModel { id: accountsModel } @@ -74,9 +69,8 @@ Controls.ToolButton { //iconName: "view-refresh" text: "Sync" - enabled: folderController.synchronizeAction.enabled onClicked: { - folderController.synchronizeAction.execute() + Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": accountSwitcher.accountId}) popup.close() } } diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml index 1b384bfa..26a3ea3e 100644 --- a/framework/qml/Messages.qml +++ b/framework/qml/Messages.qml @@ -32,6 +32,7 @@ Item { property string markAsUnread: "markAsUnread" property string toggleImportant: "toggleImportant" property string moveToFolder: "moveToFolder" + property string moveToDrafts: "moveToDrafts" property string notification: "notification" property string search: "search" diff --git a/framework/qml/Outbox.qml b/framework/qml/Outbox.qml index fc960667..46368294 100644 --- a/framework/qml/Outbox.qml +++ b/framework/qml/Outbox.qml @@ -30,9 +30,6 @@ Controls.ToolButton { visible: outboxModel.count > 0 - Kube.OutboxController { - id: outboxController - } Kube.OutboxModel { id: outboxModel } @@ -134,10 +131,7 @@ Controls.ToolButton { iconName: Kube.Icons.moveToTrash text: qsTr("Delete Mail") tooltip: text - onClicked: { - outboxController.mail = model.domainObject - outboxController.moveToTrashAction.execute() - } + onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.domainObject}) } Controls.ToolButton { @@ -145,8 +139,9 @@ Controls.ToolButton { text: qsTr("Edit") tooltip: text onClicked: { - outboxController.mail = model.domainObject - outboxController.editAction.execute() + Kube.Fabric.postMessage(Kube.Messages.moveToDrafts, {"mail": model.domainObject}) + //TODO stage upon completion + //Kube.Fabric.postMessage(Kube.Messages.edit, {"mail": model.domainObject}) } } } @@ -167,10 +162,7 @@ Controls.ToolButton { visible: listView.count != 0 text: qsTr("Send now") - enabled: outboxController.sendOutboxAction.enabled - onClicked: { - outboxController.sendOutboxAction.execute() - } + onClicked: Kube.Fabric.postMessage(Kube.Messages.sendOutbox, {}) } Kube.Label { diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 73e489b1..8dc844cc 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt @@ -39,12 +39,9 @@ set(SRCS domain/settings/accountsettings.cpp domain/selector.cpp domain/completer.cpp - domain/controller.cpp - domain/outboxcontroller.cpp - domain/mailcontroller.cpp - domain/foldercontroller.cpp domain/mouseproxy.cpp domain/contactcontroller.cpp + domain/controller.cpp domain/peoplemodel.cpp accounts/accountfactory.cpp accounts/accountsmodel.cpp diff --git a/framework/src/domain/foldercontroller.cpp b/framework/src/domain/foldercontroller.cpp deleted file mode 100644 index 3c10f773..00000000 --- a/framework/src/domain/foldercontroller.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "foldercontroller.h" - -#include -#include - -SINK_DEBUG_AREA("foldercontroller"); - -using namespace Sink; -using namespace Sink::ApplicationDomain; - -FolderController::FolderController() - : Kube::Controller(), - action_synchronize{new Kube::ControllerAction{this, &FolderController::synchronize}}, - action_moveToFolder{new Kube::ControllerAction{this, &FolderController::moveToFolder}} -{ -} - -void FolderController::synchronize() -{ - auto job = [&] { - auto accountId = getAccountId(); - if (auto folder = getFolder()) { - SinkLog() << "Synchronizing folder " << folder->resourceInstanceIdentifier() << folder->identifier(); - auto scope = SyncScope().resourceFilter(folder->resourceInstanceIdentifier()).filter(QVariant::fromValue(folder->identifier())); - scope.setType(); - return Store::synchronize(scope); - } else if (!accountId.isEmpty()) { - return Store::synchronize(SyncScope{}.resourceFilter(accountId)); - } else { - SinkLog() << "Synchronizing all"; - return Store::synchronize(SyncScope()); - } - }(); - run(job); -} - -void FolderController::moveToFolder() -{ - auto mail = getMail(); - auto targetFolder = getFolder(); - mail->setFolder(*targetFolder); - SinkLog() << "Moving to folder " << mail->identifier() << targetFolder->identifier(); - run(Store::modify(*mail)); -} diff --git a/framework/src/domain/foldercontroller.h b/framework/src/domain/foldercontroller.h deleted file mode 100644 index c0815546..00000000 --- a/framework/src/domain/foldercontroller.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#pragma once - -#include -#include "controller.h" -#include "sink/applicationdomaintype.h" - -class FolderController : public Kube::Controller -{ - Q_OBJECT - KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, Folder, folder) - KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) - KUBE_CONTROLLER_PROPERTY(QByteArray, AccountId, accountId) - KUBE_CONTROLLER_ACTION(synchronize) - KUBE_CONTROLLER_ACTION(moveToFolder) - -public: - explicit FolderController(); -}; diff --git a/framework/src/domain/mailcontroller.cpp b/framework/src/domain/mailcontroller.cpp deleted file mode 100644 index ea0fe690..00000000 --- a/framework/src/domain/mailcontroller.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "mailcontroller.h" - -#include -#include -#include - -SINK_DEBUG_AREA("mailcontroller"); - -using namespace Sink; -using namespace Sink::ApplicationDomain; - -MailController::MailController() - : Kube::Controller(), - action_markAsRead{new Kube::ControllerAction{this, &MailController::markAsRead}}, - action_markAsUnread{new Kube::ControllerAction{this, &MailController::markAsUnread}}, - action_markAsImportant{new Kube::ControllerAction{this, &MailController::markAsImportant}}, - action_toggleImportant{new Kube::ControllerAction{this, &MailController::toggleImportant}}, - action_moveToTrash{new Kube::ControllerAction{this, &MailController::moveToTrash}}, - action_restoreFromTrash{new Kube::ControllerAction{this, &MailController::restoreFromTrash}}, - action_remove{new Kube::ControllerAction{this, &MailController::remove}}, - action_moveToFolder{new Kube::ControllerAction{this, &MailController::moveToFolder}} -{ - QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); - QObject::connect(this, &MailController::importantChanged, &MailController::updateActions); - QObject::connect(this, &MailController::draftChanged, &MailController::updateActions); - QObject::connect(this, &MailController::trashChanged, &MailController::updateActions); - QObject::connect(this, &MailController::unreadChanged, &MailController::updateActions); - updateActions(); -} - -void MailController::runModification(const std::function &f) -{ - if (auto mail = getMail()) { - f(*mail); - if (getOperateOnThreads()) { - run(Store::modify(Sink::StandardQueries::completeThread(*mail), *mail)); - } else { - run(Store::modify(*mail)); - } - } -} - -void MailController::updateActions() -{ - if (auto mail = getMail()) { - action_moveToTrash->setEnabled(!getTrash()); - action_restoreFromTrash->setEnabled(getTrash()); - action_markAsRead->setEnabled(getUnread()); - action_markAsUnread->setEnabled(!getUnread()); - action_markAsImportant->setEnabled(!getImportant()); - } else { - action_moveToTrash->setEnabled(false); - action_restoreFromTrash->setEnabled(false); - action_markAsRead->setEnabled(false); - action_markAsUnread->setEnabled(false); - action_markAsImportant->setEnabled(false); - } -} - -void MailController::markAsRead() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setUnread(false); - SinkLog() << "Mark as read " << mail.identifier(); - }); -} - -void MailController::markAsUnread() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setUnread(true); - SinkLog() << "Mark as unread " << mail.identifier(); - }); -} - -void MailController::markAsImportant() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setImportant(true); - SinkLog() << "Mark as important " << mail.identifier(); - }); -} - -void MailController::toggleImportant() -{ - runModification([this] (ApplicationDomain::Mail &mail) { - mail.setImportant(!getImportant()); - SinkLog() << "Toggle important " << mail.identifier() << mail.getImportant(); - }); -} - -void MailController::moveToTrash() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setTrash(true); - SinkLog() << "Move to trash " << mail.identifier(); - }); -} - -void MailController::restoreFromTrash() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setTrash(false); - SinkLog() << "Restore from trash " << mail.identifier(); - }); -} - -void MailController::remove() -{ - runModification([] (ApplicationDomain::Mail &mail) { - mail.setTrash(true); - SinkLog() << "Remove " << mail.identifier(); - }); -} - -void MailController::moveToFolder() -{ - runModification([&] (ApplicationDomain::Mail &mail) { - auto targetFolder = getTargetFolder(); - mail.setFolder(*targetFolder); - SinkLog() << "Moving to folder " << mail.identifier() << targetFolder->identifier(); - }); -} - diff --git a/framework/src/domain/mailcontroller.h b/framework/src/domain/mailcontroller.h deleted file mode 100644 index 0bc000f1..00000000 --- a/framework/src/domain/mailcontroller.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#pragma once - -#include -#include "controller.h" -#include "sink/applicationdomaintype.h" - -class MailController : public Kube::Controller -{ - Q_OBJECT - //Use this instead of mail property to get overall status of thread. - KUBE_CONTROLLER_PROPERTY(bool, Unread, unread) - KUBE_CONTROLLER_PROPERTY(bool, Important, important) - KUBE_CONTROLLER_PROPERTY(bool, Trash, trash) - KUBE_CONTROLLER_PROPERTY(bool, Draft, draft) - - KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) - KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, TargetFolder, targetFolder) - KUBE_CONTROLLER_PROPERTY(bool, OperateOnThreads, operateOnThreads) - KUBE_CONTROLLER_ACTION(markAsRead) - KUBE_CONTROLLER_ACTION(markAsUnread) - KUBE_CONTROLLER_ACTION(markAsImportant) - KUBE_CONTROLLER_ACTION(toggleImportant) - KUBE_CONTROLLER_ACTION(moveToTrash) - KUBE_CONTROLLER_ACTION(restoreFromTrash) - KUBE_CONTROLLER_ACTION(remove) - KUBE_CONTROLLER_ACTION(moveToFolder) - -public: - explicit MailController(); -private slots: - void updateActions(); - void runModification(const std::function &f); -}; diff --git a/framework/src/domain/outboxcontroller.cpp b/framework/src/domain/outboxcontroller.cpp deleted file mode 100644 index 51b481fe..00000000 --- a/framework/src/domain/outboxcontroller.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "outboxcontroller.h" - -#include -#include - -using namespace Sink; -using namespace Sink::ApplicationDomain; - -OutboxController::OutboxController() - : Kube::Controller(), - action_sendOutbox{new Kube::ControllerAction{this, &OutboxController::sendOutbox}}, - action_edit{new Kube::ControllerAction{this, &OutboxController::edit}}, - action_moveToTrash{new Kube::ControllerAction{this, &OutboxController::moveToTrash}} -{ -} - -void OutboxController::sendOutbox() -{ - Query query; - query.containsFilter(ResourceCapabilities::Mail::transport); - auto job = Store::fetchAll(query) - .each([=](const SinkResource::Ptr &resource) -> KAsync::Job { - return Store::synchronize(SyncScope{}.resourceFilter(resource->identifier())); - }); - run(job); -} - -void OutboxController::moveToTrash() -{ - auto mail = getMail(); - mail->setTrash(true); - run(Store::modify(*mail)); -} - -void OutboxController::edit() -{ - auto mail = getMail(); - mail->setDraft(true); - run(Store::modify(*mail)); - //TODO trigger edit when item has been moved -} - diff --git a/framework/src/domain/outboxcontroller.h b/framework/src/domain/outboxcontroller.h deleted file mode 100644 index 24fe9584..00000000 --- a/framework/src/domain/outboxcontroller.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#pragma once - -#include -#include "controller.h" -#include "sink/applicationdomaintype.h" - -class OutboxController : public Kube::Controller -{ - Q_OBJECT - - KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) - KUBE_CONTROLLER_ACTION(sendOutbox) - //Trigger a move to drafts and then trigger an edit - KUBE_CONTROLLER_ACTION(edit) - KUBE_CONTROLLER_ACTION(moveToTrash) - -public: - explicit OutboxController(); -}; diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp index 2f77bef4..294fbbc7 100644 --- a/framework/src/frameworkplugin.cpp +++ b/framework/src/frameworkplugin.cpp @@ -26,9 +26,6 @@ #include "domain/messageparser.h" #include "domain/retriever.h" #include "domain/outboxmodel.h" -#include "domain/outboxcontroller.h" -#include "domain/mailcontroller.h" -#include "domain/foldercontroller.h" #include "domain/mouseproxy.h" #include "domain/contactcontroller.h" #include "domain/peoplemodel.h" @@ -57,10 +54,7 @@ void FrameworkPlugin::registerTypes (const char *uri) qmlRegisterType(uri, 1, 0, "ComposerController"); qmlRegisterType(uri, 1, 0, "MessageParser"); qmlRegisterType(uri, 1, 0, "Retriever"); - qmlRegisterType(uri, 1, 0, "OutboxController"); qmlRegisterType(uri, 1, 0, "OutboxModel"); - qmlRegisterType(uri, 1, 0, "MailController"); - qmlRegisterType(uri, 1, 0, "FolderController"); qmlRegisterType(uri, 1, 0, "MouseProxy"); qmlRegisterType(uri, 1, 0,"ContactController"); qmlRegisterType(uri, 1, 0,"PeopleModel"); diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp index 68a75a86..5e209526 100644 --- a/framework/src/sinkfabric.cpp +++ b/framework/src/sinkfabric.cpp @@ -53,6 +53,15 @@ public: Store::synchronize(SyncScope()).exec(); } } + if (id == "sendOutbox"/*Kube::Messages::synchronize*/) { + Query query; + query.containsFilter(ResourceCapabilities::Mail::transport); + auto job = Store::fetchAll(query) + .each([=](const SinkResource::Ptr &resource) -> KAsync::Job { + return Store::synchronize(SyncScope{}.resourceFilter(resource->identifier())); + }); + job.exec(); + } if (id == "markAsRead"/*Kube::Messages::synchronize*/) { if (auto mail = message["mail"].value()) { mail->setUnread(false); @@ -77,6 +86,12 @@ public: Store::modify(*mail).exec(); } } + if (id == "moveToDrafts"/*Kube::Messages::synchronize*/) { + if (auto mail = message["mail"].value()) { + mail->setDraft(true); + Store::modify(*mail).exec(); + } + } if (id == "moveToFolder"/*Kube::Messages::synchronize*/) { if (auto mail = message["mail"].value()) { auto folder = message["folder"].value(); -- cgit v1.2.3