summaryrefslogtreecommitdiffstats
path: root/core
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
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')
-rw-r--r--core/downloadfromdcthread.cpp24
-rw-r--r--core/downloadfromdcthread.h9
2 files changed, 15 insertions, 18 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;
-}
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index b20fe17a6..0a188dcad 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -38,8 +38,6 @@ public:
int deviceId() const;
int diveId() const;
- void setDiveTable(struct dive_table* downloadTable);
-
/* this needs to be a pointer to make the C-API happy */
device_data_t* internalData();
@@ -60,16 +58,17 @@ private:
class DownloadThread : public QThread {
Q_OBJECT
+ Q_PROPERTY(DCDeviceData* deviceData MEMBER m_data)
+
public:
DownloadThread();
- void setDiveTable(struct dive_table *table);
void run() override;
- DCDeviceData& data();
+ DCDeviceData *data();
QString error;
private:
- DCDeviceData m_data;
+ DCDeviceData *m_data;
};
//TODO: QList<product> ?