2014-05-30 09:56:27 +03:00
|
|
|
#ifndef CONFIGUREDIVECOMPUTER_H
|
|
|
|
#define CONFIGUREDIVECOMPUTER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QThread>
|
2014-05-30 10:49:58 +03:00
|
|
|
#include <QVariant>
|
2014-05-30 09:56:27 +03:00
|
|
|
#include "libdivecomputer.h"
|
2014-06-10 15:03:26 +03:00
|
|
|
#include "configuredivecomputerthreads.h"
|
2014-05-30 10:49:58 +03:00
|
|
|
#include <QDateTime>
|
|
|
|
|
2014-06-11 09:37:27 +03:00
|
|
|
#include "libxml/xmlreader.h"
|
|
|
|
|
2014-05-30 09:56:27 +03:00
|
|
|
class ConfigureDiveComputer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ConfigureDiveComputer(QObject *parent = 0);
|
2014-06-10 18:25:25 +03:00
|
|
|
void readSettings(device_data_t *data);
|
2014-05-30 09:56:27 +03:00
|
|
|
|
|
|
|
enum states {
|
|
|
|
INITIAL,
|
|
|
|
READING,
|
|
|
|
WRITING,
|
|
|
|
CANCELLING,
|
|
|
|
CANCELLED,
|
|
|
|
ERROR,
|
|
|
|
DONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
QString lastError;
|
|
|
|
states currentState;
|
2014-06-10 15:03:26 +03:00
|
|
|
device_data_t *m_data;
|
2014-06-10 18:25:25 +03:00
|
|
|
void saveDeviceDetails(DeviceDetails *details, device_data_t *data);
|
2014-06-10 15:03:26 +03:00
|
|
|
void fetchDeviceDetails();
|
2014-06-10 19:19:28 +03:00
|
|
|
bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText);
|
2014-06-11 09:37:27 +03:00
|
|
|
bool restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText);
|
2014-05-30 09:56:27 +03:00
|
|
|
signals:
|
|
|
|
void message(QString msg);
|
|
|
|
void error(QString err);
|
|
|
|
void readFinished();
|
|
|
|
void writeFinished();
|
|
|
|
void stateChanged(states newState);
|
2014-06-10 18:25:25 +03:00
|
|
|
void deviceDetailsChanged(DeviceDetails *newDetails);
|
2014-06-10 15:03:26 +03:00
|
|
|
|
2014-05-30 09:56:27 +03:00
|
|
|
private:
|
|
|
|
ReadSettingsThread *readThread;
|
2014-05-30 10:49:58 +03:00
|
|
|
WriteSettingsThread *writeThread;
|
2014-05-30 09:56:27 +03:00
|
|
|
void setState(states newState);
|
2014-06-11 09:37:27 +03:00
|
|
|
QString addSettingToXML(QString settingName, QVariant value);
|
2014-05-30 09:56:27 +03:00
|
|
|
private slots:
|
|
|
|
void readThreadFinished();
|
2014-05-30 10:49:58 +03:00
|
|
|
void writeThreadFinished();
|
2014-05-30 09:56:27 +03:00
|
|
|
void setError(QString err);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGUREDIVECOMPUTER_H
|