refactor(nmNum): 调整编辑井身份信息布局

- 将井号、井名和井型从基础参数分组中独立出来
- 在左侧参数区顶部固定显示井信息
- 只读展示项目级井号,保留井名编辑和同步逻辑
- 简化 nmWellParameterPanel 的控件管理职责
- 移除参数目录中不再使用的基础分组标记
- 更新中文翻译及 QM 资源
feature/refactor-well-editor-20260821
lh 3 weeks ago
parent b4321842f2
commit 3460b4680e

Binary file not shown.

@ -6542,8 +6542,6 @@ Average pressure in contour: %2 MPa</source>
<context> <context>
<name>nmWellParameterPanel</name> <name>nmWellParameterPanel</name>
<message><source>The well working copy is unavailable.</source><translation></translation></message> <message><source>The well working copy is unavailable.</source><translation></translation></message>
<message><source>Well name</source><translation></translation></message>
<message><source>Well type</source><translation></translation></message>
<message><source>Perforation</source><translation></translation></message> <message><source>Perforation</source><translation></translation></message>
<message><source>Perforation %1</source><translation> %1</translation></message> <message><source>Perforation %1</source><translation> %1</translation></message>
<message><source>No perforations</source><translation></translation></message> <message><source>No perforations</source><translation></translation></message>
@ -6559,6 +6557,11 @@ Average pressure in contour: %2 MPa</source>
<name>nmWxWellEditor</name> <name>nmWxWellEditor</name>
<message><source>Edit well</source><translation></translation></message> <message><source>Edit well</source><translation></translation></message>
<message><source>The well working copy is unavailable.</source><translation></translation></message> <message><source>The well working copy is unavailable.</source><translation></translation></message>
<message><source>Well information</source><translation></translation></message>
<message><source>Well number</source><translation></translation></message>
<message><source>Well name</source><translation></translation></message>
<message><source>Well type</source><translation></translation></message>
<message><source>Project-level unique well identifier</source><translation></translation></message>
<message><source>Vertical well</source><translation></translation></message> <message><source>Vertical well</source><translation></translation></message>
<message><source>Fractured vertical well</source><translation></translation></message> <message><source>Fractured vertical well</source><translation></translation></message>
<message><source>Multistage fractured horizontal well</source><translation></translation></message> <message><source>Multistage fractured horizontal well</source><translation></translation></message>

@ -41,7 +41,6 @@ struct NM_SUB_WXS_EXPORT nmWellParameterGroupInfo
QString m_sTitle; ///< 当前语言下的分组标题。 QString m_sTitle; ///< 当前语言下的分组标题。
QList<nmParameterFieldInfo> m_listFields; ///< 分组字段。 QList<nmParameterFieldInfo> m_listFields; ///< 分组字段。
bool m_bBasicGroup; ///< 是否承载井名和井型控件。
bool m_bPerforationGroup; ///< 是否创建射孔选择器。 bool m_bPerforationGroup; ///< 是否创建射孔选择器。
}; };

@ -14,7 +14,6 @@ class nmIParameterUnitService;
class nmParameterField; class nmParameterField;
struct nmWellParameterGroupInfo; struct nmWellParameterGroupInfo;
class QComboBox; class QComboBox;
class QLineEdit;
class QVBoxLayout; class QVBoxLayout;
/** /**
@ -43,12 +42,6 @@ public:
/** @brief 返回全部可见输入是否有效。 */ /** @brief 返回全部可见输入是否有效。 */
bool isInputValid(); bool isInputValid();
/** @brief 返回基础参数分组中的井名输入框,不转移所有权。 */
QLineEdit* wellNameEditor() const;
/** @brief 返回基础参数分组中的井型选择器,不转移所有权。 */
QComboBox* wellTypeEditor() const;
/** @brief 将焦点移动到第一个无效字段。 */ /** @brief 将焦点移动到第一个无效字段。 */
void focusFirstInvalid(); void focusFirstInvalid();
@ -93,9 +86,6 @@ private:
/** @brief 仅同步当前射孔名称,不改变选择器结构和当前选中项。 */ /** @brief 仅同步当前射孔名称,不改变选择器结构和当前选中项。 */
void updateCurrentPerforationItem(); void updateCurrentPerforationItem();
/** @brief 将井信息控件移回面板,避免分组重建时被一并销毁。 */
void detachWellInformationEditors();
/** @brief 收集基准单位值并执行字段及关联规则校验。 */ /** @brief 收集基准单位值并执行字段及关联规则校验。 */
bool collectValues(QMap<QString, QVariant>& mapValues, bool collectValues(QMap<QString, QVariant>& mapValues,
QString& sError, QString& sError,
@ -121,8 +111,6 @@ private:
nmIParameterUnitService* m_pUnitService; ///< 单位服务,不拥有所有权。 nmIParameterUnitService* m_pUnitService; ///< 单位服务,不拥有所有权。
nmDataWellBase* m_pWell; ///< 当前工作副本,不拥有所有权。 nmDataWellBase* m_pWell; ///< 当前工作副本,不拥有所有权。
QVBoxLayout* m_pMainLayout; ///< 单列分组布局。 QVBoxLayout* m_pMainLayout; ///< 单列分组布局。
QLineEdit* m_pWellNameLineEdit; ///< 基础分组中的井名输入框。
QComboBox* m_pWellTypeComboBox; ///< 基础分组中的井型选择器。
QComboBox* m_pPerforationComboBox; ///< 当前射孔选择器。 QComboBox* m_pPerforationComboBox; ///< 当前射孔选择器。
QList<nmParameterField*> m_listFields; ///< 当前井型字段。 QList<nmParameterField*> m_listFields; ///< 当前井型字段。
QMap<QString, nmParameterField*> m_mapFields; ///< 稳定ID字段映射。 QMap<QString, nmParameterField*> m_mapFields; ///< 稳定ID字段映射。

@ -98,6 +98,9 @@ private:
/** @brief 创建左侧参数区、右侧轨迹区和底部命令区。 */ /** @brief 创建左侧参数区、右侧轨迹区和底部命令区。 */
void createUi(); void createUi();
/** @brief 创建固定显示的井号、井名和井型信息区。 */
QWidget* createWellInformationWidget(QWidget* pParent);
/** @brief 创建时间变表皮入口、校验提示和确认按钮区。 */ /** @brief 创建时间变表皮入口、校验提示和确认按钮区。 */
QWidget* createFooter(); QWidget* createFooter();
@ -124,6 +127,7 @@ private:
nmWellParameterPanel* m_pParameterPanel; ///< 左侧单列参数分组。 nmWellParameterPanel* m_pParameterPanel; ///< 左侧单列参数分组。
nmWxWellboreTrajectoryDisplay* m_pTrajectoryDisplay; ///< 右侧轨迹视图。 nmWxWellboreTrajectoryDisplay* m_pTrajectoryDisplay; ///< 右侧轨迹视图。
nmWellEditorController* m_pWellEditorController; ///< 轨迹交互控制器。 nmWellEditorController* m_pWellEditorController; ///< 轨迹交互控制器。
QLineEdit* m_pWellCodeLineEdit; ///< 只读项目级井号。
QLineEdit* m_pWellNameLineEdit; ///< 井名输入框。 QLineEdit* m_pWellNameLineEdit; ///< 井名输入框。
QComboBox* m_pWellTypeComboBox; ///< 井型选择器。 QComboBox* m_pWellTypeComboBox; ///< 井型选择器。
QCheckBox* m_pTimeDependentCheckBox; ///< 时间变表皮开关。 QCheckBox* m_pTimeDependentCheckBox; ///< 时间变表皮开关。

@ -63,8 +63,7 @@ nmWellParameterGroupInfo parameterGroup(const char* pTitle)
} }
nmWellParameterGroupInfo::nmWellParameterGroupInfo() nmWellParameterGroupInfo::nmWellParameterGroupInfo()
: m_bBasicGroup(false), : m_bPerforationGroup(false)
m_bPerforationGroup(false)
{ {
} }
@ -76,7 +75,6 @@ QList<nmWellParameterGroupInfo> nmWellParameterCatalog::createGroups(
// 第一步:所有支持井型都显示通用井筒参数。 // 第一步:所有支持井型都显示通用井筒参数。
nmWellParameterGroupInfo oBasic = nmWellParameterGroupInfo oBasic =
parameterGroup("Basic parameters"); parameterGroup("Basic parameters");
oBasic.m_bBasicGroup = true;
oBasic.m_listFields oBasic.m_listFields
<< numericField(NM_WELL_PARAMETER_X, "W_X") << numericField(NM_WELL_PARAMETER_X, "W_X")
<< numericField(NM_WELL_PARAMETER_Y, "W_Y") << numericField(NM_WELL_PARAMETER_Y, "W_Y")

@ -38,8 +38,6 @@ nmWellParameterPanel::nmWellParameterPanel(
m_pUnitService(pUnitService), m_pUnitService(pUnitService),
m_pWell(nullptr), m_pWell(nullptr),
m_pMainLayout(new QVBoxLayout(this)), m_pMainLayout(new QVBoxLayout(this)),
m_pWellNameLineEdit(new QLineEdit(this)),
m_pWellTypeComboBox(new QComboBox(this)),
m_pPerforationComboBox(nullptr), m_pPerforationComboBox(nullptr),
m_listFields(), m_listFields(),
m_mapFields(), m_mapFields(),
@ -53,19 +51,6 @@ nmWellParameterPanel::nmWellParameterPanel(
m_pMainLayout->setContentsMargins(8, 8, 8, 8); m_pMainLayout->setContentsMargins(8, 8, 8, 8);
m_pMainLayout->setSpacing(10); m_pMainLayout->setSpacing(10);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_pWellNameLineEdit->setFixedHeight(nmParameterField::editorHeight());
m_pWellNameLineEdit->setMinimumWidth(
nmParameterField::editorMinimumWidth());
m_pWellNameLineEdit->setSizePolicy(
QSizePolicy::Expanding, QSizePolicy::Fixed);
m_pWellTypeComboBox->setFixedHeight(nmParameterField::editorHeight());
m_pWellTypeComboBox->setMinimumWidth(
nmParameterField::editorMinimumWidth());
m_pWellTypeComboBox->setSizePolicy(
QSizePolicy::Expanding, QSizePolicy::Fixed);
m_pWellNameLineEdit->hide();
m_pWellTypeComboBox->hide();
} }
nmWellParameterPanel::~nmWellParameterPanel() nmWellParameterPanel::~nmWellParameterPanel()
@ -216,16 +201,6 @@ bool nmWellParameterPanel::isInputValid()
return collectValues(mapValues, sError); return collectValues(mapValues, sError);
} }
QLineEdit* nmWellParameterPanel::wellNameEditor() const
{
return m_pWellNameLineEdit;
}
QComboBox* nmWellParameterPanel::wellTypeEditor() const
{
return m_pWellTypeComboBox;
}
void nmWellParameterPanel::focusFirstInvalid() void nmWellParameterPanel::focusFirstInvalid()
{ {
// 按界面显示顺序定位错误,使用户无需自行查找红色字段。 // 按界面显示顺序定位错误,使用户无需自行查找红色字段。
@ -368,8 +343,6 @@ void nmWellParameterPanel::slotWellDataChanged()
void nmWellParameterPanel::clearGroups() void nmWellParameterPanel::clearGroups()
{ {
// 井信息控件跨井型复用,删除旧基础分组前先转移回参数面板。
detachWellInformationEditors();
m_listFields.clear(); m_listFields.clear();
m_mapFields.clear(); m_mapFields.clear();
m_pPerforationComboBox = nullptr; m_pPerforationComboBox = nullptr;
@ -386,22 +359,6 @@ void nmWellParameterPanel::clearGroups()
} }
} }
void nmWellParameterPanel::detachWellInformationEditors()
{
if (m_pWellNameLineEdit != nullptr &&
m_pWellNameLineEdit->parentWidget() != this)
{
m_pWellNameLineEdit->setParent(this);
m_pWellNameLineEdit->hide();
}
if (m_pWellTypeComboBox != nullptr &&
m_pWellTypeComboBox->parentWidget() != this)
{
m_pWellTypeComboBox->setParent(this);
m_pWellTypeComboBox->hide();
}
}
bool nmWellParameterPanel::buildGroup( bool nmWellParameterPanel::buildGroup(
const nmWellParameterGroupInfo& oGroupInfo, const nmWellParameterGroupInfo& oGroupInfo,
QString& sError) QString& sError)
@ -421,27 +378,8 @@ bool nmWellParameterPanel::buildGroup(
pFieldLayout->setColumnMinimumWidth( pFieldLayout->setColumnMinimumWidth(
2, nmParameterField::unitMinimumWidth()); 2, nmParameterField::unitMinimumWidth());
// 第二步:基础分组先挂载井信息,输入控件固定在第二列,第三列留给单位 // 第二步:射孔选择器只占第二列,不侵入单位列
int nRowOffset = 0; int nRowOffset = 0;
if (oGroupInfo.m_bBasicGroup)
{
QLabel* pNameLabel = new QLabel(tr("Well name"), pGroupBox);
QLabel* pTypeLabel = new QLabel(tr("Well type"), pGroupBox);
pNameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
pTypeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_pWellNameLineEdit->setParent(pGroupBox);
m_pWellTypeComboBox->setParent(pGroupBox);
pFieldLayout->addWidget(pNameLabel, 0, 0);
pFieldLayout->addWidget(m_pWellNameLineEdit, 0, 1);
pFieldLayout->addWidget(pTypeLabel, 1, 0);
pFieldLayout->addWidget(m_pWellTypeComboBox, 1, 1);
m_pWellNameLineEdit->show();
m_pWellTypeComboBox->show();
nRowOffset = 2;
}
// 第三步:射孔选择器同样只占第二列,不侵入单位列。
if (oGroupInfo.m_bPerforationGroup) if (oGroupInfo.m_bPerforationGroup)
{ {
QLabel* pSelectorLabel = new QLabel(tr("Perforation"), pGroupBox); QLabel* pSelectorLabel = new QLabel(tr("Perforation"), pGroupBox);
@ -456,7 +394,7 @@ bool nmWellParameterPanel::buildGroup(
nRowOffset = 1; nRowOffset = 1;
} }
// 第按目录顺序创建字段并建立稳定ID到字段对象的索引。 // 第按目录顺序创建字段并建立稳定ID到字段对象的索引。
for (int nIndex = 0; nIndex < oGroupInfo.m_listFields.size(); ++nIndex) for (int nIndex = 0; nIndex < oGroupInfo.m_listFields.size(); ++nIndex)
{ {
nmParameterField* pField = new nmParameterField( nmParameterField* pField = new nmParameterField(
@ -468,10 +406,6 @@ bool nmWellParameterPanel::buildGroup(
0, 0,
sError)) sError))
{ {
if (oGroupInfo.m_bBasicGroup)
{
detachWellInformationEditors();
}
delete pGroupBox; delete pGroupBox;
return false; return false;
} }

@ -18,11 +18,14 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFrame> #include <QFrame>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QIcon> #include <QIcon>
#include <QKeyEvent> #include <QKeyEvent>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QList>
#include <QPalette> #include <QPalette>
#include <QPushButton> #include <QPushButton>
#include <QRegExp> #include <QRegExp>
@ -39,6 +42,7 @@ nmWxWellEditor::nmWxWellEditor(const nmWellEditContext& oContext,
m_pParameterPanel(nullptr), m_pParameterPanel(nullptr),
m_pTrajectoryDisplay(nullptr), m_pTrajectoryDisplay(nullptr),
m_pWellEditorController(nullptr), m_pWellEditorController(nullptr),
m_pWellCodeLineEdit(nullptr),
m_pWellNameLineEdit(nullptr), m_pWellNameLineEdit(nullptr),
m_pWellTypeComboBox(nullptr), m_pWellTypeComboBox(nullptr),
m_pTimeDependentCheckBox(nullptr), m_pTimeDependentCheckBox(nullptr),
@ -88,6 +92,7 @@ bool nmWxWellEditor::initialize(QString& sError)
} }
// 第一步:同步井信息和时间变表皮控件。 // 第一步:同步井信息和时间变表皮控件。
m_pWellCodeLineEdit->setText(pWell->getWellCode());
m_pWellNameLineEdit->setText(pWell->getWellName()); m_pWellNameLineEdit->setText(pWell->getWellName());
int nWellTypeIndex = m_pWellTypeComboBox->findData( int nWellTypeIndex = m_pWellTypeComboBox->findData(
static_cast<int>(pWell->getWellType())); static_cast<int>(pWell->getWellType()));
@ -380,21 +385,21 @@ void nmWxWellEditor::createUi()
pMainLayout->setContentsMargins(12, 10, 12, 0); pMainLayout->setContentsMargins(12, 10, 12, 0);
pMainLayout->setSpacing(8); pMainLayout->setSpacing(8);
// 第一步:左侧全部信息进入同一滚动参数面板,右侧保持常驻轨迹视图。 // 第一步:左侧固定井信息并滚动参数分组,右侧保持常驻轨迹视图。
m_pMainSplitter = new QSplitter(Qt::Horizontal, this); m_pMainSplitter = new QSplitter(Qt::Horizontal, this);
m_pMainSplitter->setChildrenCollapsible(false); m_pMainSplitter->setChildrenCollapsible(false);
QWidget* pParameterContainer = new QWidget(m_pMainSplitter); QWidget* pParameterContainer = new QWidget(m_pMainSplitter);
QVBoxLayout* pParameterLayout = new QVBoxLayout(pParameterContainer); QVBoxLayout* pParameterLayout = new QVBoxLayout(pParameterContainer);
pParameterLayout->setContentsMargins(0, 0, 0, 0); pParameterLayout->setContentsMargins(0, 0, 0, 0);
pParameterLayout->setSpacing(0); pParameterLayout->setSpacing(8);
QScrollArea* pScrollArea = new QScrollArea(pParameterContainer); QScrollArea* pScrollArea = new QScrollArea(pParameterContainer);
pScrollArea->setWidgetResizable(true); pScrollArea->setWidgetResizable(true);
pScrollArea->setFrameShape(QFrame::NoFrame); pScrollArea->setFrameShape(QFrame::NoFrame);
m_pParameterPanel = new nmWellParameterPanel(this, pScrollArea); m_pParameterPanel = new nmWellParameterPanel(this, pScrollArea);
m_pWellNameLineEdit = m_pParameterPanel->wellNameEditor(); pParameterLayout->addWidget(
m_pWellTypeComboBox = m_pParameterPanel->wellTypeEditor(); createWellInformationWidget(pParameterContainer));
m_pWellTypeComboBox->addItem( m_pWellTypeComboBox->addItem(
tr("Vertical well"), static_cast<int>(Vertical_Well)); tr("Vertical well"), static_cast<int>(Vertical_Well));
m_pWellTypeComboBox->addItem( m_pWellTypeComboBox->addItem(
@ -431,6 +436,54 @@ void nmWxWellEditor::createUi()
this, SLOT(slotPanelValidationMessageChanged(QString))); this, SLOT(slotPanelValidationMessageChanged(QString)));
} }
QWidget* nmWxWellEditor::createWellInformationWidget(QWidget* pParent)
{
QGroupBox* pInformationGroup = new QGroupBox(
tr("Well information"), pParent);
QGridLayout* pInformationLayout = new QGridLayout(pInformationGroup);
pInformationLayout->setContentsMargins(8, 15, 8, 10);
pInformationLayout->setHorizontalSpacing(6);
pInformationLayout->setVerticalSpacing(6);
pInformationLayout->setColumnStretch(0, 0);
pInformationLayout->setColumnStretch(1, 1);
QLabel* pCodeLabel = new QLabel(tr("Well number"), pInformationGroup);
QLabel* pNameLabel = new QLabel(tr("Well name"), pInformationGroup);
QLabel* pTypeLabel = new QLabel(tr("Well type"), pInformationGroup);
pCodeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
pNameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
pTypeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_pWellCodeLineEdit = new QLineEdit(pInformationGroup);
m_pWellNameLineEdit = new QLineEdit(pInformationGroup);
m_pWellTypeComboBox = new QComboBox(pInformationGroup);
m_pWellCodeLineEdit->setReadOnly(true);
m_pWellCodeLineEdit->setToolTip(
tr("Project-level unique well identifier"));
QList<QWidget*> listEditors;
listEditors << m_pWellCodeLineEdit
<< m_pWellNameLineEdit
<< m_pWellTypeComboBox;
for (int nIndex = 0; nIndex < listEditors.size(); ++nIndex)
{
listEditors[nIndex]->setFixedHeight(
nmParameterField::editorHeight());
listEditors[nIndex]->setMinimumWidth(
nmParameterField::editorMinimumWidth());
listEditors[nIndex]->setSizePolicy(
QSizePolicy::Expanding, QSizePolicy::Fixed);
}
pInformationLayout->addWidget(pCodeLabel, 0, 0);
pInformationLayout->addWidget(m_pWellCodeLineEdit, 0, 1);
pInformationLayout->addWidget(pNameLabel, 1, 0);
pInformationLayout->addWidget(m_pWellNameLineEdit, 1, 1);
pInformationLayout->addWidget(pTypeLabel, 2, 0);
pInformationLayout->addWidget(m_pWellTypeComboBox, 2, 1);
return pInformationGroup;
}
QWidget* nmWxWellEditor::createFooter() QWidget* nmWxWellEditor::createFooter()
{ {
QWidget* pFooter = new QWidget(this); QWidget* pFooter = new QWidget(this);

Loading…
Cancel
Save