diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-13 14:52:27 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-16 14:54:14 +0100 |
commit | b1a2e2de201985a00980bead5272977cda4ef637 (patch) | |
tree | 9af03b622d8c5d6a3b3ed83efb846977813b58d8 /framework/actions/actionbroker.cpp | |
parent | 3f4626d305aa43c2a720d692cdf8cf89cc658181 (diff) | |
download | kube-b1a2e2de201985a00980bead5272977cda4ef637.tar.gz kube-b1a2e2de201985a00980bead5272977cda4ef637.zip |
Preactionhandler
Diffstat (limited to 'framework/actions/actionbroker.cpp')
-rw-r--r-- | framework/actions/actionbroker.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/framework/actions/actionbroker.cpp b/framework/actions/actionbroker.cpp index 890a5566..24ef0b2c 100644 --- a/framework/actions/actionbroker.cpp +++ b/framework/actions/actionbroker.cpp | |||
@@ -44,36 +44,43 @@ bool ActionBroker::isActionReady(const QByteArray &actionId, Context *context) | |||
44 | return false; | 44 | return false; |
45 | } | 45 | } |
46 | 46 | ||
47 | //TODO This should return true if all handlers together promise to gather all necessary data, but not otherwise | ||
48 | for (const auto handler : mHandler.values(actionId)) { | 47 | for (const auto handler : mHandler.values(actionId)) { |
49 | if (handler && handler->isActionReady(context)) { | 48 | if (handler) { |
50 | return true; | 49 | if (handler-> isActionReady(context)) { |
50 | return true; | ||
51 | } | ||
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 | ||
54 | return false; | 55 | return false; |
55 | } | 56 | } |
56 | 57 | ||
57 | ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *context) | 58 | ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *context, const QList<QPointer<ActionHandler>> &preHandler, const QList<QPointer<ActionHandler>> &postHandler) |
58 | { | 59 | { |
60 | ActionResult result; | ||
59 | if (context) { | 61 | if (context) { |
62 | for (const auto handler : preHandler) { | ||
63 | handler->execute(context); | ||
64 | } | ||
65 | //TODO the main handler should only execute once the pre handler is done | ||
60 | for (const auto handler : mHandler.values(actionId)) { | 66 | for (const auto handler : mHandler.values(actionId)) { |
61 | if (handler) { | 67 | if (handler) { |
62 | //FIXME All handler together return one result | 68 | result += handler->execute(context); |
63 | return handler->execute(context); | ||
64 | } | 69 | } |
65 | } | 70 | } |
71 | //TODO the post handler should only execute once the main handler is done | ||
72 | for (const auto handler : postHandler) { | ||
73 | handler->execute(context); | ||
74 | } | ||
66 | } else { | 75 | } else { |
67 | qWarning() << "Can't execute without context"; | 76 | qWarning() << "Can't execute without context"; |
77 | result.setDone(); | ||
78 | result.setError(1); | ||
68 | } | 79 | } |
69 | ActionResult result; | ||
70 | result.setDone(); | ||
71 | result.setError(1); | ||
72 | return result; | 80 | return result; |
73 | } | 81 | } |
74 | 82 | ||
75 | void ActionBroker::registerHandler(const QByteArray &actionId, ActionHandler *handler) | 83 | void ActionBroker::registerHandler(const QByteArray &actionId, ActionHandler *handler) |
76 | { | 84 | { |
77 | //TODO get notified on destruction via QPointer | ||
78 | mHandler.insert(actionId, handler); | 85 | mHandler.insert(actionId, handler); |
79 | } | 86 | } |