diff options
author | Dan Vrátil <dvratil@redhat.com> | 2015-04-03 18:17:12 +0200 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2015-04-04 20:44:17 +0200 |
commit | 27bc3300d670d65b9c5332308605ef8263c3939c (patch) | |
tree | 038ced028bc2af9f600250feff845c9d4f936c54 /async/src/future.cpp | |
parent | 160255f96e46818b6df63b00f17f502df9ab0a79 (diff) | |
download | sink-27bc3300d670d65b9c5332308605ef8263c3939c.tar.gz sink-27bc3300d670d65b9c5332308605ef8263c3939c.zip |
Async: implement progress reporting through future
This is a simplified progress reporting, since it does not report progress
of ther overcall Job chain, but only of individual tasks, which makes it
only really useful on one-task Jobs.
TODO: propagate subjob progress to the Future user gets copy of
TODO: compound progress reporting (be able to report a progress of the overall
Job chain)
Diffstat (limited to 'async/src/future.cpp')
-rw-r--r-- | async/src/future.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/async/src/future.cpp b/async/src/future.cpp index 970060b..4f3cd80 100644 --- a/async/src/future.cpp +++ b/async/src/future.cpp | |||
@@ -102,6 +102,21 @@ QString FutureBase::errorMessage() const | |||
102 | return d->errorMessage; | 102 | return d->errorMessage; |
103 | } | 103 | } |
104 | 104 | ||
105 | void FutureBase::setProgress(int processed, int total) | ||
106 | { | ||
107 | setProgress((qreal) processed / total); | ||
108 | } | ||
109 | |||
110 | void FutureBase::setProgress(qreal progress) | ||
111 | { | ||
112 | for (auto watcher : d->watchers) { | ||
113 | if (watcher) { | ||
114 | watcher->futureProgressCallback(progress); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | |||
105 | 120 | ||
106 | void FutureBase::addWatcher(FutureWatcherBase* watcher) | 121 | void FutureBase::addWatcher(FutureWatcherBase* watcher) |
107 | { | 122 | { |
@@ -128,6 +143,11 @@ void FutureWatcherBase::futureReadyCallback() | |||
128 | Q_EMIT futureReady(); | 143 | Q_EMIT futureReady(); |
129 | } | 144 | } |
130 | 145 | ||
146 | void FutureWatcherBase::futureProgressCallback(qreal progress) | ||
147 | { | ||
148 | Q_EMIT futureProgress(progress); | ||
149 | } | ||
150 | |||
131 | void FutureWatcherBase::setFutureImpl(const FutureBase &future) | 151 | void FutureWatcherBase::setFutureImpl(const FutureBase &future) |
132 | { | 152 | { |
133 | d->future = future; | 153 | d->future = future; |