2025-09-18 15:50:18 +08:00
|
|
|
#ifndef ALARMEVENTDATAVIEW_H
|
|
|
|
|
#define ALARMEVENTDATAVIEW_H
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
2025-09-19 17:45:52 +08:00
|
|
|
#include <QTableView>
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
|
|
|
|
|
|
class AlarmEventDataModel : public QAbstractTableModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
struct RowData
|
|
|
|
|
{
|
|
|
|
|
QVector<QVariant> values;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PaginationInfo
|
|
|
|
|
{
|
|
|
|
|
int totalEntries;
|
|
|
|
|
int entriesPerpage;
|
|
|
|
|
int totalPages;
|
|
|
|
|
int currentPage;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SectionData
|
|
|
|
|
{
|
|
|
|
|
int width = -1;
|
|
|
|
|
QString text;
|
|
|
|
|
|
|
|
|
|
SectionData(QString t, int w)
|
|
|
|
|
:text(t),
|
|
|
|
|
width(w){}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit AlarmEventDataModel(QObject* parent = nullptr);
|
|
|
|
|
~AlarmEventDataModel();
|
|
|
|
|
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
|
|
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
|
//bool setData(const QModelIndex& index, const QVariant &value, int role = Qt::EditRole) override;
|
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void iniHeaderData();
|
|
|
|
|
void updateCurPageData(); //更新当前页的数据
|
|
|
|
|
void updateTotalCount(); //更新总记录数
|
|
|
|
|
|
|
|
|
|
QVector<RowData> m_curPageData;
|
|
|
|
|
QVector<SectionData> m_headerData;
|
|
|
|
|
PaginationInfo m_paginationInfo;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AlarmEventDataDelegate : public QStyledItemDelegate
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit AlarmEventDataDelegate(QTableView* view, QObject* parent = nullptr);
|
|
|
|
|
~AlarmEventDataDelegate();
|
|
|
|
|
|
|
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QTableView* m_tableView;
|
|
|
|
|
};
|
2025-09-18 15:50:18 +08:00
|
|
|
|
|
|
|
|
class QVBoxLayout;
|
|
|
|
|
class AlarmEventDataView : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AlarmEventDataView(QWidget* parent = nullptr);
|
|
|
|
|
~AlarmEventDataView();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QTableView* m_tableView;
|
2025-09-19 17:45:52 +08:00
|
|
|
AlarmEventDataModel* m_tableModel;
|
|
|
|
|
AlarmEventDataDelegate* m_delegate;
|
2025-09-18 15:50:18 +08:00
|
|
|
QVBoxLayout* m_vLayout;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|