151 lines
5.8 KiB
C++
151 lines
5.8 KiB
C++
#ifndef CEVENTITEMMODEL_H
|
||
#define CEVENTITEMMODEL_H
|
||
|
||
#include <QAbstractTableModel>
|
||
#include <QDateTime>
|
||
#include <QSet>
|
||
#include <QMutex>
|
||
#include "CEventMsgInfo.h"
|
||
#include "CEventDataCollect.h"
|
||
|
||
#define Row_Full (15000)
|
||
|
||
class CEventMsgInfo;
|
||
class QTimer;
|
||
|
||
class CEventItemModel : public QAbstractTableModel
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
CEventItemModel(QObject *parent = Q_NULLPTR);
|
||
~CEventItemModel();
|
||
|
||
void initialize();
|
||
void initFilter();
|
||
|
||
void initFilterAndReloadData();
|
||
|
||
EventMsgPtr getAlarmInfo(const QModelIndex &index) const;
|
||
|
||
const QList<EventMsgPtr> getListShowAlarmInfo() const;
|
||
|
||
/**
|
||
* @brief insertAlarmMsg 数采通知模型报警到达
|
||
* @param info
|
||
*/
|
||
void insertAlarmMsg(EventMsgPtr info);
|
||
|
||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||
virtual int columnCount(const QModelIndex &index = QModelIndex()) const;
|
||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||
void sort();
|
||
void qucikSort(QList<EventMsgPtr> &listAlarmInfo, int left, int right);
|
||
int partitionAscendingOrder(QList<EventMsgPtr> &list, int start, int last);
|
||
int partitionDescendingOrder(QList<EventMsgPtr> &list, int start, int last);
|
||
|
||
/**
|
||
* 设置模型数据过滤条件,过滤显示数据
|
||
*/
|
||
void setFilter(const bool &isLevelFilterEnable, const QList<int> &levelFilter,
|
||
const bool &isStationFilterEnable, const QList<int> &stationFilter,
|
||
const bool &isRegionFilterEnable, const QList<int> ®ionFilter,
|
||
const bool &isTypeFilterEnable, const QList<int> &typeFilter,
|
||
const bool &isDeviceTypeFilter = false, const QString &subSystem = QString(), const QString &deviceType = QString(),
|
||
const bool &isKeywordFilterEnable = false, const QString &keyword = QString(),
|
||
const bool &timeFilterEnable = false, const QDateTime &startTime = QDateTime(),
|
||
const QDateTime &endTime = QDateTime(),const bool &isReturnFilterEnable = false,const bool &isReturn = false);
|
||
|
||
/**
|
||
* 获取模型数据过滤条件,用于初始化过滤对话框
|
||
*/
|
||
void getFilter(bool &isLevelFilterEnable, QList<int> &levelFilter,
|
||
bool &isLocationFilterEnable, QList<int> &locationFilter,
|
||
bool &isRegionFilterEnable, QList<int> ®ionFilter,
|
||
bool &isTypeFilterEnable, QList<int> &alarmTypeFilter,
|
||
bool &deviceTypeFilter, QString &subSystem, QString &deviceType,
|
||
bool &keywordFilterEnable, QString &keyword,
|
||
bool &timeFilterEnable, QDateTime &startTime, QDateTime &endTime,
|
||
bool &returnFilterEnable,bool &isReturn);
|
||
|
||
bool conditionFilter(EventMsgPtr info);
|
||
|
||
void setPriorityFilter(bool &isCheck, QList<int> &priorityFilter);
|
||
void setLocationFilter(bool &isCheck, QList<int> &locationFilter);
|
||
void setEventTypeFilter(bool &isCheck, QList<int> &eventTypeFilter, bool &other);
|
||
void setEventTimeFilter(bool &isCheck,QDate &startTime,QDate &endTime);
|
||
void setEventTimeFilter(bool &isCheck);
|
||
|
||
void getPriorityFilter(bool &isCheck,QList<int> &priorityFilter);
|
||
|
||
void getLocationFilter(bool &isCheck,QList<int> &locationFilter);
|
||
|
||
void getEventStatusFilter(bool &isCheck, QList<int> &eventStatusFilter);
|
||
|
||
void getEventTimeFilter(bool &isCheck,QDateTime &startTime, QDateTime &endTime);
|
||
|
||
QList<EventMsgPtr> getListEventInfo();
|
||
|
||
void addDeviceGroupFilter();
|
||
void removeDeviceGroupFilter();
|
||
void addDeviceGroupFilter(const QString &device);
|
||
void removeDeviceGroupFilter(const QString &device);
|
||
signals:
|
||
void sigRowChanged();
|
||
|
||
public slots:
|
||
void sortColumn(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||
|
||
private slots:
|
||
/**
|
||
* @brief slotMsgRefresh 更新model,重新拉取数据
|
||
*/
|
||
void slotMsgRefresh();
|
||
|
||
/**
|
||
* @brief slotMsgArrived 报警消息到达
|
||
* @param info
|
||
*/
|
||
void slotMsgArrived(QList<EventMsgPtr> listEvents);
|
||
private:
|
||
void firstFilterByReturn(QList<EventMsgPtr> &filterSet);
|
||
|
||
private:
|
||
QStringList header;
|
||
QList<EventMsgPtr> m_listShowEventInfo;
|
||
QList<EventMsgPtr> m_listAllEventInfo;
|
||
|
||
E_ALARM_SORTKEY m_sortKey; //排序规则
|
||
Qt::SortOrder m_order;
|
||
|
||
//Filter
|
||
bool m_isLevelFilterEnable; //是否按报警级别过滤
|
||
QList<int> m_levelFilter; //报警级别过滤
|
||
bool m_isLocationFilterEnable; //是否按车站过滤
|
||
QList<int> m_locationFilter; //车站过滤
|
||
bool m_isRegionFilterEnable; //是否按责任区过滤
|
||
QList<int> m_regionFilter; //责任区过滤
|
||
bool m_isStatusFilterEnable; //是否按事件状态过滤
|
||
QList<int> m_statusFilter; //事件状态过滤(所有的要过滤事件状态--如果其他状态没有被勾选,则与下面的内容相同)
|
||
QList<int> m_statusFilter2; //事件状态过滤(显示在过滤窗中的事件状态)
|
||
bool m_isDeviceTypeFileter; //设备类型过滤
|
||
QString m_subSystem; //子系统
|
||
QString m_deviceType; //设备类型
|
||
bool m_isKeywordEnable; //关键字过滤
|
||
QString m_keyword; //关键字
|
||
bool m_timeFilterEnable; //是否根据时间过滤
|
||
QDateTime m_startTime; //起始时间
|
||
QDateTime m_endTime; //终止时间
|
||
|
||
bool m_isReturnFilterEnable; //是否根据复归状态过滤
|
||
bool m_isReturn;
|
||
|
||
QMap<int,SAreaInfo> m_areaInfoMap; //区域信息
|
||
|
||
QMap<int,QVector<int> > m_areaLocMap; //区域映射
|
||
QSet<QString> m_deviceGroupFilter; //<设备组过滤
|
||
};
|
||
|
||
#endif // CEVENTITEMMODEL_H
|