KTutorial  0.5.1
Signals | Public Member Functions | Protected Member Functions
ktutorial::scripting::ScriptedStep Class Reference

Step to be used in scripts. More...

#include <ScriptedStep.h>

Inheritance diagram for ktutorial::scripting::ScriptedStep:
Inheritance graph
[legend]
Collaboration diagram for ktutorial::scripting::ScriptedStep:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

ktutorial::scripting::ScriptedStep::ScriptedStep ( const QString &  id) [explicit]

Creates a new ScriptedStep with the given identifier.

Parameters:
idThe identifier of this Step.

Definition at line 29 of file ScriptedStep.cpp.


Member Function Documentation

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.

Parameters:
waitForThe WaitFor to connect.
receiverThe object to connect to.
slotThe 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.

Parameters:
waitForThe WaitFor to disconnect.
See also:
connectWaitFor(WaitFor*, QObject*, const QString&)

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.

Parameters:
scriptedStepA pointer to this ScriptedStep.
See also:
Step::setup()
Todo:
Change argument type to scripting::ScriptedStep* once all major Kross scripting backends support classes wrapped through WrapperInterface
void ktutorial::scripting::ScriptedStep::tearDown ( QObject *  scriptedStep) [signal]

Emitted when this ScriptedStep has to be tear down.

Parameters:
scriptedStepA pointer to this ScriptedStep.
See also:
Step::tearDown()
Todo:
Change argument type to scripting::ScriptedStep* once all major Kross scripting backends support classes wrapped through WrapperInterface

The documentation for this class was generated from the following files: