diff --git a/update_dc_event.cpp b/update_dc_event.cpp new file mode 100644 index 0000000..a3b8ec9 --- /dev/null +++ b/update_dc_event.cpp @@ -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(generatedType); + } + return customEventType; +} diff --git a/update_dc_event.h b/update_dc_event.h new file mode 100644 index 0000000..869375a --- /dev/null +++ b/update_dc_event.h @@ -0,0 +1,40 @@ +#ifndef UPDATE_DC_EVENT_H_INCLUDED +#define UPDATE_DC_EVENT_H_INCLUDED + +#include +#include + +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