From 630f45719a527f8ee739b03bc62f886badea6df3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 13 Dec 2016 16:24:31 +0100 Subject: 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. --- framework/actions/actionhandler.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'framework/actions/actionhandler.cpp') 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 } +ActionHandlerHelper::ActionHandlerHelper(const Handler &handler) + : ActionHandler(nullptr), + handlerFunction(handler) +{ +} + +ActionHandlerHelper::ActionHandlerHelper(const IsReadyFunction &isReady, const Handler &handler) + : ActionHandler(nullptr), + isReadyFunction(isReady), + handlerFunction(handler) +{ +} ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const IsReadyFunction &isReady, const Handler &handler) : ActionHandler(nullptr), @@ -96,7 +108,10 @@ ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const IsRea bool ActionHandlerHelper::isActionReady(Context *context) { - return isReadyFunction(context); + if (isReadyFunction) { + return isReadyFunction(context); + } + return true; } ActionResult ActionHandlerHelper::execute(Context *context) -- cgit v1.2.3