diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-24 12:37:51 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-24 12:37:51 +0100 |
commit | 4b094beb151373abb4a24d473c6d69a11674c5ba (patch) | |
tree | 815b83ac455d5c62948f4ab02b33ea622567127f /framework/mail | |
parent | 37d1ff146cda492b02c6b199e1b33f671c1fa9f9 (diff) | |
download | kube-4b094beb151373abb4a24d473c6d69a11674c5ba.tar.gz kube-4b094beb151373abb4a24d473c6d69a11674c5ba.zip |
Moved the ActionHandlerHelper
Diffstat (limited to 'framework/mail')
-rw-r--r-- | framework/mail/actions/sinkactions.cpp | 21 | ||||
-rw-r--r-- | framework/mail/actions/sinkactions.h | 40 |
2 files changed, 1 insertions, 60 deletions
diff --git a/framework/mail/actions/sinkactions.cpp b/framework/mail/actions/sinkactions.cpp index 978a045b..e00d3947 100644 --- a/framework/mail/actions/sinkactions.cpp +++ b/framework/mail/actions/sinkactions.cpp | |||
@@ -16,32 +16,13 @@ | |||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. | 17 | 02110-1301, USA. |
18 | */ | 18 | */ |
19 | #include "sinkactions.h" | ||
20 | |||
21 | #include <actions/context.h> | 19 | #include <actions/context.h> |
20 | #include <actions/actionhandler.h> | ||
22 | 21 | ||
23 | #include <sink/store.h> | 22 | #include <sink/store.h> |
24 | 23 | ||
25 | using namespace Kube; | 24 | using namespace Kube; |
26 | 25 | ||
27 | ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const std::function<bool(Context*)> &isReady, const std::function<void(Context*)> &handler) | ||
28 | : ActionHandler(nullptr), | ||
29 | isReadyFunction(isReady), | ||
30 | handlerFunction(handler) | ||
31 | { | ||
32 | setActionId(actionId); | ||
33 | } | ||
34 | |||
35 | bool ActionHandlerHelper::isActionReady(Context *context) | ||
36 | { | ||
37 | return isReadyFunction(context); | ||
38 | } | ||
39 | |||
40 | void ActionHandlerHelper::execute(Context *context) | ||
41 | { | ||
42 | handlerFunction(context); | ||
43 | } | ||
44 | |||
45 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", | 26 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", |
46 | [](Context *context) -> bool { | 27 | [](Context *context) -> bool { |
47 | return context->property("mail").isValid(); | 28 | return context->property("mail").isValid(); |
diff --git a/framework/mail/actions/sinkactions.h b/framework/mail/actions/sinkactions.h deleted file mode 100644 index a583ebf8..00000000 --- a/framework/mail/actions/sinkactions.h +++ /dev/null | |||
@@ -1,40 +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 <actions/actionhandler.h> | ||
22 | #include <functional> | ||
23 | |||
24 | namespace Kube { | ||
25 | class Context; | ||
26 | |||
27 | class ActionHandlerHelper : public ActionHandler | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | ActionHandlerHelper(const QByteArray &actionId, const std::function<bool(Context*)> &, const std::function<void(Context*)> &); | ||
32 | |||
33 | bool isActionReady(Context *context) Q_DECL_OVERRIDE; | ||
34 | void execute(Context *context) Q_DECL_OVERRIDE; | ||
35 | private: | ||
36 | const std::function<bool(Context*)> isReadyFunction; | ||
37 | const std::function<void(Context*)> handlerFunction; | ||
38 | }; | ||
39 | |||
40 | } | ||