summaryrefslogtreecommitdiffstats
path: root/configuredivecomputerthreads.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-01-20 22:40:51 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-21 17:03:21 +1200
commit1d67bae745e491cfe28806dc99f0db005649083d (patch)
treeb50c702c6b7d44536c6d463edec5e15e6c80f7f2 /configuredivecomputerthreads.cpp
parentba525df7665cff904818ccfc70c183f16c7b5f45 (diff)
downloadsubsurface-1d67bae745e491cfe28806dc99f0db005649083d.tar.gz
Add infrastructure to emit progress from threads
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'configuredivecomputerthreads.cpp')
-rw-r--r--configuredivecomputerthreads.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index b2dc8c87c..2e69e539d 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -1393,6 +1393,26 @@ DeviceThread::DeviceThread(QObject *parent, device_data_t *data) : QThread(paren
{
}
+void DeviceThread::progressCB(int percent)
+{
+ emit progress(percent);
+}
+
+void DeviceThread::event_cb(dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
+{
+ const dc_event_progress_t *progress = (dc_event_progress_t *) data;
+ DeviceThread *dt = static_cast<DeviceThread*>(userdata);
+
+ switch (event) {
+ case DC_EVENT_PROGRESS:
+ dt->progressCB(100.0 * (double)progress->current / (double)progress->maximum);
+ break;
+ default:
+ emit dt->error("Unexpected event recived");
+ break;
+ }
+}
+
ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
{
}