diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-12 15:20:39 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-12 15:20:39 +0200 |
commit | 288b4ea4ae38b3548f6ab8739a3ef303854886fb (patch) | |
tree | 2bc6278f6448ec89f029871947ed09bdfe64ca4e | |
parent | b07fad009b2cdfdd802bc3461c1c884c15856548 (diff) | |
download | kube-288b4ea4ae38b3548f6ab8739a3ef303854886fb.tar.gz kube-288b4ea4ae38b3548f6ab8739a3ef303854886fb.zip |
Move back to trash or drafts.
The move back to drafts should also trigger an edit of the mail, but
that's not implemented yet.
-rw-r--r-- | framework/qml/Outbox.qml | 31 | ||||
-rw-r--r-- | framework/src/domain/outboxcontroller.cpp | 29 | ||||
-rw-r--r-- | framework/src/domain/outboxcontroller.h | 13 |
3 files changed, 59 insertions, 14 deletions
diff --git a/framework/qml/Outbox.qml b/framework/qml/Outbox.qml index e9e3c677..47deb1a5 100644 --- a/framework/qml/Outbox.qml +++ b/framework/qml/Outbox.qml | |||
@@ -130,6 +130,36 @@ Rectangle { | |||
130 | } | 130 | } |
131 | ] | 131 | ] |
132 | } | 132 | } |
133 | |||
134 | Row { | ||
135 | anchors { | ||
136 | right: parent.right | ||
137 | rightMargin: Kube.Units.smallSpacing | ||
138 | verticalCenter: parent.verticalCenter | ||
139 | } | ||
140 | |||
141 | spacing: Kube.Units.smallSpacing | ||
142 | |||
143 | Controls.ToolButton { | ||
144 | iconName: Kube.Icons.moveToTrash | ||
145 | text: qsTr("Delete Mail") | ||
146 | tooltip: text | ||
147 | onClicked: { | ||
148 | outboxController.mail = model.domainObject | ||
149 | outboxController.moveToTrashAction.execute() | ||
150 | } | ||
151 | } | ||
152 | |||
153 | Controls.ToolButton { | ||
154 | iconName: Kube.Icons.edit | ||
155 | text: qsTr("Edit") | ||
156 | tooltip: text | ||
157 | onClicked: { | ||
158 | outboxController.mail = model.domainObject | ||
159 | outboxController.editAction.execute() | ||
160 | } | ||
161 | } | ||
162 | } | ||
133 | } | 163 | } |
134 | 164 | ||
135 | clip: true | 165 | clip: true |
@@ -147,6 +177,7 @@ Rectangle { | |||
147 | visible: listView.count != 0 | 177 | visible: listView.count != 0 |
148 | 178 | ||
149 | text: qsTr("Send now") | 179 | text: qsTr("Send now") |
180 | enabled: outboxController.sendOutboxAction.enabled | ||
150 | onClicked: { | 181 | onClicked: { |
151 | outboxController.sendOutboxAction.execute() | 182 | outboxController.sendOutboxAction.execute() |
152 | } | 183 | } |
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 | }; |