add monitor config ui
This commit is contained in:
parent
f0feb9c0c1
commit
e8c8b79db6
|
|
@ -9,7 +9,7 @@ set(CMAKE_AUTOMOC ON)
|
|||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Sql Xml REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Sql Xml REQUIRED Charts)
|
||||
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
|
||||
find_package(Qt6 COMPONENTS Network REQUIRED)
|
||||
find_package(PostgreSQL REQUIRED)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ public:
|
|||
virtual QJsonObject context() const {return jContext;}
|
||||
virtual void setSubList(QList<QPair<int,QUuid>> lst) {subList = lst;}
|
||||
virtual QList<QPair<int,QUuid>>& getSubList() {return subList;}
|
||||
|
||||
virtual QJsonArray saveSubToJsonArr();
|
||||
protected:
|
||||
QUuid uUid;
|
||||
QString sTag;
|
||||
|
|
|
|||
|
|
@ -1005,21 +1005,6 @@ struct pageInfo
|
|||
int op;
|
||||
};
|
||||
|
||||
struct monitorRelationSturctItem //监控关系结构item
|
||||
{
|
||||
int nCategory; //类型 0设备1间隔
|
||||
int nEquipType; //设备类别
|
||||
QString sName; //名称
|
||||
QUuid uid; //id
|
||||
};
|
||||
|
||||
struct monitorRelationItem //监控关系item
|
||||
{
|
||||
monitorRelationSturctItem parent;
|
||||
monitorRelationSturctItem item;
|
||||
QList<monitorRelationSturctItem> subList;
|
||||
};
|
||||
|
||||
struct monitorPageInfo //运行时page
|
||||
{
|
||||
int id = -1;
|
||||
|
|
@ -1091,18 +1076,35 @@ struct itemPageInfo //page中保存的item信息(大小,位置etc)
|
|||
double dRotate = 0.0;
|
||||
};
|
||||
|
||||
/*struct busStability
|
||||
/*********************运行时************************/
|
||||
struct monitorRelationSturctItem //监控关系结构item
|
||||
{
|
||||
int componentId = 0;
|
||||
double resistance = 0;
|
||||
bool anchor_v = false;
|
||||
double uv_alarm = 0;
|
||||
double ov_alarm = 0;
|
||||
bool anchor_i = false;
|
||||
double ui_alarm = 0;
|
||||
double oi_alarm = 0;
|
||||
};*/
|
||||
//Q_ENUM_NS(GraphicsItemType)
|
||||
int nCategory; //类型 0设备1间隔
|
||||
int nEquipType; //设备类别
|
||||
QString sName; //名称
|
||||
QUuid uid; //id
|
||||
};
|
||||
|
||||
struct monitorRelationItem //监控关系item
|
||||
{
|
||||
monitorRelationSturctItem parent;
|
||||
monitorRelationSturctItem item;
|
||||
QList<monitorRelationSturctItem> subList;
|
||||
};
|
||||
|
||||
struct monitorItemAttributeInfo //单个监控item属性
|
||||
{
|
||||
QString sGroup; //所属组别
|
||||
QString sTag; //索引名
|
||||
QString sName; //显示名
|
||||
QString sConnectPara; //查询参数(参数服务使用)
|
||||
int nShowType; //显示类别 0字符 1图表
|
||||
bool bShowDiagram = false; //显示到组态中
|
||||
int nGraphType = 0; //图表类型 0折线1柱状
|
||||
QString sTimeRange; //时间范围(分)
|
||||
QString sValue; //属性值
|
||||
bool bSelected = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constants used for fetching QVariant data from GraphModel.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "baseProperty.h"
|
||||
#include "dataManager.h"
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
AbstractProperty::AbstractProperty(QObject* parent)
|
||||
|
|
@ -12,6 +13,20 @@ AbstractProperty::~AbstractProperty()
|
|||
|
||||
}
|
||||
|
||||
QJsonArray AbstractProperty::saveSubToJsonArr()
|
||||
{
|
||||
QJsonArray jsonArray;
|
||||
|
||||
for (const auto& pair : subList) {
|
||||
QJsonObject itemObject;
|
||||
itemObject["category"] = pair.first;
|
||||
itemObject["uuid"] = pair.second.toString(); // 将QUuid转换为字符串
|
||||
|
||||
jsonArray.append(itemObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
/******************************模型基类*******************************/
|
||||
ModelProperty::ModelProperty(QObject* parent)
|
||||
:AbstractProperty(parent)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
|||
include/baseDrawingPanel.h
|
||||
include/drawingPanel.h
|
||||
include/monitorPanel.h
|
||||
include/monitorSideBarDlg.h
|
||||
include/monitorSelectedItemsDlg.h
|
||||
include/monitorToolPage.h
|
||||
include/monitorToolBox.h
|
||||
include/monitorAttributeDlg.h
|
||||
include/monitorAttributeGroupDlg.h
|
||||
include/monitorConfigDlg.h
|
||||
include/itemPropertyDlg.h
|
||||
include/propertyContentDlg.h
|
||||
include/serializable.h
|
||||
|
|
@ -117,6 +124,13 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
|||
source/baseDrawingPanel.cpp
|
||||
source/drawingPanel.cpp
|
||||
source/monitorPanel.cpp
|
||||
source/monitorSideBarDlg.cpp
|
||||
source/monitorSelectedItemsDlg.cpp
|
||||
source/monitorToolPage.cpp
|
||||
source/monitorToolBox.cpp
|
||||
source/monitorAttributeDlg.cpp
|
||||
source/monitorAttributeGroupDlg.cpp
|
||||
source/monitorConfigDlg.cpp
|
||||
source/itemPropertyDlg.cpp
|
||||
source/propertyContentDlg.cpp
|
||||
source/statusBar.cpp
|
||||
|
|
@ -235,6 +249,7 @@ set(UI_FILES
|
|||
ui/diagramEditorTransDetailAddDlg.ui
|
||||
ui/confirmEditorDlg.ui
|
||||
ui/projectIconSetting.ui
|
||||
ui/monitorConfigDlg.ui
|
||||
)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
|
|
@ -260,6 +275,7 @@ target_link_libraries(diagramCavas PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
|||
target_link_libraries(diagramCavas PRIVATE Qt6::SvgWidgets)
|
||||
target_link_libraries(diagramCavas PRIVATE Qt6::Xml)
|
||||
target_link_libraries(diagramCavas PRIVATE Qt6::Network)
|
||||
target_link_libraries(diagramCavas PRIVATE Qt6::Charts)
|
||||
target_link_libraries(diagramCavas PRIVATE Qt6::Sql ${PostgreSQL_LIBRARIES})
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build as shared library" ON)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
/****************工程模和运行时panel的基类*****************/
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include "global.h"
|
||||
#include "designerScene.h"
|
||||
|
||||
|
|
@ -16,7 +18,6 @@ class PowerEntity;
|
|||
class ProjectDiagramNameInput;
|
||||
class BayManagerDlg;
|
||||
|
||||
|
||||
class BaseDrawingPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -54,6 +55,9 @@ protected:
|
|||
DiagramMode _mode;
|
||||
QString _name;
|
||||
PowerEntity* _pEntity; //组态图拓扑对象
|
||||
QVBoxLayout* _verticalLayout;
|
||||
QHBoxLayout* _horizontalLayout;
|
||||
QSplitter* _hSplitter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ public:
|
|||
void initial();
|
||||
signals:
|
||||
void prepareUpdateItems(QList<monitorRelationItem>,bool refresh);
|
||||
void prepareSelectItems(QList<QPair<QString,QUuid>>);
|
||||
void prepareSelectItems(QList<monitorRelationItem>);
|
||||
void updateMonitorList(QString,QPair<QString,QUuid>,int nMode = 0); //0新增1删除
|
||||
void createdMonitorItems(QList<QPair<QString,QUuid>>); //创建的监控中item个数
|
||||
void createdMonitorItems(QList<monitorRelationItem>); //创建的监控中item个数
|
||||
public slots:
|
||||
void onSignal_addDrawingPanel(PowerEntity* p,DiagramMode = DM_edit,QString parent = QString()); //parent:派生运行时的page
|
||||
void onSignal_addGraphicsItem(modelStateInfo&);
|
||||
|
|
@ -74,10 +74,10 @@ public slots:
|
|||
void onSignl_openCurrentBay();
|
||||
/********************************运行时**********************************/
|
||||
void onSignal_updateCurItems(QList<monitorRelationItem>,bool); //更新当前设备列表
|
||||
void onSignal_selectedItems(QList<QPair<QString,QUuid>>); //当前选中设备
|
||||
void onSignal_generate(QString,QList<QPair<QString,QUuid>>); //使用选中设备生成监控 (监控名,设备)
|
||||
void onSignal_selectedItems(QList<monitorRelationItem>); //当前选中设备
|
||||
void onSignal_generate(QString,QList<monitorRelationItem>); //使用选中设备生成监控 (监控名,设备)
|
||||
void onSignal_monitorCreated(QString,QPair<QString,QUuid>); //监控已创建
|
||||
void onSignal_monitorItemCreated(QList<QPair<QString,QUuid>>); //监控中创建的对象
|
||||
void onSignal_monitorItemCreated(QList<monitorRelationItem>); //监控中创建的对象
|
||||
|
||||
void onSignal_monitorSelected(DiagramInfo); //监控选中
|
||||
void onSignal_saveMonitor(QList<QPair<QString,QUuid>>); //保存选中的监控
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class BayManagerDlg;
|
|||
class ModelProperty;
|
||||
struct itemPageInfo;
|
||||
class EditBaseItem;
|
||||
class MonitorPanel;
|
||||
|
||||
class FixedPortsModel : public BaseModel, public Serializable
|
||||
{
|
||||
|
|
@ -55,6 +56,7 @@ public:
|
|||
void setScene(DesignerScene* p){_scene = p;}
|
||||
DesignerScene* getScene() {return _scene;}
|
||||
void setTopWidget(BaseDrawingPanel* p) {_widget = p;}
|
||||
BaseDrawingPanel* getParent(){return _widget;}
|
||||
QWidget* getTopWidget();
|
||||
QPointF getTerminalPos(const QString& sTerminalId); //获取拓扑接线点在当前diagram中的位置
|
||||
ElectricConnectLineItem* getLineItemById(const QString& terminalId);
|
||||
|
|
@ -97,19 +99,26 @@ public:
|
|||
QJsonObject turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag); //将list转换为QJsonObject,<lst,内部标签,外部标签>
|
||||
QList<QUuid> turnJsonArrToList(QJsonObject obj,QString sInner,QString sOut);
|
||||
/*************************监控(运行时)**************************/
|
||||
void generateMonitor(QString,QList<QPair<QString,QUuid>>); //生成监控 (监控名,选中的设备列表)
|
||||
void generateMonitor(QString,QList<monitorRelationItem>); //生成监控 (监控名,选中的设备列表)
|
||||
void generateMonitorConfig(MonitorPanel*); //生成监控配置参数结构
|
||||
QMap<QUuid,QList<monitorItemAttributeInfo>>& getMonitorPara() {return m_monitorPara;}
|
||||
Q_SIGNALS:
|
||||
void activatePage(const QString&); //激活当前model所在page
|
||||
void updateCurrentItems(QList<monitorRelationItem>,bool); //更新当前组态元件列表 <名称,uid>
|
||||
void itemSelected(QList<QPair<QString,QUuid>>); //发送选中的元件
|
||||
void itemSelected(QList<monitorRelationItem>); //发送选中的元件
|
||||
void monitorCreated(QString,QPair<QString,QUuid>); //监控创建信号 <工程page,<监控page,page_uid>>
|
||||
void monitorItems(QList<QPair<QString,QUuid>>); //发送创建成功的Items
|
||||
void monitorItems(QList<monitorRelationItem>); //发送创建成功的Items
|
||||
public:
|
||||
void setPageName(QString s) {_pageName = s;} //设置表名称
|
||||
QString pageName() const {return _pageName;}
|
||||
void activateModel() {Q_EMIT activatePage(_pageName);} //发送激活信号(点击)
|
||||
void startHttpRequest(); //开始请求数据(运行时)
|
||||
void setCavas(DiagramCavas* p) {_cavas = p;} //设置所属顶层容器
|
||||
|
||||
QMap<QUuid,GraphicsProjectModelItem*> getProjectItems(){return _nodeItem;}
|
||||
QMap<QUuid,GraphicsBaseModelItem*> getBaseModelItems(){return _baseItem;}
|
||||
QMap<QUuid,ElectricBayItem*> getBaseBayItems(){return _baseBayItem;}
|
||||
QMap<QUuid,ElectricBayItem*> getProjectBayItems(){return _bayItem;}
|
||||
public Q_SLOTS:
|
||||
void onSignal_ifExits(QUuid id,const QString&,int type,GraphicsProjectModelItem*); //判断用户输入的名称是否已存在
|
||||
void onTimeOut();
|
||||
|
|
@ -142,6 +151,7 @@ private:
|
|||
ProjectModelSetting* m_proModelSettingDlg;
|
||||
ProjectIconSetting* m_projectIconSettingDlg;
|
||||
BayManagerDlg* m_pBayManager;
|
||||
QMap<QUuid,QList<monitorItemAttributeInfo>> m_monitorPara; //监控参数
|
||||
public:
|
||||
static bool _dataInitialised;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef MONITORATTRIBUTEDLG_H
|
||||
#define MONITORATTRIBUTEDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class MonitorToolBox;
|
||||
|
||||
class MonitorAttributeDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorAttributeDlg(QWidget *parent = nullptr);
|
||||
~MonitorAttributeDlg();
|
||||
|
||||
void initial();
|
||||
void setCurAttribute(MonitorToolBox*); //设置当前显示的属性对象
|
||||
void clearCurAttribute(); //清空属性对象
|
||||
private:
|
||||
QVBoxLayout* _pLayout;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef MONITORATTRIBUTEGROUPDLG_H
|
||||
#define MONITORATTRIBUTEGROUPDLG_H
|
||||
|
||||
/**********************监控属性页中单组的具体内容*************************/
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class MonitorAttributeGroupDlg : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorAttributeGroupDlg(QWidget *parent = nullptr);
|
||||
~MonitorAttributeGroupDlg();
|
||||
|
||||
void initial();
|
||||
void createGroupView();
|
||||
private:
|
||||
QVBoxLayout* _layout;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef MONITORCONFIGDLG_H
|
||||
#define MONITORCONFIGDLG_H
|
||||
|
||||
/*******************监控配置界面**********************/
|
||||
#include <QDialog>
|
||||
#include <QUuid>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class monitorConfigDlg; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MonitorPanel;
|
||||
class QItemSelection;
|
||||
class QStandardItemModel;
|
||||
class QStandardItem;
|
||||
struct monitorItemAttributeInfo;
|
||||
|
||||
class MonitorConfigDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorConfigDlg(QWidget *parent = nullptr);
|
||||
~MonitorConfigDlg();
|
||||
|
||||
void initial();
|
||||
void updateSelectedItems();
|
||||
public slots:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
void onTypeChanged(int); //展现类型改变
|
||||
void onItemSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); //选中设备事件
|
||||
void onPropertyCheckChanged(QStandardItem *item); //属性勾选改变信号
|
||||
void onPropertySelectionChanged(const QModelIndex ¤t, const QModelIndex &previous); //属性选中事件
|
||||
private:
|
||||
void savePropertyData(const QModelIndex ¤t,QUuid uid); //保存属性到uid的属性
|
||||
void loadPropertyData(const QModelIndex ¤t,QUuid uid);
|
||||
void clearProperty();
|
||||
private:
|
||||
Ui::monitorConfigDlg *ui;
|
||||
MonitorPanel* _parent;
|
||||
QMap<QUuid,QList<monitorItemAttributeInfo>> _tempConfig;
|
||||
QStandardItemModel* _curItemModel;
|
||||
QUuid _curUuid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -2,9 +2,12 @@
|
|||
#define MONITORPANEL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QToolBar>
|
||||
#include "baseDrawingPanel.h"
|
||||
|
||||
class PowerEntity;
|
||||
class MonitorSideBarDlg;
|
||||
class MonitorConfigDlg;
|
||||
|
||||
class MonitorPanel : public BaseDrawingPanel
|
||||
{
|
||||
|
|
@ -13,17 +16,33 @@ public:
|
|||
MonitorPanel(PowerEntity* pEntity,QWidget *parent = nullptr,DiagramMode mode = DM_edit);
|
||||
~MonitorPanel();
|
||||
|
||||
void initial();
|
||||
QJsonObject getMonitorInfo() const; //返回运行时的item信息
|
||||
void loadNodes(QJsonObject obj) override; //加载图元信息
|
||||
void saveNodes(int pageId) override; //保存到数据库
|
||||
|
||||
void setParentPage(const QString& str) {_sParentPage = str;}
|
||||
QString getParentPage() {return _sParentPage;}
|
||||
|
||||
void updateSelectedItems(QList<monitorRelationItem>,bool);
|
||||
|
||||
QStandardItemModel* getLstModel() {return _itemListmodel;}
|
||||
void initMonitorConfig(); //初始化参数设置(每个运行时可能不同)
|
||||
public slots:
|
||||
void onRunClicked();
|
||||
void onStopClicked();
|
||||
void onConfigClicked();
|
||||
void onConncecClicked();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *closeEvent) override;
|
||||
|
||||
private:
|
||||
void createToolBar();
|
||||
private:
|
||||
QString _sParentPage; //派生自哪个工程
|
||||
QToolBar* _toolBar;
|
||||
MonitorSideBarDlg* _sideBar;
|
||||
MonitorConfigDlg* _pConfigDlg;
|
||||
QStandardItemModel* _itemListmodel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef MONITORSELECTEDITEMS_H
|
||||
#define MONITORSELECTEDITEMS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTreeView>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
struct monitorRelationItem;
|
||||
class MonitorSideBarDlg;
|
||||
|
||||
class MonitorSelectedItemsDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorSelectedItemsDlg(QWidget *parent = nullptr);
|
||||
~MonitorSelectedItemsDlg();
|
||||
|
||||
void initial();
|
||||
void updateItems();
|
||||
private:
|
||||
QTreeView* _treeView;
|
||||
MonitorSideBarDlg* _parent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef MONITORSIDEBARDLG_H
|
||||
#define MONITORSIDEBARDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class MonitorSelectedItemsDlg;
|
||||
class MonitorAttributeDlg;
|
||||
class MonitorPanel;
|
||||
|
||||
class MonitorSideBarDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorSideBarDlg(QWidget *parent = nullptr);
|
||||
~MonitorSideBarDlg();
|
||||
|
||||
void initial();
|
||||
MonitorPanel* getParent() {return _parent;}
|
||||
MonitorSelectedItemsDlg* getItemsDlg() {return _itemsDlg;}
|
||||
private:
|
||||
MonitorSelectedItemsDlg* _itemsDlg;
|
||||
MonitorAttributeDlg* _attributeDlg;
|
||||
MonitorPanel* _parent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef MONITORTOOLBOX_H
|
||||
#define MONITORTOOLBOX_H
|
||||
|
||||
#include <QScrollArea >
|
||||
|
||||
class QVBoxLayout;
|
||||
class MonitorToolBox : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MonitorToolBox(QWidget *parent = nullptr);
|
||||
~MonitorToolBox();
|
||||
void addWidget(const QString &title, QWidget *widget);
|
||||
void removeWidget(const QString &title);
|
||||
private:
|
||||
QWidget* _container;
|
||||
QVBoxLayout *m_pContentVBoxLayout;
|
||||
QMap<QString,QWidget*> m_mapWidget;
|
||||
};
|
||||
#endif // MONITORTOOLBOX_H
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef MONITORTOOLPAGE_H
|
||||
#define MONITORTOOLPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QFormLayout;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
|
||||
|
||||
class MonitorToolPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MonitorToolPage(QWidget *parent = nullptr);
|
||||
~MonitorToolPage();
|
||||
public slots:
|
||||
void addWidget(const QString &title, QWidget *widget);
|
||||
void expand();
|
||||
void collapse();
|
||||
private slots:
|
||||
void onPushButtonFoldClicked();
|
||||
private:
|
||||
|
||||
bool m_bIsExpanded;
|
||||
QLabel *m_pLabel;
|
||||
QPushButton *m_pPushButtonFold;
|
||||
QWidget *m_pContent;
|
||||
};
|
||||
#endif // MONITORTOOLPAGE_HTOOLPAGE_H
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
#include "baseDrawingPanel.h"
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
#include <QVBoxLayout>
|
||||
#include "designerView.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "graphicsItem/graphicsBaseItem.h"
|
||||
|
|
@ -16,6 +15,9 @@ BaseDrawingPanel::BaseDrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramM
|
|||
,_pModel(nullptr)
|
||||
,_mode(mode)
|
||||
,_pEntity(pEntity)
|
||||
,_verticalLayout(nullptr)
|
||||
,_horizontalLayout(nullptr)
|
||||
,_hSplitter(nullptr)
|
||||
{
|
||||
_pModel = new FixedPortsModel(pEntity);
|
||||
_pModel->setTopWidget(this);
|
||||
|
|
@ -34,11 +36,22 @@ BaseDrawingPanel::BaseDrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramM
|
|||
m_pStatusBar = new StatusBar(this);
|
||||
connect(m_pGraphicsView,&DesignerView::onScaleChanged,m_pStatusBar,&StatusBar::onScaleLevelChanged);
|
||||
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->addWidget(m_pGraphicsView);
|
||||
verticalLayout->addWidget(m_pStatusBar);
|
||||
verticalLayout->setContentsMargins(0, 0, 0, 0); // 左,上,右,下
|
||||
verticalLayout->setSpacing(0); // 部件之间的间距
|
||||
_horizontalLayout = new QHBoxLayout();
|
||||
//_horizontalLayout->addWidget(m_pGraphicsView);
|
||||
_horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_horizontalLayout->setSpacing(0);
|
||||
|
||||
_hSplitter = new QSplitter(Qt::Horizontal);
|
||||
_hSplitter->setHandleWidth(2); // 设置分割条宽度
|
||||
|
||||
_hSplitter->addWidget(m_pGraphicsView);
|
||||
_horizontalLayout->addWidget(_hSplitter);
|
||||
|
||||
_verticalLayout = new QVBoxLayout(this);
|
||||
_verticalLayout->addLayout(_horizontalLayout);
|
||||
_verticalLayout->addWidget(m_pStatusBar);
|
||||
_verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_verticalLayout->setSpacing(0);
|
||||
}
|
||||
|
||||
BaseDrawingPanel::~BaseDrawingPanel()
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ void ElectricBaseModelPortItem::updateConnectData()
|
|||
QJsonArray arr;
|
||||
if(_property)
|
||||
{
|
||||
for(auto ptr:m_mapPort)
|
||||
for(auto &ptr:m_mapPort)
|
||||
{
|
||||
//if(ptr->connected())
|
||||
{
|
||||
QJsonObject port;
|
||||
port["portId"] = ptr->getId();
|
||||
auto pLine = ptr->getConnectPtr();
|
||||
//auto pLine = ptr->getConnectPtr();
|
||||
port["x"] = ptr->pos().x();
|
||||
port["y"] = ptr->pos().y();
|
||||
port["portType"] = ptr->getType();
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ void ElectricBaseModelSvgBus::updateConnectData()
|
|||
QJsonArray arr;
|
||||
if(_property)
|
||||
{
|
||||
for(auto ptr:m_mapPort)
|
||||
for(auto &ptr:m_mapPort)
|
||||
{
|
||||
//if(ptr->connected())
|
||||
{
|
||||
QJsonObject port;
|
||||
port["portId"] = ptr->getId();
|
||||
auto pLine = ptr->getConnectPtr();
|
||||
//auto pLine = ptr->getConnectPtr();
|
||||
port["x"] = ptr->pos().x();
|
||||
port["y"] = ptr->pos().y();
|
||||
port["portType"] = ptr->getType();
|
||||
|
|
@ -49,6 +49,7 @@ void ElectricBaseModelSvgBus::updateConnectData()
|
|||
|
||||
obj["port"] = arr;
|
||||
obj["metaModel"] = _property->metaModelName();
|
||||
obj["subList"] = _property->saveSubToJsonArr();
|
||||
_property->setContext(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -553,12 +553,12 @@ void DiagramCavas::onSignal_updateCurItems(QList<monitorRelationItem> lst,bool r
|
|||
emit prepareUpdateItems(lst,refresh);
|
||||
}
|
||||
|
||||
void DiagramCavas::onSignal_selectedItems(QList<QPair<QString,QUuid>> lst)
|
||||
void DiagramCavas::onSignal_selectedItems(QList<monitorRelationItem> lst)
|
||||
{
|
||||
emit prepareSelectItems(lst);
|
||||
}
|
||||
|
||||
void DiagramCavas::onSignal_generate(QString sPage,QList<QPair<QString,QUuid>> lst)
|
||||
void DiagramCavas::onSignal_generate(QString sPage,QList<monitorRelationItem> lst)
|
||||
{
|
||||
QWidget* pWindow= currentSubWindow()->widget();
|
||||
DrawingPanel* pPanel = dynamic_cast<DrawingPanel*>(pWindow);
|
||||
|
|
@ -572,7 +572,7 @@ void DiagramCavas::onSignal_monitorCreated(QString sProj,QPair<QString,QUuid> pa
|
|||
emit updateMonitorList(sProj,pair);
|
||||
}
|
||||
|
||||
void DiagramCavas::onSignal_monitorItemCreated(QList<QPair<QString,QUuid>> lst)
|
||||
void DiagramCavas::onSignal_monitorItemCreated(QList<monitorRelationItem> lst)
|
||||
{
|
||||
emit createdMonitorItems(lst);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,9 +209,6 @@ void DrawingPanel::loadNodes(QJsonObject obj)
|
|||
}
|
||||
}
|
||||
|
||||
//if(_pModel)
|
||||
//emit _pModel->updateCurrentItems(lst);
|
||||
|
||||
QJsonArray bayArr = obj["bays"].toArray();
|
||||
for(QJsonValueRef bayJson:bayArr)
|
||||
{
|
||||
|
|
@ -223,10 +220,112 @@ void DrawingPanel::loadNodes(QJsonObject obj)
|
|||
}
|
||||
}
|
||||
|
||||
if(_pModel){
|
||||
QList<monitorRelationItem> lstFirst;
|
||||
for(auto& pBaseItem:_pModel->getProjectItems()) //首次循环添加母线及独立设备(变压器等),更新列表显示使用
|
||||
{
|
||||
BaseModelProperty* pBase = dynamic_cast<BaseModelProperty*>(pBaseItem->getProperty());
|
||||
if(pBase->type() == 1){ //母线添加子间隔
|
||||
monitorRelationItem info;
|
||||
info.item.nEquipType = pBase->type();
|
||||
info.item.nCategory = 0;
|
||||
info.item.sName = pBase->name();
|
||||
info.item.uid = pBase->uuid();
|
||||
|
||||
for(auto& subPair:pBase->getSubList()){
|
||||
monitorRelationSturctItem subStruct;
|
||||
|
||||
BayProperty* pTargetBay = nullptr;
|
||||
for(auto& pOtherItem:_pModel->getProjectBayItems())
|
||||
{
|
||||
BayProperty* pBay = dynamic_cast<BayProperty*>(pOtherItem->getProperty());
|
||||
if(pBay){
|
||||
if(pBay->uuid() == subPair.second){ //从所有间隔中找到sublist中的间隔
|
||||
pTargetBay = pBay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(pTargetBay){
|
||||
subStruct.nEquipType = 0;
|
||||
subStruct.nCategory = 1;
|
||||
subStruct.sName = pTargetBay->tag();
|
||||
subStruct.uid = pTargetBay->uuid();
|
||||
info.subList.append(subStruct);
|
||||
}
|
||||
}
|
||||
lstFirst.append(info);
|
||||
}
|
||||
else if(pBase->type() == 15 || pBase->type() == 16){
|
||||
monitorRelationItem info;
|
||||
info.item.nEquipType = pBase->type();
|
||||
info.item.nCategory = 0;
|
||||
info.item.sName = pBase->name();
|
||||
info.item.uid = pBase->uuid();
|
||||
|
||||
for(auto& subPair:pBase->getSubList()){
|
||||
monitorRelationSturctItem subStruct;
|
||||
|
||||
ModelProperty* pPro = nullptr;
|
||||
for(auto& item:_pModel->getProjectItems()){
|
||||
auto p = item->getProperty();
|
||||
if(p->uuid() == subPair.second){
|
||||
pPro = p;
|
||||
}
|
||||
}
|
||||
|
||||
if(pPro){
|
||||
subStruct.nEquipType = pPro->type();
|
||||
subStruct.nCategory = 0;
|
||||
subStruct.sName = pPro->name();
|
||||
subStruct.uid = pPro->uuid();
|
||||
info.subList.append(subStruct);
|
||||
}
|
||||
}
|
||||
|
||||
lstFirst.append(info);
|
||||
}
|
||||
}
|
||||
emit _pModel->updateCurrentItems(lstFirst,true);
|
||||
|
||||
QList<monitorRelationItem> lstSecond;
|
||||
for(auto& pBaseItem:_pModel->getProjectItems()) //二次循环添加间隔内设备(更新列表显示使用)
|
||||
{
|
||||
BaseModelProperty* pBase = dynamic_cast<BaseModelProperty*>(pBaseItem->getProperty());
|
||||
if(pBase->type() != 1 && pBase->type() != 15 && pBase->type() != 16){ //设备添加
|
||||
monitorRelationItem info;
|
||||
info.item.nEquipType = pBase->type();
|
||||
info.item.nCategory = 0;
|
||||
info.item.sName = pBase->name();
|
||||
info.item.uid = pBase->uuid();
|
||||
|
||||
BayProperty* pTargetBay = nullptr;
|
||||
for(auto& pOtherItem:_pModel->getProjectBayItems())
|
||||
{
|
||||
BayProperty* pBay = dynamic_cast<BayProperty*>(pOtherItem->getProperty());
|
||||
if(pBay){
|
||||
if(pBay->tag() == pBase->getBay()){ //将bay添加到parent
|
||||
info.parent.nEquipType = 0;
|
||||
info.parent.nCategory = 1;
|
||||
info.parent.sName = pBay->tag();
|
||||
info.parent.uid = pBay->uuid();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lstSecond.append(info);
|
||||
}
|
||||
}
|
||||
emit _pModel->updateCurrentItems(lstSecond,false);
|
||||
|
||||
}
|
||||
|
||||
if(_mode == DM_run)
|
||||
{
|
||||
if(_pModel)
|
||||
_pModel->startHttpRequest();
|
||||
//if(_pModel)
|
||||
//_pModel->startHttpRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -692,11 +692,23 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
|||
pData->setGrid(info.grid);
|
||||
pData->setZone(info.zone);
|
||||
pData->setStation(info.station);
|
||||
pData->setBay(prePath);
|
||||
pData->setDataChanged(false);
|
||||
|
||||
QString sMeta = info.context["metaModel"].toString();
|
||||
pData->setMetaModelName(sMeta);
|
||||
|
||||
QJsonArray nodesJsonArray = info.context["subList"].toArray();
|
||||
QList<QPair<int, QUuid>> lst;
|
||||
for (QJsonValueRef nodeJson : nodesJsonArray)
|
||||
{
|
||||
QJsonObject node = nodeJson.toObject();
|
||||
int nCategory = node["category"].toInt();
|
||||
QUuid uid = QUuid(node["uuid"].toString());
|
||||
lst.append(qMakePair(nCategory,uid));
|
||||
}
|
||||
pData->setSubList(lst);
|
||||
|
||||
PowerEntity* pEntity = TopologyManager::instance().createEntity(EntityType::Component,info.uuid.toString(),info.name); //首先load所有data和entity,全局唯一
|
||||
if(pEntity){
|
||||
createTopoTerminalsByData(pEntity,info.context);
|
||||
|
|
@ -2167,8 +2179,9 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
|
||||
if(!proFromExist) //工程模from对象未生成
|
||||
{
|
||||
GraphicsBaseModelItem* pFromItem = _baseItem.value(QUuid(baseFromComponentId));
|
||||
QUuid id = QUuid::createUuid();
|
||||
QUuid id = QUuid(baseFromComponentId);
|
||||
GraphicsBaseModelItem* pFromItem = _baseItem.value(id);
|
||||
//QUuid id = QUuid::createUuid();
|
||||
BaseProperty* pData = pPanel->getModelController()->addNodeData(id,pFromItem->getProperty()->type(),pFromItem->getProperty()->name(),pFromItem->getProperty()->modelName());
|
||||
addProjectItemByBaseData(pPanel,pFromItem,pData);
|
||||
proFromItemId = id.toString();
|
||||
|
|
@ -2176,8 +2189,9 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
|
||||
if(!proToExist) //工程模to对象未生成
|
||||
{
|
||||
GraphicsBaseModelItem* pToItem = _baseItem.value(QUuid(baseToComponentId));
|
||||
QUuid id = QUuid::createUuid();
|
||||
QUuid id = QUuid(baseToComponentId);
|
||||
GraphicsBaseModelItem* pToItem = _baseItem.value(id);
|
||||
//QUuid id = QUuid::createUuid();
|
||||
BaseProperty* pData = pPanel->getModelController()->addNodeData(id,pToItem->getProperty()->type(),pToItem->getProperty()->name(),pToItem->getProperty()->modelName());
|
||||
addProjectItemByBaseData(pPanel,pToItem,pData);
|
||||
proToItemId = id.toString();
|
||||
|
|
@ -2570,7 +2584,7 @@ QList<QUuid> FixedPortsModel::turnJsonArrToList(QJsonObject object,QString sInne
|
|||
return lst;
|
||||
}
|
||||
|
||||
void FixedPortsModel::generateMonitor(QString sPage,QList<QPair<QString,QUuid>> lst)
|
||||
void FixedPortsModel::generateMonitor(QString sPage,QList<monitorRelationItem> lst)
|
||||
{
|
||||
MonitorPanel* pPanel = nullptr;
|
||||
if(_cavas){
|
||||
|
|
@ -2583,48 +2597,143 @@ void FixedPortsModel::generateMonitor(QString sPage,QList<QPair<QString,QUuid>>
|
|||
_cavas->onSignal_createDiagram(info,DiagramMode::DM_run);
|
||||
pPanel = _cavas->getMonitorPanel(sPage);
|
||||
|
||||
QList<QPair<QString,QUuid>> lstCreated;
|
||||
for(auto& pair:lst)
|
||||
QList<monitorRelationItem> lstFirst;
|
||||
for(auto& itemInfo:lst)
|
||||
{
|
||||
if(_nodeItem.contains(pair.second)){
|
||||
auto pItem = _nodeItem.value(pair.second);
|
||||
BaseProperty* pPro = dynamic_cast<BaseProperty*>(pItem->getProperty());
|
||||
if(pPro){
|
||||
auto pNewItem = pItem->clone();
|
||||
if(pPro->type() == 8){
|
||||
auto pLine = dynamic_cast<ElectricConnectLineItem*>(pNewItem);
|
||||
if(pLine)
|
||||
pLine->calculatePath();
|
||||
}
|
||||
else{
|
||||
pNewItem->updateItem();
|
||||
if(itemInfo.item.nCategory == 0){ //设备
|
||||
if(_nodeItem.contains(itemInfo.item.uid)){
|
||||
auto pItem = _nodeItem.value(itemInfo.item.uid);
|
||||
BaseProperty* pPro = dynamic_cast<BaseProperty*>(pItem->getProperty());
|
||||
if(pPro){
|
||||
auto pNewItem = pItem->clone();
|
||||
if(pPro->type() == 8){
|
||||
auto pLine = dynamic_cast<ElectricConnectLineItem*>(pNewItem);
|
||||
if(pLine)
|
||||
pLine->calculatePath();
|
||||
}
|
||||
else{
|
||||
pNewItem->updateItem();
|
||||
}
|
||||
|
||||
if(pNewItem && pPanel){
|
||||
pNewItem->setProperty(pPro);
|
||||
pNewItem->updateHandles();
|
||||
pNewItem->updateByProperty(); //使用模型更新自身
|
||||
pPanel->getModelController()->addNodeItem(pPro->uuid(),pNewItem);
|
||||
pPanel->getScene()->addItem(pNewItem); //绑定模型
|
||||
}
|
||||
}
|
||||
|
||||
if(pNewItem && pPanel){
|
||||
pNewItem->setProperty(pPro);
|
||||
pNewItem->updateHandles();
|
||||
pNewItem->updateByProperty(); //使用模型更新自身
|
||||
pPanel->getModelController()->addNodeItem(pPro->uuid(),pNewItem);
|
||||
pPanel->getScene()->addItem(pNewItem); //绑定模型
|
||||
if(itemInfo.item.nEquipType == 1 || itemInfo.item.nEquipType == 15 || itemInfo.item.nEquipType == 16){ //先添加母线及独立设备
|
||||
|
||||
lstCreated.append(qMakePair(pPro->name(),pPro->uuid()));
|
||||
lstFirst.append(itemInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pPanel->getScene()->items().isEmpty()) {
|
||||
QRectF itemsRect = pPanel->getScene()->itemsBoundingRect();
|
||||
itemsRect.adjust(-30, -30, 30, 30);
|
||||
auto map = _cavas->getMapMonitor();
|
||||
if(map.contains(sPage)){
|
||||
auto pSubWin = map.value(sPage).second;
|
||||
pSubWin->resize(itemsRect.width(),itemsRect.height());
|
||||
QList<monitorRelationItem> lstSecond;
|
||||
for(auto& itemInfo:lst) //第二次循环处理间隔
|
||||
{
|
||||
if(itemInfo.item.nCategory == 1){ //间隔
|
||||
if(_bayItem.contains(itemInfo.item.uid)){
|
||||
auto pBay = _bayItem.value(itemInfo.item.uid);
|
||||
BayProperty* pPro = dynamic_cast<BayProperty*>(pBay->getProperty());
|
||||
if(pPro){
|
||||
pPanel->getModelController()->addBayByData(pPro);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(itemInfo.item.nEquipType != 1 && itemInfo.item.nEquipType != 15 && itemInfo.item.nEquipType != 16){
|
||||
lstSecond.append(itemInfo);
|
||||
}
|
||||
}
|
||||
//pPanel->getScene()->setSceneRect(itemsRect);
|
||||
pPanel->getView()->fitInView(itemsRect, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
if(pPanel){
|
||||
if (!pPanel->getScene()->items().isEmpty()) {
|
||||
QRectF itemsRect = pPanel->getScene()->itemsBoundingRect();
|
||||
itemsRect.adjust(-100, -100, 100, 100);
|
||||
auto map = _cavas->getMapMonitor();
|
||||
if(map.contains(sPage)){
|
||||
auto pSubWin = map.value(sPage).second;
|
||||
pSubWin->resize(itemsRect.width(),itemsRect.height());
|
||||
}
|
||||
//pPanel->getScene()->setSceneRect(itemsRect);
|
||||
pPanel->getView()->fitInView(itemsRect, Qt::KeepAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
emit pPanel->getModelController()->monitorCreated(_pageName,qMakePair(sPage,info.id.toUuid()));
|
||||
emit pPanel->getModelController()->monitorItems(lstCreated);
|
||||
emit pPanel->getModelController()->monitorItems(lst);
|
||||
|
||||
generateMonitorConfig(pPanel);
|
||||
|
||||
pPanel->updateSelectedItems(lstFirst,true); //直接生成监控tree
|
||||
pPanel->updateSelectedItems(lstSecond,false);
|
||||
}
|
||||
}
|
||||
|
||||
void FixedPortsModel::generateMonitorConfig(MonitorPanel* pPanel)
|
||||
{
|
||||
auto itemData = DataManager::instance().modelData();
|
||||
auto itemState = DataManager::instance().modelState();
|
||||
for(auto& pItem:_nodeItem){
|
||||
auto pPro = pItem->getProperty();
|
||||
if(pPro){
|
||||
QString sModel = pPro->modelName();
|
||||
QUuid uid = pPro->uuid();
|
||||
if(itemState.contains(sModel)){
|
||||
auto mapData = itemState.value(sModel).groupInfo;
|
||||
QList<monitorItemAttributeInfo> lstInfo;
|
||||
for(auto iter = mapData.begin();iter != mapData.end();++iter){
|
||||
if(iter.value().isPublic == true) //公共属性组暂不显示
|
||||
continue;
|
||||
for(auto& attr: iter.value().info){
|
||||
monitorItemAttributeInfo info;
|
||||
info.sGroup = iter.key();
|
||||
info.sTag = attr.name; //***暂时使用相同 051121 by
|
||||
info.sName = attr.name;
|
||||
lstInfo.append(info);
|
||||
}
|
||||
}
|
||||
/*for(auto iter = mapData.begin();iter != mapData.end();iter++){ //遍历所有属性组
|
||||
if(iter.value().mapInfo.contains(uid)){
|
||||
auto pGroupAttrLst = iter.value().mapInfo.value(uid); //获取该组属性值
|
||||
for(auto& attr: pGroupAttrLst){
|
||||
monitorItemAttributeInfo info;
|
||||
info.sGroup = iter.key();
|
||||
info.sTag = attr.tagName;
|
||||
info.sName = attr.name;
|
||||
lstInfo.append(info);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if(!pPanel->getModelController()->getMonitorPara().contains(uid)){
|
||||
pPanel->getModelController()->getMonitorPara().insert(uid,lstInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if(itemData.contains(sModel)){
|
||||
auto mapData = itemData.value(sModel).groupInfo;
|
||||
QList<monitorItemAttributeInfo> lstInfo;
|
||||
/*for(auto iter = mapData.begin();iter != mapData.end();iter++){ //遍历所有属性组
|
||||
if(iter.value().mapInfo.contains(uid)){
|
||||
auto pGroupAttrLst = iter.value().mapInfo.value(uid); //获取该组属性值
|
||||
for(auto& attr: pGroupAttrLst){
|
||||
monitorItemAttributeInfo info;
|
||||
info.sGroup = iter.key();
|
||||
info.sTag = attr.tagName;
|
||||
info.sName = attr.name;
|
||||
lstInfo.append(info);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if(!pPanel->getModelController()->getMonitorPara().contains(uid)){
|
||||
pPanel->getModelController()->getMonitorPara().insert(uid,lstInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ void ElectricPortItem::updateConnectData()
|
|||
QJsonArray arr;
|
||||
if(_property)
|
||||
{
|
||||
for(auto ptr:m_mapPort)
|
||||
for(auto& ptr:m_mapPort)
|
||||
{
|
||||
//if(ptr->connected())
|
||||
{
|
||||
QJsonObject port;
|
||||
port["portId"] = ptr->getId();
|
||||
auto pLine = ptr->getConnectPtr();
|
||||
//auto pLine = ptr->getConnectPtr();
|
||||
port["x"] = ptr->pos().x();
|
||||
port["y"] = ptr->pos().y();
|
||||
port["portType"] = ptr->getType();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemBus.h"
|
||||
#include "graphicsItem/itemControlHandle.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsItem/electricConnectLineItem.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
|
@ -57,6 +56,7 @@ void ElectricSvgItemBus::updateConnectData()
|
|||
|
||||
obj["port"] = arr;
|
||||
obj["metaModel"] = _property->metaModelName();
|
||||
obj["subList"] = _property->saveSubToJsonArr();
|
||||
_property->setContext(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -556,13 +556,13 @@ void GraphicsProjectModelItem::updateConnectData()
|
|||
QJsonArray arr;
|
||||
if(_property)
|
||||
{
|
||||
for(auto ptr:m_mapPort)
|
||||
for(auto &ptr:m_mapPort)
|
||||
{
|
||||
//if(ptr->connected())
|
||||
{
|
||||
QJsonObject port;
|
||||
port["portId"] = ptr->getId();
|
||||
auto pLine = ptr->getConnectPtr();
|
||||
//auto pLine = ptr->getConnectPtr();
|
||||
port["x"] = ptr->pos().x();
|
||||
port["y"] = ptr->pos().y();
|
||||
port["locate"] = ptr->portPos();
|
||||
|
|
@ -575,6 +575,7 @@ void GraphicsProjectModelItem::updateConnectData()
|
|||
|
||||
obj["port"] = arr;
|
||||
obj["metaModel"] = _property->metaModelName();
|
||||
obj["subList"] = _property->saveSubToJsonArr();
|
||||
_property->setContext(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
#include "monitorAttributeDlg.h"
|
||||
#include "monitorToolBox.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
MonitorAttributeDlg::MonitorAttributeDlg(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
,_pLayout(nullptr)
|
||||
{
|
||||
initial();
|
||||
}
|
||||
|
||||
MonitorAttributeDlg::~MonitorAttributeDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorAttributeDlg::initial()
|
||||
{
|
||||
_pLayout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
void MonitorAttributeDlg::setCurAttribute(MonitorToolBox* pBox)
|
||||
{
|
||||
if(_pLayout->count() == 0){ //当前无对象,添加
|
||||
_pLayout->addWidget(pBox);
|
||||
}
|
||||
else{
|
||||
clearCurAttribute();
|
||||
_pLayout->addWidget(pBox);
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorAttributeDlg::clearCurAttribute() //移除当前属性
|
||||
{
|
||||
for (int i = 0; i < _pLayout->count(); ++i) {
|
||||
QLayoutItem* item = _pLayout->itemAt(i);
|
||||
auto pWidget = item->widget();
|
||||
if(pWidget){
|
||||
_pLayout->removeWidget(pWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#include "monitorAttributeGroupDlg.h"
|
||||
#include <QScrollArea>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
|
||||
MonitorAttributeGroupDlg::MonitorAttributeGroupDlg(QWidget* parent)
|
||||
: QScrollArea(parent)
|
||||
,_layout(nullptr)
|
||||
{
|
||||
initial();
|
||||
}
|
||||
|
||||
MonitorAttributeGroupDlg::~MonitorAttributeGroupDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorAttributeGroupDlg::initial()
|
||||
{
|
||||
_layout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
void MonitorAttributeGroupDlg::createGroupView()
|
||||
{
|
||||
QWidget* content = new QWidget();
|
||||
QFormLayout* layout = new QFormLayout(content);
|
||||
layout->setHorizontalSpacing(20); // 标签与控件间距
|
||||
layout->setVerticalSpacing(12); // 行间距
|
||||
layout->setLabelAlignment(Qt::AlignRight); // 标签右对齐
|
||||
layout->setContentsMargins(12, 12, 12, 12); // 内边距
|
||||
|
||||
// 动态生成字段
|
||||
/*for(auto& info:infos.info) {
|
||||
QLabel* label = new QLabel(info.name,this);
|
||||
QWidget* editor = createEditor(info);
|
||||
formLayout->addRow(label, editor);
|
||||
}*/
|
||||
|
||||
setWidget(content);
|
||||
setWidgetResizable(true);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
#include "monitorConfigDlg.h"
|
||||
#include "ui_monitorConfigDlg.h"
|
||||
#include "monitorPanel.h"
|
||||
#include "global.h"
|
||||
|
||||
MonitorConfigDlg::MonitorConfigDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::monitorConfigDlg)
|
||||
,_parent(nullptr)
|
||||
,_curItemModel(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
_parent = dynamic_cast<MonitorPanel*>(parent);
|
||||
initial();
|
||||
}
|
||||
|
||||
MonitorConfigDlg::~MonitorConfigDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::initial()
|
||||
{
|
||||
ui->treeView_item->setModel(_parent->getLstModel());
|
||||
connect(ui->btn_ok,&QPushButton::clicked,this,&MonitorConfigDlg::onOkClicked);
|
||||
connect(ui->btn_cancel,&QPushButton::clicked,this,&MonitorConfigDlg::onCancelClicked);
|
||||
connect(ui->cb_type,&QComboBox::currentIndexChanged,this,&MonitorConfigDlg::onTypeChanged);
|
||||
connect(ui->treeView_item->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &MonitorConfigDlg::onItemSelectionChanged);
|
||||
ui->treeView_item->setHeaderHidden(true);
|
||||
ui->treeView_para->setHeaderHidden(true);
|
||||
ui->le_searchPara->setPlaceholderText("搜索参数");
|
||||
_curItemModel = new QStandardItemModel(this);
|
||||
ui->treeView_para->setModel(_curItemModel);
|
||||
connect(_curItemModel,&QStandardItemModel::itemChanged, this,&MonitorConfigDlg::onPropertyCheckChanged);
|
||||
connect(ui->treeView_para->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||
this, &MonitorConfigDlg::onPropertySelectionChanged);
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::updateSelectedItems()
|
||||
{
|
||||
ui->treeView_item->expandAll();
|
||||
_tempConfig = _parent->getModelController()->getMonitorPara();
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onOkClicked()
|
||||
{
|
||||
if (ui->treeView_para->currentIndex().isValid()) { //确定前先保存当前属性
|
||||
savePropertyData(ui->treeView_para->currentIndex(),_curUuid);
|
||||
}
|
||||
_parent->getModelController()->getMonitorPara() = _tempConfig; //保存临时数据
|
||||
hide();
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onCancelClicked()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onTypeChanged(int index)
|
||||
{
|
||||
ui->stackedWidget->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onItemSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
if (ui->treeView_para->currentIndex().isValid()) { //如果切换设备,先保存属性到上个设备
|
||||
savePropertyData(ui->treeView_para->currentIndex(),_curUuid);
|
||||
}
|
||||
|
||||
clearProperty();
|
||||
|
||||
QStandardItem *root = _curItemModel->invisibleRootItem(); //先清空model
|
||||
int rowCount = root->rowCount();
|
||||
if (rowCount > 0) {
|
||||
_curItemModel->removeRows(0, rowCount);
|
||||
}
|
||||
|
||||
QModelIndexList indexes = selected.indexes();
|
||||
if(indexes.size() == 1){
|
||||
auto index = indexes.first();
|
||||
int nCategory = index.data(Qt::UserRole+1).toInt();
|
||||
if(nCategory == 0){ //是设备
|
||||
QUuid uid = index.data(Qt::UserRole+3).toUuid();
|
||||
_curUuid = uid;
|
||||
if(_tempConfig.contains(uid)){
|
||||
auto lstPara = _tempConfig.value(uid);
|
||||
for(auto& para:lstPara){
|
||||
auto pParent = findStandardItemAtLevel(_curItemModel,0,para.sGroup,nullptr,0);
|
||||
if(pParent){ //组已存在
|
||||
QStandardItem *pItem = new QStandardItem(para.sName);
|
||||
pItem->setCheckable(true);
|
||||
pItem->setCheckState(para.bSelected ? Qt::Checked : Qt::Unchecked);
|
||||
pItem->setData(nCategory,Qt::UserRole+1);
|
||||
pItem->setData(para.sTag,Qt::UserRole+2);
|
||||
pParent->appendRow(pItem);
|
||||
}
|
||||
else{
|
||||
QStandardItem *pPar = new QStandardItem(para.sGroup);
|
||||
pPar->setData(1,Qt::UserRole+1);
|
||||
QStandardItem *pItem = new QStandardItem(para.sName);
|
||||
pItem->setCheckable(true);
|
||||
pItem->setCheckState(para.bSelected ? Qt::Checked : Qt::Unchecked);
|
||||
pItem->setData(nCategory,Qt::UserRole+1);
|
||||
pItem->setData(para.sTag,Qt::UserRole+2);
|
||||
pPar->appendRow(pItem);
|
||||
_curItemModel->appendRow(pPar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->treeView_para->expandAll();
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onPropertyCheckChanged(QStandardItem *item)
|
||||
{
|
||||
if(_tempConfig.contains(_curUuid)){
|
||||
Qt::CheckState state = item->checkState();
|
||||
QString itemText = item->text();
|
||||
if (state == Qt::Checked) {
|
||||
for(auto &info:_tempConfig[_curUuid]){
|
||||
if(info.sName == itemText){
|
||||
info.bSelected = true;
|
||||
}
|
||||
}
|
||||
} else if (state == Qt::Unchecked) {
|
||||
for(auto &info:_tempConfig[_curUuid]){
|
||||
if(info.sName == itemText){
|
||||
info.bSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::onPropertySelectionChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (previous.isValid()) {
|
||||
savePropertyData(previous,_curUuid);
|
||||
}
|
||||
if (current.isValid()) {
|
||||
loadPropertyData(current,_curUuid);
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::savePropertyData(const QModelIndex &previous,QUuid uid)
|
||||
{
|
||||
if(_tempConfig.contains(uid)){
|
||||
if(previous.isValid()){ //保存数据
|
||||
QString itemText = previous.data().toString();
|
||||
for(auto &info:_tempConfig[uid]){
|
||||
if(info.sName == itemText){
|
||||
info.sTag = ui->le_name->text();
|
||||
info.sConnectPara = ui->le_query->text();
|
||||
info.nShowType = ui->cb_type->currentIndex();
|
||||
info.bShowDiagram = ui->cb_outVisible->currentIndex();
|
||||
info.nGraphType = ui->cb_graphType->currentIndex();
|
||||
info.sTimeRange = ui->cb_timeRange->currentText();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::loadPropertyData(const QModelIndex ¤t,QUuid uid)
|
||||
{
|
||||
QList<monitorItemAttributeInfo> lst;
|
||||
if(_tempConfig.contains(uid)){
|
||||
lst = _tempConfig.value(uid);
|
||||
}
|
||||
|
||||
if(current.isValid()){ //加载新数据
|
||||
QString itemText = current.data().toString();
|
||||
for(auto &info:lst){
|
||||
if(info.sName == itemText){
|
||||
ui->le_name->setText(info.sTag);
|
||||
ui->le_query->setText(info.sConnectPara);
|
||||
ui->cb_type->setCurrentIndex(info.nShowType);
|
||||
if(info.nShowType == 0){ //字符
|
||||
ui->cb_outVisible->setCurrentIndex(info.bShowDiagram);
|
||||
}else{ //图表
|
||||
ui->cb_graphType->setCurrentIndex(info.nGraphType);
|
||||
ui->cb_timeRange->setCurrentText(info.sTimeRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorConfigDlg::clearProperty()
|
||||
{
|
||||
ui->le_name->clear();
|
||||
ui->le_query->clear();
|
||||
ui->cb_type->setCurrentIndex(0);
|
||||
ui->cb_outVisible->setCurrentIndex(0);
|
||||
ui->cb_graphType->setCurrentIndex(0);
|
||||
ui->cb_timeRange->setCurrentIndex(0);
|
||||
}
|
||||
|
|
@ -1,18 +1,28 @@
|
|||
#include <QJsonArray>
|
||||
#include "monitorPanel.h"
|
||||
#include <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
#include <QToolBar>
|
||||
#include <QVBoxLayout>
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "graphicsItem/graphicsBaseItem.h"
|
||||
#include "powerEntity.h"
|
||||
#include "statusBar.h"
|
||||
#include "baseProperty.h"
|
||||
#include "graphicsItem/electricBayItem.h"
|
||||
#include "monitorSideBarDlg.h"
|
||||
#include "monitorSelectedItemsDlg.h"
|
||||
#include "monitorConfigDlg.h"
|
||||
|
||||
MonitorPanel::MonitorPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
||||
: BaseDrawingPanel(pEntity,parent,mode)
|
||||
,_toolBar(nullptr)
|
||||
,_sideBar(nullptr)
|
||||
,_pConfigDlg(nullptr)
|
||||
,_itemListmodel(nullptr)
|
||||
{
|
||||
m_pStatusBar->setButtonVisible(false);
|
||||
initial();
|
||||
}
|
||||
|
||||
MonitorPanel::~MonitorPanel()
|
||||
|
|
@ -20,11 +30,48 @@ MonitorPanel::~MonitorPanel()
|
|||
|
||||
}
|
||||
|
||||
void MonitorPanel::initial()
|
||||
{
|
||||
_itemListmodel = new QStandardItemModel(this);
|
||||
|
||||
createToolBar();
|
||||
_sideBar = new MonitorSideBarDlg(this);
|
||||
_hSplitter->addWidget(_sideBar);
|
||||
_sideBar->show();
|
||||
_pConfigDlg = new MonitorConfigDlg(this);
|
||||
}
|
||||
|
||||
void MonitorPanel::closeEvent(QCloseEvent *closeEvent)
|
||||
{
|
||||
emit panelDelete(_name,2);
|
||||
}
|
||||
|
||||
void MonitorPanel::createToolBar()
|
||||
{
|
||||
_toolBar = new QToolBar(this);
|
||||
_toolBar->setStyleSheet("QToolBar { background-color: palette(window); border: none; }");
|
||||
|
||||
QAction *runAction = new QAction("运行", this);
|
||||
connect(runAction, &QAction::triggered, this, &MonitorPanel::onRunClicked);
|
||||
_toolBar->addAction(runAction);
|
||||
|
||||
QAction *stopAction = new QAction("停止", this);
|
||||
connect(stopAction, &QAction::triggered, this, &MonitorPanel::onStopClicked);
|
||||
_toolBar->addAction(stopAction);
|
||||
|
||||
QAction *configAction = new QAction("参数配置", this);
|
||||
connect(configAction, &QAction::triggered, this, &MonitorPanel::onConfigClicked);
|
||||
_toolBar->addAction(configAction);
|
||||
|
||||
QAction *connectAction = new QAction("连接设置", this);
|
||||
connect(connectAction, &QAction::triggered, this, &MonitorPanel::onConncecClicked);
|
||||
_toolBar->addAction(connectAction);
|
||||
|
||||
// 设置工具栏样式
|
||||
_toolBar->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
||||
_verticalLayout->setMenuBar(_toolBar);
|
||||
}
|
||||
|
||||
QJsonObject MonitorPanel::getMonitorInfo() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
|
@ -85,3 +132,93 @@ void MonitorPanel::saveNodes(int pageId)
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorPanel::updateSelectedItems(QList<monitorRelationItem> lst,bool val)
|
||||
{
|
||||
if(val){
|
||||
QStandardItem *root = _itemListmodel->invisibleRootItem();
|
||||
|
||||
int rowCount = root->rowCount();
|
||||
if (rowCount > 0) {
|
||||
_itemListmodel->removeRows(0, rowCount);
|
||||
}
|
||||
}
|
||||
|
||||
for(auto &info:lst){
|
||||
auto curItem = info.item;
|
||||
if(curItem.nCategory == 0){
|
||||
|
||||
if(curItem.nEquipType == 1 || curItem.nEquipType == 15 || curItem.nEquipType == 16){ //母线与变压器等间隔外设备并列第一层
|
||||
QStandardItem *pItem = new QStandardItem(curItem.sName);
|
||||
pItem->setData(curItem.nCategory,Qt::UserRole+1);
|
||||
pItem->setData(curItem.nEquipType,Qt::UserRole+2);
|
||||
pItem->setData(curItem.uid,Qt::UserRole+3);
|
||||
|
||||
for(auto& subInfo:info.subList){ //母线挂接间隔,变压器挂接设备
|
||||
QStandardItem *pSub = new QStandardItem(subInfo.sName);
|
||||
pSub->setData(subInfo.nCategory,Qt::UserRole+1);
|
||||
pSub->setData(subInfo.nEquipType,Qt::UserRole+2);
|
||||
pSub->setData(subInfo.uid,Qt::UserRole+3);
|
||||
pItem->appendRow(pSub);
|
||||
}
|
||||
_itemListmodel->appendRow(pItem);
|
||||
}
|
||||
else{ //其他设备挂接在母线下的间隔中
|
||||
if(!info.parent.sName.isEmpty()){ //有父,在间隔内
|
||||
QStandardItem *pItem = new QStandardItem(curItem.sName);
|
||||
pItem->setData(curItem.nCategory,Qt::UserRole+1);
|
||||
pItem->setData(curItem.nEquipType,Qt::UserRole+2);
|
||||
pItem->setData(curItem.uid,Qt::UserRole+3);
|
||||
|
||||
auto pParent = findStandardItemAtLevel(_itemListmodel,1,info.parent.sName,nullptr,0); //查找父间隔所在item
|
||||
if(pParent){
|
||||
pParent->appendRow(pItem);
|
||||
}
|
||||
else{ //一层没找到父
|
||||
QStandardItem *pPar = nullptr;
|
||||
pPar = findStandardItemAtLevel(_itemListmodel,0,info.parent.sName,nullptr,0);
|
||||
if(pPar){ //顶层中找到
|
||||
pPar->appendRow(pItem); //将自己挂到父下
|
||||
}
|
||||
else{ //顶层未找到,新建
|
||||
pPar = new QStandardItem(info.parent.sName);
|
||||
pPar->setData(info.parent.nCategory,Qt::UserRole+1);
|
||||
pPar->setData(info.parent.nEquipType,Qt::UserRole+2);
|
||||
pPar->setData(info.parent.uid,Qt::UserRole+3);
|
||||
_itemListmodel->appendRow(pPar);
|
||||
pPar->appendRow(pItem); //将自己挂到父下
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_sideBar->getItemsDlg()->updateItems();
|
||||
_pConfigDlg->updateSelectedItems();
|
||||
}
|
||||
|
||||
void MonitorPanel::initMonitorConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorPanel::onRunClicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorPanel::onStopClicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorPanel::onConfigClicked()
|
||||
{
|
||||
_pConfigDlg->show();
|
||||
}
|
||||
|
||||
void MonitorPanel::onConncecClicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
#include "monitorSelectedItemsDlg.h"
|
||||
#include "monitorSideBarDlg.h"
|
||||
#include "monitorPanel.h"
|
||||
#include "global.h"
|
||||
|
||||
MonitorSelectedItemsDlg::MonitorSelectedItemsDlg(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
,_treeView(nullptr)
|
||||
,_parent(nullptr)
|
||||
{
|
||||
_parent = dynamic_cast<MonitorSideBarDlg*>(parent);
|
||||
initial();
|
||||
}
|
||||
|
||||
MonitorSelectedItemsDlg::~MonitorSelectedItemsDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorSelectedItemsDlg::initial()
|
||||
{
|
||||
_treeView = new QTreeView(this);
|
||||
_treeView->setModel(_parent->getParent()->getLstModel());
|
||||
_treeView->setHeaderHidden(true);
|
||||
}
|
||||
|
||||
void MonitorSelectedItemsDlg::updateItems()
|
||||
{
|
||||
_treeView->expandAll();
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#include "monitorSideBarDlg.h"
|
||||
#include "monitorSelectedItemsDlg.h"
|
||||
#include "monitorAttributeDlg.h"
|
||||
#include "monitorPanel.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QSplitter>
|
||||
|
||||
MonitorSideBarDlg::MonitorSideBarDlg(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
,_itemsDlg(nullptr)
|
||||
,_attributeDlg(nullptr)
|
||||
,_parent(nullptr)
|
||||
{
|
||||
_parent = dynamic_cast<MonitorPanel*>(parent);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
initial();
|
||||
setMinimumWidth(100);
|
||||
}
|
||||
|
||||
MonitorSideBarDlg::~MonitorSideBarDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorSideBarDlg::initial()
|
||||
{
|
||||
_itemsDlg = new MonitorSelectedItemsDlg(this);
|
||||
_attributeDlg = new MonitorAttributeDlg(this);
|
||||
|
||||
QVBoxLayout *sideLayout = new QVBoxLayout(this);
|
||||
sideLayout->setContentsMargins(0, 0, 0, 0);
|
||||
sideLayout->setSpacing(0);
|
||||
|
||||
// 创建垂直分割器
|
||||
QSplitter *splitter = new QSplitter(Qt::Vertical);
|
||||
splitter->setHandleWidth(2); // 设置分割条宽度
|
||||
|
||||
splitter->addWidget(_itemsDlg);
|
||||
splitter->addWidget(_attributeDlg);
|
||||
|
||||
sideLayout->addWidget(splitter);
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#include "monitorToolBox.h"
|
||||
#include "monitorToolPage.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QSpacerItem>
|
||||
|
||||
MonitorToolBox::MonitorToolBox(QWidget *parent) :
|
||||
QScrollArea(parent)
|
||||
,m_pContentVBoxLayout(nullptr)
|
||||
,_container(nullptr)
|
||||
{
|
||||
_container = new QWidget;
|
||||
m_pContentVBoxLayout = new QVBoxLayout(_container);
|
||||
setWidget(_container);
|
||||
m_pContentVBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||
setWidgetResizable(true);
|
||||
}
|
||||
|
||||
MonitorToolBox::~MonitorToolBox()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorToolBox::addWidget(const QString &title, QWidget *pWidget)
|
||||
{
|
||||
MonitorToolPage *page = new MonitorToolPage(this);
|
||||
page->addWidget(title, pWidget);
|
||||
|
||||
m_pContentVBoxLayout->addWidget(page);
|
||||
//pLayout->insertWidget(0,page);
|
||||
//pLayout->addStretch(0);
|
||||
m_mapWidget.insert(title,page);
|
||||
}
|
||||
|
||||
void MonitorToolBox::removeWidget(const QString &title)
|
||||
{
|
||||
bool bExist = m_mapWidget.contains(title);
|
||||
if(bExist)
|
||||
{
|
||||
QWidget *pWidget = m_mapWidget.take(title);
|
||||
if(pWidget)
|
||||
{
|
||||
MonitorToolPage* toolPage = dynamic_cast<MonitorToolPage*>(pWidget);
|
||||
if(toolPage)
|
||||
{
|
||||
m_pContentVBoxLayout->removeWidget(toolPage);
|
||||
delete toolPage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//cerr
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#include "monitorToolPage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
MonitorToolPage::MonitorToolPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_bIsExpanded(true),
|
||||
m_pLabel(nullptr),
|
||||
m_pPushButtonFold(nullptr),
|
||||
m_pContent(nullptr)
|
||||
{
|
||||
setAttribute(Qt::WA_StyledBackground);
|
||||
|
||||
m_pPushButtonFold = new QPushButton(this);
|
||||
m_pLabel = new QLabel(this);
|
||||
m_pLabel->setFixedSize(20, 20);
|
||||
m_pLabel->setText("+");
|
||||
QHBoxLayout *hLayout = new QHBoxLayout(m_pPushButtonFold);
|
||||
QVBoxLayout *vLayout = new QVBoxLayout(this);
|
||||
vLayout->setContentsMargins(0, 0, 0, 0);
|
||||
vLayout->setSpacing(2);
|
||||
vLayout->addWidget(m_pPushButtonFold);
|
||||
hLayout->setContentsMargins(0, 0, 5, 0);
|
||||
hLayout->addStretch(1);
|
||||
hLayout->addWidget(m_pLabel);
|
||||
|
||||
connect(m_pPushButtonFold, &QPushButton::clicked, this, &MonitorToolPage::onPushButtonFoldClicked);
|
||||
}
|
||||
|
||||
MonitorToolPage::~MonitorToolPage()
|
||||
{
|
||||
if(m_pContent)
|
||||
delete m_pContent;
|
||||
if(m_pPushButtonFold)
|
||||
delete m_pPushButtonFold;
|
||||
}
|
||||
|
||||
void MonitorToolPage::addWidget(const QString &title, QWidget *widget)
|
||||
{
|
||||
if(!m_pContent)
|
||||
{
|
||||
m_pPushButtonFold->setText(title);
|
||||
layout()->addWidget(widget);
|
||||
m_pContent = widget;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MonitorToolPage::expand()
|
||||
{
|
||||
if(m_pContent)
|
||||
m_pContent->show();
|
||||
m_bIsExpanded = true;
|
||||
m_pLabel->setText("-");
|
||||
}
|
||||
|
||||
void MonitorToolPage::collapse()
|
||||
{
|
||||
if(m_pContent)
|
||||
m_pContent->hide();
|
||||
m_bIsExpanded = false;
|
||||
m_pLabel->setText("+");
|
||||
}
|
||||
|
||||
void MonitorToolPage::onPushButtonFoldClicked()
|
||||
{
|
||||
if (m_bIsExpanded) {
|
||||
collapse();
|
||||
} else {
|
||||
expand();
|
||||
}
|
||||
}
|
||||
|
|
@ -237,6 +237,20 @@ void BaseSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScen
|
|||
emit setWorkingSelector(ST_moving);
|
||||
setCursor(scene, Qt::ClosedHandCursor);
|
||||
}
|
||||
else{
|
||||
QPointF pos = event->scenePos();
|
||||
// 遍历所有项检测点击
|
||||
for (QGraphicsItem* item : scene->items()) {
|
||||
ElectricBayItem* pItem = dynamic_cast<ElectricBayItem*>(item);
|
||||
if (pItem) {
|
||||
if(pItem->containsPoint(pos)){
|
||||
// 处理命中
|
||||
pItem->setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(m_opMode == OM_move) //可以多个选中同时移动
|
||||
{
|
||||
|
|
@ -456,14 +470,33 @@ void BaseSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerSc
|
|||
view->setDragMode(QGraphicsView::NoDrag);
|
||||
}
|
||||
|
||||
QList<QPair<QString,QUuid>> lst; //发送已选中的元件
|
||||
QList<monitorRelationItem> lst; //发送已选中的元件
|
||||
QList<QGraphicsItem *> items = scene->selectedItems();
|
||||
for(auto& pItem:items){
|
||||
GraphicsProjectModelItem* item = qgraphicsitem_cast<GraphicsProjectModelItem*>(pItem);
|
||||
GraphicsProjectModelItem* item = dynamic_cast<GraphicsProjectModelItem*>(pItem);
|
||||
if(item){
|
||||
monitorRelationItem info;
|
||||
auto pPro = item->getProperty();
|
||||
if(pPro){
|
||||
lst.append(qMakePair(pPro->name(),pPro->uuid()));
|
||||
info.item.nCategory = 0;
|
||||
info.item.nEquipType = pPro->type();
|
||||
info.item.sName = pPro->name();
|
||||
info.item.uid = pPro->uuid();
|
||||
lst.append(info);
|
||||
}
|
||||
}
|
||||
else{
|
||||
GraphicsNonStandardItem* bay = dynamic_cast<GraphicsNonStandardItem*>(pItem);
|
||||
if(bay){
|
||||
monitorRelationItem info;
|
||||
auto pBayPro = bay->getProperty();
|
||||
if(pBayPro){
|
||||
info.item.nCategory = 1;
|
||||
info.item.nEquipType = 0;
|
||||
info.item.sName = pBayPro->name();
|
||||
info.item.uid = pBayPro->uuid();
|
||||
lst.append(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ void MovingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, DesignerSce
|
|||
|
||||
void MovingSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene,DiagramMode sceneMode)
|
||||
{
|
||||
QList<QPair<QString,QUuid>> lst; //发送已选中的元件
|
||||
QList<monitorRelationItem> lst; //发送已选中的元件
|
||||
QList<QGraphicsItem *> items = scene->selectedItems();
|
||||
for(int n = 0; n < items.size(); n++)
|
||||
{
|
||||
|
|
@ -50,11 +50,30 @@ void MovingSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, Designer
|
|||
if(item)
|
||||
item->removeOperationCopy();
|
||||
|
||||
GraphicsProjectModelItem* p = qgraphicsitem_cast<GraphicsProjectModelItem*>(items.at(n));
|
||||
GraphicsProjectModelItem* p = dynamic_cast<GraphicsProjectModelItem*>(items.at(n));
|
||||
if(p){
|
||||
auto pPro = p->getProperty();
|
||||
monitorRelationItem info;
|
||||
if(pPro){
|
||||
lst.append(qMakePair(pPro->name(),pPro->uuid()));
|
||||
info.item.nCategory = 0;
|
||||
info.item.nEquipType = pPro->type();
|
||||
info.item.sName = pPro->name();
|
||||
info.item.uid = pPro->uuid();
|
||||
lst.append(info);
|
||||
}
|
||||
}
|
||||
else{
|
||||
GraphicsNonStandardItem* bay = dynamic_cast<GraphicsNonStandardItem*>(items.at(n));
|
||||
if(bay){
|
||||
monitorRelationItem info;
|
||||
auto pBayPro = bay->getProperty();
|
||||
if(pBayPro){
|
||||
info.item.nCategory = 1;
|
||||
info.item.nEquipType = 0;
|
||||
info.item.sName = pBayPro->name();
|
||||
info.item.uid = pBayPro->uuid();
|
||||
lst.append(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,384 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>monitorConfigDlg</class>
|
||||
<widget class="QDialog" name="monitorConfigDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>641</width>
|
||||
<height>504</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(192, 192, 192);</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(0, 0, 0);
|
||||
font: 12pt "Microsoft YaHei UI";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>参数配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>584</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>监控参数配置</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,2,3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>设备列表</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView_item"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>可选参数列表</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_searchPara"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView_para"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>配置详情</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>显示名称:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_name"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>查询参数:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_query"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>展示类型:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cb_type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>字符</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>图表</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>接线图中展示:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cb_outVisible">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>否</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>是</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cb_graphType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>折线</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>柱状</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>时间范围:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>图表类型:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cb_timeRange">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5min</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10min</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>30min</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_ok">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_cancel">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#define MONITORITEMSDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTreeView>
|
||||
#include "global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -18,16 +19,21 @@ public:
|
|||
|
||||
void initial();
|
||||
signals:
|
||||
void generateMonitor(QString,QList<QPair<QString,QUuid>>); //生成监控
|
||||
void generateMonitor(QString,QList<monitorRelationItem>); //生成监控
|
||||
public slots:
|
||||
void onUpdateItems(QList<monitorRelationItem>,bool refresh); //更新当前设备列表
|
||||
void onSelectItems(QList<QPair<QString,QUuid>>); //更新当前选中的设备
|
||||
void onSelectItems(QList<monitorRelationItem>); //更新当前选中的设备
|
||||
void onGenerateClicked();
|
||||
void onMonitorCreated(QList<QPair<QString,QUuid>>); //创建后的设备列表
|
||||
void onMonitorCreated(QList<monitorRelationItem>); //创建后的设备列表
|
||||
void onItemChanged(QStandardItem *item); //item勾选事件
|
||||
private:
|
||||
void resetSelect(); //重置选中
|
||||
void setChildrenCheckState(QStandardItem *parent, Qt::CheckState state);
|
||||
void traverseSelectStandardItemModel(QStandardItemModel *model,Qt::CheckState); //遍历选中
|
||||
void traverseSelectStandardItem(QStandardItem *item, int depth,Qt::CheckState); //遍历选中
|
||||
|
||||
QList<QStandardItem*> getCheckedItems(QStandardItem* parentItem); //返回checked对象
|
||||
QList<QStandardItem*> getTreeViewCheckedItems(QTreeView* treeView); //返回checked对象
|
||||
private:
|
||||
Ui::monitorItemsDlg *ui;
|
||||
QStandardItemModel* _modelAll; //图中所有item
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "monitorItemsDlg.h"
|
||||
#include "ui_monitorItemsDlg.h"
|
||||
#include "dataBase.h"
|
||||
#include "tools.h"
|
||||
#include <QToolTip>
|
||||
|
||||
|
||||
|
|
@ -86,20 +87,19 @@ void MonitorItemsDlg::onUpdateItems(QList<monitorRelationItem> lst,bool refresh)
|
|||
ui->treeView_all->expandAll();
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::onSelectItems(QList<QPair<QString,QUuid>> lst)
|
||||
void MonitorItemsDlg::onSelectItems(QList<monitorRelationItem> lst)
|
||||
{
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
/*resetSelect();
|
||||
resetSelect();
|
||||
for(auto& info:lst){
|
||||
for(int i = 0;i < ui->listWidget_all->count();++i){
|
||||
QListWidgetItem *item = ui->listWidget_all->item(i);
|
||||
QUuid uid = item->data(Qt::UserRole).toUuid();
|
||||
if(uid == info.second){ //设置选中
|
||||
item->setCheckState(Qt::Checked);
|
||||
continue;
|
||||
}
|
||||
QModelIndex itemIndex = findIndex(_modelAll,info.item.uid,Qt::UserRole+3);
|
||||
if(itemIndex.isValid())
|
||||
{
|
||||
QStandardItem *pItem = _modelAll->itemFromIndex(itemIndex);
|
||||
pItem->setCheckState(Qt::Checked);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::onGenerateClicked()
|
||||
|
|
@ -109,21 +109,38 @@ void MonitorItemsDlg::onGenerateClicked()
|
|||
ui->le_name->setFocus();
|
||||
return;
|
||||
}
|
||||
/*QList<QPair<QString,QUuid>> lst;
|
||||
for (int i = 0; i < ui->listWidget_all->count(); ++i) {
|
||||
QListWidgetItem *item = ui->listWidget_all->item(i);
|
||||
// 处理每个项
|
||||
if(item->checkState() == Qt::Checked){
|
||||
QString text = item->text();
|
||||
QUuid uid = item->data(Qt::UserRole).toUuid();
|
||||
lst.append(qMakePair(text,uid));
|
||||
QList<monitorRelationItem> lst;
|
||||
QList<QStandardItem*> lstItem = getTreeViewCheckedItems(ui->treeView_all);
|
||||
for(auto& pItem:lstItem){
|
||||
monitorRelationItem info;
|
||||
auto pParent = pItem->parent();
|
||||
if(pParent){
|
||||
info.parent.nCategory = pParent->data(Qt::UserRole+1).toInt();
|
||||
info.parent.nEquipType = pParent->data(Qt::UserRole+2).toInt();
|
||||
info.parent.uid = pParent->data(Qt::UserRole+3).toUuid();
|
||||
info.parent.sName = pParent->text();
|
||||
}
|
||||
info.item.nCategory = pItem->data(Qt::UserRole+1).toInt();
|
||||
info.item.nEquipType = pItem->data(Qt::UserRole+2).toInt();
|
||||
info.item.uid = pItem->data(Qt::UserRole+3).toUuid();
|
||||
info.item.sName = pItem->text();
|
||||
|
||||
auto lstChild = getAllChildren(pItem);
|
||||
for(auto &child:lstChild){
|
||||
monitorRelationSturctItem stru;
|
||||
stru.nCategory = child->data(Qt::UserRole+1).toInt();
|
||||
stru.nEquipType = child->data(Qt::UserRole+2).toInt();
|
||||
stru.uid = child->data(Qt::UserRole+3).toUuid();
|
||||
stru.sName = child->text();
|
||||
info.subList.append(stru);
|
||||
}
|
||||
lst.append(info);
|
||||
}
|
||||
|
||||
emit generateMonitor(sName,lst);*/
|
||||
emit generateMonitor(sName,lst);
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::onMonitorCreated(QList<QPair<QString,QUuid>> lst)
|
||||
void MonitorItemsDlg::onMonitorCreated(QList<monitorRelationItem> lst)
|
||||
{
|
||||
/*ui->stackedWidget->setCurrentIndex(1);
|
||||
ui->listWidget_select->clear();
|
||||
|
|
@ -158,10 +175,63 @@ void MonitorItemsDlg::setChildrenCheckState(QStandardItem *parent, Qt::CheckStat
|
|||
}
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::traverseSelectStandardItemModel(QStandardItemModel *model,Qt::CheckState check) {
|
||||
if (!model) return;
|
||||
|
||||
// 遍历所有顶层项
|
||||
for (int row = 0; row < model->rowCount(); ++row) {
|
||||
for (int col = 0; col < model->columnCount(); ++col) {
|
||||
QStandardItem *item = model->item(row, col);
|
||||
item->setCheckState(check);
|
||||
traverseSelectStandardItem(item, 0,check);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::traverseSelectStandardItem(QStandardItem *item, int depth,Qt::CheckState check) {
|
||||
if (!item) return;
|
||||
|
||||
// 遍历子项
|
||||
for (int row = 0; row < item->rowCount(); ++row) {
|
||||
for (int col = 0; col < item->columnCount(); ++col) {
|
||||
QStandardItem *child = item->child(row, col);
|
||||
child->setCheckState(check);
|
||||
traverseSelectStandardItem(child, depth + 1,check);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<QStandardItem*> MonitorItemsDlg::getCheckedItems(QStandardItem* parentItem) {
|
||||
QList<QStandardItem*> checkedItems;
|
||||
|
||||
if (!parentItem) return checkedItems;
|
||||
|
||||
for (int i = 0; i < parentItem->rowCount(); ++i) {
|
||||
QStandardItem* childItem = parentItem->child(i);
|
||||
|
||||
if (childItem->checkState() == Qt::Checked) {
|
||||
checkedItems.append(childItem);
|
||||
}
|
||||
|
||||
// 递归检查子项
|
||||
checkedItems.append(getCheckedItems(childItem));
|
||||
}
|
||||
|
||||
return checkedItems;
|
||||
}
|
||||
|
||||
// 主函数:获取treeView中所有checked项
|
||||
QList<QStandardItem*> MonitorItemsDlg::getTreeViewCheckedItems(QTreeView* treeView) {
|
||||
QList<QStandardItem*> checkedItems;
|
||||
|
||||
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(treeView->model());
|
||||
if (!model) return checkedItems;
|
||||
|
||||
QStandardItem* rootItem = model->invisibleRootItem();
|
||||
return getCheckedItems(rootItem);
|
||||
}
|
||||
|
||||
void MonitorItemsDlg::resetSelect()
|
||||
{
|
||||
/*for(int i = 0;i < ui->listWidget_all->count();++i){
|
||||
QListWidgetItem *item = ui->listWidget_all->item(i);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}*/
|
||||
traverseSelectStandardItemModel(_modelAll,Qt::Unchecked);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue