107 lines
2.1 KiB
C
107 lines
2.1 KiB
C
|
#ifndef CUSTOMDISPLAYPANEL_H
|
|||
|
#define CUSTOMDISPLAYPANEL_H
|
|||
|
|
|||
|
#include <QWidget>
|
|||
|
#include <QHBoxLayout>
|
|||
|
#include <QStringList>
|
|||
|
#include <QLabel>
|
|||
|
#include <QVector>
|
|||
|
#include <QTableWidget>
|
|||
|
|
|||
|
#include "openjson.h"
|
|||
|
|
|||
|
/**
|
|||
|
* 创建一个自定义的显示面板
|
|||
|
* 上半部分的左边为图示,右边为显示的主要KPI指标标签
|
|||
|
* 下半部为表格,显示主要的参数
|
|||
|
*/
|
|||
|
|
|||
|
class CustomDisplayPanel : public QWidget
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
explicit CustomDisplayPanel(QWidget *parent = nullptr);
|
|||
|
|
|||
|
protected:
|
|||
|
int m_label_count;
|
|||
|
int m_table_rows_count;
|
|||
|
int m_table_rols_count;
|
|||
|
QStringList m_lables;
|
|||
|
QStringList m_rowItems;
|
|||
|
QString m_imagePath;
|
|||
|
QString m_mainLabel;
|
|||
|
|
|||
|
QVector<QLabel*> m_txtLabels;
|
|||
|
QTableWidget* m_pTableWidget;
|
|||
|
|
|||
|
public:
|
|||
|
typedef enum _tagPanelType: int
|
|||
|
{
|
|||
|
PANEL_TEMPERATURE = 1,
|
|||
|
PANEL_BATTERY,
|
|||
|
PANEL_POWER,
|
|||
|
PANEL_AC,
|
|||
|
PANEL_PV,
|
|||
|
PANEL_ALARM,
|
|||
|
PANEL_INVERTER,
|
|||
|
PANEL_HOME,
|
|||
|
} PanelType;
|
|||
|
|
|||
|
public:
|
|||
|
void setImage(const QString& img)
|
|||
|
{
|
|||
|
m_imagePath = img;
|
|||
|
}
|
|||
|
|
|||
|
//设置显示指标和表格数据,其中显示的标签数量需要跟QStringlist的数量一致
|
|||
|
void setLableCount(int number = 5)
|
|||
|
{
|
|||
|
m_label_count = number;
|
|||
|
};
|
|||
|
void setTableRolCount(int number = 2)
|
|||
|
{
|
|||
|
m_table_rols_count = number;
|
|||
|
}
|
|||
|
void setTableRowsCount(int number = 10)
|
|||
|
{
|
|||
|
m_table_rows_count = number;
|
|||
|
};
|
|||
|
|
|||
|
void setLables(const QStringList& sl)
|
|||
|
{
|
|||
|
m_lables = sl;
|
|||
|
}
|
|||
|
void setRowItems(const QStringList& sl)
|
|||
|
{
|
|||
|
m_rowItems = sl;
|
|||
|
}
|
|||
|
//设置Panel的标题
|
|||
|
void setMainLabel(QString label)
|
|||
|
{
|
|||
|
m_mainLabel = label;
|
|||
|
}
|
|||
|
|
|||
|
virtual void Build();
|
|||
|
|
|||
|
public:
|
|||
|
//更新数据
|
|||
|
void UpdateData(OpenJson& json);
|
|||
|
|
|||
|
void UpdateTemperature(OpenJson& json);
|
|||
|
void UpdateAlarm(OpenJson& json);
|
|||
|
public:
|
|||
|
|
|||
|
|
|||
|
signals:
|
|||
|
};
|
|||
|
|
|||
|
class CustomWarningPanel : public CustomDisplayPanel
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
explicit CustomWarningPanel(QWidget *parent = nullptr);
|
|||
|
virtual void Build();
|
|||
|
};
|
|||
|
|
|||
|
#endif // CUSTOMDISPLAYPANEL_H
|