From 0787d941a0f58417a2eb1a656e54c19123366c71 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Tue, 20 Jan 2015 22:40:49 +0100 Subject: Refactor device handling threads This refactors the device handling threads into having one common ancestor class. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- configuredivecomputerthreads.h | 51 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) (limited to 'configuredivecomputerthreads.h') diff --git a/configuredivecomputerthreads.h b/configuredivecomputerthreads.h index 5c33c9de2..bc35caf5a 100644 --- a/configuredivecomputerthreads.h +++ b/configuredivecomputerthreads.h @@ -8,66 +8,55 @@ #include #include "devicedetails.h" -class ReadSettingsThread : public QThread { +class DeviceThread : public QThread { Q_OBJECT public: - ReadSettingsThread(QObject *parent, device_data_t *data); - virtual void run(); + DeviceThread(QObject *parent, device_data_t *data); + virtual void run() = 0; QString result; QString lastError; signals: void error(QString err); - void devicedetails(DeviceDetails *newDeviceDetails); - -private: + void message(QString msg); +protected: device_data_t *m_data; }; -class WriteSettingsThread : public QThread { +class ReadSettingsThread : public DeviceThread { + Q_OBJECT +public: + ReadSettingsThread(QObject *parent, device_data_t *data); + void run(); +signals: + void devicedetails(DeviceDetails *newDeviceDetails); +}; + +class WriteSettingsThread : public DeviceThread { Q_OBJECT public: WriteSettingsThread(QObject *parent, device_data_t *data); void setDeviceDetails(DeviceDetails *details); - virtual void run(); - QString result; - QString lastError; -signals: - void error(QString err); + void run(); private: - device_data_t *m_data; DeviceDetails *m_deviceDetails; }; -class FirmwareUpdateThread : public QThread { +class FirmwareUpdateThread : public DeviceThread { Q_OBJECT public: FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName); - virtual void run(); - QString lastError; -signals: - void progress(int percent); - void message(QString msg); - void error(QString err); + void run(); private: - device_data_t *m_data; QString m_fileName; }; -class ResetSettingsThread : public QThread { +class ResetSettingsThread : public DeviceThread { Q_OBJECT public: ResetSettingsThread(QObject *parent, device_data_t *data); - virtual void run(); - QString lastError; -signals: - void progress(int percent); - void message(QString msg); - void error(QString err); - -private: - device_data_t *m_data; + void run(); }; #endif // CONFIGUREDIVECOMPUTERTHREADS_H -- cgit v1.2.3-70-g09d2