summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2017-05-12 19:18:20 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-27 11:07:19 -0700
commitacbe5de1cbc446884a41e9c96b3777d2acc692c4 (patch)
tree04975da777895d7077e4a16360baaf5d82420edb /core
parent54bb5ccf9ef828ac75e6d7445a7cd91932f708ad (diff)
downloadsubsurface-acbe5de1cbc446884a41e9c96b3777d2acc692c4.tar.gz
New class DCDeviceData
this class encapsulates the device_data_t from libdivecomputer in a way that permit us to use it on QML. this will be needed to prepare the data for the download thread. 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.cpp91
-rw-r--r--core/downloadfromdcthread.h41
2 files changed, 132 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index f3dcb7224..43a6334dc 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -85,3 +85,94 @@ void fill_computer_list()
qSort(vendorList);
}
+
+QString DCDeviceData::vendor() const
+{
+ return data.vendor;
+}
+
+QString DCDeviceData::product() const
+{
+ return data.product;
+}
+
+QString DCDeviceData::devName() const
+{
+ return data.devname;
+}
+
+QString DCDeviceData::descriptor() const
+{
+ return "";
+// return data.descriptor;
+}
+
+bool DCDeviceData::bluetoothMode() const
+{
+ return data.bluetooth_mode;
+}
+
+bool DCDeviceData::forceDownload() const
+{
+ return data.force_download;
+}
+
+bool DCDeviceData::createNewTrip() const
+{
+ return data.create_new_trip;
+}
+
+int DCDeviceData::deviceId() const
+{
+ return data.deviceid;
+}
+
+int DCDeviceData::diveId() const
+{
+ return data.diveid;
+}
+
+void DCDeviceData::setVendor(const QString& vendor)
+{
+ data.vendor = strdup(qPrintable(vendor));
+}
+
+void DCDeviceData::setProduct(const QString& product)
+{
+ data.product = strdup(qPrintable(product));
+}
+
+void DCDeviceData::setDevName(const QString& devName)
+{
+ data.devname = strdup(qPrintable(devName));
+}
+
+void DCDeviceData::setDescriptor(const QString& descriptor)
+{
+ // data.descriptor =
+}
+
+void DCDeviceData::setBluetoothMode(bool mode)
+{
+ data.bluetooth_mode = mode;
+}
+
+void DCDeviceData::setForceDownload(bool force)
+{
+ data.force_download = force;
+}
+
+void DCDeviceData::setCreateNewTrip(bool create)
+{
+ data.create_new_trip = create;
+}
+
+void DCDeviceData::setDeviceId(int deviceId)
+{
+ data.deviceid = deviceId;
+}
+
+void DCDeviceData::setDiveId(int diveId)
+{
+ data.diveid = diveId;
+}
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index 23522b4d4..d0f088b51 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -8,6 +8,47 @@
#include "dive.h"
#include "libdivecomputer.h"
+/* Helper object for access of Device Data in QML */
+class DCDeviceData : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString vendor READ vendor WRITE setVendor)
+ Q_PROPERTY(QString product READ product WRITE setProduct)
+ Q_PROPERTY(bool bluetoothMode READ bluetoothMode WRITE setBluetoothMode)
+ Q_PROPERTY(QString devName READ devName WRITE setDevName)
+ Q_PROPERTY(QString descriptor READ descriptor WRITE setDescriptor)
+ Q_PROPERTY(bool forceDownload READ forceDownload WRITE setForceDownload)
+ Q_PROPERTY(bool createNewTrip READ createNewTrip WRITE setCreateNewTrip)
+ Q_PROPERTY(int deviceId READ deviceId WRITE setDeviceId)
+ Q_PROPERTY(int diveId READ diveId WRITE setDiveId)
+
+public:
+ DCDeviceData(QObject *parent = nullptr);
+
+ QString vendor() const;
+ QString product() const;
+ QString devName() const;
+ QString descriptor() const;
+ bool bluetoothMode() const;
+ bool forceDownload() const;
+ bool createNewTrip() const;
+ int deviceId() const;
+ int diveId() const;
+
+public slots:
+ void setVendor(const QString& vendor);
+ void setProduct(const QString& product);
+ void setDevName(const QString& devName);
+ void setDescriptor(const QString& descriptor);
+ void setBluetoothMode(bool mode);
+ void setForceDownload(bool force);
+ void setCreateNewTrip(bool create);
+ void setDeviceId(int deviceId);
+ void setDiveId(int diveId);
+
+private:
+ device_data_t data;
+};
+
class DownloadThread : public QThread {
Q_OBJECT
public: