mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2414 AppFwk : Do not overwrite field double value with UI text representation
This commit is contained in:
parent
1419865b89
commit
7c7a54f5aa
@ -106,6 +106,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
|
||||
}
|
||||
|
||||
double doubleValue = field()->uiValue().toDouble();
|
||||
QString textValue = field()->uiValue().toString();
|
||||
|
||||
m_slider->blockSignals(true);
|
||||
@ -118,7 +119,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_lineEdit->setValidator(pdmValidator);
|
||||
m_lineEdit->setText(textValue);
|
||||
|
||||
updateSliderPosition();
|
||||
updateSliderPosition(doubleValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -161,9 +162,12 @@ QWidget* PdmUiDoubleSliderEditor::createLabelWidget(QWidget * parent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiDoubleSliderEditor::slotEditingFinished()
|
||||
{
|
||||
updateSliderPosition();
|
||||
QString textValue = m_lineEdit->text();
|
||||
|
||||
writeValueToField();
|
||||
double doubleVal = textValue.toDouble();
|
||||
doubleVal = qBound(m_attributes.m_minimum, doubleVal, m_attributes.m_maximum);
|
||||
|
||||
writeValueToField(doubleVal);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -172,22 +176,16 @@ void PdmUiDoubleSliderEditor::slotEditingFinished()
|
||||
void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value)
|
||||
{
|
||||
double newDoubleValue = convertFromSliderValue(value);
|
||||
m_lineEdit->setText(QString::number(newDoubleValue));
|
||||
|
||||
writeValueToField();
|
||||
writeValueToField(newDoubleValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiDoubleSliderEditor::updateSliderPosition()
|
||||
void PdmUiDoubleSliderEditor::updateSliderPosition(double value)
|
||||
{
|
||||
QString textValue = m_lineEdit->text();
|
||||
|
||||
bool convertOk = false;
|
||||
double newSliderValue = textValue.toDouble(&convertOk);
|
||||
|
||||
int newSliderPosition = convertToSliderValue(newSliderValue);
|
||||
int newSliderPosition = convertToSliderValue(value);
|
||||
if (m_slider->value() != newSliderPosition)
|
||||
{
|
||||
m_slider->blockSignals(true);
|
||||
@ -199,11 +197,9 @@ void PdmUiDoubleSliderEditor::updateSliderPosition()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiDoubleSliderEditor::writeValueToField()
|
||||
void PdmUiDoubleSliderEditor::writeValueToField(double value)
|
||||
{
|
||||
QString textValue = m_lineEdit->text();
|
||||
QVariant v;
|
||||
v = textValue;
|
||||
QVariant v = value;
|
||||
this->setValueToField(v);
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ protected slots:
|
||||
void slotSliderValueChanged(int value);
|
||||
|
||||
private:
|
||||
void updateSliderPosition();
|
||||
void writeValueToField();
|
||||
void updateSliderPosition(double value);
|
||||
void writeValueToField(double value);
|
||||
|
||||
int convertToSliderValue(double value);
|
||||
double convertFromSliderValue(int sliderValue);
|
||||
|
Loading…
Reference in New Issue
Block a user