All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Static Public Member Functions | Friends
Qtilities::Core::Interfaces::ITask Class Reference

An interface through which you can communicate with a task. Qtilities::Core::Task is a ready to use implementation of this interface. More...

#include <ITask.h>

Inheritance diagram for Qtilities::Core::Interfaces::ITask:
Inheritance graph
[legend]

List of all members.

Public Types

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 Member Functions

virtual TaskBusyState busyState () const =0
 The busy state of the task.
virtual void busyStateChanged (TaskBusyState new_busy_state, TaskBusyState old_busy_state) const =0
 Signal emitted when the busy state of the task changes.
virtual bool canPause () const
 Indicates if users can pause the task.
virtual void canPauseChanged (bool new_value) const =0
 Signal emitted when a task's ability to be paused changed.
virtual bool canStart () const
 Indicates if users can start the task.
virtual void canStartChanged (bool new_value) const =0
 Signal emitted when a task's ability to be started changed.
virtual bool canStop () const
 Indicates if users can stop the task.
virtual void canStopChanged (bool new_value) const =0
 Signal emitted when a task's ability to be stopped changed.
virtual void clearLog ()
 Clears the task's log.
virtual bool clearLogOnStart () const
 When true, the task's log will be cleared everytime the task is started.
virtual int currentProgress () const
 Returns the number of subtasks completed.
virtual AbstractLoggerEnginecustomLoggerEngine () const
 Returns the custom logger engine used by this task.
virtual void displayedNameChanged (const QString &displayed_name) const =0
 Signal emitted when the task's displayed name changes.
virtual 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().
virtual int elapsedTime () const =0
 Returns the elapsed time in miliseconds of the last time the task was run.
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.
virtual QStringList lastErrorMessages (int count=-1) const =0
 Returns the last error logged in the task while it was busy.
virtual int lastErrorMessagesStackSize () const =0
 Gets the last error logged stack size.
virtual void logError (const QString &message)=0
 Convenience function to log an error in the task log.
virtual AbstractLoggerEngineloggerEngine () const
 Returns a reference to the logger engine logging activities of this task. When loggingEnabled() is false, this function will always return 0.
virtual bool loggingEnabled () const
 Indicates if the activities of this task is logged.
virtual void logMessage (const QString &message, Logger::MessageType type=Logger::Info)=0
 Logs a message to this task.
virtual void logWarning (const QString &message)=0
 Convenience function to log a warning in the task log.
virtual void newMessageLogged (const QString &message, Logger::MessageType) const =0
 Signal emitted when the new messages are logged in this task.
virtual int numberOfSubTasks () const
 Returns the number of subtasks associated with the task.
virtual ITaskparentTask () const =0
 The parent task of this task.
virtual void pause ()
 Pauses the task from the user interface.
virtual void removeCustomLoggerEngine ()
 Removes the current custom logger engine from this task.
virtual void removeParentTask ()=0
 Removes the parent task of this task.
virtual TaskResult result () const =0
 The result of the task.
virtual void resume ()
 Resumes the task after it has been paused.
virtual void setClearLogOnStart (bool clear_log_on_start=true) const =0
 Sets if the log must be cleared when the task is started.
virtual void setCustomLoggerEngine (AbstractLoggerEngine *engine, bool use_only_this_engine=false)
 Sets a custom logger engine to be used by this task.
virtual void setDisplayName (const QString &display_name)=0
 Sets the display name of the task.
virtual void setLastErrorMessagesStackSize (int size)=0
 Sets the last error logged stack size.
virtual void setLastRunTime (int msec)=0
 This function allows you to overwrite the last run time of the task.
virtual void setLogContext (Logger::MessageContextFlags message_context)=0
 Sets the default message logging context flags of this task.
virtual void setLoggerEngine (AbstractLoggerEngine *engine)
 Sets the logger engine to be used by this task.
virtual void setParentTask (ITask *parent_task)=0
 Sets the parent task of this task.
virtual void setSubTaskPerformanceIndication (SubTaskPerformanceIndication performance_indication)=0
 Sets what performance measures are used for sub tasks.
virtual void setTaskRemoveAction (TaskRemoveAction task_remove_action)=0
 Sets the task's remove action.
virtual void setTaskStopAction (TaskStopAction task_stop_action)=0
 Sets the task's stop action.
virtual void setTaskStopConfirmation (TaskStopConfirmation task_stop_confirmation)=0
 Sets the task's stop configuration action.
virtual void setTaskType (TaskType task_type)=0
 Sets the task type.
void setWidgetLoggerEngineDisplaysFlag (int message_display_flags)
 Sets the (int) WidgetLoggerEngine::MessageDisplaysFlag used when assigning logger engines to tasks.
virtual void start ()
 Starts the task from the user interface.
virtual TaskState state () const =0
 The state of the task.
virtual void stateChanged (TaskState new_state, TaskState old_state) const =0
 Signal emitted when the task's state changes.
virtual void stop ()
 Stops the task from the user interface.
virtual void subTaskCompleted (int number_task_completed=1, const QString &message=QString(), Logger::MessageType type=Logger::Info) const =0
 Signal emitted when subtasks are completed in order to show the correct progress information.
virtual
SubTaskPerformanceIndication 
subTaskPerformanceIndication () const
 Gets what performance measures are used for sub tasks.
virtual void taskAboutToComplete () const =0
 Signal emitted when the task is about to be completed.
virtual void taskAboutToPause () const =0
 Signal emitted when the task is about to be paused.
virtual void taskAboutToResume () const =0
 Signal emitted when the task is about to be resumed from a paused state.
virtual void taskAboutToStart () const =0
 Signal emitted when the task is about to be started.
virtual void taskAboutToStop () const =0
 Signal emitted when the task is about to be stopped.
virtual void taskCompleted (ITask::TaskResult result, const QString &message=QString(), Logger::MessageType type=Logger::Info) const =0
 Signal emitted when the task started.
virtual void taskElapsedTimeChanged (int msec) const =0
 Signal emitted when the task's elapsed time changes.
int taskID () const
 The ID of this task.
virtual QString taskName () const =0
 The name of the task.
virtual void taskPaused () const =0
 Signal emitted when the task is paused.
virtual 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.
virtual void taskResumed () const =0
 Signal emitted when the task is resumed after it was paused.
virtual void taskStarted (int expected_subtasks=-1, const QString &message=QString(), Logger::MessageType type=Logger::Info) const =0
 Signal emitted when the task started.
virtual 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.
virtual 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.
virtual void taskStopped () const =0
 Signal emitted when the task is stopped during execution.
virtual void taskSubTaskAboutToComplete () const =0
 Signal emitted when a sub task is about to be completed.
virtual TaskType taskType () const
 The type of this task.
virtual void taskTypeChanged (TaskType new_task_type) const =0
 Signal emitted when the task's type changes.
void toggleElapsedTimeChangedNotifications (bool is_enabled)
 Enables elapsed time changed notifications through taskElapsedTimeChanged().
- Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase
virtual QObject * objectBase ()=0
 Returns the QObject* base of the interface.
virtual const QObject * objectBase () const =0
 Returns a const QObject* base of the interface.
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.

Static Public Member Functions

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.

Friends

class Qtilities::Core::TaskManager

Detailed Description

An interface through which you can communicate with a task. Qtilities::Core::Task is a ready to use implementation of this interface.

See the Tasking article for more information on tasking.

This class was added in Qtilities v1.0.


Member Enumeration Documentation

Indicates how sub tasks are timed.

Enumerator:
SubTaskNoPerformanceIndication 

Sub tasks will not be timed, usefull for tasks with many small, quick sub tasks.

SubTaskTimeFromTaskStart 

Sub tasks are timed from the start of the task and execution times are printed in the task log when task logging is enabled.

The possible busy states of the task.

Enumerator:
TaskBusyClean 

No error or warning messages have been logged since the task was started.

TaskBusyWithWarnings 

Some warning messages have been logged since the task was started.

TaskBusyWithErrors 

Some error messages (and possibly warnings as well) have been logged since the task was started.

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.

Enumerator:
TaskDeleteWhenRemoved 

Delete the task when the "Remove Task" button is pressed.

TaskHideWhenRemoved 

Hide the task's Qtilities::CoreGui::SingleTaskWidget when the "Remove Task" button is pressed.

The possible results of a completed task.

Enumerator:
TaskNoResult 

The task does not have any result information at present. Typically the task have not been started yet.

TaskSuccessful 

The task completed successfully without any warnings and errors.

TaskSuccessfulWithWarnings 

The task completed successfully but there was some warnings.

TaskSuccessfulWithErrors 

The task completed successfully but there was some errors (and possibly warnings as well).

TaskResultFromBusyStateFailOnError 

The task completed and the result must be obtained from the task's busy state. If any errors were logged, the task will fail, thus the result will be TaskFailed.

TaskResultFromBusyStateSuccessOnError 

The task completed and the result must be obtained from the task's busy state. If any errors were logged, the task will be successfull with the TaskSuccessfulWithErrors result.

TaskFailed 

The task failed.

The possible states in which a task might find itself.

Enumerator:
TaskNotStarted 

The task has not been started.

TaskBusy 

The task is busy.

TaskPaused 

The task is paused.

TaskStopped 

The task has been stopped.

TaskCompleted 

The task has been completed.

TaskIdle 

The task is idle, thus it can be started.

Indicates what should happen to the task when the user stops it in a Qtilities::CoreGui::SingleTaskWidget.

Enumerator:
TaskDeleteWhenStopped 

Delete the task when it is stopped while it was running.

TaskHideWhenStopped 

Hide the task's Qtilities::CoreGui::SingleTaskWidget when the task when it is stopped while it was running.

TaskDoNothingWhenStopped 

Do nothing when it is stopped. This will give the user the chance to review the task log.

Indicates if an confirmation message is required when an user stops the task in a Qtilities::CoreGui::SingleTaskWidget.

Enumerator:
TaskStopConfirmationNone 

Stop the task immediately without any confirmation.

TaskStopConfirmationMsgBox 

Display a message box asking the user if they are sure that they want to stop the task.

The possible types of tasks.

Enumerator:
TaskLocal 

A local task, thus its progress should not be shown in Qtilities::CoreGui::TaskSummaryWidget.

TaskGlobal 

A global task, thus its progress should be shown in Qtilities::CoreGui::TaskSummaryWidget.


Member Function Documentation

virtual TaskBusyState Qtilities::Core::Interfaces::ITask::busyState ( ) const
pure virtual

The busy state of the task.

Default is TaskBusyClean.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::busyStateChanged ( TaskBusyState  new_busy_state,
TaskBusyState  old_busy_state 
) const
pure virtual

Signal emitted when the busy state of the task changes.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::canPauseChanged ( bool  new_value) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::canStartChanged ( bool  new_value) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::canStopChanged ( bool  new_value) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual int Qtilities::Core::Interfaces::ITask::currentProgress ( ) const
inlinevirtual

Returns the number of subtasks completed.

Default implementation returns 0, thus no sub tasks.

Reimplemented in Qtilities::Core::Task.

virtual AbstractLoggerEngine* Qtilities::Core::Interfaces::ITask::customLoggerEngine ( ) const
inlinevirtual

Returns the custom logger engine used by this task.

See also:
setCustomLoggerEngine()

Reimplemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::displayedNameChanged ( const QString &  displayed_name) const
pure virtual

Signal emitted when the task's displayed name changes.

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

Implemented in Qtilities::Core::Task.

virtual QString Qtilities::Core::Interfaces::ITask::displayName ( ) const
inlinevirtual

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 in Qtilities::Core::Task.

virtual int Qtilities::Core::Interfaces::ITask::elapsedTime ( ) const
pure 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.

Implemented in Qtilities::Core::Task.

bool Qtilities::Core::Interfaces::ITask::elapsedTimeChangedNotificationsEnabled ( ) const
inline

Indicates if elapsed time changed notifications through taskElapsedTimeChanged() are enabled.

Disabled by default.

See also:
elapsedTime(), elapsedTimeString(), taskElapsedTimeChanged(), toggleElapsedTimeChangedNotifications()
virtual QString Qtilities::Core::Interfaces::ITask::elapsedTimeString ( int  msec = -1,
const QString &  format = "hh:mm:ss.zzz" 
) const
inlinevirtual

Returns the elapsed time of the task as a string.

Parameters:
msecThe time in miliseconds to format. When -1 (default) the current elapsed time of the task is used.
formatThe format to use, see QTime::toString(const QString& format) for details.
See also:
elapsedTime(), taskElapsedTimeChanged(), toggleElapsedTimeChangedNotifications(), toggleElapsedTimeChangedNotifications()

This function was added in Qtilities v1.1.

int Qtilities::Core::Interfaces::ITask::getWidgetLoggerEngineDisplaysFlag ( ) const
inline

Gets the (int) WidgetLoggerEngine::MessageDisplaysFlag used when assigning logger engines to tasks.

The default is WidgetLoggerEngine::DefaultDisplays.

See also:
setWidgetLoggerEngineDisplaysFlag

This function was added in Qtilities v1.2.

virtual QStringList Qtilities::Core::Interfaces::ITask::lastErrorMessages ( int  count = -1) const
pure 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.

Implemented in Qtilities::Core::Task.

virtual int Qtilities::Core::Interfaces::ITask::lastErrorMessagesStackSize ( ) const
pure 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.

Implemented in Qtilities::Core::Task.

virtual AbstractLoggerEngine* Qtilities::Core::Interfaces::ITask::loggerEngine ( ) const
inlinevirtual

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 in Qtilities::Core::Task.

virtual bool Qtilities::Core::Interfaces::ITask::loggingEnabled ( ) const
inlinevirtual

Indicates if the activities of this task is logged.

False by default.

Reimplemented in Qtilities::Core::Task.

static void Qtilities::Core::Interfaces::ITask::logMessageToTask ( const QString &  message,
ITask task = 0,
Logger::MessageType  type = Logger::Info 
)
inlinestatic

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.

In some cases a function gets a task to log its messages to as a parameter. There is off course the possibility that whatever is calling the function does not pass a valid task. In those cases it is still desirable to log the messages of the function somewhere.

Thus function automatically directs messages to the correct place. For example:

void MyObject::doSomething(ITask* task) {
// Instead of having to do this:
if (task)
task->logMessage("Message",Logger::Info);
else
Log->logMessage(QString(),Logger::Info,"Message");
// We can just do this:
// Macros makes this even easier and allows us to do things like:
LOG_TASK_INFO("Message",task);
}

If no task was passed to the function, the messages will be logged as system wide messages to the logger. If a valid task was received the message will be logged to the task.

This function was added in Qtilities v1.1.

See also:
logPriorityMessageToTask
static void Qtilities::Core::Interfaces::ITask::logPriorityMessageToTask ( const QString &  message,
ITask task = 0,
Logger::MessageType  type = Logger::Info 
)
inlinestatic

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.

This function is the same as logMessage(), except that the message is also logged as a priority message. This is usefull in some scenarios, for example: When loading a project and the loading fails, we want to log this message as a priority message in order to appear in the QtilitiesMainWindow priority message area, but we also want to capture the message in the task log.

For example:

void MyObject::doSomething(ITask* task) {
// Instead of having to do this:
Log->logPriorityMessage(QString(),Logger::Info,"Message");
// We can just do this:
// Macros makes this even easier and allows us to do things like:
LOG_TASK_INFO_P("Message",task);
}

This function was added in Qtilities v1.1.

See also:
logMessageToTask()
virtual void Qtilities::Core::Interfaces::ITask::newMessageLogged ( const QString &  message,
Logger::MessageType   
) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual int Qtilities::Core::Interfaces::ITask::numberOfSubTasks ( ) const
inlinevirtual

Returns the number of subtasks associated with the task.

Default implementation returns -1, thus no sub tasks.

Reimplemented in Qtilities::Core::Task.

virtual ITask* Qtilities::Core::Interfaces::ITask::parentTask ( ) const
pure virtual

The parent task of this task.

See also:
setParentTask(), removeParentTask()

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::pause ( )
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::removeCustomLoggerEngine ( )
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::removeParentTask ( )
pure virtual

Removes the parent task of this task.

See also:
setParentTask(), parentTask()

Implemented in Qtilities::Core::Task.

virtual TaskResult Qtilities::Core::Interfaces::ITask::result ( ) const
pure virtual

The result of the task.

Default is TaskNoResult.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::resume ( )
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setClearLogOnStart ( bool  clear_log_on_start = true) const
pure virtual

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

True by default.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setCustomLoggerEngine ( AbstractLoggerEngine engine,
bool  use_only_this_engine = false 
)
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setLastErrorMessagesStackSize ( int  size)
pure 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.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setLastRunTime ( int  msec)
pure 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.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setLogContext ( Logger::MessageContextFlags  message_context)
pure virtual

Sets the default message logging context flags of this task.

Default is Logger::EngineSpecificMessages.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setLoggerEngine ( AbstractLoggerEngine engine)
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setParentTask ( ITask parent_task)
pure virtual

Sets the parent task of this task.

Allows you to make this task a subtask of another task. What this basically means is that messages from this task will be logged to the parent task and the parent task's busy state will also track the busy state of this task.

If you don't want the busy state to be tracked (thus only want to get the messages of this task in the log of a different task, use setCustomLoggerEngine() instead.

Note:
It is recommended to set the parent task of this task before starting it since the parent task will not aquire the busy state of this task in this function.
See also:
parentTask(), removeParentTask()

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setSubTaskPerformanceIndication ( SubTaskPerformanceIndication  performance_indication)
pure virtual

Sets what performance measures are used for sub tasks.

See also:
SubTaskPerformanceIndication()

This function was added in Qtilities v1.1.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::setTaskStopConfirmation ( TaskStopConfirmation  task_stop_confirmation)
pure virtual

Sets the task's stop configuration action.

See also:
taskStopConfirmation()

This function was added in Qtilities v1.3.

Implemented in Qtilities::Core::Task.

void Qtilities::Core::Interfaces::ITask::setWidgetLoggerEngineDisplaysFlag ( int  message_display_flags)
inline

Sets the (int) WidgetLoggerEngine::MessageDisplaysFlag used when assigning logger engines to tasks.

See also:
getWidgetLoggerEngineDisplaysFlag

This function was added in Qtilities v1.2.

virtual void Qtilities::Core::Interfaces::ITask::start ( )
inlinevirtual

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 in Qtilities::Core::Task.

virtual TaskState Qtilities::Core::Interfaces::ITask::state ( ) const
pure virtual

The state of the task.

Default is TaskNotStarted.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::stateChanged ( TaskState  new_state,
TaskState  old_state 
) const
pure virtual

Signal emitted when the task's state changes.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::stop ( )
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::subTaskCompleted ( int  number_task_completed = 1,
const QString &  message = QString(),
Logger::MessageType  type = Logger::Info 
) const
pure virtual

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.

Implemented in Qtilities::Core::Task.

virtual SubTaskPerformanceIndication Qtilities::Core::Interfaces::ITask::subTaskPerformanceIndication ( ) const
inlinevirtual

Gets what performance measures are used for sub tasks.

Default is SubTaskTimeFromTaskStart.

See also:
setSubTaskPerformanceIndication()

This function was added in Qtilities v1.1.

Reimplemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskAboutToComplete ( ) const
pure virtual

Signal emitted when the task is about to be completed.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskAboutToPause ( ) const
pure virtual

Signal emitted when the task is about to be paused.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskAboutToResume ( ) const
pure virtual

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.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskAboutToStart ( ) const
pure virtual

Signal emitted when the task is about to be started.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskAboutToStop ( ) const
pure virtual

Signal emitted when the task is about to be stopped.

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

Implemented in Qtilities::Core::Task.

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

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.

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskElapsedTimeChanged ( int  msec) const
pure virtual

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()

Implemented in Qtilities::Core::Task.

virtual QString Qtilities::Core::Interfaces::ITask::taskName ( ) const
pure virtual

The name of the task.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskPaused ( ) const
pure virtual

Signal emitted when the task is paused.

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

Implemented in Qtilities::Core::Task.

virtual TaskRemoveAction Qtilities::Core::Interfaces::ITask::taskRemoveAction ( ) const
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskResumed ( ) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskStarted ( int  expected_subtasks = -1,
const QString &  message = QString(),
Logger::MessageType  type = Logger::Info 
) const
pure virtual

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.

Implemented in Qtilities::Core::Task.

virtual TaskStopAction Qtilities::Core::Interfaces::ITask::taskStopAction ( ) const
inlinevirtual

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 in Qtilities::Core::Task.

virtual TaskStopConfirmation Qtilities::Core::Interfaces::ITask::taskStopConfirmation ( ) const
inlinevirtual

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 in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskStopped ( ) const
pure virtual

Signal emitted when the task is stopped during execution.

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

Implemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskSubTaskAboutToComplete ( ) const
pure virtual

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

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

Implemented in Qtilities::Core::Task.

virtual TaskType Qtilities::Core::Interfaces::ITask::taskType ( ) const
inlinevirtual

The type of this task.

Default is TaskGlobal.

Reimplemented in Qtilities::Core::Task.

virtual void Qtilities::Core::Interfaces::ITask::taskTypeChanged ( TaskType  new_task_type) const
pure virtual

Signal emitted when the task's type changes.

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

Implemented in Qtilities::Core::Task.

void Qtilities::Core::Interfaces::ITask::toggleElapsedTimeChangedNotifications ( bool  is_enabled)
inline

Enables elapsed time changed notifications through taskElapsedTimeChanged().

Disabled by default.

See also:
elapsedTime(), elapsedTimeString(), taskElapsedTimeChanged(), elapsedTimeChangedNotificationsEnabled()


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