|
Krita Source Code Documentation
|
#include <KoProgressUpdater.h>
Inheritance diagram for KoProgressUpdater:Public Types | |
| enum | Mode { Threaded , Unthreaded } |
Public Slots | |
| void | cancel () |
Signals | |
| void | triggerUpdateAsynchronously () |
Public Member Functions | |
| bool | autoNestNames () const |
| void | clearState () |
| bool | interrupted () const |
| KoProgressUpdater (KoProgressProxy *progressProxy, Mode mode=Threaded) | |
| KoProgressUpdater (QPointer< KoUpdater > updater) | |
| a special constructor for connecting the progress updater to a self-destructible KoUpdater object. | |
| Private (KoProgressUpdater *_q, KoProgressProxy *proxy, QPointer< KoUpdater > parentUpdater, Mode _mode) | |
| KoProgressProxy * | progressProxy () |
| void | removePersistentSubtask (QPointer< KoUpdater > updater) |
| void | setAutoNestNames (bool value) |
| void | setUpdateInterval (int ms) |
| void | start (int range=100, const QString &text="") |
| QPointer< KoUpdater > | startSubtask (int weight=1, const QString &name=QString(), bool isPersistent=false) |
| int | updateInterval () const |
| void | updateParentText () |
| ~KoProgressUpdater () override | |
| destructor | |
Public Attributes | |
| bool | autoNestNames = false |
| bool | canceled |
| int | currentProgress = 0 |
| bool | isStarted = false |
| bool | isUndefinedState = false |
| Mode | mode |
| QMutex | mutex |
| KoProgressUpdater * | q |
| QList< QPointer< KoUpdaterPrivate > > | subtasks |
| int | taskMax = 99 |
| QString | taskName |
| KisSignalCompressor * | updateCompressor |
| int | updateInterval = 250 |
Private Slots | |
| void | update () |
| void | updateUi () |
Private Attributes | |
| Private *const | d |
| KoProgressProxy * | parentProgressProxy |
| QPointer< KoUpdater > | parentUpdater |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
Additional Inherited Members | |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Allow multiple subtasks to safely update and report progress. This class is able to update a progress bar with the total progress of a project that may be separated into different subtasks. Each subtask will use one KoUpdater which that subtask can then report progress to. Each KoUpdater.setProgress() call will automatically calculate the total progress over the whole tasks made and update the progress bar with the total progress so far.
This class is created specifically with threading in mind so that subtasks can report their progress from their personal subthread and the progress bar will be updated correctly and not more often than repaints can occur.
Typical usage can be:
Doing a smooth.setProgress(50) will move the progress bar to 50% of the share of task 'smooth' which is 5 / 11 of the total and thus to 22.
KoProgressUpdater should be created in the main thread; KoProgressProxy must be, if it is gui subclass in the QApplication main thread. The other objects can be created in whatever thread one wants.
Also to prevent jumps in the progress-calculation and -display it is recommend to first create all the subtasks and then start to use setProgress on them.
Definition at line 23 of file KoProgressUpdater.cpp.
| Enumerator | |
|---|---|
| Threaded | |
| Unthreaded | |
Definition at line 58 of file KoProgressUpdater.h.
|
explicit |
Constructor.
| progressBar | the progress bar to update. |
Definition at line 70 of file KoProgressUpdater.cpp.
References connect(), d, KIS_ASSERT_RECOVER_RETURN, progressProxy(), start(), triggerUpdateAsynchronously(), and updateUi().
a special constructor for connecting the progress updater to a self-destructible KoUpdater object.
HACK ALERT: KoUpdater inherits KoProgressProxy, so be careful when constructing the updater and check which override is actually used.
Definition at line 79 of file KoProgressUpdater.cpp.
References connect(), d, KIS_ASSERT_RECOVER_RETURN, start(), triggerUpdateAsynchronously(), and updateUi().
|
override |
| bool KoProgressUpdater::autoNestNames | ( | ) | const |
|
slot |
Cancelling the action will make each subtask be marked as 'interrupted' and set the total progress to 100%.
NOTE: cancelling mush happen from the same thread that KoProgressUpdater resides, which is usually GUI thread.
Definition at line 163 of file KoProgressUpdater.cpp.
References d, KIS_SAFE_ASSERT_RECOVER_RETURN, subtasks, and triggerUpdateAsynchronously().
| void KoProgressUpdater::clearState | ( | ) |
| bool KoProgressUpdater::interrupted | ( | ) | const |
Definition at line 324 of file KoProgressUpdater.cpp.
References d.
|
inline |
Definition at line 27 of file KoProgressUpdater.cpp.
|
inline |
Definition at line 61 of file KoProgressUpdater.cpp.
Definition at line 143 of file KoProgressUpdater.cpp.
References d, KIS_SAFE_ASSERT_RECOVER_NOOP, and triggerUpdateAsynchronously().
| void KoProgressUpdater::setAutoNestNames | ( | bool | value | ) |
Definition at line 339 of file KoProgressUpdater.cpp.
| void KoProgressUpdater::setUpdateInterval | ( | int | ms | ) |
Definition at line 329 of file KoProgressUpdater.cpp.
References d.
| void KoProgressUpdater::start | ( | int | range = 100, |
| const QString & | text = "" ) |
Start a new task.
This will invalidate any previously created subtasks and set the range of the progressBar as well as the text in the progressbar.
| range | the total range of progress bar makes. |
| text | The text to show in the progressBar. |
Definition at line 105 of file KoProgressUpdater.cpp.
References d, and triggerUpdateAsynchronously().
| QPointer< KoUpdater > KoProgressUpdater::startSubtask | ( | int | weight = 1, |
| const QString & | name = QString(), | ||
| bool | isPersistent = false ) |
After calling start() you can create any number of Updaters, one for each subtask.
| weight | use a weight to specify the weight this subtask has compared to the rest of the subtasks. |
KoProgressUpdater will delete the KoUpdater instances when a start() is called or when it is deleted. The KoUpdater pointers are packed in a QPointer so you can check whether they have been deleted before dereferencing.
Definition at line 119 of file KoProgressUpdater.cpp.
References cancel(), connect(), d, p, start(), triggerUpdateAsynchronously(), and update().
|
signal |
|
privateslot |
Definition at line 185 of file KoProgressUpdater.cpp.
References d, KIS_SAFE_ASSERT_RECOVER_RETURN, and Unthreaded.
| int KoProgressUpdater::updateInterval | ( | ) | const |
| void KoProgressUpdater::updateParentText | ( | ) |
|
privateslot |
Definition at line 196 of file KoProgressUpdater.cpp.
References d, and KIS_SAFE_ASSERT_RECOVER_RETURN.
| bool KoProgressUpdater::autoNestNames = false |
Definition at line 51 of file KoProgressUpdater.cpp.
| bool KoProgressUpdater::canceled |
Definition at line 49 of file KoProgressUpdater.cpp.
| int KoProgressUpdater::currentProgress = 0 |
Definition at line 45 of file KoProgressUpdater.cpp.
|
private |
Definition at line 142 of file KoProgressUpdater.h.
| bool KoProgressUpdater::isStarted = false |
Definition at line 54 of file KoProgressUpdater.cpp.
| bool KoProgressUpdater::isUndefinedState = false |
Definition at line 46 of file KoProgressUpdater.cpp.
| Mode KoProgressUpdater::mode |
Definition at line 44 of file KoProgressUpdater.cpp.
| QMutex KoProgressUpdater::mutex |
Definition at line 56 of file KoProgressUpdater.cpp.
|
private |
Definition at line 40 of file KoProgressUpdater.cpp.
Definition at line 41 of file KoProgressUpdater.cpp.
| KoProgressUpdater* KoProgressUpdater::q |
Definition at line 37 of file KoProgressUpdater.cpp.
| QList<QPointer<KoUpdaterPrivate> > KoProgressUpdater::subtasks |
Definition at line 48 of file KoProgressUpdater.cpp.
| int KoProgressUpdater::taskMax = 99 |
Definition at line 53 of file KoProgressUpdater.cpp.
| QString KoProgressUpdater::taskName |
Definition at line 52 of file KoProgressUpdater.cpp.
| KisSignalCompressor* KoProgressUpdater::updateCompressor |
Definition at line 47 of file KoProgressUpdater.cpp.
| int KoProgressUpdater::updateInterval = 250 |
Definition at line 50 of file KoProgressUpdater.cpp.