diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-13 16:24:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-16 14:54:14 +0100 |
commit | 630f45719a527f8ee739b03bc62f886badea6df3 (patch) | |
tree | b9d859cbfedb30ad8a9570e3b87a419bf24ba6c7 /framework/actions/actionhandler.cpp | |
parent | b1a2e2de201985a00980bead5272977cda4ef637 (diff) | |
download | kube-630f45719a527f8ee739b03bc62f886badea6df3.tar.gz kube-630f45719a527f8ee739b03bc62f886badea6df3.zip |
Revamp of composercontroller to use actions more.
Instead of setting all properties individually we directly assign all
properties to a context that we assign to the actions.
This way actions can automatically update themselves as new data becomes
available, and we avoid the setter/getter boilerplate, at the cost of a
less explicit interface (But that could be improved by allowing to
define the required properties of a context in c++).
By relying on prehandler/posthandler to execute certain actions we
simplify the control flow and enable the future extension with handlers
that i.e. do encryption etc.
Diffstat (limited to 'framework/actions/actionhandler.cpp')
-rw-r--r-- | framework/actions/actionhandler.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/framework/actions/actionhandler.cpp b/framework/actions/actionhandler.cpp index 9d58f464..dc9edeca 100644 --- a/framework/actions/actionhandler.cpp +++ b/framework/actions/actionhandler.cpp | |||
@@ -77,6 +77,18 @@ QByteArray ActionHandler::actionId() const | |||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | ActionHandlerHelper::ActionHandlerHelper(const Handler &handler) | ||
81 | : ActionHandler(nullptr), | ||
82 | handlerFunction(handler) | ||
83 | { | ||
84 | } | ||
85 | |||
86 | ActionHandlerHelper::ActionHandlerHelper(const IsReadyFunction &isReady, const Handler &handler) | ||
87 | : ActionHandler(nullptr), | ||
88 | isReadyFunction(isReady), | ||
89 | handlerFunction(handler) | ||
90 | { | ||
91 | } | ||
80 | 92 | ||
81 | ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const IsReadyFunction &isReady, const Handler &handler) | 93 | ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const IsReadyFunction &isReady, const Handler &handler) |
82 | : ActionHandler(nullptr), | 94 | : ActionHandler(nullptr), |
@@ -96,7 +108,10 @@ ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const IsRea | |||
96 | 108 | ||
97 | bool ActionHandlerHelper::isActionReady(Context *context) | 109 | bool ActionHandlerHelper::isActionReady(Context *context) |
98 | { | 110 | { |
99 | return isReadyFunction(context); | 111 | if (isReadyFunction) { |
112 | return isReadyFunction(context); | ||
113 | } | ||
114 | return true; | ||
100 | } | 115 | } |
101 | 116 | ||
102 | ActionResult ActionHandlerHelper::execute(Context *context) | 117 | ActionResult ActionHandlerHelper::execute(Context *context) |