diff options
Diffstat (limited to 'framework/actions/actionbroker.cpp')
-rw-r--r-- | framework/actions/actionbroker.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/framework/actions/actionbroker.cpp b/framework/actions/actionbroker.cpp index 24ef0b2c..17145440 100644 --- a/framework/actions/actionbroker.cpp +++ b/framework/actions/actionbroker.cpp | |||
@@ -21,11 +21,14 @@ | |||
21 | 21 | ||
22 | #include "context.h" | 22 | #include "context.h" |
23 | #include "actionhandler.h" | 23 | #include "actionhandler.h" |
24 | #include <sink/log.h> | ||
24 | 25 | ||
25 | #include <QDebug> | 26 | #include <QDebug> |
26 | 27 | ||
27 | using namespace Kube; | 28 | using namespace Kube; |
28 | 29 | ||
30 | SINK_DEBUG_AREA("actionbroker") | ||
31 | |||
29 | ActionBroker::ActionBroker(QObject *parent) | 32 | ActionBroker::ActionBroker(QObject *parent) |
30 | : QObject(parent) | 33 | : QObject(parent) |
31 | { | 34 | { |
@@ -38,15 +41,20 @@ ActionBroker &ActionBroker::instance() | |||
38 | return instance; | 41 | return instance; |
39 | } | 42 | } |
40 | 43 | ||
41 | bool ActionBroker::isActionReady(const QByteArray &actionId, Context *context) | 44 | bool ActionBroker::isActionReady(const QByteArray &actionId, Context *context, const QList<QPointer<ActionHandler>> &preHandler) |
42 | { | 45 | { |
43 | if (!context) { | 46 | if (!context) { |
44 | return false; | 47 | return false; |
45 | } | 48 | } |
49 | for (const auto handler : preHandler) { | ||
50 | if (!handler->isActionReady(context)) { | ||
51 | return false; | ||
52 | } | ||
53 | } | ||
46 | 54 | ||
47 | for (const auto handler : mHandler.values(actionId)) { | 55 | for (const auto handler : mHandler.values(actionId)) { |
48 | if (handler) { | 56 | if (handler) { |
49 | if (handler-> isActionReady(context)) { | 57 | if (handler->isActionReady(context)) { |
50 | return true; | 58 | return true; |
51 | } | 59 | } |
52 | } | 60 | } |
@@ -59,6 +67,8 @@ ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *co | |||
59 | { | 67 | { |
60 | ActionResult result; | 68 | ActionResult result; |
61 | if (context) { | 69 | if (context) { |
70 | SinkLog() << "Executing action " << actionId; | ||
71 | SinkLog() << *context; | ||
62 | for (const auto handler : preHandler) { | 72 | for (const auto handler : preHandler) { |
63 | handler->execute(context); | 73 | handler->execute(context); |
64 | } | 74 | } |
@@ -73,7 +83,7 @@ ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *co | |||
73 | handler->execute(context); | 83 | handler->execute(context); |
74 | } | 84 | } |
75 | } else { | 85 | } else { |
76 | qWarning() << "Can't execute without context"; | 86 | SinkWarning() << "Can't execute without context"; |
77 | result.setDone(); | 87 | result.setDone(); |
78 | result.setError(1); | 88 | result.setError(1); |
79 | } | 89 | } |