All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Slots | Signals | Public Member Functions
Qtilities::Core::Task Class Reference

The Task class is a ready to use implementation of the Qtilities::Core::Interfaces::ITask interface. More...

#include <Task.h>

Inheritance diagram for Qtilities::Core::Task:
Inheritance graph
[legend]

List of all members.

Public Types

enum  TaskLifeTime {
  LifeTimeManual = 1, LifeTimeDestroyWhenSuccessful = 2, LifeTimeDestroyWhenSuccessfullWithWarnings = 4, LifeTimeDestroyWhenStopped = 8,
  LifeTimeDestroyWhenFailed = 16
}
 The possible ways that the lifetime of this task can be managed. More...
- Public Types inherited from Qtilities::Core::Interfaces::ITask
enum  SubTaskPerformanceIndication { SubTaskNoPerformanceIndication = 0, SubTaskTimeFromTaskStart = 1 }
 Indicates how sub tasks are timed. More...
enum  TaskBusyState { TaskBusyClean = 0, TaskBusyWithWarnings = 1, TaskBusyWithErrors = 2 }
 The possible busy states of the task. More...
enum  TaskRemoveAction { TaskDeleteWhenRemoved = 0, TaskHideWhenRemoved = 1 }
 Indicates what should happen to the task when the user click's on the "Remove Task" button in a Qtilities::CoreGui::SingleTaskWidget. The "Stop Task" becomes the "Remove Task" button when the task was stopped or completed. More...
enum  TaskResult {
  TaskNoResult = 0, TaskSuccessful = 1, TaskSuccessfulWithWarnings = 2, TaskSuccessfulWithErrors = 3,
  TaskResultFromBusyStateFailOnError = 4, TaskResultFromBusyStateSuccessOnError = 5, TaskFailed = 6
}
 The possible results of a completed task. More...
enum  TaskState {
  TaskNotStarted = 1, TaskBusy = 2, TaskPaused = 4, TaskStopped = 8,
  TaskCompleted = 16, TaskIdle = TaskNotStarted | TaskCompleted | TaskStopped
}
 The possible states in which a task might find itself. More...
enum  TaskStopAction { TaskDeleteWhenStopped = 0, TaskHideWhenStopped = 1, TaskDoNothingWhenStopped = 2 }
 Indicates what should happen to the task when the user stops it in a Qtilities::CoreGui::SingleTaskWidget. More...
enum  TaskStopConfirmation { TaskStopConfirmationNone = 0, TaskStopConfirmationMsgBox = 1 }
 Indicates if an confirmation message is required when an user stops the task in a Qtilities::CoreGui::SingleTaskWidget. More...
enum  TaskType { TaskLocal = 0, TaskGlobal = 1 }
 The possible types of tasks. More...

Public Slots

void addCompletedSubTasks (int number_of_sub_tasks=1, const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to add completed tasks from the process's side.
bool completeTask (ITask::TaskResult result=ITask::TaskResultFromBusyStateFailOnError, const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to complete the task from the process's side.
virtual void pause ()
 Pauses the task from the user interface.
bool pauseTask (const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to stop tasks from the process's side.
virtual void resume ()
 Resumes the task after it has been paused.
bool resumeTask (const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to stop tasks from the process's side.
virtual void start ()
 Starts the task from the user interface.
bool startTask (int expected_subtasks=-1, const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to start tasks from the process's side.
virtual void stop ()
 Stops the task from the user interface.
bool stopTask (const QString &message=QString(), Logger::MessageType type=Logger::Info)
 Function which should be used to stop tasks from the process's side.

Signals

void busyStateChanged (ITask::TaskBusyState new_busy_state, ITask::TaskBusyState old_busy_state) const
 Signal emitted when the busy state of the task changes.
void canPauseChanged (bool new_value) const
 Signal emitted when a task's ability to be paused changed.
void canStartChanged (bool new_value) const
 Signal emitted when a task's ability to be started changed.
void canStopChanged (bool new_value) const
 Signal emitted when a task's ability to be stopped changed.
void displayedNameChanged (const QString &displayed_name) const
 Signal emitted when the task's displayed name changes.
void newMessageLogged (const QString &message, Logger::MessageType) const
 Signal emitted when the new messages are logged in this task.
void stateChanged (ITask::TaskState new_state, ITask::TaskState old_state) const
 Signal emitted when the task's state changes.
void subTaskCompleted (int number_task_completed=1, const QString &message=QString(), Logger::MessageType type=Logger::Info) const
 Signal emitted when subtasks are completed in order to show the correct progress information.
void taskAboutToComplete () const
 Signal emitted when the task is about to be completed.
void taskAboutToPause () const
 Signal emitted when the task is about to be paused.
void taskAboutToResume () const
 Signal emitted when the task is about to be resumed from a paused state.
void taskAboutToStart () const
 Signal emitted when the task is about to be started.
void taskAboutToStop () const
 Signal emitted when the task is about to be stopped.
void taskCompleted (ITask::TaskResult result, const QString &message=QString(), Logger::MessageType type=Logger::Info) const
 Signal emitted when the task started.
void taskElapsedTimeChanged (int msec) const
 Signal emitted when the task's elapsed time changes.
void taskPaused () const
 Signal emitted when the task is paused.
void taskResumed () const
 Signal emitted when the task is resumed after it was paused.
void taskStarted (int expected_subtasks=-1, const QString &message=QString(), Logger::MessageType type=Logger::Info) const
 Signal emitted when the task started.
void taskStopped () const
 Signal emitted when the task is stopped during execution.
void taskSubTaskAboutToComplete () const
 Signal emitted when a sub task is about to be completed.
void taskTypeChanged (ITask::TaskType new_task_type) const
 Signal emitted when the task's type changes.

Public Member Functions

TaskBusyState busyState () const
 The busy state of the task.
bool canPause () const
bool canStart () const
bool canStop () const
void clearLog ()
 Clears the task's log.
bool clearLogOnStart () const
 When true, the task's log will be cleared everytime the task is started.
int currentProgress () const
 Returns the number of subtasks completed.
AbstractLoggerEnginecustomLoggerEngine () const
 Returns the custom logger engine used by this task.
QString displayName () const
 Returns the display name for the task. The display name will typically be set just before emitting taskStarted() and contain a little bit more information than taskName().
int elapsedTime () const
 Returns the elapsed time in miliseconds of the last time the task was run.
QStringList lastErrorMessages (int count) const
 Returns the last error logged in the task while it was busy.
int lastErrorMessagesStackSize () const
 Gets the last error logged stack size.
void logError (const QString &message)
 Convenience function to log an error in the task log.
AbstractLoggerEngineloggerEngine () const
 Returns a reference to the logger engine logging activities of this task. When loggingEnabled() is false, this function will always return 0.
bool loggingEnabled () const
 Indicates if the activities of this task is logged.
void logMessage (const QString &message, Logger::MessageType type=Logger::Info)
 Logs a message to this task.
void logWarning (const QString &message)
 Convenience function to log a warning in the task log.
int numberOfSubTasks () const
 Returns the number of subtasks associated with the task.
QObject * objectBase ()
 Returns the QObject* base of the interface.
const QObject * objectBase () const
 Returns a const QObject* base of the interface.
ITaskparentTask () const
 The parent task of this task.
void removeCustomLoggerEngine ()
 Removes the current custom logger engine from this task.
void removeParentTask ()
 Removes the parent task of this task.
TaskResult result () const
 The result of the task.
void setClearLogOnStart (bool clear_log_on_start=true) const
 Sets if the log must be cleared when the task is started.
void setCustomLoggerEngine (AbstractLoggerEngine *engine, bool use_only_this_engine=false)
 Sets a custom logger engine to be used by this task.
void setDisplayName (const QString &display_name)
 Sets the display name of the task.
void setLastErrorMessagesStackSize (int size)
 Sets the last error logged stack size.
void setLastRunTime (int msec)
 This function allows you to overwrite the last run time of the task.
void setLogContext (Logger::MessageContextFlags message_context)
 Sets the default message logging context flags of this task.
void setLoggerEngine (AbstractLoggerEngine *engine)
 Sets the logger engine to be used by this task.
void setParentTask (ITask *parent_task)
void setSubTaskPerformanceIndication (SubTaskPerformanceIndication performance_indication)
 Sets what performance measures are used for sub tasks.
void setTaskLifeTimeFlags (TaskLifeTimeFlags task_lifetime_flags)
 Sets the task lifetime.
void setTaskName (const QString &task_name)
 Sets the name of the task.
void setTaskRemoveAction (TaskRemoveAction task_remove_action)
 Sets the task's remove action.
void setTaskStopAction (TaskStopAction task_stop_action)
 Sets the task's stop action.
void setTaskStopConfirmation (TaskStopConfirmation task_stop_confirmation)
 Sets the task's stop configuration action.
void setTaskType (TaskType task_type)
 Sets the task type.
TaskState state () const
 The state of the task.
SubTaskPerformanceIndication subTaskPerformanceIndication () const
 Gets what performance measures are used for sub tasks.
 Task (const QString &task_name, bool enable_logging=true, QObject *parent=0)
 Default constructor.
TaskLifeTimeFlags taskLifeTimeFlags () const
 Gets the task lifetime.
QString taskName () const
 The name of the task.
TaskRemoveAction taskRemoveAction () const
 Indicates what should happen to the task when the user click's on the "Remove Task" button in a Qtilities::CoreGui::SingleTaskWidget.
TaskStopAction taskStopAction () const
 Indicates what should happen to the task when the user click's on the "Stop Task" button in a Qtilities::CoreGui::SingleTaskWidget.
TaskStopConfirmation taskStopConfirmation () const
 Indicates what should happen to the task when the user click's on the "Stop Task" button in a Qtilities::CoreGui::SingleTaskWidget.
TaskType taskType () const
 The type of this task.
- Public Member Functions inherited from Qtilities::Core::Interfaces::ITask
bool elapsedTimeChangedNotificationsEnabled () const
 Indicates if elapsed time changed notifications through taskElapsedTimeChanged() are enabled.
virtual QString elapsedTimeString (int msec=-1, const QString &format="hh:mm:ss.zzz") const
 Returns the elapsed time of the task as a string.
int getWidgetLoggerEngineDisplaysFlag () const
 Gets the (int) WidgetLoggerEngine::MessageDisplaysFlag used when assigning logger engines to tasks.
void setWidgetLoggerEngineDisplaysFlag (int message_display_flags)
 Sets the (int) WidgetLoggerEngine::MessageDisplaysFlag used when assigning logger engines to tasks.
int taskID () const
 The ID of this task.
void toggleElapsedTimeChangedNotifications (bool is_enabled)
 Enables elapsed time changed notifications through taskElapsedTimeChanged().
- Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase
QString objectOriginID () const
 Allows interfaces to provide some sort of source identification.
void setObjectOriginID (const QString &object_origin_id)
 Allows setting of the object source ID of this interface implementation.

Additional Inherited Members

- Static Public Member Functions inherited from Qtilities::Core::Interfaces::ITask
static void logMessageToTask (const QString &message, ITask *task=0, Logger::MessageType type=Logger::Info)
 Message logging function which directs messages aimed for a task to the task if the task exists, or to the logger as system wide messages if the task does not exist.
static void logPriorityMessageToTask (const QString &message, ITask *task=0, Logger::MessageType type=Logger::Info)
 Message logging function which logs the message as a priority message and directs messages aimed for a task to the task if the task exists, or to the logger as system wide messages if the task does not exist.

Detailed Description

The Task class is a ready to use implementation of the Qtilities::Core::Interfaces::ITask interface.

See the Tasking article for more information on tasking.

This class was added in Qtilities v1.0.


Member Enumeration Documentation

The possible ways that the lifetime of this task can be managed.

The default is LifetimeManual.

Enumerator:
LifeTimeManual 

The lifetime of this task is managed manually.

LifeTimeDestroyWhenSuccessful 

The task will destroy itself when it completed succesfully (without any warnings).

LifeTimeDestroyWhenSuccessfullWithWarnings 

The task will destroy itself when it completed succesfully (with warnings).

LifeTimeDestroyWhenStopped 

The task will destroy itself when stopped.

LifeTimeDestroyWhenFailed 

The task will destroy itself when it failed.


Constructor & Destructor Documentation

Qtilities::Core::Task::Task ( const QString &  task_name,
bool  enable_logging = true,
QObject *  parent = 0 
)

Default constructor.

Parameters:
task_nameA name for the task.
enable_loggingWhen true, the activity of this task will be logged. Thus, logMessage() will route messages to a logger engine created for this task.

Member Function Documentation

ITask::TaskBusyState Qtilities::Core::Task::busyState ( ) const
virtual

The busy state of the task.

Default is TaskBusyClean.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::busyStateChanged ( ITask::TaskBusyState  new_busy_state,
ITask::TaskBusyState  old_busy_state 
) const
virtualsignal

Signal emitted when the busy state of the task changes.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

bool Qtilities::Core::Task::canPause ( ) const
virtual

False by default in Qtilities::Core::Task.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::canPauseChanged ( bool  new_value) const
virtualsignal

Signal emitted when a task's ability to be paused changed.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

bool Qtilities::Core::Task::canStart ( ) const
virtual

False by default in Qtilities::Core::Task.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::canStartChanged ( bool  new_value) const
virtualsignal

Signal emitted when a task's ability to be started changed.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

bool Qtilities::Core::Task::canStop ( ) const
virtual

False by default in Qtilities::Core::Task.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::canStopChanged ( bool  new_value) const
virtualsignal

Signal emitted when a task's ability to be stopped changed.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

int Qtilities::Core::Task::currentProgress ( ) const
virtual

Returns the number of subtasks completed.

Default implementation returns 0, thus no sub tasks.

Reimplemented from Qtilities::Core::Interfaces::ITask.

AbstractLoggerEngine * Qtilities::Core::Task::customLoggerEngine ( ) const
virtual

Returns the custom logger engine used by this task.

See also:
setCustomLoggerEngine()

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::displayedNameChanged ( const QString &  displayed_name) const
virtualsignal

Signal emitted when the task's displayed name changes.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

QString Qtilities::Core::Task::displayName ( ) const
virtual

Returns the display name for the task. The display name will typically be set just before emitting taskStarted() and contain a little bit more information than taskName().

The default implementation will just return the task name for the task. However in many cases its possible to provide a more detailed name to display in any task widget.

Reimplemented from Qtilities::Core::Interfaces::ITask.

int Task::elapsedTime ( ) const
virtual

Returns the elapsed time in miliseconds of the last time the task was run.

When a task was paused, the timer will continue to time for the duration that the task was paused.

When the task has not been run 0 is returned. When busy the function will return the elapsed time when the function is called. When the task is completed, the function will return the total time the task took to complete.

See also:
elapsedTimeString(), taskElapsedTimeChanged(), toggleElapsedTimeChangedNotifications()

This function was added in Qtilities v1.1.

Implements Qtilities::Core::Interfaces::ITask.

QStringList Task::lastErrorMessages ( int  count) const
virtual

Returns the last error logged in the task while it was busy.

Parameters:
countThe number of messages to return. Note that the maximum returnable number of messages are defined by errorMessageStackSize(). Also, if the number of error messages that were logged at the time this function is called is less than the count specified, only the number of currently logged messages will be returned. When -1 (default) all messages in the stack are returned.
Returns:
A QStringList with the most recent message logged being the first item in the list, and the last message being the first message logged.
Note:
Only errors logged while this task is busy are taken into account.
Logging must be enabled in order for this function to work. See loggingEnabled().

This function was added in Qtilities v1.4.

Implements Qtilities::Core::Interfaces::ITask.

int Task::lastErrorMessagesStackSize ( ) const
virtual

Gets the last error logged stack size.

The default is 10.

Returns:
The size of the last error messages stack.
See also:
lastErrorMessagesStackSize(), lastErrorMessages()

This function was added in Qtilities v1.4.

Implements Qtilities::Core::Interfaces::ITask.

AbstractLoggerEngine * Qtilities::Core::Task::loggerEngine ( ) const
virtual

Returns a reference to the logger engine logging activities of this task. When loggingEnabled() is false, this function will always return 0.

See also:
setLoggerEngine()

Reimplemented from Qtilities::Core::Interfaces::ITask.

bool Qtilities::Core::Task::loggingEnabled ( ) const
virtual

Indicates if the activities of this task is logged.

False by default.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::newMessageLogged ( const QString &  message,
Logger::MessageType   
) const
virtualsignal

Signal emitted when the new messages are logged in this task.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

int Qtilities::Core::Task::numberOfSubTasks ( ) const
virtual

Returns the number of subtasks associated with the task.

Default implementation returns -1, thus no sub tasks.

Reimplemented from Qtilities::Core::Interfaces::ITask.

const QObject* Qtilities::Core::Task::objectBase ( ) const
inlinevirtual

Returns a const QObject* base of the interface.

This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.

Implements Qtilities::Core::Interfaces::IObjectBase.

ITask * Qtilities::Core::Task::parentTask ( ) const
virtual

The parent task of this task.

See also:
setParentTask(), removeParentTask()

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::pause ( )
virtualslot

Pauses the task from the user interface.

In Qtilities::Core::Task, the task will emit pauseTaskRequest() which must be handled by the process represented by Task. Qtilities::Core::QtilitiesProcess is a good example of this.

The task can be resumed through resume().

Note:
This function must be a slot in your interface implementation and will only do something when canPause() is true.

The default implementation of ITask does nothing.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::removeCustomLoggerEngine ( )
virtual

Removes the current custom logger engine from this task.

Note:
This function does not delete the custom logger engine which was used, if any.
See also:
setCustomLoggerEngine()

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::removeParentTask ( )
virtual

Removes the parent task of this task.

See also:
setParentTask(), parentTask()

Implements Qtilities::Core::Interfaces::ITask.

ITask::TaskResult Qtilities::Core::Task::result ( ) const
virtual

The result of the task.

Default is TaskNoResult.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::resume ( )
virtualslot

Resumes the task after it has been paused.

In Qtilities::Core::Task, the task will emit resumeTaskRequest() which must be handled by the process represented by Task. Qtilities::Core::QtilitiesProcess is a good example of this.

Note:
This function must be a slot in your interface implementation and will only do something if the task is in the paused state.

The default implementation of ITask does nothing.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setClearLogOnStart ( bool  clear_log_on_start = true) const
virtual

Sets if the log must be cleared when the task is started.

True by default.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setCustomLoggerEngine ( AbstractLoggerEngine engine,
bool  use_only_this_engine = false 
)
virtual

Sets a custom logger engine to be used by this task.

The task will not take ownership of the custom logger engine.

Parameters:
use_only_this_engineWhen true, the task's own logger engine will be deleted and only the custom engine will be used to log messages.
See also:
setLoggerEngine()

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Task::setLastErrorMessagesStackSize ( int  size)
virtual

Sets the last error logged stack size.

Parameters:
sizeThe new size of the last error messages stack.
See also:
lastErrorMessagesStackSize(), lastErrorMessages()

This function was added in Qtilities v1.4.

Implements Qtilities::Core::Interfaces::ITask.

void Task::setLastRunTime ( int  msec)
virtual

This function allows you to overwrite the last run time of the task.

setElapsedTime This is usefull when you need to restore the state of a task for example.

Parameters:
msecThe new elapsed time in msec.

This function was added in Qtilities v1.2.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setLogContext ( Logger::MessageContextFlags  message_context)
virtual

Sets the default message logging context flags of this task.

Default is Logger::EngineSpecificMessages.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setLoggerEngine ( AbstractLoggerEngine engine)
virtual

Sets the logger engine to be used by this task.

When logging is enabled this function will be called automatically by Qtilities::CoreGui::TaskManagerGui when the task is registered in the global object pool.

If you want this task's messages to be logged in a different logger engine you should call setCustomLoggerEngine(). An example where this is usefull is when you want to log the messages of a task in the log of another task. In that case, call setCustomLoggerEngine() with the loggerEngine() of the task where the messages should be logged.

The task will take ownership of the logger engine. This function can only be called once. Thus, if the task already has a logger engine calling this function will do nothing. To use a custom logger engine, see setCustomLoggerEngine().

See also:
setCustomLoggerEngine()

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setParentTask ( ITask parent_task)
virtual

The lifetime of the parent task will be tracked. Thus, if your parent task is deleted this task will stop to log messages to it.

Note:
The parent task does not become the parent() of this task. Thus, this task will not be deleted when the parent task is deleted.

Implements Qtilities::Core::Interfaces::ITask.

void Task::setSubTaskPerformanceIndication ( SubTaskPerformanceIndication  performance_indication)
virtual

Sets what performance measures are used for sub tasks.

See also:
SubTaskPerformanceIndication()

This function was added in Qtilities v1.1.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::setTaskLifeTimeFlags ( TaskLifeTimeFlags  task_lifetime_flags)

Sets the task lifetime.

Set this before starting your task.

void Qtilities::Core::Task::setTaskName ( const QString &  task_name)

Sets the name of the task.

Parameters:
task_nameThe new name of the task. This name is not validated in here, thus make sure its correct.

This function was added in Qtilities v1.2.

void Task::setTaskStopConfirmation ( TaskStopConfirmation  task_stop_confirmation)
virtual

Sets the task's stop configuration action.

See also:
taskStopConfirmation()

This function was added in Qtilities v1.3.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::start ( )
virtualslot

Starts the task from the user interface.

The slot called when the user starts the task from it's Qtilities::CoreGui::SingleTaskWidget. Programmatically, you should use startTask() instead of start(). In Qtilities::Core::Task, the task will emit startTaskRequest() which must be handled by the task represented by Task. Qtilities::Core::QtilitiesProcess is a good example of this.

Note:
This function must be a slot in your interface implementation and will only do something when canStart() is true.

The default implementation of ITask does nothing.

Reimplemented from Qtilities::Core::Interfaces::ITask.

ITask::TaskState Qtilities::Core::Task::state ( ) const
virtual

The state of the task.

Default is TaskNotStarted.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::stateChanged ( ITask::TaskState  new_state,
ITask::TaskState  old_state 
) const
virtualsignal

Signal emitted when the task's state changes.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::stop ( )
virtualslot

Stops the task from the user interface.

In Qtilities::Core::Task, the task will emit stopTaskRequest() which must be handled by the process represented by Task. Qtilities::Core::QtilitiesProcess is a good example of this.

Note:
This function must be a slot in your interface implementation and will only do something when canStop() is true.

The default implementation of ITask does nothing.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::subTaskCompleted ( int  number_task_completed = 1,
const QString &  message = QString(),
Logger::MessageType  type = Logger::Info 
) const
virtualsignal

Signal emitted when subtasks are completed in order to show the correct progress information.

Parameters:
number_task_completedThe number of subtasks completed, 1 by default.
subtask_messageA message which describes the subtask(s) completed.
Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

ITask::SubTaskPerformanceIndication Task::subTaskPerformanceIndication ( ) const
virtual

Gets what performance measures are used for sub tasks.

Default is SubTaskTimeFromTaskStart.

See also:
setSubTaskPerformanceIndication()

This function was added in Qtilities v1.1.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskAboutToComplete ( ) const
virtualsignal

Signal emitted when the task is about to be completed.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskAboutToPause ( ) const
virtualsignal

Signal emitted when the task is about to be paused.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskAboutToResume ( ) const
virtualsignal

Signal emitted when the task is about to be resumed from a paused state.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskAboutToStart ( ) const
virtualsignal

Signal emitted when the task is about to be started.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskAboutToStop ( ) const
virtualsignal

Signal emitted when the task is about to be stopped.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskCompleted ( ITask::TaskResult  result,
const QString &  message = QString(),
Logger::MessageType  type = Logger::Info 
) const
virtualsignal

Signal emitted when the task started.

Parameters:
resultThe result of the task.
messageA message which describes the completion of the task.
Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskElapsedTimeChanged ( int  msec) const
virtualsignal

Signal emitted when the task's elapsed time changes.

This function is only emitted while the task is busy, and when elapsed time change notifications are enabled. See toggleElapsedTimeChangedNotifications(). When enabled, it will emit every second while the task is busy.

Parameters:
Theelapsed time in miliseconds of the task at the time that the signal was emitted. You can format the received msec value to a string using elapsedTimeString().

This function is only emitted while the task is busy.

Note:
This function must be a signal in your interface implementation.
See also:
elapsedTime(), elapsedTimeString(), toggleElapsedTimeChangedNotifications(), toggleElapsedTimeChangedNotifications()

Implements Qtilities::Core::Interfaces::ITask.

QString Qtilities::Core::Task::taskName ( ) const
virtual

The name of the task.

Note:
taskName() should be short, around 3 words.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskPaused ( ) const
virtualsignal

Signal emitted when the task is paused.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

ITask::TaskRemoveAction Qtilities::Core::Task::taskRemoveAction ( ) const
virtual

Indicates what should happen to the task when the user click's on the "Remove Task" button in a Qtilities::CoreGui::SingleTaskWidget.

Default is TaskHideWhenRemoved.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskResumed ( ) const
virtualsignal

Signal emitted when the task is resumed after it was paused.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskStarted ( int  expected_subtasks = -1,
const QString &  message = QString(),
Logger::MessageType  type = Logger::Info 
) const
virtualsignal

Signal emitted when the task started.

Parameters:
expected_subtasksThe number of subtasks which must be completed in order for this task to complete. If you don't provide the number of subtasks, progress for the task will be shown as a progress bar as a busy indicator. See QProgressBar for more information on this. If you do provide the number of subtasks, the progress be updated everytime subtaskCompleted() is emitted.
Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

ITask::TaskStopAction Qtilities::Core::Task::taskStopAction ( ) const
virtual

Indicates what should happen to the task when the user click's on the "Stop Task" button in a Qtilities::CoreGui::SingleTaskWidget.

Default is TaskDoNothingWhenStopped.

Reimplemented from Qtilities::Core::Interfaces::ITask.

ITask::TaskStopConfirmation Task::taskStopConfirmation ( ) const
virtual

Indicates what should happen to the task when the user click's on the "Stop Task" button in a Qtilities::CoreGui::SingleTaskWidget.

Default is TaskStopConfirmationMsgBox.

See also:
setTaskStopConfirmation()

This function was added in Qtilities v1.3.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskStopped ( ) const
virtualsignal

Signal emitted when the task is stopped during execution.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskSubTaskAboutToComplete ( ) const
virtualsignal

Signal emitted when a sub task is about to be completed.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.

ITask::TaskType Qtilities::Core::Task::taskType ( ) const
virtual

The type of this task.

Default is TaskGlobal.

Reimplemented from Qtilities::Core::Interfaces::ITask.

void Qtilities::Core::Task::taskTypeChanged ( ITask::TaskType  new_task_type) const
virtualsignal

Signal emitted when the task's type changes.

Note:
This function must be a signal in your interface implementation.

Implements Qtilities::Core::Interfaces::ITask.



Qtilities : Reference Documentation Back to top Copyright © 2009-2013, Jaco Naudé