From 09904ddff525ccf3f1165956e0d2d5483290bf12 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 19 May 2017 11:23:11 +0200 Subject: Extract the device_data_t into helper class Keeping the Desktop and QML versions of Subsurface using the same codebase will keep the code saner, this change makes the Desktop version use the DCDeviceData helper sturct that encapsulates the device_data_t member for easy access on the QML. This also helped move a bit of initializations from the UI to the Core - and that's always good. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- core/downloadfromdcthread.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'core/downloadfromdcthread.h') diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h index d0f088b51..d2c3408f2 100644 --- a/core/downloadfromdcthread.h +++ b/core/downloadfromdcthread.h @@ -20,6 +20,8 @@ class DCDeviceData : public QObject { Q_PROPERTY(bool createNewTrip READ createNewTrip WRITE setCreateNewTrip) Q_PROPERTY(int deviceId READ deviceId WRITE setDeviceId) Q_PROPERTY(int diveId READ diveId WRITE setDiveId) + Q_PROPERTY(bool saveDump READ saveDump WRITE setSaveDump) + Q_PROPERTY(bool saveLog READ saveLog WRITE setSaveLog) public: DCDeviceData(QObject *parent = nullptr); @@ -31,9 +33,16 @@ public: bool bluetoothMode() const; bool forceDownload() const; bool createNewTrip() const; + bool saveDump() const; + bool saveLog() const; 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(); + public slots: void setVendor(const QString& vendor); void setProduct(const QString& product); @@ -44,7 +53,8 @@ public slots: void setCreateNewTrip(bool create); void setDeviceId(int deviceId); void setDiveId(int diveId); - + void setSaveDump(bool dumpMode); + void setSaveLog(bool saveLog); private: device_data_t data; }; @@ -52,28 +62,32 @@ private: class DownloadThread : public QThread { Q_OBJECT public: - DownloadThread(QObject *parent, device_data_t *data); + DownloadThread(); void setDiveTable(struct dive_table *table); void run() override; + DCDeviceData& data(); QString error; private: - device_data_t *data; + DCDeviceData m_data; }; +//TODO: QList ? struct product { const char *product; dc_descriptor_t *descriptor; struct product *next; }; +//TODO: QList ? struct vendor { const char *vendor; struct product *productlist; struct vendor *next; }; +//TODO: C++ify descriptor? struct mydescriptor { const char *vendor; const char *product; -- cgit v1.2.3-70-g09d2