2025-07-04 18:47:49 +08:00
|
|
|
|
#include <QButtonGroup>
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
#include <QMutableListIterator>
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
#include "bayInfoDlg.h"
|
|
|
|
|
|
#include "ui_bayInfoDlg.h"
|
|
|
|
|
|
#include "baseProperty.h"
|
|
|
|
|
|
#include "basePropertyManager.h"
|
|
|
|
|
|
#include "measureSettingDlg.h"
|
2025-07-11 18:13:54 +08:00
|
|
|
|
#include "graphicsItem/electricBayItem.h"
|
|
|
|
|
|
#include "graphicsDataModel/fixedPortsModel.h"
|
|
|
|
|
|
#include "basePropertyManager.h"
|
2025-07-04 18:47:49 +08:00
|
|
|
|
#include "dataBase.h"
|
|
|
|
|
|
|
|
|
|
|
|
BayInfoDlg::BayInfoDlg(QWidget *parent)
|
|
|
|
|
|
: BaseContentDlg(parent)
|
|
|
|
|
|
, ui(new Ui::bayInfoDlg)
|
|
|
|
|
|
,_measureDlg(nullptr)
|
2025-07-18 18:26:13 +08:00
|
|
|
|
,_bayProperty(nullptr)
|
|
|
|
|
|
,_itemProperty(nullptr)
|
2025-07-04 18:47:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
|
|
|
|
|
initial();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BayInfoDlg::~BayInfoDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BayInfoDlg::initial()
|
|
|
|
|
|
{
|
|
|
|
|
|
setUi();
|
|
|
|
|
|
connect(ui->btn_add,&QPushButton::clicked,this,&BayInfoDlg::onAddClicked);
|
|
|
|
|
|
connect(ui->tableWidget_local, &QTableWidget::customContextMenuRequested, this, &BayInfoDlg::onIndexRbtnClicked);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BayInfoDlg::createGroupView(groupStateInfo infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& info:infos.info) {
|
|
|
|
|
|
propertyContentInfo inf;
|
|
|
|
|
|
inf.proName = info.name;
|
|
|
|
|
|
inf.proType = info.type;
|
|
|
|
|
|
_mapPro.insert(info.name,inf);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,propertyStateInfo> BayInfoDlg::getPropertyValue(BaseProperty* pPro)
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,propertyStateInfo> map;
|
|
|
|
|
|
|
2025-07-18 18:26:13 +08:00
|
|
|
|
pPro->setDataChanged(true);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
pPro->setMeasurement(_mapMeasure);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BayInfoDlg::setPropertyValue(QVariant var)
|
|
|
|
|
|
{
|
2025-07-11 18:13:54 +08:00
|
|
|
|
_mapMeasure.clear();
|
2025-07-18 18:26:13 +08:00
|
|
|
|
ui->tableWidget_other->setRowCount(0);
|
2025-07-11 18:13:54 +08:00
|
|
|
|
ui->tableWidget_local->setRowCount(0); //清空列表
|
|
|
|
|
|
ui->le_zhbh->clear();
|
|
|
|
|
|
ui->le_jk->clear();
|
|
|
|
|
|
ui->le_dtgz->clear();
|
|
|
|
|
|
ui->le_gzlb->clear();
|
|
|
|
|
|
ui->le_ztjc->clear();
|
|
|
|
|
|
ui->le_qt->clear();
|
|
|
|
|
|
|
|
|
|
|
|
BaseProperty* property = static_cast<BaseProperty*>(var.value<void*>());
|
|
|
|
|
|
if(property)
|
2025-07-04 18:47:49 +08:00
|
|
|
|
{
|
2025-07-18 18:26:13 +08:00
|
|
|
|
_itemProperty = property;
|
2025-07-04 18:47:49 +08:00
|
|
|
|
QList<measureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
|
|
|
|
|
|
|
|
|
|
|
|
_validType = lstType;
|
|
|
|
|
|
|
2025-07-11 18:13:54 +08:00
|
|
|
|
//间隔处理
|
2025-07-18 18:26:13 +08:00
|
|
|
|
_bayProperty = nullptr;
|
2025-07-11 18:13:54 +08:00
|
|
|
|
QMap<QUuid,ElectricBayItem*> mapBay = _curModelController->allBayItem();
|
|
|
|
|
|
for(auto& item:mapBay){
|
|
|
|
|
|
AbstractProperty* pPro = item->getProperty();
|
|
|
|
|
|
BayProperty* pBayPro = dynamic_cast<BayProperty*>(pPro);
|
|
|
|
|
|
if(pBayPro){
|
|
|
|
|
|
QList<QUuid> lstCompo = pBayPro->getLstComponent(); //获取间隔下的component,找到本component对应的间隔
|
|
|
|
|
|
for(auto& id:lstCompo){
|
|
|
|
|
|
if(id == property->uuid()){
|
2025-07-18 18:26:13 +08:00
|
|
|
|
_bayProperty = pBayPro;
|
2025-07-11 18:13:54 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
auto map = property->getMeasurement();
|
|
|
|
|
|
for(auto& info:map){
|
|
|
|
|
|
addMeasure(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-18 18:26:13 +08:00
|
|
|
|
if(_bayProperty){
|
|
|
|
|
|
auto lstFrom = _bayProperty->getLstFrom();
|
|
|
|
|
|
auto lstTo = _bayProperty->getLstTo();
|
|
|
|
|
|
auto lstProtect = _bayProperty->getLstProtect();
|
|
|
|
|
|
auto lstFaultRecord = _bayProperty->getLstFaultRecord();
|
|
|
|
|
|
auto lstDynSense = _bayProperty->getLstDynSense();
|
|
|
|
|
|
auto lstStatus = _bayProperty->getLstStatus();
|
|
|
|
|
|
auto lstInstruct = _bayProperty->getLstInstruct();
|
|
|
|
|
|
auto lstEtc = _bayProperty->getLstEtc();
|
2025-07-11 18:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
QStringList sLstFrom;
|
|
|
|
|
|
for(auto& fromId:lstFrom){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(fromId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstFrom.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstTo;
|
|
|
|
|
|
for(auto& toId:lstTo){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(toId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstTo.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstProtect;
|
|
|
|
|
|
for(auto& protectId:lstProtect){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(protectId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstProtect.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstFaultRecord;
|
|
|
|
|
|
for(auto& faultRecordId:lstFaultRecord){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(faultRecordId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstFaultRecord.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstDynSense;
|
|
|
|
|
|
for(auto& dynSenseId:lstDynSense){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(dynSenseId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstDynSense.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstStatus;
|
|
|
|
|
|
for(auto& statusId:lstStatus){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(statusId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstStatus.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstInstruct;
|
|
|
|
|
|
for(auto& instructId:lstInstruct){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(instructId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstInstruct.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList sLstEtc;
|
|
|
|
|
|
for(auto& etcId:lstEtc){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(etcId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
sLstEtc.append(pPro->tag());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList<BaseProperty*> lstOther;
|
2025-07-18 18:26:13 +08:00
|
|
|
|
QList<QUuid> lstCompo = _bayProperty->getLstComponent();
|
2025-07-11 18:13:54 +08:00
|
|
|
|
for(auto& compoId:lstCompo){
|
|
|
|
|
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(compoId);
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
if(pPro->uuid() == property->uuid()){ //取本间隔内的其他元件量测
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
lstOther.append(pPro);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList lstOtherMeasure;
|
|
|
|
|
|
for(auto& compo:lstOther){
|
|
|
|
|
|
auto map = compo->getMeasurement();
|
|
|
|
|
|
for(auto& measure:map){
|
|
|
|
|
|
lstOtherMeasure.append(compo->tag()+"-"+measure.tag);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->le_zhbh->setText(sLstProtect.join("、"));
|
|
|
|
|
|
ui->le_jk->setText(sLstInstruct.join("、"));
|
|
|
|
|
|
ui->le_dtgz->setText(sLstDynSense.join("、"));
|
|
|
|
|
|
ui->le_gzlb->setText(sLstFaultRecord.join("、"));
|
|
|
|
|
|
ui->le_ztjc->setText(sLstStatus.join("、"));
|
|
|
|
|
|
ui->le_qt->setText(sLstEtc.join("、"));
|
|
|
|
|
|
|
2025-07-18 18:26:13 +08:00
|
|
|
|
ui->le_bayName->setText(_bayProperty->name());
|
2025-07-11 18:13:54 +08:00
|
|
|
|
addOtherMeasure(lstOtherMeasure);
|
|
|
|
|
|
}
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BayInfoDlg::setUi()
|
|
|
|
|
|
{
|
|
|
|
|
|
QStringList headerText;
|
|
|
|
|
|
headerText<<"TAG"<<"名称"<<"设备"<<"端子"<<"类型"<<"SIZE";
|
|
|
|
|
|
ui->tableWidget_local->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
ui->tableWidget_local->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
|
ui->tableWidget_local->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
|
ui->tableWidget_local->setColumnCount(headerText.count());
|
|
|
|
|
|
ui->tableWidget_local->setHorizontalHeaderLabels(headerText);
|
|
|
|
|
|
ui->tableWidget_local->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
|
ui->tableWidget_local->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
|
|
ui->tableWidget_local->setStyleSheet(
|
|
|
|
|
|
"QTableWidget::item {"
|
|
|
|
|
|
" padding: 5px;" // 可选:增加内边距
|
|
|
|
|
|
" white-space: pre-wrap;" // 关键:保留空白符并允许自动换行
|
|
|
|
|
|
"}"
|
|
|
|
|
|
);
|
2025-07-11 18:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
headerText.clear();
|
|
|
|
|
|
headerText<<"TAG";
|
|
|
|
|
|
ui->tableWidget_other->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
ui->tableWidget_other->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
|
ui->tableWidget_other->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
|
ui->tableWidget_other->setColumnCount(headerText.count());
|
|
|
|
|
|
ui->tableWidget_other->setHorizontalHeaderLabels(headerText);
|
|
|
|
|
|
ui->tableWidget_other->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
|
ui->tableWidget_other->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
|
|
ui->tableWidget_other->setStyleSheet(
|
|
|
|
|
|
"QTableWidget::item {"
|
|
|
|
|
|
" padding: 5px;" // 可选:增加内边距
|
|
|
|
|
|
" white-space: pre-wrap;" // 关键:保留空白符并允许自动换行
|
|
|
|
|
|
"}"
|
|
|
|
|
|
);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
void BayInfoDlg::addMeasure(MeasurementInfo info,int mode)
|
2025-07-04 18:47:49 +08:00
|
|
|
|
{
|
2025-11-05 18:14:31 +08:00
|
|
|
|
if(mode == 0){ //新建
|
|
|
|
|
|
if(_mapMeasure.contains(info.name))
|
|
|
|
|
|
return;
|
|
|
|
|
|
int row = ui->tableWidget_local->rowCount();
|
|
|
|
|
|
ui->tableWidget_local->insertRow(row);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QTableWidgetItem* tagItem = new QTableWidgetItem(info.tag);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 0, tagItem);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QTableWidgetItem* nameItem = new QTableWidgetItem(info.name);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 1, nameItem);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QTableWidgetItem* deviceItem = new QTableWidgetItem(info.equipment);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 2, deviceItem);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QTableWidgetItem* channelItem = new QTableWidgetItem(info.channel);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 3, channelItem);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QString sType;
|
|
|
|
|
|
if(info.type == 0){
|
|
|
|
|
|
sType = "遥测";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 1){
|
|
|
|
|
|
sType = "遥信";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 2){
|
|
|
|
|
|
sType = "遥控";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 3){
|
|
|
|
|
|
sType = "遥调";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 4){
|
|
|
|
|
|
sType = "整定值";
|
|
|
|
|
|
}
|
|
|
|
|
|
QTableWidgetItem* typeItem = new QTableWidgetItem(sType);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 4, typeItem);
|
|
|
|
|
|
|
|
|
|
|
|
QTableWidgetItem* sizeItem = new QTableWidgetItem(QString::number(info.size));
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 5, sizeItem);
|
|
|
|
|
|
|
|
|
|
|
|
if(_bayProperty && _itemProperty){
|
|
|
|
|
|
QUuid bayId = _bayProperty->uuid();
|
|
|
|
|
|
QUuid itemId = _itemProperty->uuid();
|
|
|
|
|
|
info.bayUuid = bayId;
|
|
|
|
|
|
info.componentUuid = itemId;
|
|
|
|
|
|
_mapMeasure.insert(info.name,info);
|
|
|
|
|
|
}
|
2025-07-04 18:47:49 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
/*for(int i = 0;i < _validType.size();++i){
|
|
|
|
|
|
if(_validType.at(i).name == info.name){ //可用类型中移除该类型
|
|
|
|
|
|
_validType.removeAt(i);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}*/
|
2025-07-18 18:26:13 +08:00
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(mode == 1){ //修改
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_local->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),1);
|
|
|
|
|
|
QString sName = indexName.data().toString();
|
|
|
|
|
|
if(_mapMeasure.contains(sName)){
|
|
|
|
|
|
auto itemType = ui->tableWidget_local->item(index.row(),4);
|
|
|
|
|
|
if(itemType){
|
|
|
|
|
|
QString sType;
|
|
|
|
|
|
if(info.type == 0){
|
|
|
|
|
|
sType = "遥测";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 1){
|
|
|
|
|
|
sType = "遥信";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 2){
|
|
|
|
|
|
sType = "遥控";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 3){
|
|
|
|
|
|
sType = "遥调";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(info.type == 4){
|
|
|
|
|
|
sType = "整定值";
|
|
|
|
|
|
}
|
2025-07-18 18:26:13 +08:00
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
itemType->setText(sType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto itemSize = ui->tableWidget_local->item(index.row(),5);
|
|
|
|
|
|
if(itemSize){
|
|
|
|
|
|
itemSize->setText(QString::number(info.size));
|
|
|
|
|
|
}
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-11 18:13:54 +08:00
|
|
|
|
void BayInfoDlg::addOtherMeasure(QStringList lst)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& str:lst){
|
|
|
|
|
|
int row = ui->tableWidget_other->rowCount();
|
|
|
|
|
|
ui->tableWidget_other->insertRow(row);
|
|
|
|
|
|
|
|
|
|
|
|
QTableWidgetItem* tagItem = new QTableWidgetItem(str);
|
|
|
|
|
|
ui->tableWidget_local->setItem(row, 0, tagItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-04 18:47:49 +08:00
|
|
|
|
void BayInfoDlg::onAddClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_measureDlg == nullptr){
|
|
|
|
|
|
_measureDlg = new MeasureSettingDlg(this);
|
|
|
|
|
|
_measureDlg->setBay(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
_measureDlg->showDlg();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BayInfoDlg::onDeleteClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前选中的索引
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_local->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),1);
|
|
|
|
|
|
QString sName = indexName.data().toString();
|
|
|
|
|
|
if(_mapMeasure.contains(sName)){
|
2025-11-05 18:14:31 +08:00
|
|
|
|
/*MeasurementInfo info = _mapMeasure.take(sName);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
measureAttributeType typ;
|
|
|
|
|
|
typ.name = info.name;
|
|
|
|
|
|
typ.tag = info.tag;
|
2025-11-05 18:14:31 +08:00
|
|
|
|
_validType.append(typ);*/
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int currentRow = ui->tableWidget_local->currentRow();
|
|
|
|
|
|
if (currentRow == -1) {
|
|
|
|
|
|
return; // 没有选中行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->tableWidget_local->removeRow(currentRow);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
void BayInfoDlg::onModifyClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前选中的索引
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_local->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),1);
|
|
|
|
|
|
QString sName = indexName.data().toString();
|
|
|
|
|
|
if(_mapMeasure.contains(sName)){
|
|
|
|
|
|
auto info = _mapMeasure.value(sName);
|
|
|
|
|
|
if(_measureDlg == nullptr){
|
|
|
|
|
|
_measureDlg = new MeasureSettingDlg(this);
|
|
|
|
|
|
_measureDlg->setBay(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
_measureDlg->showDlg(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-04 18:47:49 +08:00
|
|
|
|
void BayInfoDlg::onIndexRbtnClicked(const QPoint &pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前点击的位置对应的索引
|
|
|
|
|
|
QModelIndex index = ui->tableWidget_local->indexAt(pos);
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return; // 如果点击的是空白区域,直接返回
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QAction *modifyAction = new QAction("修改量测", this);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
QAction *deleteAction = new QAction("移除量测", this);
|
2025-11-05 18:14:31 +08:00
|
|
|
|
menu.addAction(modifyAction);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
menu.addAction(deleteAction);
|
|
|
|
|
|
|
|
|
|
|
|
// 连接删除菜单项的触发信号与槽函数
|
2025-11-05 18:14:31 +08:00
|
|
|
|
connect(modifyAction, &QAction::triggered, this, &BayInfoDlg::onModifyClicked);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
connect(deleteAction, &QAction::triggered, this, &BayInfoDlg::onDeleteClicked);
|
|
|
|
|
|
|
|
|
|
|
|
// 在点击位置显示菜单
|
|
|
|
|
|
menu.exec(ui->tableWidget_local->mapToGlobal(pos));
|
|
|
|
|
|
}
|