diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-24 21:51:24 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-24 21:51:24 +0200 |
commit | b3223155b178427354b44f05167d0afba0926cbd (patch) | |
tree | 25021116a0f465a6973e36b668945080f3b9fc4b | |
parent | 4ba8c5b72fd7a3db6e593853c4669750dc6dd2a2 (diff) | |
download | kube-b3223155b178427354b44f05167d0afba0926cbd.tar.gz kube-b3223155b178427354b44f05167d0afba0926cbd.zip |
Another bunch of controllers gone
-rw-r--r-- | components/kube/contents/ui/Kube.qml | 24 | ||||
-rw-r--r-- | framework/qml/AccountSwitcher.qml | 8 | ||||
-rw-r--r-- | framework/qml/Messages.qml | 1 | ||||
-rw-r--r-- | framework/qml/Outbox.qml | 18 | ||||
-rw-r--r-- | framework/src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | framework/src/domain/foldercontroller.cpp | 62 | ||||
-rw-r--r-- | framework/src/domain/foldercontroller.h | 36 | ||||
-rw-r--r-- | framework/src/domain/mailcontroller.cpp | 142 | ||||
-rw-r--r-- | framework/src/domain/mailcontroller.h | 51 | ||||
-rw-r--r-- | framework/src/domain/outboxcontroller.cpp | 60 | ||||
-rw-r--r-- | framework/src/domain/outboxcontroller.h | 37 | ||||
-rw-r--r-- | framework/src/frameworkplugin.cpp | 6 | ||||
-rw-r--r-- | framework/src/sinkfabric.cpp | 15 |
13 files changed, 33 insertions, 432 deletions
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index 8092a073..b3bee859 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml | |||
@@ -63,18 +63,6 @@ Controls2.ApplicationWindow { | |||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | //Controller | ||
67 | //TODO replace | ||
68 | Kube.FolderController { | ||
69 | id: folderController | ||
70 | } | ||
71 | Kube.Listener { | ||
72 | id: controllerListener | ||
73 | filter: Kube.Messages.folderSelection | ||
74 | onMessageReceived: { | ||
75 | folderController.folder = message.folder | ||
76 | } | ||
77 | } | ||
78 | 66 | ||
79 | //Model | 67 | //Model |
80 | Kube.AccountsModel { | 68 | Kube.AccountsModel { |
@@ -84,9 +72,17 @@ Controls2.ApplicationWindow { | |||
84 | 72 | ||
85 | //BEGIN Shortcuts | 73 | //BEGIN Shortcuts |
86 | Shortcut { | 74 | Shortcut { |
75 | id: syncShortcut | ||
76 | property variant folder: null | ||
87 | sequence: StandardKey.Refresh | 77 | sequence: StandardKey.Refresh |
88 | onActivated: folderController.synchronizeAction.execute() | 78 | enabled: !!folder |
89 | enabled: folderController.synchronizeAction.enabled | 79 | onActivated: Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": folder}) |
80 | } | ||
81 | Kube.Listener { | ||
82 | filter: Kube.Messages.folderSelection | ||
83 | onMessageReceived: { | ||
84 | syncShortcut.folder = message.folder | ||
85 | } | ||
90 | } | 86 | } |
91 | //END Shortcuts | 87 | //END Shortcuts |
92 | 88 | ||
diff --git a/framework/qml/AccountSwitcher.qml b/framework/qml/AccountSwitcher.qml index 7a1e7592..a8151712 100644 --- a/framework/qml/AccountSwitcher.qml +++ b/framework/qml/AccountSwitcher.qml | |||
@@ -36,11 +36,6 @@ Controls.ToolButton { | |||
36 | width: parent.width | 36 | width: parent.width |
37 | iconName: Kube.Icons.menu_inverted | 37 | iconName: Kube.Icons.menu_inverted |
38 | 38 | ||
39 | Kube.FolderController { | ||
40 | id: folderController | ||
41 | accountId: accountId | ||
42 | } | ||
43 | |||
44 | Kube.AccountsModel { | 39 | Kube.AccountsModel { |
45 | id: accountsModel | 40 | id: accountsModel |
46 | } | 41 | } |
@@ -74,9 +69,8 @@ Controls.ToolButton { | |||
74 | 69 | ||
75 | //iconName: "view-refresh" | 70 | //iconName: "view-refresh" |
76 | text: "Sync" | 71 | text: "Sync" |
77 | enabled: folderController.synchronizeAction.enabled | ||
78 | onClicked: { | 72 | onClicked: { |
79 | folderController.synchronizeAction.execute() | 73 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": accountSwitcher.accountId}) |
80 | popup.close() | 74 | popup.close() |
81 | } | 75 | } |
82 | } | 76 | } |
diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml index 1b384bfa..26a3ea3e 100644 --- a/framework/qml/Messages.qml +++ b/framework/qml/Messages.qml | |||
@@ -32,6 +32,7 @@ Item { | |||
32 | property string markAsUnread: "markAsUnread" | 32 | property string markAsUnread: "markAsUnread" |
33 | property string toggleImportant: "toggleImportant" | 33 | property string toggleImportant: "toggleImportant" |
34 | property string moveToFolder: "moveToFolder" | 34 | property string moveToFolder: "moveToFolder" |
35 | property string moveToDrafts: "moveToDrafts" | ||
35 | 36 | ||
36 | property string notification: "notification" | 37 | property string notification: "notification" |
37 | property string search: "search" | 38 | property string search: "search" |
diff --git a/framework/qml/Outbox.qml b/framework/qml/Outbox.qml index fc960667..46368294 100644 --- a/framework/qml/Outbox.qml +++ b/framework/qml/Outbox.qml | |||
@@ -30,9 +30,6 @@ Controls.ToolButton { | |||
30 | 30 | ||
31 | visible: outboxModel.count > 0 | 31 | visible: outboxModel.count > 0 |
32 | 32 | ||
33 | Kube.OutboxController { | ||
34 | id: outboxController | ||
35 | } | ||
36 | Kube.OutboxModel { | 33 | Kube.OutboxModel { |
37 | id: outboxModel | 34 | id: outboxModel |
38 | } | 35 | } |
@@ -134,10 +131,7 @@ Controls.ToolButton { | |||
134 | iconName: Kube.Icons.moveToTrash | 131 | iconName: Kube.Icons.moveToTrash |
135 | text: qsTr("Delete Mail") | 132 | text: qsTr("Delete Mail") |
136 | tooltip: text | 133 | tooltip: text |
137 | onClicked: { | 134 | onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.domainObject}) |
138 | outboxController.mail = model.domainObject | ||
139 | outboxController.moveToTrashAction.execute() | ||
140 | } | ||
141 | } | 135 | } |
142 | 136 | ||
143 | Controls.ToolButton { | 137 | Controls.ToolButton { |
@@ -145,8 +139,9 @@ Controls.ToolButton { | |||
145 | text: qsTr("Edit") | 139 | text: qsTr("Edit") |
146 | tooltip: text | 140 | tooltip: text |
147 | onClicked: { | 141 | onClicked: { |
148 | outboxController.mail = model.domainObject | 142 | Kube.Fabric.postMessage(Kube.Messages.moveToDrafts, {"mail": model.domainObject}) |
149 | outboxController.editAction.execute() | 143 | //TODO stage upon completion |
144 | //Kube.Fabric.postMessage(Kube.Messages.edit, {"mail": model.domainObject}) | ||
150 | } | 145 | } |
151 | } | 146 | } |
152 | } | 147 | } |
@@ -167,10 +162,7 @@ Controls.ToolButton { | |||
167 | visible: listView.count != 0 | 162 | visible: listView.count != 0 |
168 | 163 | ||
169 | text: qsTr("Send now") | 164 | text: qsTr("Send now") |
170 | enabled: outboxController.sendOutboxAction.enabled | 165 | onClicked: Kube.Fabric.postMessage(Kube.Messages.sendOutbox, {}) |
171 | onClicked: { | ||
172 | outboxController.sendOutboxAction.execute() | ||
173 | } | ||
174 | } | 166 | } |
175 | 167 | ||
176 | Kube.Label { | 168 | Kube.Label { |
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 73e489b1..8dc844cc 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt | |||
@@ -39,12 +39,9 @@ set(SRCS | |||
39 | domain/settings/accountsettings.cpp | 39 | domain/settings/accountsettings.cpp |
40 | domain/selector.cpp | 40 | domain/selector.cpp |
41 | domain/completer.cpp | 41 | domain/completer.cpp |
42 | domain/controller.cpp | ||
43 | domain/outboxcontroller.cpp | ||
44 | domain/mailcontroller.cpp | ||
45 | domain/foldercontroller.cpp | ||
46 | domain/mouseproxy.cpp | 42 | domain/mouseproxy.cpp |
47 | domain/contactcontroller.cpp | 43 | domain/contactcontroller.cpp |
44 | domain/controller.cpp | ||
48 | domain/peoplemodel.cpp | 45 | domain/peoplemodel.cpp |
49 | accounts/accountfactory.cpp | 46 | accounts/accountfactory.cpp |
50 | accounts/accountsmodel.cpp | 47 | accounts/accountsmodel.cpp |
diff --git a/framework/src/domain/foldercontroller.cpp b/framework/src/domain/foldercontroller.cpp deleted file mode 100644 index 3c10f773..00000000 --- a/framework/src/domain/foldercontroller.cpp +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "foldercontroller.h" | ||
20 | |||
21 | #include <sink/store.h> | ||
22 | #include <sink/log.h> | ||
23 | |||
24 | SINK_DEBUG_AREA("foldercontroller"); | ||
25 | |||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
29 | FolderController::FolderController() | ||
30 | : Kube::Controller(), | ||
31 | action_synchronize{new Kube::ControllerAction{this, &FolderController::synchronize}}, | ||
32 | action_moveToFolder{new Kube::ControllerAction{this, &FolderController::moveToFolder}} | ||
33 | { | ||
34 | } | ||
35 | |||
36 | void FolderController::synchronize() | ||
37 | { | ||
38 | auto job = [&] { | ||
39 | auto accountId = getAccountId(); | ||
40 | if (auto folder = getFolder()) { | ||
41 | SinkLog() << "Synchronizing folder " << folder->resourceInstanceIdentifier() << folder->identifier(); | ||
42 | auto scope = SyncScope().resourceFilter(folder->resourceInstanceIdentifier()).filter<ApplicationDomain::Mail::Folder>(QVariant::fromValue(folder->identifier())); | ||
43 | scope.setType<ApplicationDomain::Mail>(); | ||
44 | return Store::synchronize(scope); | ||
45 | } else if (!accountId.isEmpty()) { | ||
46 | return Store::synchronize(SyncScope{}.resourceFilter<ApplicationDomain::SinkResource::Account>(accountId)); | ||
47 | } else { | ||
48 | SinkLog() << "Synchronizing all"; | ||
49 | return Store::synchronize(SyncScope()); | ||
50 | } | ||
51 | }(); | ||
52 | run(job); | ||
53 | } | ||
54 | |||
55 | void FolderController::moveToFolder() | ||
56 | { | ||
57 | auto mail = getMail(); | ||
58 | auto targetFolder = getFolder(); | ||
59 | mail->setFolder(*targetFolder); | ||
60 | SinkLog() << "Moving to folder " << mail->identifier() << targetFolder->identifier(); | ||
61 | run(Store::modify(*mail)); | ||
62 | } | ||
diff --git a/framework/src/domain/foldercontroller.h b/framework/src/domain/foldercontroller.h deleted file mode 100644 index c0815546..00000000 --- a/framework/src/domain/foldercontroller.h +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | #include "controller.h" | ||
23 | #include "sink/applicationdomaintype.h" | ||
24 | |||
25 | class FolderController : public Kube::Controller | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, Folder, folder) | ||
29 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) | ||
30 | KUBE_CONTROLLER_PROPERTY(QByteArray, AccountId, accountId) | ||
31 | KUBE_CONTROLLER_ACTION(synchronize) | ||
32 | KUBE_CONTROLLER_ACTION(moveToFolder) | ||
33 | |||
34 | public: | ||
35 | explicit FolderController(); | ||
36 | }; | ||
diff --git a/framework/src/domain/mailcontroller.cpp b/framework/src/domain/mailcontroller.cpp deleted file mode 100644 index ea0fe690..00000000 --- a/framework/src/domain/mailcontroller.cpp +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "mailcontroller.h" | ||
20 | |||
21 | #include <sink/store.h> | ||
22 | #include <sink/log.h> | ||
23 | #include <sink/standardqueries.h> | ||
24 | |||
25 | SINK_DEBUG_AREA("mailcontroller"); | ||
26 | |||
27 | using namespace Sink; | ||
28 | using namespace Sink::ApplicationDomain; | ||
29 | |||
30 | MailController::MailController() | ||
31 | : Kube::Controller(), | ||
32 | action_markAsRead{new Kube::ControllerAction{this, &MailController::markAsRead}}, | ||
33 | action_markAsUnread{new Kube::ControllerAction{this, &MailController::markAsUnread}}, | ||
34 | action_markAsImportant{new Kube::ControllerAction{this, &MailController::markAsImportant}}, | ||
35 | action_toggleImportant{new Kube::ControllerAction{this, &MailController::toggleImportant}}, | ||
36 | action_moveToTrash{new Kube::ControllerAction{this, &MailController::moveToTrash}}, | ||
37 | action_restoreFromTrash{new Kube::ControllerAction{this, &MailController::restoreFromTrash}}, | ||
38 | action_remove{new Kube::ControllerAction{this, &MailController::remove}}, | ||
39 | action_moveToFolder{new Kube::ControllerAction{this, &MailController::moveToFolder}} | ||
40 | { | ||
41 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); | ||
42 | QObject::connect(this, &MailController::importantChanged, &MailController::updateActions); | ||
43 | QObject::connect(this, &MailController::draftChanged, &MailController::updateActions); | ||
44 | QObject::connect(this, &MailController::trashChanged, &MailController::updateActions); | ||
45 | QObject::connect(this, &MailController::unreadChanged, &MailController::updateActions); | ||
46 | updateActions(); | ||
47 | } | ||
48 | |||
49 | void MailController::runModification(const std::function<void(ApplicationDomain::Mail &)> &f) | ||
50 | { | ||
51 | if (auto mail = getMail()) { | ||
52 | f(*mail); | ||
53 | if (getOperateOnThreads()) { | ||
54 | run(Store::modify(Sink::StandardQueries::completeThread(*mail), *mail)); | ||
55 | } else { | ||
56 | run(Store::modify(*mail)); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | void MailController::updateActions() | ||
62 | { | ||
63 | if (auto mail = getMail()) { | ||
64 | action_moveToTrash->setEnabled(!getTrash()); | ||
65 | action_restoreFromTrash->setEnabled(getTrash()); | ||
66 | action_markAsRead->setEnabled(getUnread()); | ||
67 | action_markAsUnread->setEnabled(!getUnread()); | ||
68 | action_markAsImportant->setEnabled(!getImportant()); | ||
69 | } else { | ||
70 | action_moveToTrash->setEnabled(false); | ||
71 | action_restoreFromTrash->setEnabled(false); | ||
72 | action_markAsRead->setEnabled(false); | ||
73 | action_markAsUnread->setEnabled(false); | ||
74 | action_markAsImportant->setEnabled(false); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | void MailController::markAsRead() | ||
79 | { | ||
80 | runModification([] (ApplicationDomain::Mail &mail) { | ||
81 | mail.setUnread(false); | ||
82 | SinkLog() << "Mark as read " << mail.identifier(); | ||
83 | }); | ||
84 | } | ||
85 | |||
86 | void MailController::markAsUnread() | ||
87 | { | ||
88 | runModification([] (ApplicationDomain::Mail &mail) { | ||
89 | mail.setUnread(true); | ||
90 | SinkLog() << "Mark as unread " << mail.identifier(); | ||
91 | }); | ||
92 | } | ||
93 | |||
94 | void MailController::markAsImportant() | ||
95 | { | ||
96 | runModification([] (ApplicationDomain::Mail &mail) { | ||
97 | mail.setImportant(true); | ||
98 | SinkLog() << "Mark as important " << mail.identifier(); | ||
99 | }); | ||
100 | } | ||
101 | |||
102 | void MailController::toggleImportant() | ||
103 | { | ||
104 | runModification([this] (ApplicationDomain::Mail &mail) { | ||
105 | mail.setImportant(!getImportant()); | ||
106 | SinkLog() << "Toggle important " << mail.identifier() << mail.getImportant(); | ||
107 | }); | ||
108 | } | ||
109 | |||
110 | void MailController::moveToTrash() | ||
111 | { | ||
112 | runModification([] (ApplicationDomain::Mail &mail) { | ||
113 | mail.setTrash(true); | ||
114 | SinkLog() << "Move to trash " << mail.identifier(); | ||
115 | }); | ||
116 | } | ||
117 | |||
118 | void MailController::restoreFromTrash() | ||
119 | { | ||
120 | runModification([] (ApplicationDomain::Mail &mail) { | ||
121 | mail.setTrash(false); | ||
122 | SinkLog() << "Restore from trash " << mail.identifier(); | ||
123 | }); | ||
124 | } | ||
125 | |||
126 | void MailController::remove() | ||
127 | { | ||
128 | runModification([] (ApplicationDomain::Mail &mail) { | ||
129 | mail.setTrash(true); | ||
130 | SinkLog() << "Remove " << mail.identifier(); | ||
131 | }); | ||
132 | } | ||
133 | |||
134 | void MailController::moveToFolder() | ||
135 | { | ||
136 | runModification([&] (ApplicationDomain::Mail &mail) { | ||
137 | auto targetFolder = getTargetFolder(); | ||
138 | mail.setFolder(*targetFolder); | ||
139 | SinkLog() << "Moving to folder " << mail.identifier() << targetFolder->identifier(); | ||
140 | }); | ||
141 | } | ||
142 | |||
diff --git a/framework/src/domain/mailcontroller.h b/framework/src/domain/mailcontroller.h deleted file mode 100644 index 0bc000f1..00000000 --- a/framework/src/domain/mailcontroller.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | #include "controller.h" | ||
23 | #include "sink/applicationdomaintype.h" | ||
24 | |||
25 | class MailController : public Kube::Controller | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | //Use this instead of mail property to get overall status of thread. | ||
29 | KUBE_CONTROLLER_PROPERTY(bool, Unread, unread) | ||
30 | KUBE_CONTROLLER_PROPERTY(bool, Important, important) | ||
31 | KUBE_CONTROLLER_PROPERTY(bool, Trash, trash) | ||
32 | KUBE_CONTROLLER_PROPERTY(bool, Draft, draft) | ||
33 | |||
34 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail::Ptr, Mail, mail) | ||
35 | KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, TargetFolder, targetFolder) | ||
36 | KUBE_CONTROLLER_PROPERTY(bool, OperateOnThreads, operateOnThreads) | ||
37 | KUBE_CONTROLLER_ACTION(markAsRead) | ||
38 | KUBE_CONTROLLER_ACTION(markAsUnread) | ||
39 | KUBE_CONTROLLER_ACTION(markAsImportant) | ||
40 | KUBE_CONTROLLER_ACTION(toggleImportant) | ||
41 | KUBE_CONTROLLER_ACTION(moveToTrash) | ||
42 | KUBE_CONTROLLER_ACTION(restoreFromTrash) | ||
43 | KUBE_CONTROLLER_ACTION(remove) | ||
44 | KUBE_CONTROLLER_ACTION(moveToFolder) | ||
45 | |||
46 | public: | ||
47 | explicit MailController(); | ||
48 | private slots: | ||
49 | void updateActions(); | ||
50 | void runModification(const std::function<void(Sink::ApplicationDomain::Mail &)> &f); | ||
51 | }; | ||
diff --git a/framework/src/domain/outboxcontroller.cpp b/framework/src/domain/outboxcontroller.cpp deleted file mode 100644 index 51b481fe..00000000 --- a/framework/src/domain/outboxcontroller.cpp +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "outboxcontroller.h" | ||
20 | |||
21 | #include <sink/store.h> | ||
22 | #include <sink/log.h> | ||
23 | |||
24 | using namespace Sink; | ||
25 | using namespace Sink::ApplicationDomain; | ||
26 | |||
27 | OutboxController::OutboxController() | ||
28 | : Kube::Controller(), | ||
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}} | ||
32 | { | ||
33 | } | ||
34 | |||
35 | void OutboxController::sendOutbox() | ||
36 | { | ||
37 | Query query; | ||
38 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); | ||
39 | auto job = Store::fetchAll<SinkResource>(query) | ||
40 | .each([=](const SinkResource::Ptr &resource) -> KAsync::Job<void> { | ||
41 | return Store::synchronize(SyncScope{}.resourceFilter(resource->identifier())); | ||
42 | }); | ||
43 | run(job); | ||
44 | } | ||
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 deleted file mode 100644 index 24fe9584..00000000 --- a/framework/src/domain/outboxcontroller.h +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | #include "controller.h" | ||
23 | #include "sink/applicationdomaintype.h" | ||
24 | |||
25 | class OutboxController : public Kube::Controller | ||
26 | { | ||
27 | Q_OBJECT | ||
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) | ||
34 | |||
35 | public: | ||
36 | explicit OutboxController(); | ||
37 | }; | ||
diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp index 2f77bef4..294fbbc7 100644 --- a/framework/src/frameworkplugin.cpp +++ b/framework/src/frameworkplugin.cpp | |||
@@ -26,9 +26,6 @@ | |||
26 | #include "domain/messageparser.h" | 26 | #include "domain/messageparser.h" |
27 | #include "domain/retriever.h" | 27 | #include "domain/retriever.h" |
28 | #include "domain/outboxmodel.h" | 28 | #include "domain/outboxmodel.h" |
29 | #include "domain/outboxcontroller.h" | ||
30 | #include "domain/mailcontroller.h" | ||
31 | #include "domain/foldercontroller.h" | ||
32 | #include "domain/mouseproxy.h" | 29 | #include "domain/mouseproxy.h" |
33 | #include "domain/contactcontroller.h" | 30 | #include "domain/contactcontroller.h" |
34 | #include "domain/peoplemodel.h" | 31 | #include "domain/peoplemodel.h" |
@@ -57,10 +54,7 @@ void FrameworkPlugin::registerTypes (const char *uri) | |||
57 | qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController"); | 54 | qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController"); |
58 | qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser"); | 55 | qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser"); |
59 | qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); | 56 | qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); |
60 | qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController"); | ||
61 | qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); | 57 | qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); |
62 | qmlRegisterType<MailController>(uri, 1, 0, "MailController"); | ||
63 | qmlRegisterType<FolderController>(uri, 1, 0, "FolderController"); | ||
64 | qmlRegisterType<MouseProxy>(uri, 1, 0, "MouseProxy"); | 58 | qmlRegisterType<MouseProxy>(uri, 1, 0, "MouseProxy"); |
65 | qmlRegisterType<ContactController>(uri, 1, 0,"ContactController"); | 59 | qmlRegisterType<ContactController>(uri, 1, 0,"ContactController"); |
66 | qmlRegisterType<PeopleModel>(uri, 1, 0,"PeopleModel"); | 60 | qmlRegisterType<PeopleModel>(uri, 1, 0,"PeopleModel"); |
diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp index 68a75a86..5e209526 100644 --- a/framework/src/sinkfabric.cpp +++ b/framework/src/sinkfabric.cpp | |||
@@ -53,6 +53,15 @@ public: | |||
53 | Store::synchronize(SyncScope()).exec(); | 53 | Store::synchronize(SyncScope()).exec(); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | if (id == "sendOutbox"/*Kube::Messages::synchronize*/) { | ||
57 | Query query; | ||
58 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); | ||
59 | auto job = Store::fetchAll<SinkResource>(query) | ||
60 | .each([=](const SinkResource::Ptr &resource) -> KAsync::Job<void> { | ||
61 | return Store::synchronize(SyncScope{}.resourceFilter(resource->identifier())); | ||
62 | }); | ||
63 | job.exec(); | ||
64 | } | ||
56 | if (id == "markAsRead"/*Kube::Messages::synchronize*/) { | 65 | if (id == "markAsRead"/*Kube::Messages::synchronize*/) { |
57 | if (auto mail = message["mail"].value<ApplicationDomain::Mail::Ptr>()) { | 66 | if (auto mail = message["mail"].value<ApplicationDomain::Mail::Ptr>()) { |
58 | mail->setUnread(false); | 67 | mail->setUnread(false); |
@@ -77,6 +86,12 @@ public: | |||
77 | Store::modify(*mail).exec(); | 86 | Store::modify(*mail).exec(); |
78 | } | 87 | } |
79 | } | 88 | } |
89 | if (id == "moveToDrafts"/*Kube::Messages::synchronize*/) { | ||
90 | if (auto mail = message["mail"].value<ApplicationDomain::Mail::Ptr>()) { | ||
91 | mail->setDraft(true); | ||
92 | Store::modify(*mail).exec(); | ||
93 | } | ||
94 | } | ||
80 | if (id == "moveToFolder"/*Kube::Messages::synchronize*/) { | 95 | if (id == "moveToFolder"/*Kube::Messages::synchronize*/) { |
81 | if (auto mail = message["mail"].value<ApplicationDomain::Mail::Ptr>()) { | 96 | if (auto mail = message["mail"].value<ApplicationDomain::Mail::Ptr>()) { |
82 | auto folder = message["folder"].value<ApplicationDomain::Folder::Ptr>(); | 97 | auto folder = message["folder"].value<ApplicationDomain::Folder::Ptr>(); |