Add helper class update_dc_event to dend customer messages from the worker-thread
to the gui-thread. The gui-thread will then perform bl_rebootDC, bl_startBL, bl_checkBL(), bl_isUp() and bl_stopBL().
This commit is contained in:
parent
6773a7243a
commit
e82742a609
25
update_dc_event.cpp
Normal file
25
update_dc_event.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "update_dc_event.h"
|
||||
|
||||
QEvent::Type UpdateDcEvent::customEventType = QEvent::None;
|
||||
|
||||
UpdateDcEvent::UpdateDcEvent(QObject const *sender,
|
||||
UpdateStep updateStep,
|
||||
int count,
|
||||
QDateTime const &sendDateTime)
|
||||
: QEvent(UpdateDcEvent::type())
|
||||
, m_sender(sender)
|
||||
, m_updateStep(updateStep)
|
||||
, m_count(count)
|
||||
, m_sendDateTime(sendDateTime) {
|
||||
}
|
||||
|
||||
UpdateDcEvent::~UpdateDcEvent() {
|
||||
}
|
||||
|
||||
QEvent::Type UpdateDcEvent::type() {
|
||||
if (customEventType == QEvent::None) {
|
||||
int generatedType = QEvent::registerEventType();
|
||||
customEventType = static_cast<QEvent::Type>(generatedType);
|
||||
}
|
||||
return customEventType;
|
||||
}
|
40
update_dc_event.h
Normal file
40
update_dc_event.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef UPDATE_DC_EVENT_H_INCLUDED
|
||||
#define UPDATE_DC_EVENT_H_INCLUDED
|
||||
|
||||
#include <QEvent>
|
||||
#include <QDateTime>
|
||||
|
||||
class UpdateDcEvent : public QEvent {
|
||||
public:
|
||||
enum UpdateStep { NONE, DC_REBOOT, BL_START, BL_CHECK, BL_CHECK_AFTER_STOP, BL_IS_UP, BL_IS_DOWN, BL_STOP};
|
||||
|
||||
private:
|
||||
QObject const *m_sender;
|
||||
UpdateStep m_updateStep;
|
||||
int m_count;
|
||||
QDateTime m_sendDateTime;
|
||||
|
||||
public:
|
||||
explicit UpdateDcEvent(QObject const *sender, UpdateStep updateStep,
|
||||
int count,
|
||||
QDateTime const &sendDateTime = QDateTime::currentDateTime());
|
||||
virtual ~UpdateDcEvent();
|
||||
static QEvent::Type type();
|
||||
|
||||
QObject const *sender() { return m_sender; }
|
||||
QObject const *sender() const { return m_sender; }
|
||||
|
||||
void setUpdateStep(UpdateStep updateStep) { m_updateStep = updateStep; }
|
||||
UpdateStep updateStep() { return m_updateStep; }
|
||||
UpdateStep updateStep() const { return m_updateStep; }
|
||||
int count() const { return m_count; }
|
||||
void setCount(int count) { m_count = count; }
|
||||
QDateTime &sendDateTime() { return m_sendDateTime; }
|
||||
QDateTime const &sendDateTime() const { return m_sendDateTime; }
|
||||
|
||||
private:
|
||||
static QEvent::Type customEventType;
|
||||
};
|
||||
|
||||
|
||||
#endif // PROGRESS_EVENT_H_INCLUDED
|
Loading…
Reference in New Issue
Block a user