summaryrefslogtreecommitdiffstats
path: root/framework/actions/action.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/actions/action.cpp')
-rw-r--r--framework/actions/action.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/framework/actions/action.cpp b/framework/actions/action.cpp
index f41feb66..1344d112 100644
--- a/framework/actions/action.cpp
+++ b/framework/actions/action.cpp
@@ -42,7 +42,11 @@ Action::Action(const QByteArray &actionId, Context &context, QObject *parent)
42 mContext(&context), 42 mContext(&context),
43 mActionId(actionId) 43 mActionId(actionId)
44{ 44{
45 setContext(&context);
46}
45 47
48Action::~Action()
49{
46} 50}
47 51
48void Action::setContext(Context *context) 52void Action::setContext(Context *context)
@@ -61,6 +65,16 @@ void Action::setContext(Context *context)
61 emit readyChanged(); 65 emit readyChanged();
62} 66}
63 67
68bool Action::eventFilter(QObject *obj, QEvent *e)
69{
70 if (obj == mContext) {
71 if (e->type() == QEvent::DynamicPropertyChange) {
72 contextChanged();
73 }
74 }
75 return QObject::eventFilter(obj, e);
76}
77
64void Action::contextChanged() 78void Action::contextChanged()
65{ 79{
66 emit readyChanged(); 80 emit readyChanged();
@@ -84,7 +98,7 @@ QByteArray Action::actionId() const
84 98
85bool Action::ready() const 99bool Action::ready() const
86{ 100{
87 return ActionBroker::instance().isActionReady(mActionId, mContext); 101 return ActionBroker::instance().isActionReady(mActionId, mContext, mPreHandler);
88} 102}
89 103
90void Action::execute() 104void Action::execute()
@@ -99,11 +113,15 @@ ActionResult Action::executeWithResult()
99 113
100void Action::addPreHandler(ActionHandler *handler) 114void Action::addPreHandler(ActionHandler *handler)
101{ 115{
116 //For cleanup
117 handler->setParent(this);
102 mPreHandler << handler; 118 mPreHandler << handler;
103} 119}
104 120
105void Action::addPostHandler(ActionHandler *handler) 121void Action::addPostHandler(ActionHandler *handler)
106{ 122{
123 //For cleanup
124 handler->setParent(this);
107 mPostHandler << handler; 125 mPostHandler << handler;
108} 126}
109 127