59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include "toolBox.h"
|
|
#include "toolPage.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QSpacerItem>
|
|
|
|
ToolBox::ToolBox(QWidget *parent) :
|
|
QWidget(parent),
|
|
m_pContentVBoxLayout(nullptr)
|
|
{
|
|
|
|
QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
|
|
vBoxLayout->setContentsMargins(0, 0, 0, 0);
|
|
//vBoxLayout->addLayout(m_pContentVBoxLayout);
|
|
//vBoxLayout->addStretch(0);
|
|
|
|
}
|
|
|
|
ToolBox::~ToolBox()
|
|
{
|
|
|
|
}
|
|
|
|
void ToolBox::addWidget(const QString &title, QWidget *pWidget)
|
|
{
|
|
ToolPage *page = new ToolPage(this);
|
|
page->addWidget(title, pWidget);
|
|
|
|
QBoxLayout* pLayout = dynamic_cast<QBoxLayout*>(layout());
|
|
pLayout->insertWidget(0,page);
|
|
pLayout->addStretch(0);
|
|
m_mapWidget.insert(title,page);
|
|
}
|
|
|
|
void ToolBox::removeWidget(const QString &title)
|
|
{
|
|
bool bExist = m_mapWidget.contains(title);
|
|
if(bExist)
|
|
{
|
|
QWidget *pWidget = m_mapWidget.take(title);
|
|
if(pWidget)
|
|
{
|
|
QBoxLayout* pLayout = dynamic_cast<QBoxLayout*>(layout());
|
|
ToolPage* toolPage = dynamic_cast<ToolPage*>(pWidget);
|
|
if(toolPage)
|
|
{
|
|
pLayout->removeWidget(toolPage);
|
|
delete toolPage;
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//cerr
|
|
}
|
|
|
|
}
|