diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm
index c9591eb6..920aec6b 100644
Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ
diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts
index f1bdacd1..6a8259c4 100644
--- a/Bin/Config/Lang/cn/nmNum_cn.ts
+++ b/Bin/Config/Lang/cn/nmNum_cn.ts
@@ -5220,6 +5220,9 @@ Please check your input coordinates.
Unknown未知
None无
(unnamed)(未命名)
+ Curve name: %1曲线名称:%1
+ Gauge Code: %1记录编号:%1
+ Measurement time: %1测量时间:%1
(Empty)(空)
(Corrupt)(损坏)
(Invalid)(无效)
@@ -7213,7 +7216,11 @@ Average pressure in contour: %2 MPa
Pressure Record压力记录
Flow Record流量记录
Display Phase显示相
- This page only displays the selected record.此页面仅展示当前选中的记录。
+ (unnamed)(未命名)
+ Curve name: %1曲线名称:%1
+ Gauge Code: %1记录编号:%1
+ Measurement time: %1测量时间:%1
+ Preview only; calculation settings are unchanged.仅切换页面预览,不影响计算配置。
(Invalid) (无效)
(Empty) (空)
(Corrupt) (损坏)
diff --git a/Include/nmNum/nmSubWxs/nmWellPressureFlowPage.h b/Include/nmNum/nmSubWxs/nmWellPressureFlowPage.h
index 65097ad4..28badf99 100644
--- a/Include/nmNum/nmSubWxs/nmWellPressureFlowPage.h
+++ b/Include/nmNum/nmSubWxs/nmWellPressureFlowPage.h
@@ -59,6 +59,12 @@ private slots:
/** @brief 将流量曲线点击时间映射为表格行选择。 */
void slotFlowChartPointClicked(double dTimePoint);
+ /** @brief 切换压力记录预览,仅刷新页面,不修改井的计算记录选择。 */
+ void slotPressureGaugePreviewChanged(int nIndex);
+
+ /** @brief 切换流量记录预览,仅刷新页面,不修改井的计算记录选择。 */
+ void slotFlowGaugePreviewChanged(int nIndex);
+
/** @brief 切换显示相下拉框,仅重新按新相取点刷新视图,不改变井数据。 */
void slotDisplayPhaseChanged(int nIndex);
@@ -72,10 +78,10 @@ private:
/** @brief 创建顶部压力/流量记录与显示相三个下拉框所在行。 */
void createRecordSelectionBar();
- /** @brief 按 m_pWell->getPressureRecords() 填充压力记录下拉框,恢复当前选中项。 */
+ /** @brief 填充压力记录预览下拉框,优先恢复页面预览项。 */
void populatePressureGaugeCombo();
- /** @brief 按 m_pWell->getFlowRecords() 填充流量记录下拉框,恢复当前选中项。 */
+ /** @brief 填充流量记录预览下拉框,优先恢复页面预览项。 */
void populateFlowGaugeCombo();
/** @brief 按当前选中流量记录的真实相填充显示相下拉框;至多 1 项时隐藏整行。 */
@@ -84,7 +90,10 @@ private:
/** @brief 返回记录的默认显示相:优先井别参考相,否则记录中第一个有真实数据的相。 */
NM_PHASE_TYPE defaultDisplayPhase(const nmFlowGaugeRecord* pRecord) const;
- /** @brief 按 m_pWell->getSelectedFlowGaugeCode() 在流量记录列表中查找当前选中记录。 */
+ /** @brief 在缓存中查找当前预览的压力记录。 */
+ const nmPressureGaugeRecord* currentPressureRecord() const;
+
+ /** @brief 在缓存中查找当前预览的流量记录。 */
const nmFlowGaugeRecord* currentFlowRecord() const;
/** @brief 重新获取框架单位组并同步双行表头。 */
@@ -162,11 +171,14 @@ private:
int m_nSelectedFlowSegment;
QWidget* m_pRecordSelectionBar; ///< 顶部压力/流量记录与显示相下拉框所在行容器。
- QComboBox* m_pPressureGaugeCombo; ///< 当前压力记录只读展示,itemData 存 Gauge Code。
- QComboBox* m_pFlowGaugeCombo; ///< 当前流量记录只读展示,itemData 存 Gauge Code。
+ QComboBox* m_pPressureGaugeCombo; ///< 压力记录预览选择,itemData 存 Gauge Code。
+ QComboBox* m_pFlowGaugeCombo; ///< 流量记录预览选择,itemData 存 Gauge Code。
QComboBox* m_pDisplayPhaseCombo; ///< 显示相下拉框,itemData 存 NM_PHASE_TYPE。
QWidget* m_pDisplayPhaseContainer; ///< 承载显示相下拉框与标签,整体隐藏用。
QPushButton* m_pCheckDataButton; ///< 临时“检查数据”诊断按钮,只读展示用。
NM_PHASE_TYPE m_eDisplayPhase; ///< 当前预览的流量相,纯展示状态,不写回井对象。
+ QString m_sPreviewPressureGaugeCode; ///< 当前页面预览的压力记录,不持久化。
+ QString m_sPreviewFlowGaugeCode; ///< 当前页面预览的流量记录,不持久化。
+ QVector m_vecPressureGaugeRecords; ///< 压力记录页面缓存。
QVector m_vecFlowGaugeRecords; ///< 每次填充流量下拉框时缓存的记录列表,供 currentFlowRecord() 安全返回内部指针。
};
diff --git a/Src/nmNum/nmSubWxs/nmWellPressureFlowPage.cpp b/Src/nmNum/nmSubWxs/nmWellPressureFlowPage.cpp
index 1529215b..cc68567e 100644
--- a/Src/nmNum/nmSubWxs/nmWellPressureFlowPage.cpp
+++ b/Src/nmNum/nmSubWxs/nmWellPressureFlowPage.cpp
@@ -127,7 +127,71 @@ QString formatGaugeRecordLabel(const QString& sGaugeName,
return sGaugeCode.isEmpty() ? sGaugeName : sGaugeCode;
}
-// 统一向压力/流量记录下拉框追加一项:身份无效的记录禁用不可选,空/损坏记录仍可选但追加提示后缀。
+QString gaugeMetadataText(const QString& sText)
+{
+ return sText.trimmed().isEmpty()
+ ? nmWellPressureFlowPage::tr("(none)") : sText;
+}
+
+QString gaugeNameText(const QString& sGaugeName)
+{
+ return sGaugeName.trimmed().isEmpty()
+ ? nmWellPressureFlowPage::tr("(unnamed)") : sGaugeName;
+}
+
+QString gaugeRecordToolTip(const QString& sGaugeName,
+ const QString& sGaugeCode,
+ const QString& sGaugeTime)
+{
+ QStringList listLines;
+ listLines << nmWellPressureFlowPage::tr("Curve name: %1")
+ .arg(gaugeNameText(sGaugeName));
+ listLines << nmWellPressureFlowPage::tr("Gauge Code: %1")
+ .arg(gaugeMetadataText(sGaugeCode));
+ listLines << nmWellPressureFlowPage::tr("Measurement time: %1")
+ .arg(gaugeMetadataText(sGaugeTime));
+ return listLines.join(QLatin1String("\n"));
+}
+
+void disableGaugeComboItem(QComboBox* pCombo, int nItemIndex)
+{
+ QStandardItemModel* pModel =
+ qobject_cast(pCombo->model());
+ if (pModel == nullptr)
+ {
+ return;
+ }
+ QStandardItem* pItem = pModel->item(nItemIndex);
+ if (pItem != nullptr)
+ {
+ pItem->setFlags(pItem->flags() & ~Qt::ItemIsEnabled);
+ }
+}
+
+void updatePreviewComboToolTip(QComboBox* pCombo)
+{
+ if (pCombo == nullptr || pCombo->currentIndex() < 0 ||
+ pCombo->itemData(pCombo->currentIndex()).toString().isEmpty())
+ {
+ if (pCombo != nullptr)
+ {
+ pCombo->setToolTip(QString());
+ }
+ return;
+ }
+
+ QString sToolTip = pCombo->itemData(
+ pCombo->currentIndex(), Qt::ToolTipRole).toString();
+ if (!sToolTip.isEmpty())
+ {
+ sToolTip += QLatin1Char('\n');
+ }
+ sToolTip += nmWellPressureFlowPage::tr(
+ "Preview only; calculation settings are unchanged.");
+ pCombo->setToolTip(sToolTip);
+}
+
+// 统一向压力/流量记录下拉框追加一项;异常记录保留状态提示但不可选。
void appendGaugeComboItem(QComboBox* pCombo,
const QString& sGaugeName,
const QString& sGaugeCode,
@@ -151,18 +215,13 @@ void appendGaugeComboItem(QComboBox* pCombo,
}
pCombo->addItem(sLabel, sGaugeCode);
- if (eStatus == NM_GaugeRecord_InvalidIdentity)
+ const int nItemIndex = pCombo->count() - 1;
+ pCombo->setItemData(nItemIndex,
+ gaugeRecordToolTip(sGaugeName, sGaugeCode, sGaugeTime),
+ Qt::ToolTipRole);
+ if (eStatus != NM_GaugeRecord_Usable)
{
- QStandardItemModel* pModel =
- qobject_cast(pCombo->model());
- if (pModel != nullptr)
- {
- QStandardItem* pItem = pModel->item(pCombo->count() - 1);
- if (pItem != nullptr)
- {
- pItem->setFlags(pItem->flags() & ~Qt::ItemIsEnabled);
- }
- }
+ disableGaugeComboItem(pCombo, nItemIndex);
}
}
@@ -686,6 +745,10 @@ void nmWellPressureFlowPage::setWell(nmDataWellBase* pWell)
}
m_pWell = pWell;
+ m_sPreviewPressureGaugeCode = pWell == nullptr
+ ? QString() : pWell->getSelectedPressureGaugeCode();
+ m_sPreviewFlowGaugeCode = pWell == nullptr
+ ? QString() : pWell->getSelectedFlowGaugeCode();
resetDataViews();
}
@@ -697,17 +760,34 @@ void nmWellPressureFlowPage::refreshData()
return;
}
- // 第一步:先刷新记录下拉框,确保当前选中 Code、显示相与后续取点保持一致。
+ // 第一步:恢复页面自己的预览记录,不修改井对象保存的计算记录选择。
populatePressureGaugeCombo();
populateFlowGaugeCombo();
populateDisplayPhaseCombo(currentFlowRecord());
- // 第二步:井数据只复制到页面基准副本,后续显示换算不会回写井对象;
- // 流量点按当前展示相读取,切换展示相不影响井别、m_nIndexF 或求解器输入。
- QVector vecRawPressurePoints =
- m_pWell->getPressurePoints();
- QVector vecRawFlowPoints =
- m_pWell->getFlowPoints(m_eDisplayPhase);
+ // 第二步:直接从预览记录复制数据,后续记录、相别和单位切换都不回写井对象。
+ const nmPressureGaugeRecord* pPressureRecord = currentPressureRecord();
+ const nmFlowGaugeRecord* pFlowRecord = currentFlowRecord();
+ QVector vecRawPressurePoints = pPressureRecord == nullptr
+ ? QVector() : pPressureRecord->vecPressurePoints;
+ QVector vecRawFlowPoints;
+ if (pFlowRecord != nullptr)
+ {
+ switch (m_eDisplayPhase)
+ {
+ case PHASE_Oil:
+ vecRawFlowPoints = pFlowRecord->vecOilPoints;
+ break;
+ case PHASE_Gas:
+ vecRawFlowPoints = pFlowRecord->vecGasPoints;
+ break;
+ case PHASE_Water:
+ vecRawFlowPoints = pFlowRecord->vecWaterPoints;
+ break;
+ default:
+ break;
+ }
+ }
// 第三步:单位服务可能晚于页面构造完成,再刷新一次可用单位组。
initializeUnitSupport();
@@ -750,6 +830,8 @@ void nmWellPressureFlowPage::refreshData()
void nmWellPressureFlowPage::clearData()
{
m_pWell = nullptr;
+ m_sPreviewPressureGaugeCode.clear();
+ m_sPreviewFlowGaugeCode.clear();
resetDataViews();
}
@@ -841,6 +923,47 @@ void nmWellPressureFlowPage::slotFlowChartPointClicked(double dTimePoint)
findFlowSegmentByTableTime(dTableTimePoint));
}
+void nmWellPressureFlowPage::slotPressureGaugePreviewChanged(int nIndex)
+{
+ if (m_pWell == nullptr || nIndex < 0)
+ {
+ return;
+ }
+
+ const QString sGaugeCode =
+ m_pPressureGaugeCombo->itemData(nIndex).toString();
+ if (sGaugeCode.isEmpty() ||
+ sGaugeCode == m_sPreviewPressureGaugeCode)
+ {
+ updatePreviewComboToolTip(m_pPressureGaugeCombo);
+ return;
+ }
+
+ m_sPreviewPressureGaugeCode = sGaugeCode;
+ refreshData();
+}
+
+void nmWellPressureFlowPage::slotFlowGaugePreviewChanged(int nIndex)
+{
+ if (m_pWell == nullptr || nIndex < 0)
+ {
+ return;
+ }
+
+ const QString sGaugeCode =
+ m_pFlowGaugeCombo->itemData(nIndex).toString();
+ if (sGaugeCode.isEmpty() || sGaugeCode == m_sPreviewFlowGaugeCode)
+ {
+ updatePreviewComboToolTip(m_pFlowGaugeCombo);
+ return;
+ }
+
+ m_sPreviewFlowGaugeCode = sGaugeCode;
+ m_eDisplayPhase = defaultDisplayPhase(currentFlowRecord());
+ m_nSelectedFlowSegment = -1;
+ refreshData();
+}
+
void nmWellPressureFlowPage::slotDisplayPhaseChanged(int nIndex)
{
if (m_pWell == nullptr || nIndex < 0)
@@ -1025,16 +1148,14 @@ void nmWellPressureFlowPage::createRecordSelectionBar()
m_pPressureGaugeCombo = new QComboBox(m_pRecordSelectionBar);
m_pPressureGaugeCombo->setEnabled(false);
m_pPressureGaugeCombo->setMinimumWidth(160);
- m_pPressureGaugeCombo->setToolTip(
- tr("This page only displays the selected record."));
+ m_pPressureGaugeCombo->setMaxVisibleItems(16);
QLabel* pFlowLabel = new QLabel(
tr("Flow Record"), m_pRecordSelectionBar);
m_pFlowGaugeCombo = new QComboBox(m_pRecordSelectionBar);
m_pFlowGaugeCombo->setEnabled(false);
m_pFlowGaugeCombo->setMinimumWidth(160);
- m_pFlowGaugeCombo->setToolTip(
- tr("This page only displays the selected record."));
+ m_pFlowGaugeCombo->setMaxVisibleItems(16);
// 显示相是纯展示状态,整体容器随记录是否为多相含数据而隐藏/显示。
m_pDisplayPhaseContainer = new QWidget(m_pRecordSelectionBar);
@@ -1063,6 +1184,14 @@ void nmWellPressureFlowPage::createRecordSelectionBar()
pBarLayout->addStretch(1);
pBarLayout->addWidget(m_pCheckDataButton);
+ connect(m_pPressureGaugeCombo,
+ SIGNAL(currentIndexChanged(int)),
+ this,
+ SLOT(slotPressureGaugePreviewChanged(int)));
+ connect(m_pFlowGaugeCombo,
+ SIGNAL(currentIndexChanged(int)),
+ this,
+ SLOT(slotFlowGaugePreviewChanged(int)));
connect(m_pDisplayPhaseCombo,
SIGNAL(currentIndexChanged(int)),
this,
@@ -1090,25 +1219,48 @@ void nmWellPressureFlowPage::populatePressureGaugeCombo()
return;
}
- QVector vecRecords =
- m_pWell->getPressureRecords();
- m_pPressureGaugeCombo->setEnabled(false);
- m_pPressureGaugeCombo->addItem(tr("None"), QString());
+ m_vecPressureGaugeRecords = m_pWell->getPressureRecords();
- const QString sSelectedCode = m_pWell->getSelectedPressureGaugeCode();
- int nCurrentIndex = 0;
- for (int nIndex = 0; nIndex < vecRecords.size(); ++nIndex)
+ int nPreviewIndex = -1;
+ int nCalculationIndex = -1;
+ int nFirstUsableIndex = -1;
+ const QString sCalculationCode =
+ m_pWell->getSelectedPressureGaugeCode();
+ for (int nIndex = 0; nIndex < m_vecPressureGaugeRecords.size(); ++nIndex)
{
- const nmPressureGaugeRecord& oRecord = vecRecords[nIndex];
+ const nmPressureGaugeRecord& oRecord =
+ m_vecPressureGaugeRecords[nIndex];
appendGaugeComboItem(m_pPressureGaugeCombo,
oRecord.sGaugeName, oRecord.sGaugeCode,
oRecord.sGaugeTime, oRecord.eStatus);
- if (oRecord.sGaugeCode == sSelectedCode)
+ const int nItemIndex = m_pPressureGaugeCombo->count() - 1;
+ if (oRecord.eStatus != NM_GaugeRecord_Usable)
{
- nCurrentIndex = nIndex + 1;
+ continue;
+ }
+ if (nFirstUsableIndex < 0)
+ {
+ nFirstUsableIndex = nItemIndex;
+ }
+ if (oRecord.sGaugeCode == m_sPreviewPressureGaugeCode)
+ {
+ nPreviewIndex = nItemIndex;
+ }
+ if (oRecord.sGaugeCode == sCalculationCode)
+ {
+ nCalculationIndex = nItemIndex;
}
}
+ const int nCurrentIndex = nPreviewIndex >= 0
+ ? nPreviewIndex : (nCalculationIndex >= 0
+ ? nCalculationIndex : (nFirstUsableIndex >= 0
+ ? nFirstUsableIndex : -1));
m_pPressureGaugeCombo->setCurrentIndex(nCurrentIndex);
+ m_pPressureGaugeCombo->setEnabled(nFirstUsableIndex >= 0);
+ m_sPreviewPressureGaugeCode = nCurrentIndex >= 0
+ ? m_pPressureGaugeCombo->itemData(nCurrentIndex).toString()
+ : QString();
+ updatePreviewComboToolTip(m_pPressureGaugeCombo);
m_pPressureGaugeCombo->blockSignals(bSignalsWereBlocked);
}
@@ -1132,23 +1284,45 @@ void nmWellPressureFlowPage::populateFlowGaugeCombo()
// 缓存整份记录列表供 currentFlowRecord() 安全返回内部指针,记录内容切换记录时不变。
m_vecFlowGaugeRecords = m_pWell->getFlowRecords();
- m_pFlowGaugeCombo->setEnabled(false);
- m_pFlowGaugeCombo->addItem(tr("None"), QString());
- const QString sSelectedCode = m_pWell->getSelectedFlowGaugeCode();
- int nCurrentIndex = 0;
+ int nPreviewIndex = -1;
+ int nCalculationIndex = -1;
+ int nFirstUsableIndex = -1;
+ const QString sCalculationCode = m_pWell->getSelectedFlowGaugeCode();
for (int nIndex = 0; nIndex < m_vecFlowGaugeRecords.size(); ++nIndex)
{
const nmFlowGaugeRecord& oRecord = m_vecFlowGaugeRecords[nIndex];
appendGaugeComboItem(m_pFlowGaugeCombo,
oRecord.sGaugeName, oRecord.sGaugeCode,
oRecord.sGaugeTime, oRecord.eStatus);
- if (oRecord.sGaugeCode == sSelectedCode)
+ const int nItemIndex = m_pFlowGaugeCombo->count() - 1;
+ if (oRecord.eStatus != NM_GaugeRecord_Usable)
+ {
+ continue;
+ }
+ if (nFirstUsableIndex < 0)
+ {
+ nFirstUsableIndex = nItemIndex;
+ }
+ if (oRecord.sGaugeCode == m_sPreviewFlowGaugeCode)
+ {
+ nPreviewIndex = nItemIndex;
+ }
+ if (oRecord.sGaugeCode == sCalculationCode)
{
- nCurrentIndex = nIndex + 1;
+ nCalculationIndex = nItemIndex;
}
}
+ const int nCurrentIndex = nPreviewIndex >= 0
+ ? nPreviewIndex : (nCalculationIndex >= 0
+ ? nCalculationIndex : (nFirstUsableIndex >= 0
+ ? nFirstUsableIndex : -1));
m_pFlowGaugeCombo->setCurrentIndex(nCurrentIndex);
+ m_pFlowGaugeCombo->setEnabled(nFirstUsableIndex >= 0);
+ m_sPreviewFlowGaugeCode = nCurrentIndex >= 0
+ ? m_pFlowGaugeCombo->itemData(nCurrentIndex).toString()
+ : QString();
+ updatePreviewComboToolTip(m_pFlowGaugeCombo);
m_pFlowGaugeCombo->blockSignals(bSignalsWereBlocked);
}
@@ -1273,17 +1447,25 @@ NM_PHASE_TYPE nmWellPressureFlowPage::defaultDisplayPhase(
return PHASE_UNKNOWN;
}
-const nmFlowGaugeRecord* nmWellPressureFlowPage::currentFlowRecord() const
+const nmPressureGaugeRecord* nmWellPressureFlowPage::currentPressureRecord() const
{
- if (m_pWell == nullptr)
+ for (int nIndex = 0; nIndex < m_vecPressureGaugeRecords.size(); ++nIndex)
{
- return nullptr;
+ if (m_vecPressureGaugeRecords[nIndex].sGaugeCode ==
+ m_sPreviewPressureGaugeCode)
+ {
+ return &m_vecPressureGaugeRecords[nIndex];
+ }
}
+ return nullptr;
+}
- const QString sSelectedCode = m_pWell->getSelectedFlowGaugeCode();
+const nmFlowGaugeRecord* nmWellPressureFlowPage::currentFlowRecord() const
+{
for (int nIndex = 0; nIndex < m_vecFlowGaugeRecords.size(); ++nIndex)
{
- if (m_vecFlowGaugeRecords[nIndex].sGaugeCode == sSelectedCode)
+ if (m_vecFlowGaugeRecords[nIndex].sGaugeCode ==
+ m_sPreviewFlowGaugeCode)
{
return &m_vecFlowGaugeRecords[nIndex];
}
@@ -1686,6 +1868,11 @@ void nmWellPressureFlowPage::resetDataViews()
m_vecRawFlowPoints.clear();
m_vecTableFlowPoints.clear();
m_nSelectedFlowSegment = -1;
+ if (m_pWell == nullptr)
+ {
+ m_sPreviewPressureGaugeCode.clear();
+ m_sPreviewFlowGaugeCode.clear();
+ }
// 井绑定切换或清空时先清空并禁用三个记录/相下拉框,等待 refreshData() 重新填充。
if (m_pPressureGaugeCombo != nullptr)
@@ -1693,6 +1880,7 @@ void nmWellPressureFlowPage::resetDataViews()
bool bSignalsWereBlocked = m_pPressureGaugeCombo->blockSignals(true);
m_pPressureGaugeCombo->clear();
m_pPressureGaugeCombo->setEnabled(false);
+ m_pPressureGaugeCombo->setToolTip(QString());
m_pPressureGaugeCombo->blockSignals(bSignalsWereBlocked);
}
if (m_pFlowGaugeCombo != nullptr)
@@ -1700,8 +1888,10 @@ void nmWellPressureFlowPage::resetDataViews()
bool bSignalsWereBlocked = m_pFlowGaugeCombo->blockSignals(true);
m_pFlowGaugeCombo->clear();
m_pFlowGaugeCombo->setEnabled(false);
+ m_pFlowGaugeCombo->setToolTip(QString());
m_pFlowGaugeCombo->blockSignals(bSignalsWereBlocked);
}
+ m_vecPressureGaugeRecords.clear();
m_vecFlowGaugeRecords.clear();
if (m_pDisplayPhaseCombo != nullptr)
{
diff --git a/Src/nmNum/nmSubWxs/nmWxIncludeOtherWells.cpp b/Src/nmNum/nmSubWxs/nmWxIncludeOtherWells.cpp
index 5a82e1b7..023a5e9e 100644
--- a/Src/nmNum/nmSubWxs/nmWxIncludeOtherWells.cpp
+++ b/Src/nmNum/nmSubWxs/nmWxIncludeOtherWells.cpp
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include
#include
@@ -125,6 +126,46 @@ QString gaugeRecordLabel(const QString& sGaugeName,
return sLabel;
}
+QString gaugeRecordToolTip(const QString& sGaugeName,
+ const QString& sGaugeCode, const QString& sGaugeTime)
+{
+ const QString sName = sGaugeName.trimmed().isEmpty()
+ ? nmWxIncludeOtherWells::tr("(unnamed)") : sGaugeName;
+ const QString sCode = sGaugeCode.trimmed().isEmpty()
+ ? nmWxIncludeOtherWells::tr("None") : sGaugeCode;
+ const QString sTime = sGaugeTime.trimmed().isEmpty()
+ ? nmWxIncludeOtherWells::tr("None") : sGaugeTime;
+ QStringList listLines;
+ listLines << nmWxIncludeOtherWells::tr("Curve name: %1").arg(sName);
+ listLines << nmWxIncludeOtherWells::tr("Gauge Code: %1").arg(sCode);
+ listLines << nmWxIncludeOtherWells::tr("Measurement time: %1").arg(sTime);
+ return listLines.join(QLatin1String("\n"));
+}
+
+void appendGaugeRecordItem(QComboBox* pComboBox,
+ const QString& sGaugeName, const QString& sGaugeCode,
+ const QString& sGaugeTime)
+{
+ pComboBox->addItem(gaugeRecordLabel(
+ sGaugeName, sGaugeCode, sGaugeTime), sGaugeCode);
+ pComboBox->setItemData(pComboBox->count() - 1,
+ gaugeRecordToolTip(sGaugeName, sGaugeCode, sGaugeTime),
+ Qt::ToolTipRole);
+}
+
+void updateGaugeComboToolTip(QComboBox* pComboBox)
+{
+ if(pComboBox == nullptr || pComboBox->currentIndex() < 0) {
+ return;
+ }
+ QString sToolTip = pComboBox->itemData(
+ pComboBox->currentIndex(), Qt::ToolTipRole).toString();
+ if(sToolTip.isEmpty()) {
+ sToolTip = pComboBox->currentText();
+ }
+ pComboBox->setToolTip(sToolTip);
+}
+
// 流动段索引是一基索引;统计段数时必须先排除框架可能写入的公共占位行。
int flowRecordSegmentCount(const nmFlowGaugeRecord& oRecord)
{
@@ -588,6 +629,7 @@ void nmWxIncludeOtherWells::populateRateCombo(
const bool bSignalsWereBlocked = pComboBox->blockSignals(true);
pComboBox->clear();
pComboBox->addItem(tr("None"), QString());
+ pComboBox->setItemData(0, tr("None"), Qt::ToolTipRole);
// 选择控件只展示当前相真正可用的记录;异常记录仍可在“检查数据”中查看。
for(int nIndex = 0; nIndex < data.m_vecFlowRecords.size(); ++nIndex) {
@@ -595,9 +637,8 @@ void nmWxIncludeOtherWells::populateRateCombo(
if(!isSelectableFlowPhase(oRecord, ePhase)) {
continue;
}
- pComboBox->addItem(gaugeRecordLabel(
- oRecord.sGaugeName, oRecord.sGaugeCode, oRecord.sGaugeTime),
- oRecord.sGaugeCode);
+ appendGaugeRecordItem(pComboBox,
+ oRecord.sGaugeName, oRecord.sGaugeCode, oRecord.sGaugeTime);
}
int nCurrentIndex = 0;
@@ -608,7 +649,7 @@ void nmWxIncludeOtherWells::populateRateCombo(
}
}
pComboBox->setCurrentIndex(nCurrentIndex);
- pComboBox->setToolTip(pComboBox->currentText());
+ updateGaugeComboToolTip(pComboBox);
pComboBox->blockSignals(bSignalsWereBlocked);
}
@@ -621,20 +662,20 @@ void nmWxIncludeOtherWells::populatePressureCombo(
const bool bSignalsWereBlocked = pComboBox->blockSignals(true);
pComboBox->clear();
pComboBox->addItem(tr("None"), QString());
+ pComboBox->setItemData(0, tr("None"), Qt::ToolTipRole);
for(int nIndex = 0; nIndex < data.m_vecPressureRecords.size(); ++nIndex) {
const nmPressureGaugeRecord& oRecord = data.m_vecPressureRecords[nIndex];
if(!isSelectablePressureRecord(oRecord)) {
continue;
}
- pComboBox->addItem(gaugeRecordLabel(
- oRecord.sGaugeName, oRecord.sGaugeCode, oRecord.sGaugeTime),
- oRecord.sGaugeCode);
+ appendGaugeRecordItem(pComboBox,
+ oRecord.sGaugeName, oRecord.sGaugeCode, oRecord.sGaugeTime);
}
const int nCurrentIndex = pComboBox->findData(
data.m_sPressureGaugeCode);
pComboBox->setCurrentIndex(nCurrentIndex < 0 ? 0 : nCurrentIndex);
- pComboBox->setToolTip(pComboBox->currentText());
+ updateGaugeComboToolTip(pComboBox);
pComboBox->blockSignals(bSignalsWereBlocked);
}
@@ -779,7 +820,7 @@ void nmWxIncludeOtherWells::onPressureSourceChanged(int nIndex)
}
m_vecWellData[nRow].m_sPressureGaugeCode =
pComboBox->itemData(nIndex).toString();
- pComboBox->setToolTip(pComboBox->currentText());
+ updateGaugeComboToolTip(pComboBox);
}
void nmWxIncludeOtherWells::onFlowSegmentChanged(int nIndex)