fix(nmNum): 修复地图测距和区域绘制并简化删除确认

- 移除测距触发的网格失效通知,保留已有 PEBI 网格和计算结果
- 将区域填充、轮廓和选中标记裁剪在绘图区内,避免遮挡坐标刻度
- 使用 Qt 标准删除确认框,按内容自动定尺寸,默认选择「取消」并更新中文翻译
feature/fix-result-persistence-20261118
lh 2 days ago
parent f552645543
commit 5efb2668d9

Binary file not shown.

@ -2451,7 +2451,7 @@ No valid error was returned; keep the last accepted result and reduce the step.<
<name>nmDeleteConfirmationDlg</name>
<message><source>Delete object</source><translation>删除图元</translation></message>
<message><source>Delete %1 "%2"?</source><translation>确定删除%1“%2”?</translation></message>
<message><source>Unnamed object</source><translation>未命名图元</translation></message>
<message><source>Delete %1?</source><translation>确定删除%1?</translation></message>
<message><source>Delete</source><translation>删除</translation></message>
<message><source>Cancel</source><translation>取消</translation></message>
</context>

@ -1,13 +1,13 @@
#ifndef NMDELETECONFIRMATIONDLG_H
#define NMDELETECONFIRMATIONDLG_H
#include "iDlgBase.h"
#include "nmSubWxs_global.h"
#include <QMessageBox>
#include <QString>
/** @brief 展示待删除图元的名称和类型,仅返回用户确认结果。 */
class NM_SUB_WXS_EXPORT nmDeleteConfirmationDlg : public iDlgBase
class NM_SUB_WXS_EXPORT nmDeleteConfirmationDlg : public QMessageBox
{
Q_OBJECT
@ -20,12 +20,6 @@ public:
private:
Q_DISABLE_COPY(nmDeleteConfirmationDlg)
/** @brief 创建图标、可换行的纯文本确认信息及统一底栏,尺寸随内容与主题调整。 */
void createUi(const QString& sObjectName,
const QString& sObjectType);
/** @brief 创建确认和取消按钮,默认焦点停留在取消,操作结果由 accept/reject 返回。 */
QWidget* createFooter();
};
#endif // NMDELETECONFIRMATIONDLG_H

@ -233,6 +233,7 @@ void nmObjRegion::paintBack(QPainter* painter, const ZxPaintParam& param)
}
painter->save();
painter->setClipRect(getOuterRect(), Qt::IntersectClip);
QVector<QPointF> pts = getPosOf(m_vecPoints);
// 不选中的状态

@ -1269,10 +1269,9 @@ void nmPlotGraphicBinder::createMeasureForGraphic(nmObjLineMeasure* pGraphic)
m_mapMeasureData[pGraphic] = pData;
pGraphic->setGraphicBinder(this);
// 对话框只修改模型;由绑定器负责把变更送回所属画布,不依赖偶然重绘。
// 测距通过测量数据自己的信号刷新,避免触发 PEBI 网格失效。
QObject::connect(pData, SIGNAL(sigMeasureDataChanged()),
this, SLOT(onMeasureDataChanged()), Qt::UniqueConnection);
m_pDataMgr->notifyDataChanged();
}
// 删除测量线图元:移除映射(不删除数据对象,由 DataManager 管理)

@ -1,82 +1,22 @@
#include "nmDeleteConfirmationDlg.h"
#include "ZxBaseUtil.h"
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QSizePolicy>
#include <QStyle>
#include <QVBoxLayout>
#include <QAbstractButton>
#include <QIcon>
nmDeleteConfirmationDlg::nmDeleteConfirmationDlg(
const QString& sObjectName, const QString& sObjectType, QWidget* pParent)
: iDlgBase(pParent)
: QMessageBox(QMessageBox::Warning, tr("Delete object"), QString(),
QMessageBox::Ok | QMessageBox::Cancel, pParent)
{
createUi(sObjectName, sObjectType);
// 按提示文字、图标和按钮计算初始尺寸,避免短提示右侧出现额外留白。
adjustSize();
}
void nmDeleteConfirmationDlg::createUi(
const QString& sObjectName, const QString& sObjectType)
{
setWindowTitle(tr("Delete object"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setModal(true);
// Esc 和取消按钮均只返回拒绝结果,不执行任何删除或边界切换操作。
setIgnoreEsc(false);
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
pMainLayout->setContentsMargins(12, 10, 12, 0);
pMainLayout->setSpacing(10);
setTextFormat(Qt::PlainText);
setText(sObjectName.trimmed().isEmpty()
? tr("Delete %1?").arg(sObjectType)
: tr("Delete %1 \"%2\"?").arg(sObjectType, sObjectName));
QWidget* pContent = new QWidget(this);
pContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QHBoxLayout* pContentLayout = new QHBoxLayout(pContent);
pContentLayout->setContentsMargins(0, 0, 0, 0);
pContentLayout->setSpacing(10);
// 提示图标与确认文字并排展示,避免把只供核对的信息排成参数编辑表单。
QLabel* pIconLabel = new QLabel(pContent);
const int nIconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
pIconLabel->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(nIconSize, nIconSize));
pContentLayout->addWidget(pIconLabel, 0, Qt::AlignTop);
const QString sDisplayName = sObjectName.trimmed().isEmpty()
? tr("Unnamed object") : sObjectName;
const QString sMessage = tr("Delete %1 \"%2\"?").arg(sObjectType, sDisplayName);
QLabel* pMessageLabel = new QLabel(sMessage, pContent);
// 名称中的尖括号等字符按原文显示,不被解释为富文本;长文字随窗口换行。
pMessageLabel->setTextFormat(Qt::PlainText);
pMessageLabel->setWordWrap(true);
pMessageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
pContentLayout->addWidget(pMessageLabel, 1);
pMainLayout->addWidget(pContent);
pMainLayout->addStretch(1);
pMainLayout->addWidget(createFooter());
}
QWidget* nmDeleteConfirmationDlg::createFooter()
{
QWidget* pFooter = new QWidget(this);
pFooter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
QHBoxLayout* pLayout = new QHBoxLayout(pFooter);
pLayout->setContentsMargins(4, 5, 4, 5);
pLayout->setSpacing(8);
pLayout->addStretch(1);
QDialogButtonBox* pButtons = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, pFooter);
QPushButton* pConfirmButton = pButtons->button(QDialogButtonBox::Ok);
QPushButton* pCancelButton = pButtons->button(QDialogButtonBox::Cancel);
pConfirmButton->setText(tr("Delete"));
pConfirmButton->setIcon(zxLoadIcon("NmDelete"));
pConfirmButton->setDefault(false);
pCancelButton->setText(tr("Cancel"));
pCancelButton->setIcon(zxLoadIcon("Cancel"));
pCancelButton->setDefault(true);
pCancelButton->setFocus(Qt::OtherFocusReason);
pLayout->addWidget(pButtons);
connect(pButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(pButtons, SIGNAL(rejected()), this, SLOT(reject()));
return pFooter;
button(QMessageBox::Ok)->setText(tr("Delete"));
button(QMessageBox::Ok)->setIcon(QIcon());
button(QMessageBox::Cancel)->setText(tr("Cancel"));
button(QMessageBox::Cancel)->setIcon(QIcon());
setDefaultButton(QMessageBox::Cancel);
setEscapeButton(QMessageBox::Cancel);
}

@ -84,7 +84,7 @@ bool nmSubWxsPlotDialogController::confirmDeleteObject(
QWidget* pParent, const QString& sObjectName, const QString& sObjectTag)
{
nmDeleteConfirmationDlg oDialog(sObjectName, objectTypeText(sObjectTag), pParent);
return oDialog.exec() == QDialog::Accepted;
return oDialog.exec() == QMessageBox::Ok;
}
bool nmSubWxsPlotDialogController::confirmSwitchOutline(

Loading…
Cancel
Save