DiagramDesigner/diagramCavas/source/bayManagerContentDlg.cpp

290 lines
12 KiB
C++
Raw Normal View History

2025-07-18 18:26:13 +08:00
#include <QButtonGroup>
2025-07-04 18:47:49 +08:00
#include "bayManagerContentDlg.h"
2025-07-11 18:13:54 +08:00
#include "baseProperty.h"
2025-07-04 18:47:49 +08:00
#include "ui_bayManagerContentDlg.h"
2025-07-11 18:13:54 +08:00
#include "basePropertyManager.h"
2025-07-04 18:47:49 +08:00
BayManagerContentDlg::BayManagerContentDlg(QWidget *parent)
: QDialog(parent)
, ui(new Ui::bayManagerContentDlg)
2025-07-11 18:13:54 +08:00
,_pData(nullptr)
2025-07-04 18:47:49 +08:00
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
initial();
}
BayManagerContentDlg::~BayManagerContentDlg()
{
delete ui;
}
void BayManagerContentDlg::initial()
{
2025-07-18 18:26:13 +08:00
_stateGroup = new QButtonGroup(this);
_stateGroup->addButton(ui->rbtn_in,1);
_stateGroup->addButton(ui->rbtn_out,0);
_stateGroup->setExclusive(true);
2025-07-11 18:13:54 +08:00
QStringList headerText;
headerText<<"选择"<<"名称";
ui->tw_zongHe->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_zongHe->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_zongHe->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_zongHe->setColumnCount(headerText.count());
ui->tw_zongHe->setHorizontalHeaderLabels(headerText);
ui->tw_zongHe->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
2025-07-04 18:47:49 +08:00
2025-07-11 18:13:54 +08:00
ui->tw_jianKong->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_jianKong->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_jianKong->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_jianKong->setColumnCount(headerText.count());
ui->tw_jianKong->setHorizontalHeaderLabels(headerText);
ui->tw_jianKong->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tw_dongTai->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_dongTai->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_dongTai->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_dongTai->setColumnCount(headerText.count());
ui->tw_dongTai->setHorizontalHeaderLabels(headerText);
ui->tw_dongTai->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tw_guZhang->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_guZhang->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_guZhang->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_guZhang->setColumnCount(headerText.count());
ui->tw_guZhang->setHorizontalHeaderLabels(headerText);
ui->tw_guZhang->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tw_zhuangTai->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_zhuangTai->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_zhuangTai->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_zhuangTai->setColumnCount(headerText.count());
ui->tw_zhuangTai->setHorizontalHeaderLabels(headerText);
ui->tw_zhuangTai->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tw_qiTa->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tw_qiTa->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tw_qiTa->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tw_qiTa->setColumnCount(headerText.count());
ui->tw_qiTa->setHorizontalHeaderLabels(headerText);
ui->tw_qiTa->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
}
void BayManagerContentDlg::updateByProperty()
{
if(_pData){
2025-07-18 18:26:13 +08:00
ui->le_name->setText(_pData->name());
2025-07-11 18:13:54 +08:00
ui->tw_zongHe->setRowCount(0);
ui->tw_jianKong->setRowCount(0);
ui->tw_dongTai->setRowCount(0);
ui->tw_guZhang->setRowCount(0);
ui->tw_zhuangTai->setRowCount(0);
ui->tw_qiTa->setRowCount(0);
2025-10-21 18:46:51 +08:00
ui->le_index->setText(_pData->uuid().toString());
ui->le_type->setText(_pData->getType());
QStringList lstFrom;
for(auto uid:_pData->getLstFrom()){
lstFrom.append(uid.toString());
}
ui->le_from->setText(lstFrom.join(" "));
QStringList lstTo;
for(auto uid:_pData->getLstTo()){
lstTo.append(uid.toString());
}
ui->le_to->setText(lstTo.join(" "));
ui->le_voltage->setText(QString::number(_pData->getVoltage()));
ui->le_fla->setText(QString::number(_pData->getFla()));
ui->le_capacity->setText(QString::number(_pData->getCapacity()));
2025-07-11 18:13:54 +08:00
QList<BaseProperty*> lstPro;
QList<QUuid> lstId = _pData->getLstComponent();
QList<QUuid> lstProtectId = _pData->getLstProtect(); //综合保护
QList<QUuid> lstInsId = _pData->getLstInstruct(); //监控
QList<QUuid> lstDynSenId = _pData->getLstDynSense(); //动态感知
QList<QUuid> lstFauRecId = _pData->getLstFaultRecord(); //故障录播
QList<QUuid> lstStaId= _pData->getLstStatus(); //状态监测
QList<QUuid> lstEtcId= _pData->getLstEtc(); //其他设备
for(auto& id:lstId){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(id); //根据id找到对应的设备
if(pPro){
lstPro.append(pPro);
}
}
for(auto& pro:lstPro){ //初始化tablewidget
int row = ui->tw_zongHe->rowCount(); //综合保护
ui->tw_zongHe->insertRow(row);
QTableWidgetItem *checkItemProtec = new QTableWidgetItem();
checkItemProtec->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemProtec->setCheckState(Qt::Unchecked); // 默认未勾选
checkItemProtec->setData(Qt::UserRole+1,pro->uuid());
ui->tw_zongHe->setItem(row, 0, checkItemProtec); // 设置到第一列
QTableWidgetItem* tagItemProtec = new QTableWidgetItem(pro->tag());
ui->tw_zongHe->setItem(row, 1, tagItemProtec);
row = ui->tw_jianKong->rowCount(); //监控
ui->tw_jianKong->insertRow(row);
QTableWidgetItem *checkItemIns = new QTableWidgetItem();
checkItemIns->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemIns->setCheckState(Qt::Unchecked);
checkItemIns->setData(Qt::UserRole+1,pro->uuid());
ui->tw_jianKong->setItem(row, 0, checkItemIns);
QTableWidgetItem* tagItemIns = new QTableWidgetItem(pro->tag());
ui->tw_jianKong->setItem(row, 1, tagItemIns);
row = ui->tw_dongTai->rowCount(); //动态感知
ui->tw_dongTai->insertRow(row);
QTableWidgetItem *checkItemDynSen = new QTableWidgetItem();
checkItemDynSen->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemDynSen->setCheckState(Qt::Unchecked);
checkItemDynSen->setData(Qt::UserRole+1,pro->uuid());
ui->tw_dongTai->setItem(row, 0, checkItemDynSen);
QTableWidgetItem* tagItemDynSen = new QTableWidgetItem(pro->tag());
ui->tw_dongTai->setItem(row, 1, tagItemDynSen);
row = ui->tw_guZhang->rowCount(); //故障录播
ui->tw_guZhang->insertRow(row);
QTableWidgetItem *checkItemFauRec = new QTableWidgetItem();
checkItemFauRec->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemFauRec->setCheckState(Qt::Unchecked);
checkItemFauRec->setData(Qt::UserRole+1,pro->uuid());
ui->tw_guZhang->setItem(row, 0, checkItemFauRec);
QTableWidgetItem* tagItemFauRec = new QTableWidgetItem(pro->tag());
ui->tw_guZhang->setItem(row, 1, tagItemFauRec);
row = ui->tw_zhuangTai->rowCount(); //状态监测
ui->tw_zhuangTai->insertRow(row);
QTableWidgetItem *checkItemSta = new QTableWidgetItem();
checkItemSta->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemSta->setCheckState(Qt::Unchecked);
checkItemSta->setData(Qt::UserRole+1,pro->uuid());
ui->tw_zhuangTai->setItem(row, 0, checkItemSta);
QTableWidgetItem* tagItemSta = new QTableWidgetItem(pro->tag());
ui->tw_zhuangTai->setItem(row, 1, tagItemSta);
row = ui->tw_qiTa->rowCount(); //其他设备
ui->tw_qiTa->insertRow(row);
QTableWidgetItem *checkItemEtc = new QTableWidgetItem();
checkItemEtc->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
checkItemEtc->setCheckState(Qt::Unchecked);
checkItemEtc->setData(Qt::UserRole+1,pro->uuid());
ui->tw_qiTa->setItem(row, 0, checkItemEtc);
QTableWidgetItem* tagItemEtc = new QTableWidgetItem(pro->tag());
ui->tw_qiTa->setItem(row, 1, tagItemEtc);
}
for(auto& id:lstProtectId){ //设置勾选状态
for(int i = 0;i < ui->tw_zongHe->rowCount();++i){
if(ui->tw_zongHe->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_zongHe->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
for(auto& id:lstInsId){
for(int i = 0;i < ui->tw_jianKong->rowCount();++i){
if(ui->tw_jianKong->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_jianKong->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
for(auto& id:lstDynSenId){
for(int i = 0;i < ui->tw_dongTai->rowCount();++i){
if(ui->tw_dongTai->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_dongTai->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
for(auto& id:lstFauRecId){
for(int i = 0;i < ui->tw_guZhang->rowCount();++i){
if(ui->tw_guZhang->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_guZhang->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
for(auto& id:lstStaId){
for(int i = 0;i < ui->tw_zhuangTai->rowCount();++i){
if(ui->tw_zhuangTai->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_zhuangTai->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
for(auto& id:lstEtcId){
for(int i = 0;i < ui->tw_qiTa->rowCount();++i){
if(ui->tw_qiTa->item(i,0)->data(Qt::UserRole+1).toUuid() == id){
ui->tw_qiTa->item(i,0)->setCheckState(Qt::Checked);
break;
}
}
}
}
}
void BayManagerContentDlg::saveSetting()
{
if(_pData){
QList<QUuid> lstProtec;
for(int i = 0;i < ui->tw_zongHe->rowCount();++i){
if(Qt::Checked == ui->tw_zongHe->item(i,0)->checkState()){
lstProtec.append(ui->tw_zongHe->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
QList<QUuid> lstIns;
for(int i = 0;i < ui->tw_jianKong->rowCount();++i){
if(Qt::Checked == ui->tw_jianKong->item(i,0)->checkState()){
lstIns.append(ui->tw_jianKong->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
QList<QUuid> lstDynSen;
for(int i = 0;i < ui->tw_dongTai->rowCount();++i){
if(Qt::Checked == ui->tw_dongTai->item(i,0)->checkState()){
lstDynSen.append(ui->tw_dongTai->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
QList<QUuid> lstFauRec;
for(int i = 0;i < ui->tw_guZhang->rowCount();++i){
if(Qt::Checked == ui->tw_guZhang->item(i,0)->checkState()){
lstFauRec.append(ui->tw_guZhang->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
QList<QUuid> lstSta;
for(int i = 0;i < ui->tw_zhuangTai->rowCount();++i){
if(Qt::Checked == ui->tw_zhuangTai->item(i,0)->checkState()){
lstSta.append(ui->tw_zhuangTai->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
QList<QUuid> lstEtc;
for(int i = 0;i < ui->tw_qiTa->rowCount();++i){
if(Qt::Checked == ui->tw_qiTa->item(i,0)->checkState()){
lstEtc.append(ui->tw_qiTa->item(i,0)->data(Qt::UserRole+1).toUuid());
}
}
_pData->setLstProtect(lstProtec);
_pData->setLstInstruct(lstIns);
_pData->setLstDynSense(lstDynSen);
_pData->setLstFaultRecord(lstFauRec);
_pData->setLstStatus(lstSta);
_pData->setLstEtc(lstEtc);
}
2025-07-04 18:47:49 +08:00
}