2025-05-16 19:20:46 +08:00
|
|
|
|
#include <QMessageBox>
|
2025-02-06 16:36:50 +08:00
|
|
|
|
#include "itemPropertyDlg.h"
|
2025-04-03 18:33:10 +08:00
|
|
|
|
#include "propertyContentDlg.h"
|
2025-04-07 08:46:03 +08:00
|
|
|
|
#include "dataManager.h"
|
2025-04-09 16:20:34 +08:00
|
|
|
|
#include "graphicsItem/graphicsBaseItem.h"
|
2025-02-06 16:36:50 +08:00
|
|
|
|
#include "ui_itemPropertyDlg.h"
|
2025-05-16 19:20:46 +08:00
|
|
|
|
#include "baseContentDlg.h"
|
|
|
|
|
|
#include "baseInfoDlg.h"
|
2025-05-23 10:30:52 +08:00
|
|
|
|
//#include "topologyManager.h"
|
|
|
|
|
|
#include "basePropertyManager.h"
|
|
|
|
|
|
#include "baseProperty.h"
|
|
|
|
|
|
#include "ptExtraInfoDlg.h"
|
|
|
|
|
|
#include "ctExtraInfoDlg.h"
|
2025-02-06 16:36:50 +08:00
|
|
|
|
|
|
|
|
|
|
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
|
, ui(new Ui::itemPropertyDlg)
|
2025-04-03 18:33:10 +08:00
|
|
|
|
,layout_(nullptr)
|
|
|
|
|
|
,btnGroup_(nullptr)
|
2025-04-09 16:20:34 +08:00
|
|
|
|
,_curItem(nullptr)
|
2025-02-06 16:36:50 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
2025-04-03 18:33:10 +08:00
|
|
|
|
initial();
|
2025-02-06 16:36:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ItemPropertyDlg::~ItemPropertyDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-03 18:33:10 +08:00
|
|
|
|
void ItemPropertyDlg::initial()
|
2025-02-06 16:36:50 +08:00
|
|
|
|
{
|
2025-04-03 18:33:10 +08:00
|
|
|
|
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);
|
2025-04-30 16:29:17 +08:00
|
|
|
|
if(info.isPublic) //公共属性组置顶
|
|
|
|
|
|
layout_->insertWidget(0,btn);
|
|
|
|
|
|
else
|
|
|
|
|
|
layout_->addWidget(btn);
|
2025-04-03 18:33:10 +08:00
|
|
|
|
|
|
|
|
|
|
connect(btn, &QAbstractButton::clicked, [this, info](){
|
|
|
|
|
|
onGroupSelected(info.groupName);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-04-09 16:20:34 +08:00
|
|
|
|
layout_->addStretch();
|
2025-02-06 16:36:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ItemPropertyDlg::onOkClicked()
|
|
|
|
|
|
{
|
2025-04-03 18:33:10 +08:00
|
|
|
|
//todo:将属性页中的值读取到当前uuid对象
|
2025-04-09 16:20:34 +08:00
|
|
|
|
if(_curItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_curItem->getProperty() == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
//todo:弹出输入框输入名称
|
|
|
|
|
|
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"对象未命名"));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
curUuid_ = _curItem->getProperty()->uuid(); //使用数据uuid,数据唯一,item不唯一
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-07 08:46:03 +08:00
|
|
|
|
QMap<QString, QWidget*>::Iterator iter;
|
2025-05-23 10:30:52 +08:00
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(curUuid_);
|
2025-04-07 08:46:03 +08:00
|
|
|
|
for(iter = groupViews_.begin();iter != groupViews_.end();++iter)
|
2025-04-03 18:33:10 +08:00
|
|
|
|
{
|
2025-05-23 10:30:52 +08:00
|
|
|
|
BaseContentDlg* pDlg = qobject_cast<BaseContentDlg*>(iter.value());
|
|
|
|
|
|
QMap<QString,propertyStateInfo> mapPro = pDlg->getPropertyValue(pPro);
|
|
|
|
|
|
if(!mapPro.empty())
|
|
|
|
|
|
DataManager::instance().updateModelData(_curModel,curUuid_,iter.key(),mapPro);
|
2025-04-03 18:33:10 +08:00
|
|
|
|
}
|
2025-02-06 16:36:50 +08:00
|
|
|
|
hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ItemPropertyDlg::onCancelClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-03 18:33:10 +08:00
|
|
|
|
void ItemPropertyDlg::onGroupSelected(const QString& str)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!groupViews_.contains(str)) {
|
|
|
|
|
|
createGroupView(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-16 19:20:46 +08:00
|
|
|
|
BaseContentDlg* pDlg = qobject_cast<BaseContentDlg*>(groupViews_[str]);
|
2025-04-03 18:33:10 +08:00
|
|
|
|
if(pDlg)
|
|
|
|
|
|
{
|
2025-05-09 19:36:32 +08:00
|
|
|
|
QMap<QString,propertyStateInfo> valueMap;
|
2025-05-23 10:30:52 +08:00
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(curUuid_);
|
|
|
|
|
|
if(str != QString("component") && str != QString("基本信息"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if(groupValue_[str].mapInfo.contains(curUuid_))
|
|
|
|
|
|
valueMap = groupValue_[str].mapInfo[curUuid_];
|
|
|
|
|
|
else //没有值时使用默认值
|
|
|
|
|
|
valueMap = groupInfo_[str].info;
|
|
|
|
|
|
pDlg->setPropertyValue(QVariant::fromValue(valueMap));
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
pDlg->setPropertyValue(QVariant::fromValue(static_cast<void*>(pPro)));
|
|
|
|
|
|
}
|
2025-04-03 18:33:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->stackedWidget->setCurrentWidget(groupViews_[str]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ItemPropertyDlg::createGroupView(const QString& str)
|
|
|
|
|
|
{
|
2025-05-16 19:20:46 +08:00
|
|
|
|
//todo:基础信息、间隔信息、动态界面在此分支
|
|
|
|
|
|
BaseContentDlg* contentDlg = nullptr;
|
2025-05-23 10:30:52 +08:00
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(curUuid_);
|
2025-05-16 19:20:46 +08:00
|
|
|
|
if(str == QString("component") || str == QString::fromWCharArray(L"基本信息")){
|
|
|
|
|
|
contentDlg = new BaseInfoDlg(ui->stackedWidget);
|
|
|
|
|
|
}
|
2025-05-23 10:30:52 +08:00
|
|
|
|
else if(str == "base_extend" || str == QString::fromWCharArray(L"扩展信息")){
|
|
|
|
|
|
//if(pPro->type() == pt)
|
|
|
|
|
|
contentDlg = new CtExtraInfoDlg(ui->stackedWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(str == "bay" || str == QString::fromWCharArray(L"间隔信息")){
|
2025-05-16 19:20:46 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
contentDlg = new PropertyContentDlg(ui->stackedWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-03 18:33:10 +08:00
|
|
|
|
if(contentDlg)
|
|
|
|
|
|
{
|
|
|
|
|
|
contentDlg->createGroupView(groupInfo_[str]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groupViews_.insert(str, contentDlg);
|
|
|
|
|
|
ui->stackedWidget->addWidget(contentDlg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-09 16:20:34 +08:00
|
|
|
|
void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid,GraphicsBaseItem* pItem)
|
2025-02-06 16:36:50 +08:00
|
|
|
|
{
|
2025-04-03 18:33:10 +08:00
|
|
|
|
groupValue_ = dataInfo.groupInfo;
|
|
|
|
|
|
curUuid_ = uuid;
|
|
|
|
|
|
_curModel = dataInfo.modelName;
|
2025-04-09 16:20:34 +08:00
|
|
|
|
_curItem = pItem;
|
2025-04-03 18:33:10 +08:00
|
|
|
|
QString firstName = groupInfo_.constBegin().key();
|
|
|
|
|
|
onGroupSelected(firstName); //打开默认显示第一个属性组
|
|
|
|
|
|
show();
|
2025-02-06 16:36:50 +08:00
|
|
|
|
}
|