108 lines
3.2 KiB
C++
108 lines
3.2 KiB
C++
#include <QVBoxLayout>
|
|
#include <QJsonArray>
|
|
#include "electricElementsPanel.h"
|
|
#include "electricElementsBox.h"
|
|
#include "toolBox.h"
|
|
#include "util/baseSelector.h"
|
|
#include "dataBase.h"
|
|
|
|
ElectricElementsBox::ElectricElementsBox(QObject *parent)
|
|
: QObject(parent),
|
|
m_pToolBox(nullptr)
|
|
{
|
|
m_pToolBox = new ToolBox();
|
|
|
|
}
|
|
|
|
ElectricElementsBox::~ElectricElementsBox()
|
|
{
|
|
if(m_pToolBox)
|
|
delete m_pToolBox;
|
|
}
|
|
|
|
void ElectricElementsBox::initial()
|
|
{
|
|
addPanelItems("Items");
|
|
}
|
|
|
|
void ElectricElementsBox::addPanelItems(const QString& sPanel)
|
|
{
|
|
ElectricElementsPanel* pPanel = new ElectricElementsPanel();
|
|
|
|
for(auto &model:_modelInfo)
|
|
{
|
|
GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType];
|
|
model.modelType = localType; //转换图元类别,从字典表转到内部类别
|
|
}
|
|
|
|
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
|
|
{
|
|
return m_pToolBox;
|
|
}
|
|
|
|
void ElectricElementsBox::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);
|
|
}
|
|
_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);
|
|
|
|
}
|