From 288b4ea4ae38b3548f6ab8739a3ef303854886fb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 12 Apr 2017 15:20:39 +0200 Subject: 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. --- framework/qml/Outbox.qml | 31 +++++++++++++++++++++++++++++++ framework/src/domain/outboxcontroller.cpp | 29 +++++++++++++++++++++-------- 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 { } ] } + + Row { + anchors { + right: parent.right + rightMargin: Kube.Units.smallSpacing + verticalCenter: parent.verticalCenter + } + + spacing: Kube.Units.smallSpacing + + Controls.ToolButton { + iconName: Kube.Icons.moveToTrash + text: qsTr("Delete Mail") + tooltip: text + onClicked: { + outboxController.mail = model.domainObject + outboxController.moveToTrashAction.execute() + } + } + + Controls.ToolButton { + iconName: Kube.Icons.edit + text: qsTr("Edit") + tooltip: text + onClicked: { + outboxController.mail = model.domainObject + outboxController.editAction.execute() + } + } + } } clip: true @@ -147,6 +177,7 @@ Rectangle { visible: listView.count != 0 text: qsTr("Send now") + enabled: outboxController.sendOutboxAction.enabled onClicked: { outboxController.sendOutboxAction.execute() } 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 @@ #include #include +using namespace Sink; +using namespace Sink::ApplicationDomain; + OutboxController::OutboxController() : Kube::Controller(), - mSynchronizeOutboxAction{new Kube::ControllerAction{this, &OutboxController::sendOutbox}} + action_sendOutbox{new Kube::ControllerAction{this, &OutboxController::sendOutbox}}, + action_edit{new Kube::ControllerAction{this, &OutboxController::edit}}, + action_moveToTrash{new Kube::ControllerAction{this, &OutboxController::moveToTrash}} { } -Kube::ControllerAction* OutboxController::sendOutboxAction() const -{ - return mSynchronizeOutboxAction.data(); -} - void OutboxController::sendOutbox() { - using namespace Sink; - using namespace Sink::ApplicationDomain; Query query; query.containsFilter(ResourceCapabilities::Mail::transport); auto job = Store::fetchAll(query) @@ -45,3 +43,18 @@ void OutboxController::sendOutbox() 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 index 4c24ad59..0d33956a 100644 --- a/framework/src/domain/outboxcontroller.h +++ b/framework/src/domain/outboxcontroller.h @@ -20,20 +20,21 @@ #include #include "controller.h" +#include "sink/applicationdomaintype.h" class OutboxController : public Kube::Controller { Q_OBJECT - Q_PROPERTY (Kube::ControllerAction* sendOutboxAction READ sendOutboxAction CONSTANT) + + 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(); - Kube::ControllerAction* sendOutboxAction() const; - -private slots: - void sendOutbox(); - private: QScopedPointer mSynchronizeOutboxAction; }; -- cgit v1.2.3