|
|
|
@ -10,6 +10,7 @@
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QSizePolicy>
|
|
|
|
#include <QSizePolicy>
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
@ -31,6 +32,24 @@ QString fieldText(const char* pText)
|
|
|
|
"nmReservoirParameterField", pText);
|
|
|
|
"nmReservoirParameterField", pText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 根据有效状态生成悬浮提示文字。 */
|
|
|
|
|
|
|
|
QString validationToolTip(const QString& sText, bool bValid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (bValid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return sText;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString sEscaped = sText;
|
|
|
|
|
|
|
|
sEscaped.replace("&", "&");
|
|
|
|
|
|
|
|
sEscaped.replace("<", "<");
|
|
|
|
|
|
|
|
sEscaped.replace(">", ">");
|
|
|
|
|
|
|
|
sEscaped.replace("\"", """);
|
|
|
|
|
|
|
|
sEscaped.replace("\n", "<br/>");
|
|
|
|
|
|
|
|
return "<span style=\"color:red;\">" +
|
|
|
|
|
|
|
|
sEscaped + "</span>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nmReservoirParameterField::nmReservoirParameterField(
|
|
|
|
nmReservoirParameterField::nmReservoirParameterField(
|
|
|
|
@ -46,6 +65,7 @@ nmReservoirParameterField::nmReservoirParameterField(
|
|
|
|
m_pValueComboBox(nullptr),
|
|
|
|
m_pValueComboBox(nullptr),
|
|
|
|
m_pUnitComboBox(nullptr),
|
|
|
|
m_pUnitComboBox(nullptr),
|
|
|
|
m_pUnitLabel(nullptr),
|
|
|
|
m_pUnitLabel(nullptr),
|
|
|
|
|
|
|
|
m_clrNormalText(),
|
|
|
|
m_bVisible(true),
|
|
|
|
m_bVisible(true),
|
|
|
|
m_bUpdating(false)
|
|
|
|
m_bUpdating(false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -149,6 +169,7 @@ bool nmReservoirParameterField::createNumericEditor(
|
|
|
|
QSizePolicy::Fixed);
|
|
|
|
QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
|
|
|
|
m_pLineEdit = new QLineEdit(pParentWidget);
|
|
|
|
m_pLineEdit = new QLineEdit(pParentWidget);
|
|
|
|
|
|
|
|
m_clrNormalText = m_pLineEdit->palette().color(QPalette::Text);
|
|
|
|
m_pLineEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
m_pLineEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
m_pLineEdit->setFixedHeight(editorHeight());
|
|
|
|
m_pLineEdit->setFixedHeight(editorHeight());
|
|
|
|
m_pLineEdit->setMinimumWidth(editorMinimumWidth());
|
|
|
|
m_pLineEdit->setMinimumWidth(editorMinimumWidth());
|
|
|
|
@ -399,12 +420,17 @@ QString nmReservoirParameterField::formatBaseValue(double dValue) const
|
|
|
|
|
|
|
|
|
|
|
|
void nmReservoirParameterField::updateValidationAppearance(bool bValid)
|
|
|
|
void nmReservoirParameterField::updateValidationAppearance(bool bValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_UNUSED(bValid);
|
|
|
|
|
|
|
|
if (m_pLineEdit == nullptr || m_pParameter == nullptr)
|
|
|
|
if (m_pLineEdit == nullptr || m_pParameter == nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只修改文字色,避免Qt 4.8样式表绘制覆盖原生输入框边框。
|
|
|
|
|
|
|
|
QPalette oPalette = m_pLineEdit->palette();
|
|
|
|
|
|
|
|
oPalette.setColor(QPalette::Text,
|
|
|
|
|
|
|
|
bValid ? m_clrNormalText : QColor(Qt::red));
|
|
|
|
|
|
|
|
m_pLineEdit->setPalette(oPalette);
|
|
|
|
|
|
|
|
|
|
|
|
QString sCurrentUnit;
|
|
|
|
QString sCurrentUnit;
|
|
|
|
iUnitGroup* pUnitGroup = nullptr;
|
|
|
|
iUnitGroup* pUnitGroup = nullptr;
|
|
|
|
if (m_pUnitComboBox != nullptr && m_pUnitService != nullptr)
|
|
|
|
if (m_pUnitComboBox != nullptr && m_pUnitService != nullptr)
|
|
|
|
@ -414,7 +440,19 @@ void nmReservoirParameterField::updateValidationAppearance(bool bValid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QString sRange = iParaItemCtrl::getScaleStrOf(
|
|
|
|
QString sRange = iParaItemCtrl::getScaleStrOf(
|
|
|
|
m_pParameter, sCurrentUnit, pUnitGroup);
|
|
|
|
m_pParameter, sCurrentUnit, pUnitGroup);
|
|
|
|
QString sHelp = m_pParameter->m_sDesc;
|
|
|
|
// 参数别名来自当前语言XML,稳定ID便于定位参数定义。
|
|
|
|
|
|
|
|
QString sHelp = m_pParameter->m_sAlias;
|
|
|
|
|
|
|
|
if (!m_pParameter->m_sName.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!sHelp.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sHelp += "[" + m_pParameter->m_sName + "]";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sHelp = m_pParameter->m_sName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!sRange.isEmpty())
|
|
|
|
if (!sRange.isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!sHelp.isEmpty())
|
|
|
|
if (!sHelp.isEmpty())
|
|
|
|
@ -423,7 +461,7 @@ void nmReservoirParameterField::updateValidationAppearance(bool bValid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sHelp += sRange;
|
|
|
|
sHelp += sRange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pLineEdit->setToolTip(sHelp);
|
|
|
|
m_pLineEdit->setToolTip(validationToolTip(sHelp, bValid));
|
|
|
|
m_pLineEdit->setWhatsThis(sHelp);
|
|
|
|
m_pLineEdit->setWhatsThis(sHelp);
|
|
|
|
if (m_pLabel != nullptr)
|
|
|
|
if (m_pLabel != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|