summaryrefslogtreecommitdiffstats
path: root/qt-ui/configuredivecomputer.h
blob: 65ceaa780f646b75e7066bf3202a8e23ff8b6a27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CONFIGUREDIVECOMPUTER_H
#define CONFIGUREDIVECOMPUTER_H

#include <QObject>
#include <QThread>
#include <QVariant>
#include "libdivecomputer.h"
#include "configuredivecomputerthreads.h"
#include <QDateTime>

class ConfigureDiveComputer : public QObject
{
	Q_OBJECT
public:
	explicit ConfigureDiveComputer(QObject *parent = 0);
	void readSettings(DeviceDetails *deviceDetails, device_data_t *data);

	enum states {
			INITIAL,
			READING,
			WRITING,
			CANCELLING,
			CANCELLED,
			ERROR,
			DONE,
		};

	QString lastError;
	states currentState;
	DeviceDetails *m_deviceDetails;
	device_data_t *m_data;
	void saveDeviceDetails();
	void fetchDeviceDetails();

signals:
	void message(QString msg);
	void error(QString err);
	void readFinished();
	void writeFinished();
	void stateChanged(states newState);

private:
	ReadSettingsThread *readThread;
	WriteSettingsThread *writeThread;
	void setState(states newState);

private slots:
	void readThreadFinished();
	void writeThreadFinished();
	void setError(QString err);
};

#endif // CONFIGUREDIVECOMPUTER_H