fix part of memory leak
This commit is contained in:
parent
4f3c865126
commit
42735dc4d8
|
|
@ -50,12 +50,10 @@ enum class ModelFunctionType //模型函数的类型
|
||||||
BaseModel
|
BaseModel
|
||||||
};
|
};
|
||||||
|
|
||||||
class corresbondItem //类型关联函数
|
|
||||||
{
|
extern const QMap<AbstractItemType,GraphicsItemType> linkType;
|
||||||
public:
|
//类型转换
|
||||||
static QMap<AbstractItemType,GraphicsItemType> linkType;
|
extern const QMap<int,GraphicsItemType> typeToProGraphic;
|
||||||
static QMap<int,GraphicsItemType> typeToProGraphic;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DiagramMode //组态图模式
|
enum DiagramMode //组态图模式
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
QMap<AbstractItemType,GraphicsItemType> corresbondItem::linkType = {
|
const QMap<AbstractItemType,GraphicsItemType> linkType = {
|
||||||
{AIT_motor,GIT_itemRect},{AIT_bus,GIT_bus},
|
{AIT_motor,GIT_itemRect},{AIT_bus,GIT_bus},
|
||||||
};
|
};
|
||||||
QMap<int,GraphicsItemType> corresbondItem::typeToProGraphic = {
|
//类型转换
|
||||||
|
const QMap<int,GraphicsItemType> typeToProGraphic = {
|
||||||
{1,GIT_bus},{3,GIT_itemRect},{8,GIT_link}
|
{1,GIT_bus},{3,GIT_itemRect},{8,GIT_link}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,22 @@ void DiagramEditorWizard::reOrderBus()
|
||||||
for(int row = 0 ;row < ui->tableWidget_bus->rowCount();++row)
|
for(int row = 0 ;row < ui->tableWidget_bus->rowCount();++row)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* pItem = ui->tableWidget_bus->item(row,0);
|
QTableWidgetItem* pItem = ui->tableWidget_bus->item(row,0);
|
||||||
pItem->setText("第"+QString::number(row)+"层");
|
pItem->setText("第"+QString::number(row+1)+"层");
|
||||||
pItem->setData(Qt::UserRole,row);
|
pItem->setData(Qt::UserRole,row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagramEditorWizard::generateBayPage()
|
||||||
|
{
|
||||||
|
for(auto& busInfo:_mapBus)
|
||||||
|
{
|
||||||
|
QListWidgetItem* item = new QListWidgetItem("第"+QString::number(busInfo.nIndex+1)+"层");
|
||||||
|
item->setData(Qt::UserRole,busInfo.nIndex);
|
||||||
|
ui->listWidget_bay->addItem(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> void DiagramEditorWizard::reindexQMap(QMap<int, T> &map) {
|
template <typename T> void DiagramEditorWizard::reindexQMap(QMap<int, T> &map) {
|
||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name,QStrin
|
||||||
item->setUuid(id);
|
item->setUuid(id);
|
||||||
item->setModelName(modelName);
|
item->setModelName(modelName);
|
||||||
item->setType(type);
|
item->setType(type);
|
||||||
GraphicsItemType localType = corresbondItem::typeToProGraphic[type]; //将通用类型转换为工程模图元
|
GraphicsItemType localType = typeToProGraphic[type]; //将通用类型转换为工程模图元
|
||||||
item->setGraphicsType(localType);
|
item->setGraphicsType(localType);
|
||||||
item->setTag(name);
|
item->setTag(name);
|
||||||
item->setName(name);
|
item->setName(name);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ void ElectricElementsBox::addPanelItems(const QString& sPanel)
|
||||||
|
|
||||||
for(auto &model:_modelInfo)
|
for(auto &model:_modelInfo)
|
||||||
{
|
{
|
||||||
GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType];
|
GraphicsItemType localType = linkType[(AbstractItemType)model.modelType];
|
||||||
model.modelType = localType; //转换图元类别,从字典表转到内部类别
|
model.modelType = localType; //转换图元类别,从字典表转到内部类别
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ void ElectricElementsBox::updateModelList()
|
||||||
{
|
{
|
||||||
for(auto &model:_modelInfo)
|
for(auto &model:_modelInfo)
|
||||||
{
|
{
|
||||||
GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType];
|
GraphicsItemType localType = linkType[(AbstractItemType)model.modelType];
|
||||||
model.modelType = localType;
|
model.modelType = localType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue