From 7858376727ee467ae59a18d84d40e3148ea3e38b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 26 May 2017 16:40:50 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- core/downloadfromdcthread.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'core/downloadfromdcthread.cpp') 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; -} -- cgit v1.2.3-70-g09d2