#ifndef ALARMEVENTREALTIMEDOCK_H
#define ALARMEVENTREALTIMEDOCK_H

#include <QWidget>
#include "alarmEventGlobal.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class alarmEventRealTimeDock;
}
QT_END_NAMESPACE

class AlarmEventDataView;
class QPropertyAnimation;
class AlarmEventRealTimeDock : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(float alertWidgetBGColorAlpha READ alertWidgetBGColorAlpha WRITE setAlertWidgetBGColorAlpha NOTIFY alertWidgetBGColorAlphaChanged)

public:
    struct AlarmDataStatics
    {
        int allCount = 0; //总数量
        int accidentCount = 0; //事故数量
        int abnormalCount = 0; //异常数量
        int alertCount = 0; //预警数量
        int informCount = 0; //告知数量
    };

    AlarmEventRealTimeDock(QWidget *parent = nullptr);
    ~AlarmEventRealTimeDock();

    void updateGeometry();

signals:
    void alertWidgetBGColorAlphaChanged(float value);
    void viewAllRealTimeEvents();
    void openConfigDialog();

public slots:
    void onBtnClicked_open();
    void onBtnClicked_close();
    void onBtnClicked_confirmAll();
    void onBtnClicked_checkAll();
    void onBtnClicked_setting();
    void onSIG_receivedNewAlarm(const EventData& event);
    //void onSIG_configFinish(const AlarmConfigurationResults&);

private:
    void expand();
    void collapse();

    void startAlarmAlert();
    void stopAlarmAlert();
    float alertWidgetBGColorAlpha() {return m_alertWidgetBGColorAlpha;}
    void setAlertWidgetBGColorAlpha(float value);
    void updateAlertWidgetBGColorAlpha();

    Ui::alarmEventRealTimeDock*  ui;
    AlarmEventDataView* m_tableView;
    QPropertyAnimation* m_animationExpand;
    QPropertyAnimation* m_animationAlert;
    bool m_isInAnimationExpand;
    bool m_isInAnimationAlert;
    float m_alertWidgetBGColorAlpha;
    QString m_alertWidgetStyleSheet;
    QString m_curState;
    AlarmDataStatics m_alarmDataStatics;
    AlarmConfigurationResults m_cfgResults;
};

#endif
