DiagramDesigner/source/electricElementsBox.cpp

54 lines
1.6 KiB
C++
Raw Normal View History

2024-12-03 20:07:25 +08:00
#include <QVBoxLayout>
#include "electricElementsPanel.h"
#include "electricElementsBox.h"
#include "toolBox.h"
#include "util/baseSelector.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()
{
ElectricElementsPanel* pPanel1 = new ElectricElementsPanel();
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();
QMap<QString,GraphicsItemType> map2;
map2.insert(QString::fromWCharArray(L"总线"),GIT_bus);
map2.insert(QString::fromWCharArray(L"单线"),GIT_itemRect);
map2.insert(QString::fromWCharArray(L"双线"),GIT_itemTri);
pPanel2->setData(map2);
m_mapPanels.insert("eletricElements",pPanel2);
m_pToolBox->addWidget("eletricElements",pPanel2);
connect(pPanel2,&ElectricElementsPanel::addGraphicsItem,this,&ElectricElementsBox::onSignal_addEletricItem);
}
ToolBox* ElectricElementsBox::getToolBox() const
{
return m_pToolBox;
}
void ElectricElementsBox::onSignal_addEletricItem(GraphicsItemType& type)
{
emit addEletricItem(type);
}