Task Class | Qt Installer Framework Manual

Qt Installer Framework Manual | Task

# Task Class

(KDUpdater::Task)

The Task class is the base class for all tasks in KDUpdater. More...

Header: | #include <Task>
Inherited By: | KDUpdater::UpdateFinder

- List of all members, including inherited members

## Public Types

enum | Capability { NoCapability, Pausable, Stoppable }

## Public Functions

bool | autoDelete() const
int | capabilities() const
int | error() const
QString | errorString() const
bool | isFinished() const
bool | isPaused() const
bool | isRunning() const
bool | isStopped() const
QString | name() const
int | progressPercent() const
QString | progressText() const
void | setAutoDelete(bool autoDelete)

## Public Slots

void | pause()
void | resume()
void | run()
void | stop()

## Signals

void | error(int code, const QString &errorText)
void | finished()
void | paused()
void | progressText(const QString &progressText)
void | progressValue(int percent)
void | resumed()
void | started()
void | stopped()

## Protected Functions

virtual bool | doPause() = 0
virtual bool | doResume() = 0
virtual void | doRun() = 0
virtual bool | doStop() = 0

## Detailed Description

The Task class is the base class for all tasks in KDUpdater.

This class is the base class for all task classes in KDUpdater. Task is an activity that occupies certain amount of execution time. It can be started, stopped (or canceled), paused and resumed. Tasks can report progress and error messages which an application can show in any sort of UI. The KDUpdater::Task class provides a common interface for dealing with all kinds of tasks in KDUpdater.

User should be careful of these points:

- Task classes can be started only once.
- Instances of this class cannot be created. Only instances of the subclasses can.

## Member Type Documentation

### enum Task::Capability

This enum value sets the capabilities of the task.

Constant | Value | Description
--- | --- | ---
`KDUpdater::Task::NoCapability` | `0` | The task has no capabilities, so it cannot be paused or stopped.
`KDUpdater::Task::Pausable` | `1` | The task can be paused.
`KDUpdater::Task::Stoppable` | `2` | The task can be stopped.

## Member Function Documentation

### bool Task::autoDelete() const

Returns `true` if the task will be automatically deleted.

See also setAutoDelete().

### int Task::capabilities() const

Returns the capabilities of the task. It is a combination of one or more Task::Capability flags.

### `[pure virtual protected]` bool Task::doPause()

Returns `true` if the task is paused.

### `[pure virtual protected]` bool Task::doResume()

Returns `true` if the task is resumed.

### `[pure virtual protected]` void Task::doRun()

Returns `0` if the task is run.

### `[pure virtual protected]` bool Task::doStop()

Returns `true` if the task is stopped.

### int Task::error() const

Returns the last reported error code.

### `[signal]` void Task::error(int code, const QString &errorText)

This signal is emitted to notify an error during the execution of this task.

The code parameter indicates the error that was found during the execution of the task, while the errorText is the human-readable description of the last error that occurred.

Note:Signal error is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

      connect(task, static_cast<void(Task::*)(int, const QString &)>(&Task::error),
          [=](int code, const QString &errorText){ /* ... */ });

### QString Task::errorString() const

Returns the last reported error message text.

### `[signal]` void Task::finished()

This signal is emitted when the task has finished.

### bool Task::isFinished() const

Returns whether the task has finished or not.

Note: Stopped (or canceled) tasks are not finished tasks.

### bool Task::isPaused() const

Returns whether the task is paused or not.

### bool Task::isRunning() const

Returns whether the task has started and is running.

### bool Task::isStopped() const

Returns whether the task is stopped or not.

Note: Finished tasks are not stopped classes.

### QString Task::name() const

Returns the name of the task.

### `[slot]` void Task::pause()

Pauses the task, provided the task has the Task::Pausable capability.

### `[signal]` void Task::paused()

This signal is emitted when the task has paused.

### int Task::progressPercent() const

Returns the progress in percentage made by this task.

### QString Task::progressText() const

Returns a string that describes the progress made by this task as a string.

### `[signal]` void Task::progressText(const QString &progressText)

This signal is emitted to report the progress made by the task. The progressText parameter represents the progress made in a human-readable form.

Note:Signal progressText is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

      connect(task, static_cast<void(Task::*)(const QString &)>(&Task::progressText),
          [=](const QString &progressText){ /* ... */ });

### `[signal]` void Task::progressValue(int percent)

This signal is emitted to report progress made by the task. The percent parameter gives the progress made as a percentage.

### `[slot]` void Task::resume()

Resumes the task if it was paused.

### `[signal]` void Task::resumed()

This signal is emitted when the task has resumed.

### `[slot]` void Task::run()

Starts the task.

### void Task::setAutoDelete(bool autoDelete)

Automatically deletes the task if autoDelete is `true`.

See also autoDelete().

### `[signal]` void Task::started()

This signal is emitted when the task has started.

### `[slot]` void Task::stop()

Stops the task, provided the task has the Task::Stoppable capability.

Note: Once the task is stopped, it cannot be restarted.

### `[signal]` void Task::stopped()

This signal is emitted when the task has stopped (or canceled).