diff options
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/domain/outboxcontroller.cpp | 29 | ||||
-rw-r--r-- | framework/src/domain/outboxcontroller.h | 13 |
2 files changed, 28 insertions, 14 deletions
diff --git a/framework/src/domain/outboxcontroller.cpp b/framework/src/domain/outboxcontroller.cpp index 590b6c49..51b481fe 100644 --- a/framework/src/domain/outboxcontroller.cpp +++ b/framework/src/domain/outboxcontroller.cpp | |||
@@ -21,21 +21,19 @@ | |||
21 | #include <sink/store.h> | 21 | #include <sink/store.h> |
22 | #include <sink/log.h> | 22 | #include <sink/log.h> |
23 | 23 | ||
24 | using namespace Sink; | ||
25 | using namespace Sink::ApplicationDomain; | ||
26 | |||
24 | OutboxController::OutboxController() | 27 | OutboxController::OutboxController() |
25 | : Kube::Controller(), | 28 | : Kube::Controller(), |
26 | mSynchronizeOutboxAction{new Kube::ControllerAction{this, &OutboxController::sendOutbox}} | 29 | action_sendOutbox{new Kube::ControllerAction{this, &OutboxController::sendOutbox}}, |
30 | action_edit{new Kube::ControllerAction{this, &OutboxController::edit}}, | ||
31 | action_moveToTrash{new Kube::ControllerAction{this, &OutboxController::moveToTrash}} | ||
27 | { | 32 | { |
28 | } | 33 | } |
29 | 34 | ||
30 | Kube::ControllerAction* OutboxController::sendOutboxAction() const | ||
31 | { | ||
32 | return mSynchronizeOutboxAction.data(); | ||
33 | } | ||
34 | |||
35 | void OutboxController::sendOutbox() | 35 | void OutboxController::sendOutbox() |
36 | { | 36 | { |
37 | using namespace Sink; | ||
38 | using namespace Sink::ApplicationDomain; | ||
39 | Query query; | 37 | Query query; |
40 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); | 38 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); |
41 | auto job = Store::fetchAll<SinkResource>(query) | 39 | auto job = Store::fetchAll<SinkResource>(query) |
@@ -45,3 +43,18 @@ void OutboxController::sendOutbox() | |||
45 | run(job); | 43 | run(job); |
46 | } | 44 | } |
47 | 45 | ||
46 | void OutboxController::moveToTrash() | ||
47 | { | ||
48 | auto mail = getMail(); | ||
49 | mail->setTrash(true); | ||
50 | run(Store::modify(*mail)); | ||
51 | } | ||
52 | |||
53 | void OutboxController::edit() | ||
54 | { | ||
55 | auto mail = getMail(); | ||
56 | mail->setDraft(true); | ||
57 | run(Store::modify(*mail)); | ||
58 | //TODO trigger edit when item has been moved | ||
59 | } | ||
60 | |||
diff --git a/framework/src/domain/outboxcontroller.h b/framework/src/domain/outboxcontroller.h index 4c24ad59..0d33956a 100644 --- a/framework/src/domain/outboxcontroller.h +++ b/framework/src/domain/outboxcontroller.h | |||
@@ -20,20 +20,21 @@ | |||
20 | 20 | ||
21 | #include <QObject> | 21 | #include <QObject> |
22 | #include "controller.h" | 22 | #include "controller.h" |
23 | #include "sink/applicationdomaintype.h" | ||
23 | 24 | ||
24 | class OutboxController : public Kube::Controller | 25 | class OutboxController : public Kube::Controller |
25 | { | 26 | { |
26 | Q_OBJECT | 27 | Q_OBJECT |
27 | Q_PROPERTY (Kube::ControllerAction* sendOutboxAction READ sendOutboxAction CONSTANT) | 28 | |
29 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) | ||
30 | KUBE_CONTROLLER_ACTION(sendOutbox) | ||
31 | //Trigger a move to drafts and then trigger an edit | ||
32 | KUBE_CONTROLLER_ACTION(edit) | ||
33 | KUBE_CONTROLLER_ACTION(moveToTrash) | ||
28 | 34 | ||
29 | public: | 35 | public: |
30 | explicit OutboxController(); | 36 | explicit OutboxController(); |
31 | 37 | ||
32 | Kube::ControllerAction* sendOutboxAction() const; | ||
33 | |||
34 | private slots: | ||
35 | void sendOutbox(); | ||
36 | |||
37 | private: | 38 | private: |
38 | QScopedPointer<Kube::ControllerAction> mSynchronizeOutboxAction; | 39 | QScopedPointer<Kube::ControllerAction> mSynchronizeOutboxAction; |
39 | }; | 40 | }; |