From 4b1798f0cdf87361869e7cf2b341acacd056c410 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 5 Apr 2017 15:04:00 +0200 Subject: Moved cpp code into src directory --- framework/domain/mailcontroller.cpp | 125 ------------------------------------ 1 file changed, 125 deletions(-) delete mode 100644 framework/domain/mailcontroller.cpp (limited to 'framework/domain/mailcontroller.cpp') diff --git a/framework/domain/mailcontroller.cpp b/framework/domain/mailcontroller.cpp deleted file mode 100644 index b912567a..00000000 --- a/framework/domain/mailcontroller.cpp +++ /dev/null @@ -1,125 +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_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); - updateActions(); -} - -void MailController::runModification(const std::function &f) -{ - if (auto mail = getMail()) { - f(*mail); - run(Store::modify(*mail)); - } else if (auto mail = getThreadLeader()) { - f(*mail); - run(Store::modify(Sink::StandardQueries::completeThread(*mail), *mail)); - } -} - -void MailController::updateActions() -{ - auto mail = getMail(); - if (!mail) { - mail= getThreadLeader(); - } - if (mail) { - action_moveToTrash->setEnabled(!mail->getTrash()); - action_restoreFromTrash->setEnabled(mail->getTrash()); - action_markAsRead->setEnabled(mail->getUnread()); - action_markAsUnread->setEnabled(!mail->getUnread()); - } -} - -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::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(); - }); -} - -- cgit v1.2.3