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/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 -------- 6 files changed, 388 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/src/domain') 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(); -}; -- cgit v1.2.3