KTutorial
0.5.1
|
Waits for a signal to be emitted. More...
#include <WaitForSignal.h>
Public Slots | |
void | signalWaitEnd () |
Notifies that the wait for the signal ended. | |
Public Member Functions | |
Q_INVOKABLE | WaitForSignal () |
Creates a new WaitForSignal. | |
WaitForSignal (QObject *sender, const QString &signal) | |
Creates a new WaitForSignal. | |
virtual | ~WaitForSignal () |
Destroys this WaitForSignal. | |
Q_INVOKABLE void | setSignal (QObject *sender, const QString &signal) |
Sets the signal to wait for. | |
virtual bool | conditionMet () const |
Returns true if the connected signal was emitted while active, false otherwise. | |
virtual void | setActive (bool active) |
Sets this WaitForSignal active or inactive. |
Waits for a signal to be emitted.
When the signal is emitted and the WaitForSignal is active, the wait ends.
Note that if the signal is emitted while the WaitFor isn't active, it won't be registered and the condition won't be met. In order to met the condition, the signal must be emitted while the WaitForSignal is active.
Definition at line 38 of file WaitForSignal.h.
Creates a new WaitForSignal.
This constructor is needed to dynamically create WaitForSignal objects in scripts using ScriptingModule::newWaitFor(const QString&). Method setSignal(QObject*, const QString&) must be called to finish setting up the object. For C++ tutorials, use WaitForSignal(QObject*, const QString&) constructor instead of this one.
Definition at line 34 of file WaitForSignal.cpp.
References ktutorial::WaitForSignalPrivate::mConditionMet.
ktutorial::WaitForSignal::WaitForSignal | ( | QObject * | sender, |
const QString & | signal | ||
) |
Creates a new WaitForSignal.
Note that the signal name can be set with or without using the SIGNAL macro.
sender | The sender of the signal. |
signal | The signal to wait for. |
Definition at line 39 of file WaitForSignal.cpp.
References ktutorial::WaitForSignalPrivate::mConditionMet, and setSignal().
bool ktutorial::WaitForSignal::conditionMet | ( | ) | const [virtual] |
Returns true if the connected signal was emitted while active, false otherwise.
Implements ktutorial::WaitFor.
Definition at line 64 of file WaitForSignal.cpp.
References ktutorial::WaitForSignalPrivate::mConditionMet.
void ktutorial::WaitForSignal::setActive | ( | bool | active | ) | [virtual] |
Sets this WaitForSignal active or inactive.
Activating it resets its condition.
active | True to set it active, false otherwise. |
Reimplemented from ktutorial::WaitFor.
Definition at line 68 of file WaitForSignal.cpp.
References ktutorial::WaitForSignalPrivate::mConditionMet.
void ktutorial::WaitForSignal::setSignal | ( | QObject * | sender, |
const QString & | signal | ||
) |
Sets the signal to wait for.
Note that the signal name can be set with or without using the SIGNAL macro (in fact, in a script you will not have a SIGNAL macro). This method can be invoked from a script.
In fact, you should only invoke this method from a script, and only once, to set up the object. For C++ tutorials, use WaitForSignal(QObject*, const QString&) constructor when creating this WaitForSignal.
sender | The sender of the signal. |
signal | The signal to wait for. |
Definition at line 49 of file WaitForSignal.cpp.
References signalWaitEnd().
Referenced by WaitForSignal().
void ktutorial::WaitForSignal::signalWaitEnd | ( | ) | [slot] |
Notifies that the wait for the signal ended.
If active, it sets the condition as met and ends its wait.
Definition at line 78 of file WaitForSignal.cpp.
References ktutorial::WaitFor::isActive(), ktutorial::WaitForSignalPrivate::mConditionMet, and ktutorial::WaitFor::waitEnded().
Referenced by setSignal().