KoAction Class Reference

This class represent the glue between a user event and a piece of controlling logic. More...

#include <KoAction.h>

List of all members.

Public Member Functions

 KoAction (QObject *parent=0)
 Create a new Action object.
void setWeaver (ThreadWeaver::WeaverInterface *weaver)
 Set a ThreadWeaver on this action which is used to execute the action in a different thread when it is activated; Notice that setting the static weaver instance is enough for most cases;.
ThreadWeaver::WeaverInterface * weaver () const
 Return the currently set threadWeaver.
void setExecutePolicy (KoExecutePolicy *policy)
 Set a new policy for this action.
void setEnabled (bool enabled)
 Enable disable this action and all its registered components.
bool isEnabled () const
 return if the action is enabled.
int jobCount ()
 Return te amount of executes there are still to finish.
void updateUi (const QVariant &params)
 The signal emitted directly after the triggered() signal completed, but this signal is guaranteed to be in the Gui thread and can be used to update the user interface after an action has been completed.

Public Attributes

Q_SIGNALS __pad0__: void triggered(const QVariant &params)
public Q_SLOTS: void execute(const QVariant &params = QVariant())

Friends

class ActionJob


Detailed Description

This class represent the glue between a user event and a piece of controlling logic.

Events based programming creates the need to execute certain pieces of logic based on the incoming event, conveniently grouped per action. An action can be something like 'print'. This action uses a ThreadWeaver object to handle the actions and therefor this action is implicitly multithreading. Example usage:

    Action *myAction = new KoAction();
    myAction->setWeaver(m_weaver);
    myAction->connect(myAction, SIGNAL(triggered(const QVariant&)),
        target, SLOT(slot()), Qt::DirectConnection);

    myAction->execute();
In this example the method 'slot' will be called each time the 'execute()' method is called on the action. It will be called in a different thread from the main thread and you get the guarantee that it will never be called before a previous call has ended. The execute() method can be called from any thread to simply move control to an anonymous thread.

Notice that the default version uses the SimpleQueuedPolicy.


Constructor & Destructor Documentation

KoAction::KoAction ( QObject *  parent = 0  )  [explicit]

Create a new Action object.

The action will start with a SimpleQueuedPolicy.

Parameters:
parent the parent QObject, for memory mangement purposes.


Member Function Documentation

void KoAction::setEnabled ( bool  enabled  ) 

Enable disable this action and all its registered components.

Incoming events will not cause the action to be committed when the action is disabled.

Parameters:
enabled the new state of the action.

void KoAction::setWeaver ( ThreadWeaver::WeaverInterface *  weaver  ) 

Set a ThreadWeaver on this action which is used to execute the action in a different thread when it is activated; Notice that setting the static weaver instance is enough for most cases;.

    setWeaver(ThreadWeaver::Weaver::instance());
Parameters:
weaver the weaver to be used

void KoAction::updateUi ( const QVariant &  params  ) 

The signal emitted directly after the triggered() signal completed, but this signal is guaranteed to be in the Gui thread and can be used to update the user interface after an action has been completed.

Parameters:
params a variant that equals the variant given in the execute() signal


The documentation for this class was generated from the following files:
Generated on Sun May 11 22:36:09 2008 for libs by  doxygen 1.4.7