2014-05-30 06:56:27 +00:00
|
|
|
#ifndef CONFIGUREDIVECOMPUTER_H
|
|
|
|
#define CONFIGUREDIVECOMPUTER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QThread>
|
2014-05-30 07:49:58 +00:00
|
|
|
#include <QVariant>
|
2014-05-30 06:56:27 +00:00
|
|
|
#include "libdivecomputer.h"
|
2014-05-30 07:49:58 +00:00
|
|
|
#include <QDateTime>
|
2014-05-30 06:56:27 +00:00
|
|
|
class ReadSettingsThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ReadSettingsThread(QObject *parent, device_data_t *data);
|
|
|
|
virtual void run();
|
|
|
|
QString result;
|
|
|
|
QString lastError;
|
|
|
|
signals:
|
|
|
|
void error(QString err);
|
|
|
|
private:
|
|
|
|
device_data_t *data;
|
|
|
|
};
|
|
|
|
|
2014-05-30 07:49:58 +00:00
|
|
|
class WriteSettingsThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WriteSettingsThread(QObject *parent, device_data_t *data, QString settingName, QVariant settingValue);
|
|
|
|
virtual void run();
|
|
|
|
QString result;
|
|
|
|
QString lastError;
|
|
|
|
signals:
|
|
|
|
void error(QString err);
|
|
|
|
private:
|
|
|
|
device_data_t *data;
|
|
|
|
QString m_settingName;
|
|
|
|
QVariant m_settingValue;
|
|
|
|
};
|
|
|
|
|
2014-05-30 06:56:27 +00:00
|
|
|
class ConfigureDiveComputer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ConfigureDiveComputer(QObject *parent = 0);
|
|
|
|
void readSettings(device_data_t *data);
|
|
|
|
|
|
|
|
enum states {
|
|
|
|
INITIAL,
|
|
|
|
READING,
|
|
|
|
WRITING,
|
|
|
|
CANCELLING,
|
|
|
|
CANCELLED,
|
|
|
|
ERROR,
|
|
|
|
DONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
QString lastError;
|
|
|
|
states currentState;
|
2014-05-30 07:49:58 +00:00
|
|
|
|
|
|
|
void setDeviceName(device_data_t *data, QString newName);
|
|
|
|
void setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime);
|
2014-06-07 18:56:44 +00:00
|
|
|
void setDeviceBrightness(device_data_t *data, int brighnessLevel);
|
2014-05-30 06:56:27 +00:00
|
|
|
signals:
|
|
|
|
void deviceSettings(QString settings);
|
|
|
|
void message(QString msg);
|
|
|
|
void error(QString err);
|
|
|
|
void readFinished();
|
|
|
|
void writeFinished();
|
|
|
|
void stateChanged(states newState);
|
|
|
|
private:
|
|
|
|
ReadSettingsThread *readThread;
|
2014-05-30 07:49:58 +00:00
|
|
|
WriteSettingsThread *writeThread;
|
2014-05-30 06:56:27 +00:00
|
|
|
void setState(states newState);
|
|
|
|
|
2014-05-30 07:49:58 +00:00
|
|
|
void writeSettingToDevice(device_data_t *data, QString settingName, QVariant settingValue);
|
2014-05-30 06:56:27 +00:00
|
|
|
private slots:
|
|
|
|
void readThreadFinished();
|
2014-05-30 07:49:58 +00:00
|
|
|
void writeThreadFinished();
|
2014-05-30 06:56:27 +00:00
|
|
|
void setError(QString err);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGUREDIVECOMPUTER_H
|