QGIS API Documentation
3.2.0-Bonn (bc43194)
|
Task manager for managing a set of long-running QgsTask tasks. More...
#include <qgstaskmanager.h>
Classes | |
struct | TaskDefinition |
Definition of a task for inclusion in the manager. More... | |
Public Slots | |
void | triggerTask (QgsTask *task) |
Triggers a task, e.g. More... | |
Signals | |
void | allTasksFinished () |
Emitted when all tasks are complete. More... | |
void | countActiveTasksChanged (int count) |
Emitted when the number of active tasks changes. More... | |
void | finalTaskProgressChanged (double progress) |
Will be emitted when only a single task remains to complete and that task has reported a progress change. More... | |
void | progressChanged (long taskId, double progress) |
Will be emitted when a task reports a progress change. More... | |
void | statusChanged (long taskId, int status) |
Will be emitted when a task reports a status change. More... | |
void | taskAboutToBeDeleted (long taskId) |
Emitted when a task is about to be deleted. More... | |
void | taskAdded (long taskId) |
Emitted when a new task has been added to the manager. More... | |
void | taskTriggered (QgsTask *task) |
Emitted when a task is triggered. More... | |
Public Member Functions | |
QgsTaskManager (QObject *parent=nullptr) | |
Constructor for QgsTaskManager. More... | |
~QgsTaskManager () override | |
QList< QgsTask *> | activeTasks () const |
Returns a list of the active (queued or running) tasks. More... | |
long | addTask (QgsTask *task, int priority=0) |
Adds a task to the manager. More... | |
long | addTask (const TaskDefinition &task, int priority=0) |
Adds a task to the manager, using a full task definition (including dependency handling). More... | |
void | cancelAll () |
Instructs all tasks tracked by the manager to terminate. More... | |
int | count () const |
Returns the number of tasks tracked by the manager. More... | |
int | countActiveTasks () const |
Returns the number of active (queued or running) tasks. More... | |
QSet< long > | dependencies (long taskId) const |
Returns the set of task IDs on which a task is dependent. More... | |
bool | dependenciesSatisfied (long taskId) const |
Returns true if all dependencies for the specified task are satisfied. More... | |
QList< QgsMapLayer *> | dependentLayers (long taskId) const |
Returns a list of layers on which as task is dependent. More... | |
QgsTask * | task (long id) const |
Returns the task with matching ID. More... | |
long | taskId (QgsTask *task) const |
Returns the unique task ID corresponding to a task managed by the class. More... | |
QList< QgsTask * > | tasks () const |
Returns all tasks tracked by the manager. More... | |
QList< QgsTask *> | tasksDependentOnLayer (QgsMapLayer *layer) const |
Returns a list of tasks which depend on a layer. More... | |
Friends | |
class | TestQgsTaskManager |
Task manager for managing a set of long-running QgsTask tasks.
This class can be created directly, or accessed via QgsApplication::taskManager().
Definition at line 361 of file qgstaskmanager.h.
QgsTaskManager::QgsTaskManager | ( | QObject * | parent = nullptr | ) |
Constructor for QgsTaskManager.
parent | parent QObject |
Definition at line 350 of file qgstaskmanager.cpp.
|
override |
Definition at line 358 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::activeTasks | ( | ) | const |
Returns a list of the active (queued or running) tasks.
Definition at line 601 of file qgstaskmanager.cpp.
long QgsTaskManager::addTask | ( | QgsTask * | task, |
int | priority = 0 |
||
) |
Adds a task to the manager.
Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue's order of execution, with larger numbers taking precedence over lower priority numbers.
Definition at line 377 of file qgstaskmanager.cpp.
long QgsTaskManager::addTask | ( | const TaskDefinition & | task, |
int | priority = 0 |
||
) |
Adds a task to the manager, using a full task definition (including dependency handling).
Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue's order of execution, with larger numbers taking precedence over lower priority numbers.
Definition at line 382 of file qgstaskmanager.cpp.
|
signal |
Emitted when all tasks are complete.
void QgsTaskManager::cancelAll | ( | ) |
Instructs all tasks tracked by the manager to terminate.
Individual tasks may take some time to cancel, or may totally ignore this instruction. Calling this does not block but will instead signal the tasks to cancel and then return immediately.
Definition at line 492 of file qgstaskmanager.cpp.
int QgsTaskManager::count | ( | ) | const |
Returns the number of tasks tracked by the manager.
Definition at line 469 of file qgstaskmanager.cpp.
int QgsTaskManager::countActiveTasks | ( | ) | const |
Returns the number of active (queued or running) tasks.
Definition at line 609 of file qgstaskmanager.cpp.
|
signal |
Emitted when the number of active tasks changes.
QSet< long > QgsTaskManager::dependencies | ( | long | taskId | ) | const |
Returns the set of task IDs on which a task is dependent.
Definition at line 524 of file qgstaskmanager.cpp.
bool QgsTaskManager::dependenciesSatisfied | ( | long | taskId | ) | const |
Returns true if all dependencies for the specified task are satisfied.
Definition at line 505 of file qgstaskmanager.cpp.
QList< QgsMapLayer * > QgsTaskManager::dependentLayers | ( | long | taskId | ) | const |
Returns a list of layers on which as task is dependent.
The task will automatically be canceled if any of these layers are above to be removed.
taskId | task ID |
Definition at line 578 of file qgstaskmanager.cpp.
|
signal |
Will be emitted when only a single task remains to complete and that task has reported a progress change.
progress | percent of progress, from 0.0 - 100.0 |
|
signal |
Will be emitted when a task reports a progress change.
taskId | ID of task |
progress | percent of progress, from 0.0 - 100.0 |
|
signal |
Will be emitted when a task reports a status change.
taskId | ID of task |
status | new task status |
QgsTask * QgsTaskManager::task | ( | long | id | ) | const |
Returns the task with matching ID.
id | task ID |
Definition at line 454 of file qgstaskmanager.cpp.
|
signal |
Emitted when a task is about to be deleted.
taskId | ID of task |
|
signal |
Emitted when a new task has been added to the manager.
taskId | ID of task |
long QgsTaskManager::taskId | ( | QgsTask * | task | ) | const |
Returns the unique task ID corresponding to a task managed by the class.
task | task to find |
Definition at line 475 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::tasks | ( | ) | const |
Returns all tasks tracked by the manager.
Definition at line 463 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::tasksDependentOnLayer | ( | QgsMapLayer * | layer | ) | const |
Returns a list of tasks which depend on a layer.
Definition at line 584 of file qgstaskmanager.cpp.
|
signal |
Emitted when a task is triggered.
This occurs when a user clicks on the task from the QGIS GUI, and can be used to show detailed progress reports or re-open a related dialog.
|
slot |
Triggers a task, e.g.
as a result of a GUI interaction.
Definition at line 616 of file qgstaskmanager.cpp.
|
friend |
Definition at line 612 of file qgstaskmanager.h.