aboutsummaryrefslogtreecommitdiffstats
path: root/core/downloadfromdcthread.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2017-05-26 16:40:50 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-27 11:07:20 -0700
commit7858376727ee467ae59a18d84d40e3148ea3e38b (patch)
tree9dc19db2ec7facb3641e79f3804685803d2c063b /core/downloadfromdcthread.cpp
parent85e92597b561f349d24f2181e763c6ed381654ce (diff)
downloadsubsurface-7858376727ee467ae59a18d84d40e3148ea3e38b.tar.gz
QML UI: add the DownloadThread
For this I had to also make the DCDeviceData accessible, and for that it needed to be a pointer. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r--core/downloadfromdcthread.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index 46adbe54c..3c3e0df0a 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -16,19 +16,20 @@ static QString str_error(const char *fmt, ...)
return str;
}
-DownloadThread::DownloadThread()
+DownloadThread::DownloadThread() : m_data(new DCDeviceData())
{
}
-void DownloadThread::setDiveTable(struct dive_table* table)
-{
- m_data.setDiveTable(table);
-}
void DownloadThread::run()
{
- auto internalData = m_data.internalData();
- internalData->descriptor = descriptorLookup[m_data.vendor() + m_data.product()];
+ auto internalData = m_data->internalData();
+ internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
+ internalData->download_table = &downloadTable;
+
+ downloadTable.nr = 0;
+ qDebug() << "Starting the thread" << downloadTable.nr;
+
Q_ASSERT(internalData->download_table != nullptr);
const char *errorText;
import_thread_cancelled = false;
@@ -38,6 +39,8 @@ void DownloadThread::run()
errorText = do_libdivecomputer_import(internalData);
if (errorText)
error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
+
+ qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
}
void fill_computer_list()
@@ -96,7 +99,7 @@ DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
data.deviceid = 0;
}
-DCDeviceData & DownloadThread::data()
+DCDeviceData * DownloadThread::data()
{
return m_data;
}
@@ -210,8 +213,3 @@ device_data_t* DCDeviceData::internalData()
{
return &data;
}
-
-void DCDeviceData::setDiveTable(struct dive_table* downloadTable)
-{
- data.download_table = downloadTable;
-}