2017-04-18 17:14:03 +00:00
|
|
|
#ifndef DOWNLOADFROMDCTHREAD_H
|
|
|
|
#define DOWNLOADFROMDCTHREAD_H
|
|
|
|
|
|
|
|
#include <QThread>
|
2017-04-27 18:24:14 +00:00
|
|
|
#include <QMap>
|
|
|
|
#include <QHash>
|
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
#include "dive.h"
|
|
|
|
#include "libdivecomputer.h"
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
/* 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)
|
2017-05-19 09:23:11 +00:00
|
|
|
Q_PROPERTY(bool saveDump READ saveDump WRITE setSaveDump)
|
|
|
|
Q_PROPERTY(bool saveLog READ saveLog WRITE setSaveLog)
|
2017-05-12 17:18:20 +00:00
|
|
|
|
|
|
|
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;
|
2017-05-19 09:23:11 +00:00
|
|
|
bool saveDump() const;
|
|
|
|
bool saveLog() const;
|
2017-05-12 17:18:20 +00:00
|
|
|
int deviceId() const;
|
|
|
|
int diveId() const;
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
/* this needs to be a pointer to make the C-API happy */
|
|
|
|
device_data_t* internalData();
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
public slots:
|
|
|
|
void setVendor(const QString& vendor);
|
|
|
|
void setProduct(const QString& product);
|
|
|
|
void setDevName(const QString& devName);
|
|
|
|
void setBluetoothMode(bool mode);
|
|
|
|
void setForceDownload(bool force);
|
|
|
|
void setCreateNewTrip(bool create);
|
|
|
|
void setDeviceId(int deviceId);
|
|
|
|
void setDiveId(int diveId);
|
2017-05-19 09:23:11 +00:00
|
|
|
void setSaveDump(bool dumpMode);
|
|
|
|
void setSaveLog(bool saveLog);
|
2017-05-12 17:18:20 +00:00
|
|
|
private:
|
|
|
|
device_data_t data;
|
|
|
|
};
|
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
class DownloadThread : public QThread {
|
|
|
|
Q_OBJECT
|
2017-05-26 14:40:50 +00:00
|
|
|
Q_PROPERTY(DCDeviceData* deviceData MEMBER m_data)
|
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
public:
|
2017-05-19 09:23:11 +00:00
|
|
|
DownloadThread();
|
2017-04-18 17:14:03 +00:00
|
|
|
void run() override;
|
|
|
|
|
2017-05-26 14:40:50 +00:00
|
|
|
DCDeviceData *data();
|
2017-04-18 17:14:03 +00:00
|
|
|
QString error;
|
|
|
|
|
|
|
|
private:
|
2017-05-26 14:40:50 +00:00
|
|
|
DCDeviceData *m_data;
|
2017-04-18 17:14:03 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
//TODO: QList<product> ?
|
2017-04-27 18:24:14 +00:00
|
|
|
struct product {
|
|
|
|
const char *product;
|
|
|
|
dc_descriptor_t *descriptor;
|
|
|
|
struct product *next;
|
|
|
|
};
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
//TODO: QList<vendor> ?
|
2017-04-27 18:24:14 +00:00
|
|
|
struct vendor {
|
|
|
|
const char *vendor;
|
|
|
|
struct product *productlist;
|
|
|
|
struct vendor *next;
|
|
|
|
};
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
//TODO: C++ify descriptor?
|
2017-04-27 18:24:14 +00:00
|
|
|
struct mydescriptor {
|
|
|
|
const char *vendor;
|
|
|
|
const char *product;
|
|
|
|
dc_family_t type;
|
|
|
|
unsigned int model;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This fills the vendor list QStringList and related members.
|
|
|
|
* this code needs to be reworked to be less ugly, but it will
|
|
|
|
* stay like this for now.
|
|
|
|
*/
|
|
|
|
void fill_computer_list();
|
|
|
|
extern QStringList vendorList;
|
|
|
|
extern QHash<QString, QStringList> productList;
|
|
|
|
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
#endif
|