refactor(nmNum): 优化储层参数对象切换布局

- 使用原生分组框承载对象切换下拉框
- 统一对象显示标签并移除重复页面标题
- 保持原有切换、校验和提交逻辑不变
feature/ReservoirPropertiesDlg-Refactoring-20260813
lh 5 days ago
parent 8eebf98ba2
commit 226b942bbf

Binary file not shown.

@ -6790,18 +6790,8 @@ Average pressure in contour: %2 MPa</source>
</context> </context>
<context> <context>
<name>nmReservoirParameterPage</name> <name>nmReservoirParameterPage</name>
<message><source>Reservoir parameters</source><translation></translation></message> <message><source>Object display</source><translation></translation></message>
<message><source>Well parameters</source><translation></translation></message> <message><source>Display:</source><translation></translation></message>
<message><source>Fault parameters</source><translation></translation></message>
<message><source>Fracture parameters</source><translation></translation></message>
<message><source>Composite region parameters</source><translation></translation></message>
<message><source>Region mark parameters</source><translation></translation></message>
<message><source>Select well:</source><translation></translation></message>
<message><source>Select fault:</source><translation></translation></message>
<message><source>Select fracture:</source><translation></translation></message>
<message><source>Select composite region:</source><translation></translation></message>
<message><source>Select region mark:</source><translation></translation></message>
<message><source>Select object:</source><translation></translation></message>
<message><source>No editable objects in this category.</source><translation></translation></message> <message><source>No editable objects in this category.</source><translation></translation></message>
</context> </context>
<context> <context>

@ -12,6 +12,7 @@ class nmReservoirParameterField;
class nmReservoirPropertiesSession; class nmReservoirPropertiesSession;
class QComboBox; class QComboBox;
class QGridLayout; class QGridLayout;
class QGroupBox;
class QLabel; class QLabel;
class QVBoxLayout; class QVBoxLayout;
@ -76,15 +77,9 @@ private slots:
void slotEnumIndexChanged(int nIndex); void slotEnumIndexChanged(int nIndex);
private: private:
/** @brief 创建页标题、对象选择器和单层分组区域。 */ /** @brief 创建对象显示控制区和单层参数分组区域。 */
void createUi(); void createUi();
/** @brief 根据当前分类返回标题。 */
QString categoryTitle() const;
/** @brief 根据当前分类返回对象选择标签。 */
QString objectSelectorLabel() const;
/** @brief 构建指定对象的全部分组和字段。 */ /** @brief 构建指定对象的全部分组和字段。 */
bool buildObject(int nObjectIndex, QString& sError); bool buildObject(int nObjectIndex, QString& sError);
@ -115,8 +110,8 @@ private:
bool m_bUpdatingObject; ///< 阻止对象下拉框回滚重入。 bool m_bUpdatingObject; ///< 阻止对象下拉框回滚重入。
bool m_bBuildingFields; ///< 阻止加载数据时触发业务信号。 bool m_bBuildingFields; ///< 阻止加载数据时触发业务信号。
QLabel* m_pTitleLabel; ///< 页面标题 QGroupBox* m_pObjectDisplayGroup; ///< 对象显示控制分组
QLabel* m_pObjectLabel; ///< 对象选择标签。 QLabel* m_pObjectLabel; ///< 对象显示标签。
QComboBox* m_pObjectComboBox; ///< 多对象选择下拉框。 QComboBox* m_pObjectComboBox; ///< 多对象选择下拉框。
QWidget* m_pGroupsWidget; ///< 无边框的分组布局载体。 QWidget* m_pGroupsWidget; ///< 无边框的分组布局载体。
QGridLayout* m_pGroupsLayout; ///< 两列分组布局。 QGridLayout* m_pGroupsLayout; ///< 两列分组布局。

@ -23,7 +23,7 @@ nmReservoirParameterPage::nmReservoirParameterPage(
m_nCurrentObjectIndex(-1), m_nCurrentObjectIndex(-1),
m_bUpdatingObject(false), m_bUpdatingObject(false),
m_bBuildingFields(false), m_bBuildingFields(false),
m_pTitleLabel(nullptr), m_pObjectDisplayGroup(nullptr),
m_pObjectLabel(nullptr), m_pObjectLabel(nullptr),
m_pObjectComboBox(nullptr), m_pObjectComboBox(nullptr),
m_pGroupsWidget(nullptr), m_pGroupsWidget(nullptr),
@ -45,35 +45,31 @@ nmReservoirParameterPage::~nmReservoirParameterPage()
void nmReservoirParameterPage::createUi() void nmReservoirParameterPage::createUi()
{ {
// 第一步:创建原型中的单层内容头,储层页自动隐藏对象选择器 // 第一步:创建单行对象显示控制区,储层页自动隐藏该分组
m_pMainLayout = new QVBoxLayout(this); m_pMainLayout = new QVBoxLayout(this);
m_pMainLayout->setContentsMargins(8, 6, 8, 8); m_pMainLayout->setContentsMargins(8, 6, 8, 8);
m_pMainLayout->setSpacing(8); m_pMainLayout->setSpacing(8);
QWidget* pHeaderWidget = new QWidget(this); m_pObjectDisplayGroup = new QGroupBox(tr("Object display"), this);
QHBoxLayout* pHeaderLayout = new QHBoxLayout(pHeaderWidget); m_pObjectDisplayGroup->setSizePolicy(
pHeaderLayout->setContentsMargins(8, 4, 8, 4); QSizePolicy::Expanding, QSizePolicy::Fixed);
pHeaderLayout->setSpacing(9); QHBoxLayout* pObjectLayout = new QHBoxLayout(m_pObjectDisplayGroup);
pObjectLayout->setContentsMargins(8, 15, 8, 8);
pObjectLayout->setSpacing(9);
m_pTitleLabel = new QLabel(categoryTitle(), pHeaderWidget); m_pObjectLabel = new QLabel(tr("Display:"), m_pObjectDisplayGroup);
pHeaderLayout->addWidget(m_pTitleLabel, 1); m_pObjectLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_pObjectComboBox = new QComboBox(m_pObjectDisplayGroup);
m_pObjectLabel = new QLabel(objectSelectorLabel(), pHeaderWidget);
m_pObjectComboBox = new QComboBox(pHeaderWidget);
m_pObjectComboBox->setMinimumWidth(260); m_pObjectComboBox->setMinimumWidth(260);
m_pObjectComboBox->setMaximumWidth(420);
m_pObjectComboBox->setMinimumHeight(27); m_pObjectComboBox->setMinimumHeight(27);
pHeaderLayout->addWidget(m_pObjectLabel); pObjectLayout->addStretch(1);
pHeaderLayout->addWidget(m_pObjectComboBox); pObjectLayout->addWidget(m_pObjectLabel);
// 储层页只有一个固定对象,顶部分类按钮已经说明当前页面, pObjectLayout->addWidget(m_pObjectComboBox);
// 不再重复显示无操作价值的页标题;其他页面保留对象选择区。 pObjectLayout->addStretch(1);
if (m_eCategory == NM_RESERVOIR_PAGE_RESERVOIR) m_pMainLayout->addWidget(m_pObjectDisplayGroup);
{ m_pObjectDisplayGroup->setVisible(
pHeaderWidget->hide(); m_eCategory != NM_RESERVOIR_PAGE_RESERVOIR);
}
else
{
m_pMainLayout->addWidget(pHeaderWidget);
}
// 第二步:分组载体没有边框,仅用于实现原型中的两列网格。 // 第二步:分组载体没有边框,仅用于实现原型中的两列网格。
m_pGroupsWidget = new QWidget(this); m_pGroupsWidget = new QWidget(this);
@ -90,46 +86,6 @@ void nmReservoirParameterPage::createUi()
this, SLOT(slotObjectChanged(int))); this, SLOT(slotObjectChanged(int)));
} }
QString nmReservoirParameterPage::categoryTitle() const
{
switch (m_eCategory)
{
case NM_RESERVOIR_PAGE_RESERVOIR:
return tr("Reservoir parameters");
case NM_RESERVOIR_PAGE_WELL:
return tr("Well parameters");
case NM_RESERVOIR_PAGE_FAULT:
return tr("Fault parameters");
case NM_RESERVOIR_PAGE_FRACTURE:
return tr("Fracture parameters");
case NM_RESERVOIR_PAGE_COMPOSITE_REGION:
return tr("Composite region parameters");
case NM_RESERVOIR_PAGE_REGION_MARK:
return tr("Region mark parameters");
default:
return QString();
}
}
QString nmReservoirParameterPage::objectSelectorLabel() const
{
switch (m_eCategory)
{
case NM_RESERVOIR_PAGE_WELL:
return tr("Select well:");
case NM_RESERVOIR_PAGE_FAULT:
return tr("Select fault:");
case NM_RESERVOIR_PAGE_FRACTURE:
return tr("Select fracture:");
case NM_RESERVOIR_PAGE_COMPOSITE_REGION:
return tr("Select composite region:");
case NM_RESERVOIR_PAGE_REGION_MARK:
return tr("Select region mark:");
default:
return tr("Select object:");
}
}
bool nmReservoirParameterPage::reloadObjects(QString& sError) bool nmReservoirParameterPage::reloadObjects(QString& sError)
{ {
// 第一步重新取得会话对象描述并把稳定对象code放入UserRole。 // 第一步重新取得会话对象描述并把稳定对象code放入UserRole。
@ -148,8 +104,7 @@ bool nmReservoirParameterPage::reloadObjects(QString& sError)
m_bUpdatingObject = false; m_bUpdatingObject = false;
bool bShowSelector = m_eCategory != NM_RESERVOIR_PAGE_RESERVOIR; bool bShowSelector = m_eCategory != NM_RESERVOIR_PAGE_RESERVOIR;
m_pObjectLabel->setVisible(bShowSelector); m_pObjectDisplayGroup->setVisible(bShowSelector);
m_pObjectComboBox->setVisible(bShowSelector);
// 第二步:构建首个对象;空分类显示无额外面板的空状态。 // 第二步:构建首个对象;空分类显示无额外面板的空状态。
return buildObject(m_listObjectInfos.isEmpty() ? -1 : 0, sError); return buildObject(m_listObjectInfos.isEmpty() ? -1 : 0, sError);

Loading…
Cancel
Save