101 lines
2.6 KiB
C++
101 lines
2.6 KiB
C++
#include "itemPropertyDlg.h"
|
|
#include "propertyContentDlg.h"
|
|
#include "ui_itemPropertyDlg.h"
|
|
|
|
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
|
: QDialog(parent)
|
|
, ui(new Ui::itemPropertyDlg)
|
|
,layout_(nullptr)
|
|
,btnGroup_(nullptr)
|
|
{
|
|
ui->setupUi(this);
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
|
initial();
|
|
}
|
|
|
|
ItemPropertyDlg::~ItemPropertyDlg()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void ItemPropertyDlg::initial()
|
|
{
|
|
layout_ = new QVBoxLayout(ui->widget_button);
|
|
btnGroup_ = new QButtonGroup(this);
|
|
connect(ui->btn_ok,&QPushButton::clicked,this,&ItemPropertyDlg::onOkClicked);
|
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&ItemPropertyDlg::onCancelClicked);
|
|
}
|
|
|
|
void ItemPropertyDlg::loadGroupButton(QMap<QString,groupStateInfo> map)
|
|
{
|
|
groupInfo_ = map;
|
|
for(auto &info:map)
|
|
{
|
|
QPushButton* btn = new QPushButton(ui->widget_button);
|
|
btn->setText(info.groupName);
|
|
btn->setCheckable(true);
|
|
btnGroup_->addButton(btn);
|
|
btnMap_.insert(info.groupName, btn);
|
|
layout_->addWidget(btn);
|
|
|
|
connect(btn, &QAbstractButton::clicked, [this, info](){
|
|
onGroupSelected(info.groupName);
|
|
});
|
|
}
|
|
}
|
|
|
|
void ItemPropertyDlg::onOkClicked()
|
|
{
|
|
//todo:将属性页中的值读取到当前uuid对象
|
|
for(auto &dlg:groupViews_)
|
|
{
|
|
PropertyContentDlg* pDlg = qobject_cast<PropertyContentDlg*>(dlg);
|
|
QMap<QString,propertyStateInfo> mapPro = pDlg->getPropertyValue();
|
|
}
|
|
hide();
|
|
}
|
|
|
|
void ItemPropertyDlg::onCancelClicked()
|
|
{
|
|
hide();
|
|
}
|
|
|
|
void ItemPropertyDlg::onGroupSelected(const QString& str)
|
|
{
|
|
if (!groupViews_.contains(str)) {
|
|
createGroupView(str);
|
|
}
|
|
|
|
PropertyContentDlg* pDlg = qobject_cast<PropertyContentDlg*>(groupViews_[str]);
|
|
if(pDlg)
|
|
{
|
|
QMap<QString,propertyStateInfo> valueMap = groupValue_[str].mapInfo[curUuid_];
|
|
pDlg->setPropertyValue(valueMap);
|
|
}
|
|
|
|
ui->stackedWidget->setCurrentWidget(groupViews_[str]);
|
|
}
|
|
|
|
|
|
void ItemPropertyDlg::createGroupView(const QString& str)
|
|
{
|
|
PropertyContentDlg* contentDlg = new PropertyContentDlg(ui->stackedWidget);
|
|
if(contentDlg)
|
|
{
|
|
contentDlg->createGroupView(groupInfo_[str]);
|
|
}
|
|
|
|
groupViews_.insert(str, contentDlg);
|
|
ui->stackedWidget->addWidget(contentDlg);
|
|
}
|
|
|
|
void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid)
|
|
{
|
|
groupValue_ = dataInfo.groupInfo;
|
|
curUuid_ = uuid;
|
|
_curModel = dataInfo.modelName;
|
|
QString firstName = groupInfo_.constBegin().key();
|
|
onGroupSelected(firstName); //打开默认显示第一个属性组
|
|
show();
|
|
}
|