KTutorial
0.5.1
|
Step to be used in scripts. More...
#include <ScriptedStep.h>
Signals | |
void | setup (QObject *scriptedStep) |
Emitted when this ScriptedStep has to be set up. | |
void | tearDown (QObject *scriptedStep) |
Emitted when this ScriptedStep has to be tear down. | |
Public Member Functions | |
ScriptedStep (const QString &id) | |
Creates a new ScriptedStep with the given identifier. | |
Protected Member Functions | |
virtual void | setup () |
Emits setup(scripting::ScriptedStep*) signal using this ScriptedStep as parameter. | |
virtual void | tearDown () |
Emits tearDown(scripting::ScriptedStep*) signal using this ScriptedStep as parameter. | |
virtual void | connectWaitFor (WaitFor *waitFor, QObject *receiver, const QString &slot) |
Connects the given WaitFor with the slot in the receiver. | |
virtual void | disconnectWaitFor (WaitFor *waitFor) |
Disconnects the given WaitFor. |
Step to be used in scripts.
It is just a special subclass of Step that makes possible to perform actions when the Step is activated or deactivated connecting to a signal instead of redefining C++ methods (as that can't be done in scripts). It also makes possible to execute functions in the script when a WaitFor waiting ends or an Option is selected.
If something must be performed when a Step is activated, implement a function in the script and connect it to setup(QObject*) signal. If something must be performed when a Step is deactivated, do the same with tearDown(QObject*) signal instead. Note that, although the argument in those signals is declared as QObject*, it is in fact the ScriptedStep that emitted the signals. It is a Kross limitation.
If a function of the script must be executed when an Option is selected or when the waiting of a WaitFor ends, just use addOption(Option*, QObject*, const QString&) or addWaitFor(WaitFor*, QObject*, const QString&) like you would do with a normal slot, but using "self" as the receiver and the function name (with or without parenthesis, at your option) as the slot.
Definition at line 55 of file ScriptedStep.h.
ktutorial::scripting::ScriptedStep::ScriptedStep | ( | const QString & | id | ) | [explicit] |
Creates a new ScriptedStep with the given identifier.
id | The identifier of this Step. |
Definition at line 29 of file ScriptedStep.cpp.
void ktutorial::scripting::ScriptedStep::connectWaitFor | ( | WaitFor * | waitFor, |
QObject * | receiver, | ||
const QString & | slot | ||
) | [protected, virtual] |
Connects the given WaitFor with the slot in the receiver.
If the receiver is a Kross::Action, the slot must be the name of a callable function (with or without parenthesis) instead of a true slot. When the WaitFor::waitEnded(WaitFor*) signal is emitted, the function will be called (thus behaving like a slot).
If the receiver is not a Kross::Action, the parent method is called.
waitFor | The WaitFor to connect. |
receiver | The object to connect to. |
slot | The slot to connect to. |
Reimplemented from ktutorial::Step.
Definition at line 43 of file ScriptedStep.cpp.
void ktutorial::scripting::ScriptedStep::disconnectWaitFor | ( | WaitFor * | waitFor | ) | [protected, virtual] |
Disconnects the given WaitFor.
If the WaitFor was connected to a Kross::Action function, the function will be "disconnected" from the WaitFor.
If the WaitFor was not connected to a Kross::Action function, the parent method is called.
waitFor | The WaitFor to disconnect. |
Reimplemented from ktutorial::Step.
Definition at line 69 of file ScriptedStep.cpp.
void ktutorial::scripting::ScriptedStep::setup | ( | QObject * | scriptedStep | ) | [signal] |
Emitted when this ScriptedStep has to be set up.
scriptedStep | A pointer to this ScriptedStep. |
void ktutorial::scripting::ScriptedStep::tearDown | ( | QObject * | scriptedStep | ) | [signal] |
Emitted when this ScriptedStep has to be tear down.
scriptedStep | A pointer to this ScriptedStep. |