diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/domain/mailcontroller.cpp | 30 | ||||
-rw-r--r-- | framework/domain/mailcontroller.h | 2 |
2 files changed, 26 insertions, 6 deletions
diff --git a/framework/domain/mailcontroller.cpp b/framework/domain/mailcontroller.cpp index 3d29ba22..0163d41e 100644 --- a/framework/domain/mailcontroller.cpp +++ b/framework/domain/mailcontroller.cpp | |||
@@ -23,14 +23,21 @@ | |||
23 | 23 | ||
24 | SINK_DEBUG_AREA("mailcontroller"); | 24 | SINK_DEBUG_AREA("mailcontroller"); |
25 | 25 | ||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
26 | MailController::MailController() | 29 | MailController::MailController() |
27 | : Kube::Controller(), | 30 | : Kube::Controller(), |
28 | action_markAsRead{new Kube::ControllerAction}, | 31 | action_markAsRead{new Kube::ControllerAction}, |
32 | action_markAsImportant{new Kube::ControllerAction}, | ||
29 | action_moveToTrash{new Kube::ControllerAction}, | 33 | action_moveToTrash{new Kube::ControllerAction}, |
34 | action_restoreFromTrash{new Kube::ControllerAction}, | ||
30 | action_remove{new Kube::ControllerAction} | 35 | action_remove{new Kube::ControllerAction} |
31 | { | 36 | { |
32 | QObject::connect(markAsReadAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsRead); | 37 | QObject::connect(markAsReadAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsRead); |
38 | QObject::connect(markAsImportantAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsImportant); | ||
33 | QObject::connect(moveToTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::moveToTrash); | 39 | QObject::connect(moveToTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::moveToTrash); |
40 | QObject::connect(restoreFromTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::restoreFromTrash); | ||
34 | QObject::connect(removeAction(), &Kube::ControllerAction::triggered, this, &MailController::remove); | 41 | QObject::connect(removeAction(), &Kube::ControllerAction::triggered, this, &MailController::remove); |
35 | 42 | ||
36 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); | 43 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); |
@@ -41,33 +48,44 @@ void MailController::updateActions() | |||
41 | { | 48 | { |
42 | if (auto mail = getMail()) { | 49 | if (auto mail = getMail()) { |
43 | action_moveToTrash->setEnabled(!mail->getTrash()); | 50 | action_moveToTrash->setEnabled(!mail->getTrash()); |
51 | action_restoreFromTrash->setEnabled(mail->getTrash()); | ||
44 | } | 52 | } |
45 | } | 53 | } |
46 | 54 | ||
47 | void MailController::markAsRead() | 55 | void MailController::markAsRead() |
48 | { | 56 | { |
49 | using namespace Sink; | ||
50 | using namespace Sink::ApplicationDomain; | ||
51 | auto mail = getMail(); | 57 | auto mail = getMail(); |
52 | mail->setUnread(false); | 58 | mail->setUnread(false); |
53 | SinkLog() << "Mark as read " << mail->identifier(); | 59 | SinkLog() << "Mark as read " << mail->identifier(); |
54 | run(Store::modify(*mail)); | 60 | run(Store::modify(*mail)); |
55 | } | 61 | } |
56 | 62 | ||
63 | void MailController::markAsImportant() | ||
64 | { | ||
65 | auto mail = getMail(); | ||
66 | mail->setImportant(true); | ||
67 | SinkLog() << "Mark as important " << mail->identifier(); | ||
68 | run(Store::modify(*mail)); | ||
69 | } | ||
70 | |||
57 | void MailController::moveToTrash() | 71 | void MailController::moveToTrash() |
58 | { | 72 | { |
59 | using namespace Sink; | ||
60 | using namespace Sink::ApplicationDomain; | ||
61 | auto mail = getMail(); | 73 | auto mail = getMail(); |
62 | mail->setTrash(true); | 74 | mail->setTrash(true); |
63 | SinkLog() << "Move to trash " << mail->identifier(); | 75 | SinkLog() << "Move to trash " << mail->identifier(); |
64 | run(Store::modify(*mail)); | 76 | run(Store::modify(*mail)); |
65 | } | 77 | } |
66 | 78 | ||
79 | void MailController::restoreFromTrash() | ||
80 | { | ||
81 | auto mail = getMail(); | ||
82 | mail->setTrash(false); | ||
83 | SinkLog() << "Move to trash " << mail->identifier(); | ||
84 | run(Store::modify(*mail)); | ||
85 | } | ||
86 | |||
67 | void MailController::remove() | 87 | void MailController::remove() |
68 | { | 88 | { |
69 | using namespace Sink; | ||
70 | using namespace Sink::ApplicationDomain; | ||
71 | auto mail = getMail(); | 89 | auto mail = getMail(); |
72 | mail->setTrash(true); | 90 | mail->setTrash(true); |
73 | SinkLog() << "Remove " << mail->identifier(); | 91 | SinkLog() << "Remove " << mail->identifier(); |
diff --git a/framework/domain/mailcontroller.h b/framework/domain/mailcontroller.h index c20cf595..324f6c62 100644 --- a/framework/domain/mailcontroller.h +++ b/framework/domain/mailcontroller.h | |||
@@ -27,7 +27,9 @@ class MailController : public Kube::Controller | |||
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) | 28 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) |
29 | KUBE_CONTROLLER_ACTION(markAsRead) | 29 | KUBE_CONTROLLER_ACTION(markAsRead) |
30 | KUBE_CONTROLLER_ACTION(markAsImportant) | ||
30 | KUBE_CONTROLLER_ACTION(moveToTrash) | 31 | KUBE_CONTROLLER_ACTION(moveToTrash) |
32 | KUBE_CONTROLLER_ACTION(restoreFromTrash) | ||
31 | KUBE_CONTROLLER_ACTION(remove) | 33 | KUBE_CONTROLLER_ACTION(remove) |
32 | 34 | ||
33 | public: | 35 | public: |