Refactor device handling threads

This refactors the device handling threads into having one common
ancestor class.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2015-01-20 22:40:49 +01:00 committed by Dirk Hohndel
parent a700be3207
commit 0787d941a0
2 changed files with 28 additions and 35 deletions

View file

@ -1389,7 +1389,11 @@ static dc_status_t write_ostc_settings(dc_device_t *device, DeviceDetails *m_dev
return rc;
}
ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data)
DeviceThread::DeviceThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data)
{
}
ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
{
}
@ -1452,7 +1456,7 @@ void ReadSettingsThread::run()
}
}
WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data)
WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
{
}
@ -1513,7 +1517,7 @@ void WriteSettingsThread::run()
}
FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName) : QThread(parent), m_data(data), m_fileName(fileName)
FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName) : DeviceThread(parent, data), m_fileName(fileName)
{
}
@ -1553,7 +1557,7 @@ void FirmwareUpdateThread::run()
}
ResetSettingsThread::ResetSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data)
ResetSettingsThread::ResetSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
{
}

View file

@ -8,66 +8,55 @@
#include <QDateTime>
#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