add load project model logical
This commit is contained in:
parent
2660140626
commit
f34fe96ae4
|
|
@ -70,6 +70,7 @@ set(CPP_SOURCE_FILES
|
||||||
source/renameModel.cpp
|
source/renameModel.cpp
|
||||||
|
|
||||||
common/source/httpInterface.cpp
|
common/source/httpInterface.cpp
|
||||||
|
common/source/global.cpp
|
||||||
)
|
)
|
||||||
set(UI_FILES
|
set(UI_FILES
|
||||||
ui/mainwindow.ui
|
ui/mainwindow.ui
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,14 @@ enum GraphicsItemType
|
||||||
|
|
||||||
enum AbstractItemType //工程模关联的对象类型
|
enum AbstractItemType //工程模关联的对象类型
|
||||||
{
|
{
|
||||||
|
AIT_bus = 1,
|
||||||
|
AIT_motor
|
||||||
|
};
|
||||||
|
|
||||||
|
class corresbondItem //类型关联函数
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QMap<AbstractItemType,GraphicsItemType> linkType;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DiagramMode //组态图模式
|
enum DiagramMode //组态图模式
|
||||||
|
|
@ -123,12 +130,60 @@ struct projectManager //工程模管理类
|
||||||
QJsonObject checkState; //属性选择状态
|
QJsonObject checkState; //属性选择状态
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//=====================================
|
||||||
|
struct propertyGroupState //模型属性组信息
|
||||||
|
{
|
||||||
|
QString groupName; //属性组名称
|
||||||
|
QString tableName; //属性组表名
|
||||||
|
QJsonObject propertyState; //属性状态信息
|
||||||
|
};
|
||||||
|
|
||||||
|
//================工程模使用======================
|
||||||
|
|
||||||
|
struct propertyStateInfo //属性
|
||||||
|
{
|
||||||
|
QString name; //属性名
|
||||||
|
QString tagName; //别名
|
||||||
|
QString type; //属性类型
|
||||||
|
QString defaultValue; //默认值
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QMap<QString,propertyStateInfo> PropertyValueInfo;
|
||||||
|
|
||||||
|
struct groupStateInfo //属性组(结构信息)
|
||||||
|
{
|
||||||
|
QString groupName; //组名
|
||||||
|
QString tableName; //表名
|
||||||
|
PropertyValueInfo info; //属性信息
|
||||||
|
};
|
||||||
|
|
||||||
|
struct groupStateValue //属性组(实时数据)
|
||||||
|
{
|
||||||
|
QString groupName; //组名
|
||||||
|
QString tableName; //表名
|
||||||
|
QMap<QUuid,PropertyValueInfo> mapInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct modelStateInfo //模型结构信息
|
||||||
|
{
|
||||||
|
QString modelName;
|
||||||
|
int modelType;
|
||||||
|
QMap<QString,groupStateInfo> groupInfo; //属性组信息
|
||||||
|
};
|
||||||
|
|
||||||
|
struct modelDataInfo //模型数据信息
|
||||||
|
{
|
||||||
|
QString modelName;
|
||||||
|
int modelType;
|
||||||
|
QMap<QString,groupStateValue> groupInfo; //属性组实时信息
|
||||||
|
};
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
struct componentInfo
|
struct componentInfo
|
||||||
{
|
{
|
||||||
int id = 0;
|
int id = 0;
|
||||||
QUuid uuid;
|
QUuid uuid;
|
||||||
|
QString modelName;
|
||||||
QString nspath;
|
QString nspath;
|
||||||
QString tag;
|
QString tag;
|
||||||
QString name;
|
QString name;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
QMap<AbstractItemType,GraphicsItemType> corresbondItem::linkType = {
|
||||||
|
{AIT_bus,GIT_bus},
|
||||||
|
};
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
void initial();
|
void initial();
|
||||||
public slots:
|
public slots:
|
||||||
void onSignal_addDrawingPanel(const QString& sTitile,DiagramMode = DM_edit);
|
void onSignal_addDrawingPanel(const QString& sTitile,DiagramMode = DM_edit);
|
||||||
void onSignal_addGraphicsItem(GraphicsItemType&);
|
void onSignal_addGraphicsItem(modelStateInfo&);
|
||||||
void onSignal_addPage();
|
void onSignal_addPage();
|
||||||
void onSignal_savePage();
|
void onSignal_savePage();
|
||||||
void onSignal_loadPage(const QString&);
|
void onSignal_loadPage(const QString&);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *closeEvent);
|
void closeEvent(QCloseEvent *closeEvent);
|
||||||
public slots:
|
public slots:
|
||||||
void onSignal_addGraphicsItem(GraphicsItemType&);
|
void onSignal_addGraphicsItem(modelStateInfo&);
|
||||||
private:
|
private:
|
||||||
Ui::drawingPanel *ui;
|
Ui::drawingPanel *ui;
|
||||||
DesignerView* m_pGraphicsView;
|
DesignerView* m_pGraphicsView;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
bool addNodeItem(QUuid uuid,GraphicsBaseItem*);
|
bool addNodeItem(QUuid uuid,GraphicsBaseItem*);
|
||||||
void addNodeItem(QUuid id,/*int type,*/QPointF pos);
|
void addNodeItem(QUuid id,/*int type,*/QPointF pos);
|
||||||
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
||||||
BaseProperty* addNodeData(QUuid id,int type,QString name); //对应component数据,一个data可对应多个item
|
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item
|
||||||
void loadNodeDataFromDataBase(); //从数据库加载数据
|
void loadNodeDataFromDataBase(); //从数据库加载数据
|
||||||
void addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort);
|
void addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort);
|
||||||
void deleteNodeItem(GraphicsBaseItem*);
|
void deleteNodeItem(GraphicsBaseItem*);
|
||||||
|
|
@ -37,6 +37,9 @@ 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 getModelData(); //获取模型数据
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activatePage(const QString&); //激活当前model所在page
|
void activatePage(const QString&); //激活当前model所在page
|
||||||
public:
|
public:
|
||||||
|
|
@ -58,6 +61,8 @@ private:
|
||||||
DrawingPanel* _widget; //顶层widget
|
DrawingPanel* _widget; //顶层widget
|
||||||
HttpInterface* _Interface;
|
HttpInterface* _Interface;
|
||||||
QTimer* _timer;
|
QTimer* _timer;
|
||||||
|
QMap<QString,modelStateInfo> _modelStateInfo; //接收的模型结构信息
|
||||||
|
QMap<QString,modelDataInfo> _modleDataInfo; //模型实时数据
|
||||||
public:
|
public:
|
||||||
static bool _dataInitialised;
|
static bool _dataInitialised;
|
||||||
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
||||||
|
|
|
||||||
|
|
@ -486,6 +486,8 @@ public:
|
||||||
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;}
|
||||||
|
virtual void setModelName(QString sName){_modelName = sName;}
|
||||||
|
virtual QString getModelName() const {return _modelName;}
|
||||||
protected:
|
protected:
|
||||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
||||||
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
|
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
|
||||||
|
|
@ -505,6 +507,7 @@ protected:
|
||||||
int _lastPort; //最后触碰的port
|
int _lastPort; //最后触碰的port
|
||||||
BaseProperty* _property;
|
BaseProperty* _property;
|
||||||
bool _itemChanged; //图元变化标志,判断是否需要保存
|
bool _itemChanged; //图元变化标志,判断是否需要保存
|
||||||
|
QString _modelName; //当前图元使用的模型名,用来在model中检索属性信息
|
||||||
};
|
};
|
||||||
|
|
||||||
class BaseProperty:public QObject //属性类,存放电路元件属性
|
class BaseProperty:public QObject //属性类,存放电路元件属性
|
||||||
|
|
@ -516,6 +519,8 @@ public:
|
||||||
|
|
||||||
void setUuid(QUuid id) {uUid = id;}
|
void setUuid(QUuid id) {uUid = id;}
|
||||||
QUuid uuid() const {return uUid;}
|
QUuid uuid() const {return uUid;}
|
||||||
|
void setModelName(QString sName) {sModelName = sName;}
|
||||||
|
QString modelName() const {return sModelName;}
|
||||||
void setType(int n) {nType = n;}
|
void setType(int n) {nType = n;}
|
||||||
int type() const {return nType;}
|
int type() const {return nType;}
|
||||||
void setPage(int n){nPageId = n;}
|
void setPage(int n){nPageId = n;}
|
||||||
|
|
@ -554,6 +559,7 @@ signals:
|
||||||
void updateData(); //通知数据拥有者更新
|
void updateData(); //通知数据拥有者更新
|
||||||
protected:
|
protected:
|
||||||
QUuid uUid;
|
QUuid uUid;
|
||||||
|
QString sModelName; //模型名
|
||||||
int nType; //设备类型
|
int nType; //设备类型
|
||||||
int nPageId; //暂定为创建本数据的图Id(待定)
|
int nPageId; //暂定为创建本数据的图Id(待定)
|
||||||
QString sTag;
|
QString sTag;
|
||||||
|
|
@ -573,4 +579,17 @@ protected:
|
||||||
bool _prepareDelete; //状态,为真准备删除
|
bool _prepareDelete; //状态,为真准备删除
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef QMap<QString,QVariant> VariableMap; //属性名,值
|
||||||
|
|
||||||
|
class VariableProperty:public BaseProperty //收到的变量数据
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VariableProperty(QObject* parent);
|
||||||
|
~VariableProperty();
|
||||||
|
QMap<QString,VariableMap>& getMapGroup() {return _MapGroup;}
|
||||||
|
private:
|
||||||
|
QMap<QString,VariableMap> _MapGroup; //<属性组,属性集>
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ public:
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
||||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
||||||
|
|
||||||
void setCreatingItem(GraphicsItemType& type) { m_creatingItemType=type; }
|
void setCreatingItem(modelStateInfo& info) { m_creatingItemInfo=info; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CreatingMethod m_creatingMethod;
|
CreatingMethod m_creatingMethod;
|
||||||
GraphicsItemType m_creatingItemType;
|
modelStateInfo m_creatingItemInfo;
|
||||||
GraphicsBaseItem* m_pCreatingItem;
|
GraphicsBaseItem* m_pCreatingItem;
|
||||||
QPointF m_scalBasePoint;
|
QPointF m_scalBasePoint;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
void setWorkingSelector(SelectorType s) { m_curSelector=s; }
|
void setWorkingSelector(SelectorType s) { m_curSelector=s; }
|
||||||
BaseSelector* getWorkingSelector(); //根据操作方式获取selector
|
BaseSelector* getWorkingSelector(); //根据操作方式获取selector
|
||||||
|
|
||||||
void setDrawGraphicsItem(GraphicsItemType);
|
void setDrawGraphicsItem(modelStateInfo&);
|
||||||
void setName(const QString&);
|
void setName(const QString&);
|
||||||
public slots:
|
public slots:
|
||||||
void onSignal_setWorkingSelector(SelectorType);
|
void onSignal_setWorkingSelector(SelectorType);
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ void DiagramCavas::onSignal_addDrawingPanel(const QString& sTitile,DiagramMode m
|
||||||
connect(pPanel,&DrawingPanel::panelDelete,this,&DiagramCavas::onSignal_panelDelete);
|
connect(pPanel,&DrawingPanel::panelDelete,this,&DiagramCavas::onSignal_panelDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramCavas::onSignal_addGraphicsItem(GraphicsItemType& type)
|
void DiagramCavas::onSignal_addGraphicsItem(modelStateInfo& info)
|
||||||
{
|
{
|
||||||
QWidget* pWindow= currentSubWindow()->widget();
|
QWidget* pWindow= currentSubWindow()->widget();
|
||||||
DrawingPanel* pPanel = dynamic_cast<DrawingPanel*>(pWindow);
|
DrawingPanel* pPanel = dynamic_cast<DrawingPanel*>(pWindow);
|
||||||
|
|
||||||
if(pPanel)
|
if(pPanel)
|
||||||
pPanel->onSignal_addGraphicsItem(type);
|
pPanel->onSignal_addGraphicsItem(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramCavas::onSignal_addPage()
|
void DiagramCavas::onSignal_addPage()
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,12 @@ void DrawingPanel::closeEvent(QCloseEvent *closeEvent)
|
||||||
emit panelDelete(_name);
|
emit panelDelete(_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawingPanel::onSignal_addGraphicsItem(GraphicsItemType& itemType)
|
void DrawingPanel::onSignal_addGraphicsItem(modelStateInfo& info)
|
||||||
{
|
{
|
||||||
if(m_pSelectorManager)
|
if(m_pSelectorManager)
|
||||||
{
|
{
|
||||||
m_pSelectorManager->setWorkingSelector(ST_cerating);
|
m_pSelectorManager->setWorkingSelector(ST_cerating);
|
||||||
m_pSelectorManager->setDrawGraphicsItem(itemType);
|
m_pSelectorManager->setDrawGraphicsItem(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
item->addPoint(pos);
|
item->addPoint(pos);
|
||||||
item->setProperty(pro); //绑定模型
|
item->setProperty(pro); //绑定模型
|
||||||
item->updateByProperty(); //使用模型更新自身
|
item->updateByProperty(); //使用模型更新自身
|
||||||
|
item->setModelName(pro->modelName());
|
||||||
_nodeItem.insert(id,item);
|
_nodeItem.insert(id,item);
|
||||||
connect(item,&GraphicsBaseItem::ifExist,this,&FixedPortsModel::onSignal_ifExits);
|
connect(item,&GraphicsBaseItem::ifExist,this,&FixedPortsModel::onSignal_ifExits);
|
||||||
}
|
}
|
||||||
|
|
@ -131,26 +132,34 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name)
|
BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name,QString modelName)
|
||||||
{
|
{
|
||||||
if(_nodeData.contains(id))
|
if(_nodeData.contains(id))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
BaseProperty* item = nullptr;
|
modelStateInfo modelInfo;
|
||||||
if(type == GIT_itemTri)
|
for(auto &model:_modelStateInfo){ //找到对象对应的工程模
|
||||||
{
|
if(model.modelName == modelName){
|
||||||
item = new ElectricSvgItemTriangle_Property(this);
|
modelInfo = model;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if(type == GIT_itemRect)
|
|
||||||
{
|
|
||||||
item = new ElectricSvgItemRect_Property(this);
|
|
||||||
}
|
}
|
||||||
else if(type == GIT_bus)
|
|
||||||
|
VariableProperty* item = new VariableProperty(this);
|
||||||
|
QMap<QString,VariableMap>& propertyGroup = item->getMapGroup();
|
||||||
|
for(auto &groupInfo:modelInfo.groupInfo)
|
||||||
{
|
{
|
||||||
item = new ElectricSvgItemBus_Property(this);
|
VariableMap map;
|
||||||
|
for(auto &pro:groupInfo.info)
|
||||||
|
{
|
||||||
|
map.insert(pro.name,pro.defaultValue); //添加属性信息
|
||||||
}
|
}
|
||||||
|
propertyGroup.insert(groupInfo.groupName,map);
|
||||||
|
}
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
item->setUuid(id);
|
item->setUuid(id);
|
||||||
|
item->setModelName(modelName);
|
||||||
item->setType(type);
|
item->setType(type);
|
||||||
item->setTag(name);
|
item->setTag(name);
|
||||||
item->setName(name);
|
item->setName(name);
|
||||||
|
|
@ -166,7 +175,7 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
QList<componentInfo> lst= DataBase::GetInstance()->getAllComponents();
|
QList<componentInfo> lst= DataBase::GetInstance()->getAllComponents();
|
||||||
for(auto &info:lst)
|
for(auto &info:lst)
|
||||||
{
|
{
|
||||||
BaseProperty* pData = addNodeData(info.uuid,info.type,info.name);
|
BaseProperty* pData = addNodeData(info.uuid,info.type,info.name,info.modelName);
|
||||||
pData->setPage(info.page_id);
|
pData->setPage(info.page_id);
|
||||||
pData->setTag(info.tag);
|
pData->setTag(info.tag);
|
||||||
pData->setName(info.name);
|
pData->setName(info.name);
|
||||||
|
|
@ -182,6 +191,28 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
pData->setStation(info.station);
|
pData->setStation(info.station);
|
||||||
pData->setDataChanged(false);
|
pData->setDataChanged(false);
|
||||||
|
|
||||||
|
VariableProperty* pPro = dynamic_cast<VariableProperty*>(pData);
|
||||||
|
if(pPro)
|
||||||
|
{
|
||||||
|
QMap<QString,VariableMap>& mapVariableGroup = pPro->getMapGroup();
|
||||||
|
|
||||||
|
QMap<QString,groupStateValue> mapGroup = _modleDataInfo[info.modelName].groupInfo; //取得该模型下的所有属性组
|
||||||
|
QMap<QString,groupStateValue>::Iterator iter;
|
||||||
|
for(iter = mapGroup.begin();iter != mapGroup.end();++iter)
|
||||||
|
{
|
||||||
|
VariableMap varMap;
|
||||||
|
|
||||||
|
PropertyValueInfo valueInfo = iter->mapInfo[info.uuid];
|
||||||
|
PropertyValueInfo::Iterator it;
|
||||||
|
for(it = valueInfo.begin(); it != valueInfo.end();++it)
|
||||||
|
{
|
||||||
|
varMap.insert(it.key(),it->defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapVariableGroup.insert(iter.key(),varMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(info.type == GIT_itemTri)
|
if(info.type == GIT_itemTri)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -451,7 +482,7 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->connectedBus(),pData->label(),pData->context(),nPageId,1);
|
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->modelName(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->connectedBus(),pData->label(),pData->context(),nPageId,1);
|
||||||
int type = pData->type();
|
int type = pData->type();
|
||||||
if(type == GIT_itemRect)
|
if(type == GIT_itemRect)
|
||||||
{
|
{
|
||||||
|
|
@ -512,7 +543,7 @@ void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,Grap
|
||||||
}
|
}
|
||||||
else //创建新data并绑定
|
else //创建新data并绑定
|
||||||
{
|
{
|
||||||
BaseProperty* pItem = addNodeData(id,type,str);
|
BaseProperty* pItem = addNodeData(id,type,str,pitem->getModelName());
|
||||||
if(pItem)
|
if(pItem)
|
||||||
{
|
{
|
||||||
pitem->setProperty(pItem);
|
pitem->setProperty(pItem);
|
||||||
|
|
@ -569,3 +600,101 @@ QWidget* FixedPortsModel::getTopWidget()
|
||||||
return dynamic_cast<QWidget*>(_widget);
|
return dynamic_cast<QWidget*>(_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::addModelProperty(modelStateInfo info)
|
||||||
|
{
|
||||||
|
if(!_modelStateInfo.contains(info.modelName))
|
||||||
|
{
|
||||||
|
_modelStateInfo.insert(info.modelName,info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::getModelInfo()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -321,3 +321,16 @@ BaseProperty::~BaseProperty()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************属性变量*************************/
|
||||||
|
|
||||||
|
VariableProperty::VariableProperty(QObject* parent)
|
||||||
|
:BaseProperty(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableProperty::~VariableProperty()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
|
||||||
{
|
{
|
||||||
scene->clearSelection();
|
scene->clearSelection();
|
||||||
|
|
||||||
switch (m_creatingItemType)
|
switch (m_creatingItemInfo.modelType)
|
||||||
{
|
{
|
||||||
case GIT_rect:
|
case GIT_rect:
|
||||||
{
|
{
|
||||||
|
|
@ -111,7 +111,9 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
|
||||||
m_pCreatingItem->addPoint(ms_ptMouseDown);
|
m_pCreatingItem->addPoint(ms_ptMouseDown);
|
||||||
ms_nDragHandle = m_pCreatingItem->handleCount();
|
ms_nDragHandle = m_pCreatingItem->handleCount();
|
||||||
//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);
|
||||||
_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,14 @@ BaseSelector* SelectorManager::getWorkingSelector()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectorManager::setDrawGraphicsItem(GraphicsItemType item)
|
void SelectorManager::setDrawGraphicsItem(modelStateInfo& info)
|
||||||
{
|
{
|
||||||
for(auto it = m_vecSelectors.begin(); it != m_vecSelectors.end(); it++)
|
for(auto it = m_vecSelectors.begin(); it != m_vecSelectors.end(); it++)
|
||||||
{
|
{
|
||||||
if((*it)->getSelectorType()==ST_cerating)
|
if((*it)->getSelectorType()==ST_cerating)
|
||||||
{
|
{
|
||||||
CreatingSelector* creatingSelector = dynamic_cast<CreatingSelector*>(*it);
|
CreatingSelector* creatingSelector = dynamic_cast<CreatingSelector*>(*it);
|
||||||
creatingSelector->setCreatingItem(item);
|
creatingSelector->setCreatingItem(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,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
|
||||||
|
../common/source/global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public:
|
||||||
busStability getBusStabilityById(int componentId);
|
busStability getBusStabilityById(int componentId);
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
|
bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
|
||||||
bool insertComponent(QUuid uuid,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
|
bool insertComponent(QUuid uuid,QString modelName,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
|
||||||
componentInfo getComponentInfoByUuid(QString uuid);
|
componentInfo getComponentInfoByUuid(QString uuid);
|
||||||
QList<componentInfo> getAllComponents();
|
QList<componentInfo> getAllComponents();
|
||||||
bool componentExist(QString uuid);
|
bool componentExist(QString uuid);
|
||||||
|
|
@ -85,7 +85,9 @@ public:
|
||||||
bool modifyProjectTable(QString sTable,QMap<QString,QString> mOld,QMap<QString,QString> mNew);
|
bool modifyProjectTable(QString sTable,QMap<QString,QString> mOld,QMap<QString,QString> mNew);
|
||||||
//**********使用工程模
|
//**********使用工程模
|
||||||
QMap<QString,int> getAllProjectModel(); //获取所有工程模<名称,图元类型>
|
QMap<QString,int> getAllProjectModel(); //获取所有工程模<名称,图元类型>
|
||||||
|
QMap<QString,propertyGroupState> getModelInfo(const QString&); //获取模型信息
|
||||||
QMap<QString,projectManager> getProjectModelGroupInfo(const QString&); //获取指定工程模所有属性组信息<属性组名,属性信息>
|
QMap<QString,projectManager> getProjectModelGroupInfo(const QString&); //获取指定工程模所有属性组信息<属性组名,属性信息>
|
||||||
|
QMap<QUuid,PropertyValueInfo> selectGroupProperty(const QString& tableName,const QStringList& paramList); //返回属性组表中的信息
|
||||||
private:
|
private:
|
||||||
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
||||||
QMap<int,dataType> _dataType; //数据类型组
|
QMap<int,dataType> _dataType; //数据类型组
|
||||||
|
|
|
||||||
|
|
@ -225,51 +225,28 @@ QSqlQuery DataBase::executeBatchSQL(const QStringList& sqlStatements, bool creat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DataBase::insertComponent(QUuid uuid,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op)
|
bool DataBase::insertComponent(QUuid uuid,QString modelName,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op)
|
||||||
{
|
{
|
||||||
if(db.open())
|
if(db.open())
|
||||||
{
|
{
|
||||||
QSqlQuery qry(db);
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
/*QJsonDocument busDoc(connected_bus);
|
|
||||||
QString strBus = busDoc.toJson(QJsonDocument::Compact);
|
|
||||||
|
|
||||||
QJsonDocument labelDoc(label);
|
|
||||||
QString strLabel = labelDoc.toJson(QJsonDocument::Compact);*/
|
|
||||||
|
|
||||||
QJsonDocument contextDoc(context);
|
QJsonDocument contextDoc(context);
|
||||||
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
|
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
/*qry.prepare("INSERT INTO component(global_uuid, nspath, tag, name, description, grid, zone, station, type, in_service, state, connected_bus, label, context, page_id, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
qry.prepare("INSERT INTO component(global_uuid, model_name,tag, name, grid, zone, station, type, context, page_id, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
qry.bindValue(0,uuid);
|
qry.bindValue(0,uuid);
|
||||||
qry.bindValue(1,nspath);
|
qry.bindValue(1,modelName);
|
||||||
qry.bindValue(2,tag);
|
qry.bindValue(2,tag);
|
||||||
qry.bindValue(3,name);
|
qry.bindValue(3,name);
|
||||||
qry.bindValue(4,description);
|
qry.bindValue(4,grid);
|
||||||
qry.bindValue(5,grid);
|
qry.bindValue(5,zone);
|
||||||
qry.bindValue(6,zone);
|
qry.bindValue(6,station);
|
||||||
qry.bindValue(7,station);
|
qry.bindValue(7,type);
|
||||||
qry.bindValue(8,type);
|
qry.bindValue(8,strCon);
|
||||||
qry.bindValue(9,inService);
|
qry.bindValue(9,page_id);
|
||||||
qry.bindValue(10,state);
|
qry.bindValue(10,op);
|
||||||
qry.bindValue(11,strBus);
|
qry.bindValue(11,QDateTime::currentDateTime());
|
||||||
qry.bindValue(12,strLabel);
|
|
||||||
qry.bindValue(13,strCon);
|
|
||||||
qry.bindValue(14,page_id);
|
|
||||||
qry.bindValue(15,op);
|
|
||||||
qry.bindValue(16,QDateTime::currentDateTime());*/
|
|
||||||
qry.prepare("INSERT INTO component(global_uuid, tag, name, grid, zone, station, type, context, page_id, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
|
||||||
qry.bindValue(0,uuid);
|
|
||||||
qry.bindValue(1,tag);
|
|
||||||
qry.bindValue(2,name);
|
|
||||||
qry.bindValue(3,grid);
|
|
||||||
qry.bindValue(4,zone);
|
|
||||||
qry.bindValue(5,station);
|
|
||||||
qry.bindValue(6,type);
|
|
||||||
qry.bindValue(7,strCon);
|
|
||||||
qry.bindValue(8,page_id);
|
|
||||||
qry.bindValue(9,op);
|
|
||||||
qry.bindValue(10,QDateTime::currentDateTime());
|
|
||||||
bool res = qry.exec();
|
bool res = qry.exec();
|
||||||
QString str = qry.lastQuery();
|
QString str = qry.lastQuery();
|
||||||
const QVariantList list = qry.boundValues();
|
const QVariantList list = qry.boundValues();
|
||||||
|
|
@ -557,7 +534,7 @@ componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
||||||
QSqlQuery qry(db);
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
//qry.prepare("SELECT * FROM component WHERE global_uuid = ?");
|
//qry.prepare("SELECT * FROM component WHERE global_uuid = ?");
|
||||||
qry.prepare("SELECT id, global_uuid, tag, name, grid, zone, station, type, context, page_id, op FROM component WHERE global_uuid = ?");
|
qry.prepare("SELECT id, global_uuid, model_name, tag, name, grid, zone, station, type, context, page_id, op FROM component WHERE global_uuid = ?");
|
||||||
qry.bindValue(0,uuid);
|
qry.bindValue(0,uuid);
|
||||||
bool res = qry.exec();
|
bool res = qry.exec();
|
||||||
QString str = qry.lastQuery();
|
QString str = qry.lastQuery();
|
||||||
|
|
@ -572,16 +549,17 @@ componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
||||||
{
|
{
|
||||||
inf.id = qry.value(0).toInt();
|
inf.id = qry.value(0).toInt();
|
||||||
inf.uuid = QUuid(qry.value(1).toString());
|
inf.uuid = QUuid(qry.value(1).toString());
|
||||||
inf.tag = qry.value(2).toString();
|
inf.modelName = qry.value(2).toString();
|
||||||
inf.name = qry.value(3).toString();
|
inf.tag = qry.value(3).toString();
|
||||||
inf.grid = qry.value(4).toString();
|
inf.name = qry.value(4).toString();
|
||||||
inf.zone = qry.value(5).toString();
|
inf.grid = qry.value(5).toString();
|
||||||
inf.station = qry.value(6).toString();
|
inf.zone = qry.value(6).toString();
|
||||||
inf.type = qry.value(7).toInt();
|
inf.station = qry.value(7).toString();
|
||||||
QString str = qry.value(8).toString();
|
inf.type = qry.value(8).toInt();
|
||||||
|
QString str = qry.value(9).toString();
|
||||||
inf.context = QstringToJson(str);
|
inf.context = QstringToJson(str);
|
||||||
inf.page_id = qry.value(9).toInt();
|
inf.page_id = qry.value(10).toInt();
|
||||||
inf.op = qry.value(10).toInt();
|
inf.op = qry.value(11).toInt();
|
||||||
qry.clear();
|
qry.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1367,6 +1345,33 @@ QMap<QString,int> DataBase::getAllProjectModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString,propertyGroupState> DataBase::getModelInfo(const QString& sProject)
|
||||||
|
{
|
||||||
|
QMap<QString,propertyGroupState> map;
|
||||||
|
QString strSQL = "SELECT group_name,name,check_state FROM project_manager WHERE tag = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(sProject);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
propertyGroupState sta;
|
||||||
|
sta.groupName = query.value(0).toString();
|
||||||
|
sta.tableName = query.value(1).toString();
|
||||||
|
sta.propertyState = QstringToJson(query.value(2).toString());
|
||||||
|
map.insert(sta.groupName,sta);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString,projectManager> DataBase::getProjectModelGroupInfo(const QString& sTable)
|
QMap<QString,projectManager> DataBase::getProjectModelGroupInfo(const QString& sTable)
|
||||||
{
|
{
|
||||||
QMap<QString,projectManager> map;
|
QMap<QString,projectManager> map;
|
||||||
|
|
@ -1401,6 +1406,40 @@ QMap<QString,projectManager> DataBase::getProjectModelGroupInfo(const QString& s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& tableName,const QStringList& paramList)
|
||||||
|
{
|
||||||
|
QString strSQL = QString("SELECT %1 FROM %2").arg(paramList.join(", ")).arg(tableName);
|
||||||
|
QMap<QUuid,PropertyValueInfo> map;
|
||||||
|
PropertyValueInfo info;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QUuid uuid;
|
||||||
|
for(auto ¶m:paramList)
|
||||||
|
{
|
||||||
|
propertyStateInfo pro;
|
||||||
|
if(param == "global_uuid")
|
||||||
|
{
|
||||||
|
uuid = QUuid(query.value(param).toString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pro.defaultValue = query.value(param).toString();
|
||||||
|
info.insert(param,pro);
|
||||||
|
}
|
||||||
|
map.insert(uuid,info);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DataBase::createDynamicTable(const QString &tableName, const QStringList &fields)
|
bool DataBase::createDynamicTable(const QString &tableName, const QStringList &fields)
|
||||||
{
|
{
|
||||||
QString strSQL = "CREATE TABLE IF NOT EXISTS " + tableName + " (";
|
QString strSQL = "CREATE TABLE IF NOT EXISTS " + tableName + " (";
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,18 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initial();
|
void initial();
|
||||||
|
void addPanelItems(const QString& sPanel); //添加面板图元
|
||||||
ToolBox* getToolBox() const;
|
ToolBox* getToolBox() const;
|
||||||
void updateProjectModelItemList(); //更新工程模对象列表
|
void getModelInfo(); //获取模型信息
|
||||||
|
void updateModelList(); //更新工程模对象列表
|
||||||
signals:
|
signals:
|
||||||
void addEletricItem(GraphicsItemType&);
|
void addEletricItem(modelStateInfo&);
|
||||||
public slots:
|
public slots:
|
||||||
void onSignal_addEletricItem(GraphicsItemType&);
|
void onSignal_addEletricItem(modelStateInfo&);
|
||||||
private:
|
private:
|
||||||
ToolBox* m_pToolBox;
|
ToolBox* m_pToolBox;
|
||||||
QMap<QString,ElectricElementsPanel*> m_mapPanels;
|
QMap<QString,ElectricElementsPanel*> m_mapPanels;
|
||||||
|
QMap<QString,modelStateInfo> _modelInfo; //模型信息
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,16 @@ public:
|
||||||
~ElectricElementsPanel();
|
~ElectricElementsPanel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addGraphicsItem(GraphicsItemType&);
|
void addGraphicsItem(modelStateInfo&);
|
||||||
public:
|
public:
|
||||||
void setData(const QMap<QString,GraphicsItemType>&);
|
void setData(QMap<QString,modelStateInfo>);
|
||||||
private:
|
private:
|
||||||
void initial();
|
void initial();
|
||||||
public slots:
|
public slots:
|
||||||
void onItemClicked(QListWidgetItem*);
|
void onItemClicked(QListWidgetItem*);
|
||||||
private:
|
private:
|
||||||
ElectricElementsListwidget* m_pListWidget;
|
ElectricElementsListwidget* m_pListWidget;
|
||||||
QMap<QString,GraphicsItemType> m_mapEleData;
|
QMap<QString,modelStateInfo> m_mapEleData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QJsonArray>
|
||||||
#include "electricElementsPanel.h"
|
#include "electricElementsPanel.h"
|
||||||
#include "electricElementsBox.h"
|
#include "electricElementsBox.h"
|
||||||
#include "toolBox.h"
|
#include "toolBox.h"
|
||||||
|
|
@ -21,24 +22,23 @@ ElectricElementsBox::~ElectricElementsBox()
|
||||||
|
|
||||||
void ElectricElementsBox::initial()
|
void ElectricElementsBox::initial()
|
||||||
{
|
{
|
||||||
ElectricElementsPanel* pPanel1 = new ElectricElementsPanel();
|
addPanelItems("Items");
|
||||||
QMap<QString,GraphicsItemType> map1;
|
}
|
||||||
map1.insert(QString::fromWCharArray(L"三角"),GIT_rect);
|
|
||||||
map1.insert(QString::fromWCharArray(L"四边"),GIT_roundRect);
|
|
||||||
pPanel1->setData(map1);
|
|
||||||
m_mapPanels.insert("baseElements",pPanel1);
|
|
||||||
m_pToolBox->addWidget("baseElements",pPanel1);
|
|
||||||
connect(pPanel1,&ElectricElementsPanel::addGraphicsItem,this,&ElectricElementsBox::onSignal_addEletricItem);
|
|
||||||
|
|
||||||
ElectricElementsPanel* pPanel2 = new ElectricElementsPanel();
|
void ElectricElementsBox::addPanelItems(const QString& sPanel)
|
||||||
QMap<QString,GraphicsItemType> map2;
|
{
|
||||||
map2.insert(QString::fromWCharArray(L"总线"),GIT_bus);
|
ElectricElementsPanel* pPanel = new ElectricElementsPanel();
|
||||||
map2.insert(QString::fromWCharArray(L"单线"),GIT_itemRect);
|
|
||||||
map2.insert(QString::fromWCharArray(L"双线"),GIT_itemTri);
|
for(auto &model:_modelInfo)
|
||||||
pPanel2->setData(map2);
|
{
|
||||||
m_mapPanels.insert("eletricElements",pPanel2);
|
GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType];
|
||||||
m_pToolBox->addWidget("eletricElements",pPanel2);
|
model.modelType = localType; //转换图元类别,从字典表转到内部类别
|
||||||
connect(pPanel2,&ElectricElementsPanel::addGraphicsItem,this,&ElectricElementsBox::onSignal_addEletricItem);
|
}
|
||||||
|
|
||||||
|
pPanel->setData(_modelInfo);
|
||||||
|
m_mapPanels.insert(sPanel,pPanel);
|
||||||
|
m_pToolBox->addWidget(sPanel,pPanel);
|
||||||
|
connect(pPanel,&ElectricElementsPanel::addGraphicsItem,this,&ElectricElementsBox::onSignal_addEletricItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolBox* ElectricElementsBox::getToolBox() const
|
ToolBox* ElectricElementsBox::getToolBox() const
|
||||||
|
|
@ -46,13 +46,62 @@ ToolBox* ElectricElementsBox::getToolBox() const
|
||||||
return m_pToolBox;
|
return m_pToolBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricElementsBox::updateProjectModelItemList()
|
void ElectricElementsBox::getModelInfo()
|
||||||
{
|
{
|
||||||
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
||||||
}
|
|
||||||
|
|
||||||
void ElectricElementsBox::onSignal_addEletricItem(GraphicsItemType& type)
|
QMap<QString,int>::Iterator iter;
|
||||||
|
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
||||||
{
|
{
|
||||||
emit addEletricItem(type);
|
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()
|
||||||
|
{
|
||||||
|
for(auto &model:_modelInfo)
|
||||||
|
{
|
||||||
|
GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricElementsBox::onSignal_addEletricItem(modelStateInfo& info)
|
||||||
|
{
|
||||||
|
emit addEletricItem(info);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,21 +33,18 @@ void ElectricElementsPanel::initial()
|
||||||
QIcon icon(":/images/element/icons_triangle.png");
|
QIcon icon(":/images/element/icons_triangle.png");
|
||||||
QListWidgetItem* pItem = new QListWidgetItem(icon,iter.key());
|
QListWidgetItem* pItem = new QListWidgetItem(icon,iter.key());
|
||||||
pItem->setSizeHint(QSize(50,50));
|
pItem->setSizeHint(QSize(50,50));
|
||||||
pItem->setData(Qt::UserRole,iter.value());
|
|
||||||
m_pListWidget->addItem(pItem);
|
m_pListWidget->addItem(pItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricElementsPanel::setData(const QMap<QString,GraphicsItemType>& map)
|
void ElectricElementsPanel::setData(QMap<QString,modelStateInfo> map)
|
||||||
{
|
{
|
||||||
m_mapEleData = map;
|
m_mapEleData = map;
|
||||||
initial();
|
initial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ElectricElementsPanel::onItemClicked(QListWidgetItem* item)
|
void ElectricElementsPanel::onItemClicked(QListWidgetItem* item)
|
||||||
{
|
{
|
||||||
item->setBackground(QBrush(QColor(135,206,235,220)));
|
item->setBackground(QBrush(QColor(135,206,235,220)));
|
||||||
GraphicsItemType itetType = (GraphicsItemType)item->data(Qt::UserRole).toInt();
|
emit addGraphicsItem(m_mapEleData[item->text()]);
|
||||||
emit addGraphicsItem(itetType);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ MapProperty projectModelDlg::addNewProject(const QString& sMeta,const QString& s
|
||||||
QString propertyName = node["name"].toString();
|
QString propertyName = node["name"].toString();
|
||||||
int nState = node["checked"].toInt();
|
int nState = node["checked"].toInt();
|
||||||
QString dataType = node["type"].toString();
|
QString dataType = node["type"].toString();
|
||||||
|
QString defaultValue = node["defaultValue"].toString();
|
||||||
|
|
||||||
QStandardItem* pItem = new QStandardItem(propertyName);
|
QStandardItem* pItem = new QStandardItem(propertyName);
|
||||||
setItemAttribute(propertyName,pItem);
|
setItemAttribute(propertyName,pItem);
|
||||||
|
|
@ -919,6 +920,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
QString dataType = childItem->data(DataType).toString();
|
QString dataType = childItem->data(DataType).toString();
|
||||||
int lengthPrecision = childItem->data(LengthPrecision).toInt();
|
int lengthPrecision = childItem->data(LengthPrecision).toInt();
|
||||||
int scale = childItem->data(Scale).toInt();
|
int scale = childItem->data(Scale).toInt();
|
||||||
|
QString defaultValue = childItem->data(DefaultValue).toString();
|
||||||
|
|
||||||
QString dataTypePart = dataType; //拼接数据类型
|
QString dataTypePart = dataType; //拼接数据类型
|
||||||
if (lengthPrecision > 0) {
|
if (lengthPrecision > 0) {
|
||||||
|
|
@ -933,6 +935,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
node["name"] = childItem->text();
|
node["name"] = childItem->text();
|
||||||
node["checked"] = 1;
|
node["checked"] = 1;
|
||||||
node["type"] = dataTypePart;
|
node["type"] = dataTypePart;
|
||||||
|
node["defaultValue"] = defaultValue;
|
||||||
arrState.append(node);
|
arrState.append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -944,6 +947,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
QString dataType = childItem->data(DataType).toString();
|
QString dataType = childItem->data(DataType).toString();
|
||||||
int lengthPrecision = childItem->data(LengthPrecision).toInt();
|
int lengthPrecision = childItem->data(LengthPrecision).toInt();
|
||||||
int scale = childItem->data(Scale).toInt();
|
int scale = childItem->data(Scale).toInt();
|
||||||
|
QString defaultValue = childItem->data(DefaultValue).toString();
|
||||||
|
|
||||||
QString dataTypePart = dataType; //拼接数据类型
|
QString dataTypePart = dataType; //拼接数据类型
|
||||||
if (lengthPrecision > 0) {
|
if (lengthPrecision > 0) {
|
||||||
|
|
@ -958,6 +962,7 @@ QJsonObject projectModelDlg::getSelectedState(MapProperty::Iterator iter)
|
||||||
node["name"] = childItem->text();
|
node["name"] = childItem->text();
|
||||||
node["checked"] = 0;
|
node["checked"] = 0;
|
||||||
node["type"] = dataTypePart;
|
node["type"] = dataTypePart;
|
||||||
|
node["defaultValue"] = defaultValue;
|
||||||
arrState.append(node);
|
arrState.append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue