generate dynamic setting page logical added
This commit is contained in:
parent
f34fe96ae4
commit
a903f862a9
|
|
@ -145,7 +145,8 @@ struct propertyStateInfo //属性
|
||||||
QString name; //属性名
|
QString name; //属性名
|
||||||
QString tagName; //别名
|
QString tagName; //别名
|
||||||
QString type; //属性类型
|
QString type; //属性类型
|
||||||
QString defaultValue; //默认值
|
QVariant defaultValue; //默认值
|
||||||
|
int lengthPrecision = 999; //长度限制
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QMap<QString,propertyStateInfo> PropertyValueInfo;
|
typedef QMap<QString,propertyStateInfo> PropertyValueInfo;
|
||||||
|
|
@ -168,6 +169,7 @@ struct modelStateInfo //模型结构信息
|
||||||
{
|
{
|
||||||
QString modelName;
|
QString modelName;
|
||||||
int modelType;
|
int modelType;
|
||||||
|
QWidget* _PropertyDlg = NULL; //属性设置界面,每个模型维护一种界面
|
||||||
QMap<QString,groupStateInfo> groupInfo; //属性组信息
|
QMap<QString,groupStateInfo> groupInfo; //属性组信息
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -177,6 +179,13 @@ struct modelDataInfo //模型数据信息
|
||||||
int modelType;
|
int modelType;
|
||||||
QMap<QString,groupStateValue> groupInfo; //属性组实时信息
|
QMap<QString,groupStateValue> groupInfo; //属性组实时信息
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct propertyContentInfo //单个属性结构
|
||||||
|
{
|
||||||
|
QString proName; //名称
|
||||||
|
QString proType; //类型
|
||||||
|
QWidget* proEditer = NULL; //编辑窗口对象
|
||||||
|
};
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
struct componentInfo
|
struct componentInfo
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
||||||
include/diagramCavas.h
|
include/diagramCavas.h
|
||||||
include/drawingPanel.h
|
include/drawingPanel.h
|
||||||
include/itemPropertyDlg.h
|
include/itemPropertyDlg.h
|
||||||
|
include/propertyContentDlg.h
|
||||||
include/serializable.h
|
include/serializable.h
|
||||||
include/statusBar.h
|
include/statusBar.h
|
||||||
include/graphicsDataModel/baseModel.h
|
include/graphicsDataModel/baseModel.h
|
||||||
|
|
@ -48,6 +49,7 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
||||||
source/diagramCavas.cpp
|
source/diagramCavas.cpp
|
||||||
source/drawingPanel.cpp
|
source/drawingPanel.cpp
|
||||||
source/itemPropertyDlg.cpp
|
source/itemPropertyDlg.cpp
|
||||||
|
source/propertyContentDlg.cpp
|
||||||
source/statusBar.cpp
|
source/statusBar.cpp
|
||||||
#source/serializable.cpp
|
#source/serializable.cpp
|
||||||
source/graphicsDataModel/baseModel.cpp
|
source/graphicsDataModel/baseModel.cpp
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,10 @@ public:
|
||||||
void setScene(DesignerScene* p){_scene = p;}
|
void setScene(DesignerScene* p){_scene = p;}
|
||||||
void setTopWidget(DrawingPanel* p) {_widget = p;}
|
void setTopWidget(DrawingPanel* p) {_widget = p;}
|
||||||
QWidget* getTopWidget();
|
QWidget* getTopWidget();
|
||||||
void addModelProperty(modelStateInfo); //使用信号接收属性数据
|
|
||||||
void getModelInfo(); //获取模型结构信息
|
void showModelDlg(const QString&,QUuid); //点击时显示指定模型的dlg、指定item的数据(模型名,对象Uuid)
|
||||||
void getModelData(); //获取模型数据
|
void initialPropertyDlg(); //初始化属性设置dlg,每个模型拥各自的dlg
|
||||||
|
void generatePropertyDlg(const QString&);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activatePage(const QString&); //激活当前model所在page
|
void activatePage(const QString&); //激活当前model所在page
|
||||||
public:
|
public:
|
||||||
|
|
@ -61,8 +62,8 @@ private:
|
||||||
DrawingPanel* _widget; //顶层widget
|
DrawingPanel* _widget; //顶层widget
|
||||||
HttpInterface* _Interface;
|
HttpInterface* _Interface;
|
||||||
QTimer* _timer;
|
QTimer* _timer;
|
||||||
QMap<QString,modelStateInfo> _modelStateInfo; //接收的模型结构信息
|
|
||||||
QMap<QString,modelDataInfo> _modleDataInfo; //模型实时数据
|
QMap<QString,modelStateInfo> _modelStateInfo; //模型结构信息
|
||||||
public:
|
public:
|
||||||
static bool _dataInitialised;
|
static bool _dataInitialised;
|
||||||
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
||||||
|
|
|
||||||
|
|
@ -4,72 +4,6 @@
|
||||||
#include "electricSvgItem.h"
|
#include "electricSvgItem.h"
|
||||||
#include "itemPropertyDlg.h"
|
#include "itemPropertyDlg.h"
|
||||||
|
|
||||||
class ElectricSvgItemRect_Property: public BaseProperty
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ElectricSvgItemRect_Property(QObject* parent);
|
|
||||||
~ElectricSvgItemRect_Property();
|
|
||||||
|
|
||||||
void setComponent_id(int n) {componentId = n;}
|
|
||||||
int component_id() const {return componentId;}
|
|
||||||
|
|
||||||
void setResistance(double d){resistance = d;}
|
|
||||||
double getResistance() const {return resistance;}
|
|
||||||
|
|
||||||
void setAnchor_v(bool b){anchor_v = b;}
|
|
||||||
bool getAnchor_v() const {return anchor_v;}
|
|
||||||
|
|
||||||
void setUv_alarm(double d){uv_alarm = d;}
|
|
||||||
double getUv_alarm() const {return uv_alarm;}
|
|
||||||
|
|
||||||
void setOv_alarm(double d){ov_alarm = d;}
|
|
||||||
double getOv_alarm() const {return ov_alarm;}
|
|
||||||
|
|
||||||
void setAnchor_i(bool b) {anchor_i = b;}
|
|
||||||
bool getAnchor_i() const {return anchor_i;}
|
|
||||||
|
|
||||||
void setUi_alarm(double d) {ui_alarm = d;}
|
|
||||||
double getUi_alarm() const {return ui_alarm;}
|
|
||||||
|
|
||||||
void setOi_alarm(double d) {oi_alarm = d;}
|
|
||||||
double getOi_alarm() const {return oi_alarm;}
|
|
||||||
|
|
||||||
void setElec(double d) {electricity = d;}
|
|
||||||
double getElec() const {return electricity;}
|
|
||||||
|
|
||||||
void setVolt(double d) {voltage = d;}
|
|
||||||
double getVolt() const {return voltage;}
|
|
||||||
protected:
|
|
||||||
int componentId;
|
|
||||||
double resistance; //电阻 DEFAULT 2,
|
|
||||||
bool anchor_v; //是否锚定电压 DEFAULT FALSE,
|
|
||||||
double uv_alarm; //电压下限 DEFAULT 90,
|
|
||||||
double ov_alarm; //电压上限 DEFAULT 110,
|
|
||||||
bool anchor_i; //是否锚定电流 DEFAULT FALSE,
|
|
||||||
double ui_alarm; //电流下限 DEFAULT 45,
|
|
||||||
double oi_alarm; //电流上限 DEFAULT 55,
|
|
||||||
double electricity;
|
|
||||||
double voltage;
|
|
||||||
/*double uv_warn_rate; //-- 欠压预警 阈值 0~100(%) DEFAULT 95 *********正式参数**********
|
|
||||||
QString uv_warn_unit; //欠压预警 单位 周波t/秒s/分钟m/小时h DEFAULT 's'
|
|
||||||
double uv_warn_dur; //DEFAULT 10, -- 欠压预警 运行时间 0~100
|
|
||||||
double uv_alarm_rate; //DEFAULT 90, -- 欠压警告 阈值 0~100(%)
|
|
||||||
QString uv_alarm_unit; //DEFAULT 's', -- 欠压警告 单位 周波t/秒s/分钟m/小时h
|
|
||||||
double uv_alarm_dur; //DEFAULT 10, -- 欠压警告 运行时间 0~100
|
|
||||||
double ov_warn_rate; //DEFAULT 105, -- 过压预警 阈值 100~500(%)
|
|
||||||
QString ov_warn_unit; //DEFAULT 's', -- 过压预警 单位 周波t/秒s/分钟m/小时h
|
|
||||||
double ov_warn_dur; //DEFAULT 10, -- 过压预警 运行时间 0~100
|
|
||||||
double ov_alarm_rate; //DEFAULT 110, -- 过压警告 阈值 100~500(%)
|
|
||||||
QString ov_alarm_unit; //DEFAULT 's', -- 过压警告 单位 周波t/秒s/分钟m/小时h
|
|
||||||
double ov_alarm_dur; //DEFAULT 10, -- 过压警告 运行时间 0~100
|
|
||||||
double svm_pmax; //DEFAULT 0, -- 区域电压静稳裕度参数 Pmax 0~65536
|
|
||||||
double svm_qmax; //DEFAULT 0, -- 区域电压静稳裕度参数 Qmax 0~65536
|
|
||||||
double svm_ulim; //DEFAULT 90, -- 区域电压静稳裕度参数 Ulim 0~1000
|
|
||||||
double svm_prate; //DEFAULT 30, -- 区域电压静稳裕度参数 有功稳定裕度限值 0~100(%)
|
|
||||||
double svm_qrate; //DEFAULT 30, -- 区域电压静稳裕度参数 无功稳定裕度限值 0~100(%)*/
|
|
||||||
int op;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ElectricSvgItemRect :public ElectricSvgItem
|
class ElectricSvgItemRect :public ElectricSvgItem
|
||||||
{
|
{
|
||||||
|
|
@ -78,18 +12,14 @@ public:
|
||||||
ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
|
ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
|
||||||
virtual ~ElectricSvgItemRect();
|
virtual ~ElectricSvgItemRect();
|
||||||
|
|
||||||
virtual ElectricSvgItemRect_Property* getProperty() {return dynamic_cast<ElectricSvgItemRect_Property*>(_property);}
|
|
||||||
virtual void showPropertyDlg(QWidget* p);
|
|
||||||
virtual void updateByProperty();
|
virtual void updateByProperty();
|
||||||
public slots:
|
|
||||||
void onPropertyChanged(const PropertyInfo);
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
private:
|
private:
|
||||||
virtual void updateHandles();
|
virtual void updateHandles();
|
||||||
|
|
||||||
double m_dRatioX;
|
double m_dRatioX;
|
||||||
ItemPropertyDlg* _pDlg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,6 @@ public:
|
||||||
virtual BaseProperty* getProperty() {return _property;}
|
virtual BaseProperty* getProperty() {return _property;}
|
||||||
virtual void unbindProperty(); //断开图元与数据的绑定
|
virtual void unbindProperty(); //断开图元与数据的绑定
|
||||||
virtual void updateByProperty(); //使用data对象更新自己
|
virtual void updateByProperty(); //使用data对象更新自己
|
||||||
virtual void showPropertyDlg(QWidget* p); //显示属性对话框,参数为父对象
|
|
||||||
virtual void updateConnectData(); //更新连接关系数据
|
virtual void updateConnectData(); //更新连接关系数据
|
||||||
virtual void setItemChanged(bool b){_itemChanged = b;}
|
virtual void setItemChanged(bool b){_itemChanged = b;}
|
||||||
virtual bool itemChanged() const {return _itemChanged;}
|
virtual bool itemChanged() const {return _itemChanged;}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class itemPropertyDlg; }
|
namespace Ui { class itemPropertyDlg; }
|
||||||
|
|
@ -28,16 +31,28 @@ public:
|
||||||
ItemPropertyDlg(QWidget *parent = nullptr);
|
ItemPropertyDlg(QWidget *parent = nullptr);
|
||||||
~ItemPropertyDlg();
|
~ItemPropertyDlg();
|
||||||
|
|
||||||
void synchroniseData(const PropertyInfo); //外部调用
|
void initial();
|
||||||
|
void loadGroupButton(QMap<QString,groupStateInfo>); //加载属性组列表
|
||||||
|
void createGroupView(const QString&); //创建属性页
|
||||||
|
void showDlg(modelDataInfo,QUuid); //显示属性页面
|
||||||
signals:
|
signals:
|
||||||
void PropertyChange(const PropertyInfo);
|
void PropertyChange(const PropertyInfo);
|
||||||
public slots:
|
public slots:
|
||||||
void onOkClicked();
|
void onOkClicked();
|
||||||
void onCancelClicked();
|
void onCancelClicked();
|
||||||
void onApplyClicked();
|
void onGroupSelected(const QString&);
|
||||||
private:
|
private:
|
||||||
Ui::itemPropertyDlg *ui;
|
Ui::itemPropertyDlg *ui;
|
||||||
|
|
||||||
|
QVBoxLayout* layout_;
|
||||||
|
QButtonGroup* btnGroup_;
|
||||||
|
QMap<QString, QAbstractButton*> btnMap_;
|
||||||
|
|
||||||
|
QMap<QString, QWidget*> groupViews_; //stack中存储的属性页
|
||||||
|
QMap<QString,groupStateInfo> groupInfo_; //属性组结构信息
|
||||||
|
QMap<QString,groupStateValue> groupValue_; //属性数据
|
||||||
|
QUuid curUuid_; //当前显示对象的uuid
|
||||||
|
QString _curModel; //当前模型名
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef PROPERTYCONTENTDLG_H
|
||||||
|
#define PROPERTYCONTENTDLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include "global.h"
|
||||||
|
/*******************************************************
|
||||||
|
每个属性组单独的界面信息,动态生成后加入到itemPropertyDlg
|
||||||
|
********************************************************/
|
||||||
|
|
||||||
|
class PropertyContentDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PropertyContentDlg(QWidget *parent = nullptr);
|
||||||
|
~PropertyContentDlg();
|
||||||
|
|
||||||
|
void createGroupView(groupStateInfo); //创建页面
|
||||||
|
QWidget* createEditor(propertyStateInfo); //创建属性
|
||||||
|
QMap<QString,propertyStateInfo> getPropertyValue() const; //返回当前页面的属性值
|
||||||
|
void setPropertyValue(QMap<QString,propertyStateInfo>);
|
||||||
|
private:
|
||||||
|
QVBoxLayout* _layout;
|
||||||
|
|
||||||
|
QMap<QString,propertyContentInfo> _mapPro;
|
||||||
|
private:
|
||||||
|
QFormLayout* createFormLayout();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#include "dataBase.h"
|
#include "dataBase.h"
|
||||||
#include "httpInterface.h"
|
#include "httpInterface.h"
|
||||||
#include "drawingPanel.h"
|
#include "drawingPanel.h"
|
||||||
|
#include "itemPropertyDlg.h"
|
||||||
|
#include "dataManager.h"
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
@ -24,6 +26,8 @@ FixedPortsModel::FixedPortsModel()
|
||||||
_Interface = new HttpInterface(this);
|
_Interface = new HttpInterface(this);
|
||||||
_timer = new QTimer(this);
|
_timer = new QTimer(this);
|
||||||
|
|
||||||
|
_modelStateInfo = DataManager::instance().modelState();
|
||||||
|
initialPropertyDlg();
|
||||||
connect(_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
|
connect(_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
|
||||||
connect(_Interface,&HttpInterface::sendPointData,this,&FixedPortsModel::onSignal_GetPointData);
|
connect(_Interface,&HttpInterface::sendPointData,this,&FixedPortsModel::onSignal_GetPointData);
|
||||||
}
|
}
|
||||||
|
|
@ -195,8 +199,9 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
if(pPro)
|
if(pPro)
|
||||||
{
|
{
|
||||||
QMap<QString,VariableMap>& mapVariableGroup = pPro->getMapGroup();
|
QMap<QString,VariableMap>& mapVariableGroup = pPro->getMapGroup();
|
||||||
|
ModelDataMap mapData = DataManager::instance().modelData();
|
||||||
|
|
||||||
QMap<QString,groupStateValue> mapGroup = _modleDataInfo[info.modelName].groupInfo; //取得该模型下的所有属性组
|
QMap<QString,groupStateValue> mapGroup = mapData[info.modelName].groupInfo; //取得该模型下的所有属性组
|
||||||
QMap<QString,groupStateValue>::Iterator iter;
|
QMap<QString,groupStateValue>::Iterator iter;
|
||||||
for(iter = mapGroup.begin();iter != mapGroup.end();++iter)
|
for(iter = mapGroup.begin();iter != mapGroup.end();++iter)
|
||||||
{
|
{
|
||||||
|
|
@ -220,18 +225,10 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
else if(info.type == GIT_itemRect)
|
else if(info.type == GIT_itemRect)
|
||||||
{
|
{
|
||||||
busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
|
busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
|
||||||
ElectricSvgItemRect_Property* pPro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
/*ElectricSvgItemRect_Property* pPro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||||
if(pPro)
|
if(pPro)
|
||||||
{
|
{
|
||||||
pPro->setComponent_id(info.id);
|
}*/
|
||||||
pPro->setResistance(bility.resistance);
|
|
||||||
pPro->setAnchor_v(bility.anchor_v);
|
|
||||||
pPro->setUv_alarm(bility.uv_alarm);
|
|
||||||
pPro->setOv_alarm(bility.ov_alarm);
|
|
||||||
pPro->setAnchor_i(bility.anchor_i);
|
|
||||||
pPro->setUi_alarm(bility.ui_alarm);
|
|
||||||
pPro->setOi_alarm(bility.oi_alarm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(info.type == GIT_bus)
|
else if(info.type == GIT_bus)
|
||||||
{
|
{
|
||||||
|
|
@ -473,11 +470,11 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
int type = pData->type();
|
int type = pData->type();
|
||||||
if(type == GIT_itemRect)
|
if(type == GIT_itemRect)
|
||||||
{
|
{
|
||||||
ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
/*ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||||
if(pro)
|
if(pro)
|
||||||
{
|
{
|
||||||
DataBase::GetInstance()->updateBus_stability(pro->component_id(),pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
DataBase::GetInstance()->updateBus_stability(pro->component_id(),pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -486,12 +483,12 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
int type = pData->type();
|
int type = pData->type();
|
||||||
if(type == GIT_itemRect)
|
if(type == GIT_itemRect)
|
||||||
{
|
{
|
||||||
ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
/*ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||||
if(pro)
|
if(pro)
|
||||||
{
|
{
|
||||||
componentInfo info = DataBase::GetInstance()->getComponentInfoByUuid(pData->uuid().toString());
|
componentInfo info = DataBase::GetInstance()->getComponentInfoByUuid(pData->uuid().toString());
|
||||||
DataBase::GetInstance()->insertBus_stability(info.id,pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
DataBase::GetInstance()->insertBus_stability(info.id,pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -571,16 +568,11 @@ void FixedPortsModel::onSignal_GetPointData(QString type,QMap<qint64,double> map
|
||||||
if(t == GIT_itemRect)
|
if(t == GIT_itemRect)
|
||||||
{
|
{
|
||||||
//todo:根据id匹配数据
|
//todo:根据id匹配数据
|
||||||
auto p = dynamic_cast<ElectricSvgItemRect_Property*>(pro);
|
/*auto p = dynamic_cast<ElectricSvgItemRect_Property*>(pro);
|
||||||
if(p)
|
if(p)
|
||||||
{
|
{
|
||||||
if(type == QString("v"))
|
|
||||||
p->setVolt(d);
|
|
||||||
else if(type == QString("i"))
|
|
||||||
p->setElec(d);
|
|
||||||
|
|
||||||
p->notifyUpdate(); //通知更新
|
p->notifyUpdate(); //通知更新
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -600,101 +592,39 @@ QWidget* FixedPortsModel::getTopWidget()
|
||||||
return dynamic_cast<QWidget*>(_widget);
|
return dynamic_cast<QWidget*>(_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::addModelProperty(modelStateInfo info)
|
void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid)
|
||||||
{
|
{
|
||||||
if(!_modelStateInfo.contains(info.modelName))
|
modelStateInfo stateInfo = _modelStateInfo[sName];
|
||||||
|
ModelDataMap mapData = DataManager::instance().modelData();
|
||||||
|
ItemPropertyDlg* pDlg = dynamic_cast<ItemPropertyDlg*>(stateInfo._PropertyDlg);
|
||||||
|
if(pDlg)
|
||||||
{
|
{
|
||||||
_modelStateInfo.insert(info.modelName,info);
|
pDlg->showDlg(mapData[sName],uuid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug()<<"showModelDlg err";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::initialPropertyDlg()
|
||||||
|
{
|
||||||
|
for(auto &modelInfo:_modelStateInfo)
|
||||||
|
{
|
||||||
|
if(modelInfo._PropertyDlg == NULL)
|
||||||
|
{
|
||||||
|
generatePropertyDlg(modelInfo.modelName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::getModelInfo()
|
void FixedPortsModel::generatePropertyDlg(const QString& sModel)
|
||||||
{
|
{
|
||||||
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
modelStateInfo info = _modelStateInfo[sModel];
|
||||||
|
if(info._PropertyDlg == NULL)
|
||||||
QMap<QString,int>::Iterator iter;
|
|
||||||
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
|
||||||
{
|
{
|
||||||
modelStateInfo modelInfo;
|
ItemPropertyDlg* dlg = new ItemPropertyDlg(_widget);
|
||||||
modelInfo.modelType = iter.value(); //模型类型
|
if(dlg)
|
||||||
|
|
||||||
groupStateInfo groupInfo;
|
|
||||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
|
||||||
|
|
||||||
QMap<QString,propertyGroupState>::Iterator it;
|
|
||||||
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
|
||||||
{
|
{
|
||||||
groupInfo.groupName = it.key();
|
dlg->loadGroupButton(info.groupInfo);
|
||||||
groupInfo.tableName = it->tableName;
|
|
||||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
|
||||||
|
|
||||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
|
||||||
{
|
|
||||||
propertyStateInfo propertyInfo;
|
|
||||||
|
|
||||||
QJsonObject node = nodeJson.toObject();
|
|
||||||
QString propertyName = node["name"].toString();
|
|
||||||
int nState = node["checked"].toInt();
|
|
||||||
QString dataType = node["type"].toString();
|
|
||||||
QString defaultValue = node["defaultValue"].toString();
|
|
||||||
|
|
||||||
if(nState)
|
|
||||||
{
|
|
||||||
//todo:别名赋值
|
|
||||||
propertyInfo.name = propertyName;
|
|
||||||
propertyInfo.type = dataType;
|
|
||||||
propertyInfo.defaultValue = defaultValue;
|
|
||||||
|
|
||||||
groupInfo.info.insert(propertyName,propertyInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelInfo.groupInfo.insert(it.key(),groupInfo);
|
|
||||||
}
|
|
||||||
_modelStateInfo.insert(iter.key(),modelInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixedPortsModel::getModelData()
|
|
||||||
{
|
|
||||||
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
|
||||||
|
|
||||||
QMap<QString,int>::Iterator iter;
|
|
||||||
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
|
||||||
{
|
|
||||||
modelDataInfo modelInfo;
|
|
||||||
modelInfo.modelType = iter.value(); //模型类型
|
|
||||||
|
|
||||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
|
||||||
|
|
||||||
QMap<QString,propertyGroupState>::Iterator it;
|
|
||||||
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
|
||||||
{
|
|
||||||
groupStateValue groupValue;
|
|
||||||
groupValue.groupName = it.key();
|
|
||||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
|
||||||
|
|
||||||
QStringList lstParam; //需检索的属性组中属性名列表
|
|
||||||
|
|
||||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
|
||||||
{
|
|
||||||
propertyStateInfo propertyInfo;
|
|
||||||
|
|
||||||
QJsonObject node = nodeJson.toObject();
|
|
||||||
QString propertyName = node["name"].toString();
|
|
||||||
int nState = node["checked"].toInt();
|
|
||||||
QString dataType = node["type"].toString();
|
|
||||||
QString defaultValue = node["defaultValue"].toString();
|
|
||||||
|
|
||||||
if(nState)
|
|
||||||
{
|
|
||||||
lstParam.append(propertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lstParam.append("global_uuid"); //全局id未添加到属性状态中,手动选择
|
|
||||||
groupValue.mapInfo = DataBase::GetInstance()->selectGroupProperty(it->tableName,lstParam); //返回表中属性值
|
|
||||||
|
|
||||||
modelInfo.groupInfo.insert(it.key(),groupValue);
|
|
||||||
}
|
|
||||||
_modleDataInfo.insert(iter.key(),modelInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent)
|
ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent)
|
||||||
: ElectricSvgItem(rect,parent)
|
: ElectricSvgItem(rect,parent)
|
||||||
,_pDlg(nullptr)
|
|
||||||
{
|
{
|
||||||
loadSvg(":/images/element/svg_rect.svg");
|
loadSvg(":/images/element/svg_rect.svg");
|
||||||
setHandleIfShow(H_textCaption,false);
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
|
@ -66,89 +65,13 @@ void ElectricSvgItemRect::updateHandles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricSvgItemRect::onPropertyChanged(PropertyInfo inf)
|
|
||||||
{
|
|
||||||
auto p = getProperty();
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
p->setResistance(inf.resistance);
|
|
||||||
p->setAnchor_v(inf.anchor_v);
|
|
||||||
p->setUv_alarm(inf.uv_alarm);
|
|
||||||
p->setOv_alarm(inf.ov_alarm);
|
|
||||||
p->setAnchor_i(inf.anchor_i);
|
|
||||||
p->setUi_alarm(inf.ui_alarm);
|
|
||||||
p->setOi_alarm(inf.oi_alarm);
|
|
||||||
p->setDataChanged(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElectricSvgItemRect::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
void ElectricSvgItemRect::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
{
|
{
|
||||||
ElectricSvgItem::paint(painter,option,widget);
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricSvgItemRect::showPropertyDlg(QWidget* p)
|
|
||||||
{
|
|
||||||
auto pro = getProperty();
|
|
||||||
if(pro)
|
|
||||||
{
|
|
||||||
PropertyInfo data;
|
|
||||||
data.resistance = pro->getResistance();
|
|
||||||
data.anchor_v = pro->getAnchor_v();
|
|
||||||
data.uv_alarm = pro->getUv_alarm();
|
|
||||||
data.ov_alarm = pro->getOv_alarm();
|
|
||||||
data.anchor_i = pro->getAnchor_i();
|
|
||||||
data.ui_alarm = pro->getUi_alarm();
|
|
||||||
data.oi_alarm = pro->getOi_alarm();
|
|
||||||
if(_pDlg)
|
|
||||||
{
|
|
||||||
_pDlg->show();
|
|
||||||
_pDlg->synchroniseData(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_pDlg = new ItemPropertyDlg(p);
|
|
||||||
connect(_pDlg,&ItemPropertyDlg::PropertyChange,this,&ElectricSvgItemRect::onPropertyChanged);
|
|
||||||
_pDlg->show();
|
|
||||||
_pDlg->synchroniseData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//todo:没有关联数据,提示
|
|
||||||
qDebug()<<"no associate data";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElectricSvgItemRect::updateByProperty()
|
void ElectricSvgItemRect::updateByProperty()
|
||||||
{
|
|
||||||
auto p = dynamic_cast<ElectricSvgItemRect_Property*>(_property);
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
setLabelTag(p->tag());
|
|
||||||
setLabelVoltage(QString::number(p->getVolt()));
|
|
||||||
setLabelCurrent(QString::number(p->getElec()));
|
|
||||||
scene()->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/****************************************************************/
|
|
||||||
|
|
||||||
ElectricSvgItemRect_Property::ElectricSvgItemRect_Property(QObject* parent)
|
|
||||||
:BaseProperty(parent)
|
|
||||||
{
|
|
||||||
electricity = 0;
|
|
||||||
voltage = 0;
|
|
||||||
resistance = 2; //电阻
|
|
||||||
anchor_v = false; //是否锚定电压
|
|
||||||
uv_alarm = 90; //电压下限
|
|
||||||
ov_alarm = 110; //电压上限
|
|
||||||
anchor_i = false; //是否锚定电流
|
|
||||||
ui_alarm = 45; //电流下限
|
|
||||||
oi_alarm = 55; //电流上限
|
|
||||||
}
|
|
||||||
|
|
||||||
ElectricSvgItemRect_Property::~ElectricSvgItemRect_Property()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,6 @@ void GraphicsBaseItem::unbindProperty()
|
||||||
_property = nullptr;
|
_property = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsBaseItem::showPropertyDlg(QWidget* p)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsBaseItem::updateConnectData()
|
void GraphicsBaseItem::updateConnectData()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
#include "itemPropertyDlg.h"
|
#include "itemPropertyDlg.h"
|
||||||
|
#include "propertyContentDlg.h"
|
||||||
#include "ui_itemPropertyDlg.h"
|
#include "ui_itemPropertyDlg.h"
|
||||||
|
|
||||||
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::itemPropertyDlg)
|
, ui(new Ui::itemPropertyDlg)
|
||||||
|
,layout_(nullptr)
|
||||||
|
,btnGroup_(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
connect(ui->btn_ok_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onOkClicked);
|
initial();
|
||||||
connect(ui->btn_apply_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onApplyClicked);
|
|
||||||
connect(ui->btn_cancel_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onCancelClicked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemPropertyDlg::~ItemPropertyDlg()
|
ItemPropertyDlg::~ItemPropertyDlg()
|
||||||
|
|
@ -17,20 +18,40 @@ ItemPropertyDlg::~ItemPropertyDlg()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemPropertyDlg::synchroniseData(const PropertyInfo pro)
|
void ItemPropertyDlg::initial()
|
||||||
{
|
{
|
||||||
ui->sp_DianZu->setValue(pro.resistance);
|
layout_ = new QVBoxLayout(ui->widget_button);
|
||||||
ui->cb_MaoDingDianYa->setChecked(pro.anchor_v);
|
btnGroup_ = new QButtonGroup(this);
|
||||||
ui->sp_DianYaXiaXian->setValue(pro.uv_alarm);
|
connect(ui->btn_ok,&QPushButton::clicked,this,&ItemPropertyDlg::onOkClicked);
|
||||||
ui->sp_DianYaShangXian->setValue(pro.ov_alarm);
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&ItemPropertyDlg::onCancelClicked);
|
||||||
ui->cb_MaoDingDianLiu->setChecked(pro.anchor_i);
|
}
|
||||||
ui->sp_DianLiuXiaXian->setValue(pro.ui_alarm);
|
|
||||||
ui->sp_DianLiuShangXian->setValue(pro.oi_alarm);
|
void ItemPropertyDlg::loadGroupButton(QMap<QString,groupStateInfo> map)
|
||||||
|
{
|
||||||
|
groupInfo_ = map;
|
||||||
|
for(auto &info:map)
|
||||||
|
{
|
||||||
|
QPushButton* btn = new QPushButton(ui->widget_button);
|
||||||
|
btn->setText(info.groupName);
|
||||||
|
btn->setCheckable(true);
|
||||||
|
btnGroup_->addButton(btn);
|
||||||
|
btnMap_.insert(info.groupName, btn);
|
||||||
|
layout_->addWidget(btn);
|
||||||
|
|
||||||
|
connect(btn, &QAbstractButton::clicked, [this, info](){
|
||||||
|
onGroupSelected(info.groupName);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemPropertyDlg::onOkClicked()
|
void ItemPropertyDlg::onOkClicked()
|
||||||
{
|
{
|
||||||
onApplyClicked();
|
//todo:将属性页中的值读取到当前uuid对象
|
||||||
|
for(auto &dlg:groupViews_)
|
||||||
|
{
|
||||||
|
PropertyContentDlg* pDlg = qobject_cast<PropertyContentDlg*>(dlg);
|
||||||
|
QMap<QString,propertyStateInfo> mapPro = pDlg->getPropertyValue();
|
||||||
|
}
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,15 +60,41 @@ void ItemPropertyDlg::onCancelClicked()
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemPropertyDlg::onApplyClicked()
|
void ItemPropertyDlg::onGroupSelected(const QString& str)
|
||||||
{
|
{
|
||||||
PropertyInfo info;
|
if (!groupViews_.contains(str)) {
|
||||||
info.resistance = ui->sp_DianZu->value();
|
createGroupView(str);
|
||||||
info.anchor_v = ui->cb_MaoDingDianYa->isChecked();
|
}
|
||||||
info.uv_alarm = ui->sp_DianYaXiaXian->value();
|
|
||||||
info.ov_alarm = ui->sp_DianYaShangXian->value();
|
PropertyContentDlg* pDlg = qobject_cast<PropertyContentDlg*>(groupViews_[str]);
|
||||||
info.anchor_i = ui->cb_MaoDingDianLiu->isChecked();
|
if(pDlg)
|
||||||
info.ui_alarm = ui->sp_DianLiuXiaXian->value();
|
{
|
||||||
info.oi_alarm = ui->sp_DianLiuShangXian->value();
|
QMap<QString,propertyStateInfo> valueMap = groupValue_[str].mapInfo[curUuid_];
|
||||||
emit PropertyChange(info);
|
pDlg->setPropertyValue(valueMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->stackedWidget->setCurrentWidget(groupViews_[str]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemPropertyDlg::createGroupView(const QString& str)
|
||||||
|
{
|
||||||
|
PropertyContentDlg* contentDlg = new PropertyContentDlg(ui->stackedWidget);
|
||||||
|
if(contentDlg)
|
||||||
|
{
|
||||||
|
contentDlg->createGroupView(groupInfo_[str]);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupViews_.insert(str, contentDlg);
|
||||||
|
ui->stackedWidget->addWidget(contentDlg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid)
|
||||||
|
{
|
||||||
|
groupValue_ = dataInfo.groupInfo;
|
||||||
|
curUuid_ = uuid;
|
||||||
|
_curModel = dataInfo.modelName;
|
||||||
|
QString firstName = groupInfo_.constBegin().key();
|
||||||
|
onGroupSelected(firstName); //打开默认显示第一个属性组
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,345 @@
|
||||||
|
#include "propertyContentDlg.h"
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QDateEdit>
|
||||||
|
|
||||||
|
PropertyContentDlg::PropertyContentDlg(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
,_layout(nullptr)
|
||||||
|
{
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
_layout = new QVBoxLayout(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyContentDlg::~PropertyContentDlg()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyContentDlg::createGroupView(groupStateInfo infos)
|
||||||
|
{
|
||||||
|
QScrollArea* scrollArea = new QScrollArea(this);
|
||||||
|
QWidget* content = new QWidget();
|
||||||
|
QFormLayout* formLayout = createFormLayout();
|
||||||
|
|
||||||
|
// 动态生成字段
|
||||||
|
for(auto& info:infos.info) {
|
||||||
|
QLabel* label = new QLabel(info.name);
|
||||||
|
QWidget* editor = createEditor(info);
|
||||||
|
formLayout->addRow(label, editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollArea->setWidget(content);
|
||||||
|
scrollArea->setWidgetResizable(true);
|
||||||
|
_layout->addWidget(scrollArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* PropertyContentDlg::createEditor(propertyStateInfo pro)
|
||||||
|
{
|
||||||
|
QWidget* pWidget = nullptr;
|
||||||
|
if(pro.type.contains("SMALLINT"))
|
||||||
|
{
|
||||||
|
QSpinBox* spin = new QSpinBox(this);
|
||||||
|
spin->setRange(-32768, 32767);
|
||||||
|
pWidget = spin;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("INTEGER"))
|
||||||
|
{
|
||||||
|
QSpinBox* spin = new QSpinBox(this);
|
||||||
|
pWidget = spin;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("BIGINT"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
QRegularExpression regExp("^[+-]?(0|[1-9][0-9]{0,18})$");
|
||||||
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
|
||||||
|
lineEdit->setValidator(validator);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("REAL"))
|
||||||
|
{
|
||||||
|
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
||||||
|
dbSpin->setDecimals(6);
|
||||||
|
pWidget = dbSpin;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("DOUBLE PRECISION"))
|
||||||
|
{
|
||||||
|
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
||||||
|
dbSpin->setDecimals(15);
|
||||||
|
pWidget = dbSpin;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("NUMERIC") || pro.type.contains("DECIMAL"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
|
||||||
|
// 正则表达式:支持正负号、整数/小数、科学计数法
|
||||||
|
QRegularExpression regExp(
|
||||||
|
"^[+-]?" // 可选正负号
|
||||||
|
"(?:0|[1-9]\\d*)(?:\\.\\d+)?" // 整数部分(避免前导零)和小数部分
|
||||||
|
"(?:[eE][+-]?\\d+)?" // 科学计数法(如e5, E-3)
|
||||||
|
);
|
||||||
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
|
||||||
|
lineEdit->setValidator(validator);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("SERIAL") || pro.type.contains("BIGSERIAL"))
|
||||||
|
{
|
||||||
|
QLabel *label = new QLabel(this);
|
||||||
|
pWidget = label;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("CHAR") || pro.type.contains("VARCHAR"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
lineEdit->setMaxLength(pro.lengthPrecision);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("TEXT"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("BYTEA"))
|
||||||
|
{
|
||||||
|
//todo:二进制文件上传
|
||||||
|
QLabel *label = new QLabel(this);
|
||||||
|
pWidget = label;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("DATE"))
|
||||||
|
{
|
||||||
|
QDateEdit* dateEdit = new QDateEdit(this);
|
||||||
|
dateEdit->setDisplayFormat("yyyy-MM-dd");
|
||||||
|
pWidget = dateEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("TIME"))
|
||||||
|
{
|
||||||
|
QTimeEdit* timeEdit = new QTimeEdit(this);
|
||||||
|
timeEdit->setDisplayFormat("HH:mm:ss");
|
||||||
|
pWidget = timeEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("TIMESTAMP"))
|
||||||
|
{
|
||||||
|
QDateTimeEdit* dateTimeEidt = new QDateTimeEdit(this);
|
||||||
|
dateTimeEidt->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
pWidget = dateTimeEidt;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("UUID"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
QRegularExpression regExp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
||||||
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
|
||||||
|
lineEdit->setValidator(validator);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
else if(pro.type.contains("JSON") || pro.type.contains("JSONB"))
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
pWidget = lineEdit;
|
||||||
|
}
|
||||||
|
if(pWidget)
|
||||||
|
{
|
||||||
|
pWidget->setProperty("name",pro.name);
|
||||||
|
propertyContentInfo info;
|
||||||
|
info.proName = pro.name;
|
||||||
|
info.proType = pro.type;
|
||||||
|
info.proEditer = pWidget;
|
||||||
|
_mapPro.insert(pro.name,info);
|
||||||
|
}
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString,propertyStateInfo> PropertyContentDlg::getPropertyValue() const
|
||||||
|
{
|
||||||
|
QMap<QString,propertyStateInfo> map;
|
||||||
|
|
||||||
|
for(auto &pro:_mapPro)
|
||||||
|
{
|
||||||
|
propertyStateInfo info;
|
||||||
|
info.type = pro.proType;
|
||||||
|
info.name = pro.proName;
|
||||||
|
if(pro.proEditer != nullptr)
|
||||||
|
{
|
||||||
|
if(pro.proType.contains("SMALLINT") || pro.proType.contains("INTEGER"))
|
||||||
|
{
|
||||||
|
QSpinBox* spin = qobject_cast<QSpinBox*>(pro.proEditer);
|
||||||
|
if(spin)
|
||||||
|
info.defaultValue = spin->value();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("BIGINT"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("REAL") || pro.proType.contains("DOUBLE PRECISION"))
|
||||||
|
{
|
||||||
|
QDoubleSpinBox* dbSpin = qobject_cast<QDoubleSpinBox*>(pro.proEditer);
|
||||||
|
if(dbSpin)
|
||||||
|
info.defaultValue = dbSpin->value();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("NUMERIC") || pro.proType.contains("DECIMAL"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("SERIAL") || pro.proType.contains("BIGSERIAL"))
|
||||||
|
{
|
||||||
|
QLabel* label = qobject_cast<QLabel*>(pro.proEditer);
|
||||||
|
if(label)
|
||||||
|
info.defaultValue = label->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("CHAR") || pro.proType.contains("VARCHAR"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("TEXT"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("BYTEA"))
|
||||||
|
{
|
||||||
|
QLabel* label = qobject_cast<QLabel*>(pro.proEditer);
|
||||||
|
if(label)
|
||||||
|
info.defaultValue = label->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("DATE"))
|
||||||
|
{
|
||||||
|
QDateEdit* dateEdit = qobject_cast<QDateEdit*>(pro.proEditer);
|
||||||
|
if(dateEdit)
|
||||||
|
info.defaultValue = dateEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("TIME"))
|
||||||
|
{
|
||||||
|
QTimeEdit* timeEdit = qobject_cast<QTimeEdit*>(pro.proEditer);
|
||||||
|
if(timeEdit)
|
||||||
|
info.defaultValue = timeEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("TIMESTAMP"))
|
||||||
|
{
|
||||||
|
QDateTimeEdit* dateTimeEidt = qobject_cast<QDateTimeEdit*>(pro.proEditer);
|
||||||
|
if(dateTimeEidt)
|
||||||
|
info.defaultValue = dateTimeEidt->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("UUID"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
else if(pro.proType.contains("JSON") || pro.proType.contains("JSONB"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
info.defaultValue = lineEdit->text();
|
||||||
|
}
|
||||||
|
map.insert(pro.proName,info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyContentDlg::setPropertyValue(QMap<QString,propertyStateInfo> map)
|
||||||
|
{
|
||||||
|
for(auto &info:map)
|
||||||
|
{
|
||||||
|
propertyContentInfo pro = _mapPro[info.name];
|
||||||
|
if(info.type.contains("SMALLINT") || info.type.contains("INTEGER"))
|
||||||
|
{
|
||||||
|
QSpinBox* spin = qobject_cast<QSpinBox*>(pro.proEditer);
|
||||||
|
if(spin)
|
||||||
|
spin->setValue(info.defaultValue.toInt());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("BIGINT"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("REAL") || info.type.contains("DOUBLE PRECISION"))
|
||||||
|
{
|
||||||
|
QDoubleSpinBox* dbSpin = qobject_cast<QDoubleSpinBox*>(pro.proEditer);
|
||||||
|
if(dbSpin)
|
||||||
|
dbSpin->setValue(info.defaultValue.toDouble());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("NUMERIC") || info.type.contains("DECIMAL"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("SERIAL") || info.type.contains("BIGSERIAL"))
|
||||||
|
{
|
||||||
|
QLabel* label = qobject_cast<QLabel*>(pro.proEditer);
|
||||||
|
if(label)
|
||||||
|
label->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("CHAR") || info.type.contains("VARCHAR"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("TEXT"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("BYTEA"))
|
||||||
|
{
|
||||||
|
QLabel* label = qobject_cast<QLabel*>(pro.proEditer);
|
||||||
|
if(label)
|
||||||
|
label->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("DATE"))
|
||||||
|
{
|
||||||
|
QDateEdit* dateEdit = qobject_cast<QDateEdit*>(pro.proEditer);
|
||||||
|
QDate date = QDate::fromString(info.defaultValue.toString(), "yyyy-MM-dd");
|
||||||
|
if(dateEdit)
|
||||||
|
dateEdit->setDate(date);
|
||||||
|
}
|
||||||
|
else if(info.type.contains("TIME"))
|
||||||
|
{
|
||||||
|
QTimeEdit* timeEdit = qobject_cast<QTimeEdit*>(pro.proEditer);
|
||||||
|
QTime time = QTime::fromString(info.defaultValue.toString(), "HH:mm:ss");
|
||||||
|
if(timeEdit)
|
||||||
|
timeEdit->setTime(time);
|
||||||
|
}
|
||||||
|
else if(info.type.contains("TIMESTAMP"))
|
||||||
|
{
|
||||||
|
QDateTimeEdit* dateTimeEidt = qobject_cast<QDateTimeEdit*>(pro.proEditer);
|
||||||
|
QDateTime dateTime = QDateTime::fromString(info.defaultValue.toString(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
if(dateTimeEidt)
|
||||||
|
dateTimeEidt->setDateTime(dateTime);
|
||||||
|
}
|
||||||
|
else if(info.type.contains("UUID"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
else if(info.type.contains("JSON") || info.type.contains("JSONB"))
|
||||||
|
{
|
||||||
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(pro.proEditer);
|
||||||
|
if(lineEdit)
|
||||||
|
lineEdit->setText(info.defaultValue.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QFormLayout* PropertyContentDlg::createFormLayout()
|
||||||
|
{
|
||||||
|
QFormLayout* layout = new QFormLayout;
|
||||||
|
layout->setHorizontalSpacing(20); // 标签与控件间距
|
||||||
|
layout->setVerticalSpacing(12); // 行间距
|
||||||
|
layout->setLabelAlignment(Qt::AlignRight); // 标签右对齐
|
||||||
|
layout->setContentsMargins(12, 12, 12, 12); // 内边距
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
@ -371,7 +371,9 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
|
||||||
GraphicsItemType tpe = item->getItemType();
|
GraphicsItemType tpe = item->getItemType();
|
||||||
if(tpe != GIT_link)
|
if(tpe != GIT_link)
|
||||||
{
|
{
|
||||||
item->showPropertyDlg(_model->getTopWidget());
|
QString modelName = item->getModelName(); //todo:additem时填写模型类型
|
||||||
|
QUuid uuid = item->itemId();
|
||||||
|
_model->showModelDlg(modelName,uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,6 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
|
||||||
//m_graphicsItem[sceneName()].insert(QString::number(m_pCreatingItem->itemId()),m_pCreatingItem); //插入数据到总表
|
//m_graphicsItem[sceneName()].insert(QString::number(m_pCreatingItem->itemId()),m_pCreatingItem); //插入数据到总表
|
||||||
m_pCreatingItem->setModelName(m_creatingItemInfo.modelName);
|
m_pCreatingItem->setModelName(m_creatingItemInfo.modelName);
|
||||||
_model->addNodeItem(m_pCreatingItem->itemId(),m_pCreatingItem);
|
_model->addNodeItem(m_pCreatingItem->itemId(),m_pCreatingItem);
|
||||||
_model->addModelProperty(m_creatingItemInfo); //添加当前模型状态
|
|
||||||
m_pCreatingItem = nullptr; //先舍弃多次点击创建对象241124 by
|
m_pCreatingItem = nullptr; //先舍弃多次点击创建对象241124 by
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,273 +53,94 @@
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="1,4">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="leftMargin">
|
<item row="0" column="0" rowspan="2">
|
||||||
<number>10</number>
|
<widget class="QWidget" name="widget_button" native="true">
|
||||||
</property>
|
<property name="minimumSize">
|
||||||
<property name="topMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QStackedWidget" name="stackedWidget_button">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="page">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_JianGeXinXi">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>12</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>间隔信息</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>150</width>
|
||||||
<height>471</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="styleSheet">
|
||||||
</item>
|
<string notr="true">background-color: rgb(219, 219, 219);</string>
|
||||||
</layout>
|
</property>
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="page_2"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QWidget" name="widget_content" native="true">
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Microsoft YaHei UI</family>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: rgb(224, 224, 224);
|
<string notr="true">background-color: rgb(219, 219, 219);</string>
|
||||||
color:black;
|
|
||||||
font: 10pt "Microsoft YaHei UI";</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="page_JianGeXinXi">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QStackedWidget" name="stackedWidget"/>
|
||||||
<property name="title">
|
|
||||||
<string>间隔信息</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0,0" columnstretch="1,1,1,1,2,1,1,2">
|
|
||||||
<item row="0" column="6" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="cb_MaoDingDianLiu">
|
|
||||||
<property name="text">
|
|
||||||
<string>是否锚定电流</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="5" rowspan="4">
|
|
||||||
<widget class="Line" name="line_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4" rowspan="2">
|
|
||||||
<widget class="QDoubleSpinBox" name="sp_DianYaXiaXian">
|
|
||||||
<property name="value">
|
|
||||||
<double>90.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>电压下限</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2" rowspan="4">
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="6">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>电流下限</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="4">
|
|
||||||
<widget class="QDoubleSpinBox" name="sp_DianYaShangXian">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>200.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>110.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" rowspan="2">
|
|
||||||
<widget class="QDoubleSpinBox" name="sp_DianZu">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>10000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>2.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="cb_MaoDingDianYa">
|
|
||||||
<property name="text">
|
|
||||||
<string>是否锚定电压</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="6">
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>电流上限</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="7">
|
|
||||||
<widget class="QDoubleSpinBox" name="sp_DianLiuXiaXian">
|
|
||||||
<property name="value">
|
|
||||||
<double>45.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="7" rowspan="2">
|
|
||||||
<widget class="QDoubleSpinBox" name="sp_DianLiuShangXian">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>200.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>55.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="3">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>电压上限</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" rowspan="2">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>电阻</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
<spacer name="verticalSpacer_2">
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
<property name="orientation">
|
<property name="minimumSize">
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>0</width>
|
||||||
<height>354</height>
|
<height>30</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="styleSheet">
|
||||||
</item>
|
<string notr="true">background-color: rgb(219, 219, 219);</string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QWidget" name="widget_2" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<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>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QPushButton" name="btn_ok">
|
||||||
<property name="orientation">
|
<property name="minimumSize">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
<size>
|
||||||
<width>223</width>
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="font">
|
||||||
</item>
|
<font>
|
||||||
<item>
|
<pointsize>14</pointsize>
|
||||||
<widget class="QPushButton" name="btn_cancel_jianGe">
|
</font>
|
||||||
<property name="text">
|
|
||||||
<string>取消</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="styleSheet">
|
||||||
</item>
|
<string notr="true">color: rgb(6, 6, 6);</string>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_apply_jianGe">
|
|
||||||
<property name="text">
|
|
||||||
<string>应用</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_ok_jianGe">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>确定</string>
|
<string>确定</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_cancel">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>14</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: rgb(6, 6, 6);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>取消</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_4"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ project(diagramUtils)
|
||||||
|
|
||||||
set(DIAGRAMUTILS_HEADER_FILES
|
set(DIAGRAMUTILS_HEADER_FILES
|
||||||
include/logger.h
|
include/logger.h
|
||||||
|
include/dataManager.h
|
||||||
../common/include/global.h
|
../common/include/global.h
|
||||||
../common/include/compiler.hpp
|
../common/include/compiler.hpp
|
||||||
../common/include/export.hpp
|
../common/include/export.hpp
|
||||||
|
|
@ -11,6 +12,7 @@ set(DIAGRAMUTILS_HEADER_FILES
|
||||||
set(DIAGRAMUTILS_SOURCE_FILES
|
set(DIAGRAMUTILS_SOURCE_FILES
|
||||||
source/logger.cpp
|
source/logger.cpp
|
||||||
source/dataBase.cpp
|
source/dataBase.cpp
|
||||||
|
source/dataManager.cpp
|
||||||
../common/source/global.cpp
|
../common/source/global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef DATAMANAGER_H
|
||||||
|
#define DATAMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "global.h"
|
||||||
|
#include "export.hpp"
|
||||||
|
/****数据管理类
|
||||||
|
* 对模型数据的集中分发、更新
|
||||||
|
*****/
|
||||||
|
typedef QMap<QString,modelStateInfo> ModleStateMap;
|
||||||
|
typedef QMap<QString,modelDataInfo> ModelDataMap;
|
||||||
|
|
||||||
|
class DIAGRAM_DESIGNER_PUBLIC DataManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DataManager(QObject *parent = nullptr);
|
||||||
|
~DataManager();
|
||||||
|
|
||||||
|
static DataManager& instance();
|
||||||
|
public:
|
||||||
|
void initialModelState();
|
||||||
|
void initialModelData();
|
||||||
|
|
||||||
|
void updateModelData(const QString& sModel,QUuid uuid,const QString& sGroup,QMap<QString,propertyStateInfo> mapPro);
|
||||||
|
|
||||||
|
ModleStateMap& modelState();
|
||||||
|
ModelDataMap& modelData();
|
||||||
|
private:
|
||||||
|
ModleStateMap _modelStateInfo; //接收的模型结构信息(可直接返回引用)
|
||||||
|
ModelDataMap _modleDataInfo; //模型实时数据(使用接口获取数据)
|
||||||
|
|
||||||
|
bool _stateInitialised;
|
||||||
|
bool _dataInitialised;
|
||||||
|
};
|
||||||
|
#endif // DATAMANAGER_H
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include "dataManager.h"
|
||||||
|
#include "DataBase.h"
|
||||||
|
|
||||||
|
DataManager& DataManager::instance()
|
||||||
|
{
|
||||||
|
//采用静态局部变量的方式,静态局部变量的初始化是在第一次访问时,以后的调用不会多次初始化,并且生命周期和程序一致
|
||||||
|
static DataManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager::DataManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
_stateInitialised = false;
|
||||||
|
_dataInitialised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager::~DataManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataManager::initialModelState()
|
||||||
|
{
|
||||||
|
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
||||||
|
|
||||||
|
QMap<QString,int>::Iterator iter;
|
||||||
|
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
||||||
|
{
|
||||||
|
modelStateInfo modelInfo;
|
||||||
|
modelInfo.modelType = iter.value(); //模型类型
|
||||||
|
|
||||||
|
groupStateInfo groupInfo;
|
||||||
|
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
||||||
|
|
||||||
|
QMap<QString,propertyGroupState>::Iterator it;
|
||||||
|
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
||||||
|
{
|
||||||
|
groupInfo.groupName = it.key();
|
||||||
|
groupInfo.tableName = it->tableName;
|
||||||
|
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||||
|
|
||||||
|
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
||||||
|
{
|
||||||
|
propertyStateInfo propertyInfo;
|
||||||
|
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QString propertyName = node["name"].toString();
|
||||||
|
int nState = node["checked"].toInt();
|
||||||
|
QString dataType = node["type"].toString();
|
||||||
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
|
int lengthPrecision = node["lengthPrecision"].toInt();
|
||||||
|
if(nState)
|
||||||
|
{
|
||||||
|
//todo:别名赋值
|
||||||
|
propertyInfo.name = propertyName;
|
||||||
|
propertyInfo.type = dataType;
|
||||||
|
propertyInfo.defaultValue = defaultValue;
|
||||||
|
propertyInfo.lengthPrecision = lengthPrecision;
|
||||||
|
|
||||||
|
groupInfo.info.insert(propertyName,propertyInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modelInfo.groupInfo.insert(it.key(),groupInfo);
|
||||||
|
}
|
||||||
|
_modelStateInfo.insert(iter.key(),modelInfo);
|
||||||
|
}
|
||||||
|
_stateInitialised = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataManager::initialModelData()
|
||||||
|
{
|
||||||
|
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
||||||
|
|
||||||
|
QMap<QString,int>::Iterator iter;
|
||||||
|
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
||||||
|
{
|
||||||
|
modelDataInfo modelInfo;
|
||||||
|
modelInfo.modelType = iter.value(); //模型类型
|
||||||
|
|
||||||
|
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
||||||
|
|
||||||
|
QMap<QString,propertyGroupState>::Iterator it;
|
||||||
|
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
||||||
|
{
|
||||||
|
groupStateValue groupValue;
|
||||||
|
groupValue.groupName = it.key();
|
||||||
|
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||||
|
|
||||||
|
QStringList lstParam; //需检索的属性组中属性名列表
|
||||||
|
|
||||||
|
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
||||||
|
{
|
||||||
|
propertyStateInfo propertyInfo;
|
||||||
|
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QString propertyName = node["name"].toString();
|
||||||
|
int nState = node["checked"].toInt();
|
||||||
|
QString dataType = node["type"].toString();
|
||||||
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
|
|
||||||
|
if(nState)
|
||||||
|
{
|
||||||
|
lstParam.append(propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lstParam.append("global_uuid"); //全局id未添加到属性状态中,手动选择
|
||||||
|
groupValue.mapInfo = DataBase::GetInstance()->selectGroupProperty(it->tableName,lstParam); //返回表中属性值
|
||||||
|
|
||||||
|
modelInfo.groupInfo.insert(it.key(),groupValue);
|
||||||
|
}
|
||||||
|
_modleDataInfo.insert(iter.key(),modelInfo);
|
||||||
|
}
|
||||||
|
_dataInitialised = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataManager::updateModelData(const QString& sModel,QUuid uuid,const QString& sGroup,QMap<QString,propertyStateInfo> mapPro)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ModleStateMap& DataManager::modelState()
|
||||||
|
{
|
||||||
|
if(!_stateInitialised)
|
||||||
|
initialModelState();
|
||||||
|
return _modelStateInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelDataMap& DataManager::modelData()
|
||||||
|
{
|
||||||
|
if(!_dataInitialised)
|
||||||
|
initialModelData();
|
||||||
|
return _modleDataInfo;
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ public slots:
|
||||||
private:
|
private:
|
||||||
ToolBox* m_pToolBox;
|
ToolBox* m_pToolBox;
|
||||||
QMap<QString,ElectricElementsPanel*> m_mapPanels;
|
QMap<QString,ElectricElementsPanel*> m_mapPanels;
|
||||||
QMap<QString,modelStateInfo> _modelInfo; //模型信息
|
QMap<QString,modelStateInfo> _modelInfo; //模型结构信息
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
#include "toolBox.h"
|
#include "toolBox.h"
|
||||||
#include "util/baseSelector.h"
|
#include "util/baseSelector.h"
|
||||||
#include "dataBase.h"
|
#include "dataBase.h"
|
||||||
|
#include "dataManager.h"
|
||||||
|
|
||||||
ElectricElementsBox::ElectricElementsBox(QObject *parent)
|
ElectricElementsBox::ElectricElementsBox(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_pToolBox(nullptr)
|
m_pToolBox(nullptr)
|
||||||
{
|
{
|
||||||
m_pToolBox = new ToolBox();
|
m_pToolBox = new ToolBox();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ElectricElementsBox::~ElectricElementsBox()
|
ElectricElementsBox::~ElectricElementsBox()
|
||||||
|
|
@ -22,6 +22,7 @@ ElectricElementsBox::~ElectricElementsBox()
|
||||||
|
|
||||||
void ElectricElementsBox::initial()
|
void ElectricElementsBox::initial()
|
||||||
{
|
{
|
||||||
|
getModelInfo();
|
||||||
addPanelItems("Items");
|
addPanelItems("Items");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,48 +49,9 @@ ToolBox* ElectricElementsBox::getToolBox() const
|
||||||
|
|
||||||
void ElectricElementsBox::getModelInfo()
|
void ElectricElementsBox::getModelInfo()
|
||||||
{
|
{
|
||||||
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
DataManager::instance().initialModelState();
|
||||||
|
DataManager::instance().initialModelData();
|
||||||
QMap<QString,int>::Iterator iter;
|
_modelInfo = DataManager::instance().modelState();
|
||||||
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
|
||||||
{
|
|
||||||
modelStateInfo modelInfo;
|
|
||||||
modelInfo.modelType = iter.value(); //模型类型
|
|
||||||
|
|
||||||
groupStateInfo groupInfo;
|
|
||||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
|
||||||
|
|
||||||
QMap<QString,propertyGroupState>::Iterator it;
|
|
||||||
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
|
||||||
{
|
|
||||||
groupInfo.groupName = it.key();
|
|
||||||
groupInfo.tableName = it->tableName;
|
|
||||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
|
||||||
|
|
||||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
|
||||||
{
|
|
||||||
propertyStateInfo propertyInfo;
|
|
||||||
|
|
||||||
QJsonObject node = nodeJson.toObject();
|
|
||||||
QString propertyName = node["name"].toString();
|
|
||||||
int nState = node["checked"].toInt();
|
|
||||||
QString dataType = node["type"].toString();
|
|
||||||
QString defaultValue = node["defaultValue"].toString();
|
|
||||||
|
|
||||||
if(nState)
|
|
||||||
{
|
|
||||||
//todo:别名赋值
|
|
||||||
propertyInfo.name = propertyName;
|
|
||||||
propertyInfo.type = dataType;
|
|
||||||
propertyInfo.defaultValue = defaultValue;
|
|
||||||
|
|
||||||
groupInfo.info.insert(propertyName,propertyInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
modelInfo.groupInfo.insert(it.key(),groupInfo);
|
|
||||||
}
|
|
||||||
_modelInfo.insert(iter.key(),modelInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricElementsBox::updateModelList()
|
void ElectricElementsBox::updateModelList()
|
||||||
|
|
|
||||||
|
|
@ -936,6 +936,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
node["checked"] = 1;
|
node["checked"] = 1;
|
||||||
node["type"] = dataTypePart;
|
node["type"] = dataTypePart;
|
||||||
node["defaultValue"] = defaultValue;
|
node["defaultValue"] = defaultValue;
|
||||||
|
node["lengthPrecision"] = lengthPrecision;
|
||||||
arrState.append(node);
|
arrState.append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -963,6 +964,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
node["checked"] = 0;
|
node["checked"] = 0;
|
||||||
node["type"] = dataTypePart;
|
node["type"] = dataTypePart;
|
||||||
node["defaultValue"] = defaultValue;
|
node["defaultValue"] = defaultValue;
|
||||||
|
node["lengthPrecision"] = lengthPrecision;
|
||||||
arrState.append(node);
|
arrState.append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue