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
906484bd46
commit
4b00c6e144
@ -106,6 +106,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
|
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double doubleValue = field()->uiValue().toDouble();
|
||||||
QString textValue = field()->uiValue().toString();
|
QString textValue = field()->uiValue().toString();
|
||||||
|
|
||||||
m_slider->blockSignals(true);
|
m_slider->blockSignals(true);
|
||||||
@ -118,7 +119,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
m_lineEdit->setValidator(pdmValidator);
|
m_lineEdit->setValidator(pdmValidator);
|
||||||
m_lineEdit->setText(textValue);
|
m_lineEdit->setText(textValue);
|
||||||
|
|
||||||
updateSliderPosition();
|
updateSliderPosition(doubleValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -161,9 +162,12 @@ QWidget* PdmUiDoubleSliderEditor::createLabelWidget(QWidget * parent)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void PdmUiDoubleSliderEditor::slotEditingFinished()
|
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)
|
void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value)
|
||||||
{
|
{
|
||||||
double newDoubleValue = convertFromSliderValue(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();
|
int newSliderPosition = convertToSliderValue(value);
|
||||||
|
|
||||||
bool convertOk = false;
|
|
||||||
double newSliderValue = textValue.toDouble(&convertOk);
|
|
||||||
|
|
||||||
int newSliderPosition = convertToSliderValue(newSliderValue);
|
|
||||||
if (m_slider->value() != newSliderPosition)
|
if (m_slider->value() != newSliderPosition)
|
||||||
{
|
{
|
||||||
m_slider->blockSignals(true);
|
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 = value;
|
||||||
QVariant v;
|
|
||||||
v = textValue;
|
|
||||||
this->setValueToField(v);
|
this->setValueToField(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ protected slots:
|
|||||||
void slotSliderValueChanged(int value);
|
void slotSliderValueChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSliderPosition();
|
void updateSliderPosition(double value);
|
||||||
void writeValueToField();
|
void writeValueToField(double value);
|
||||||
|
|
||||||
int convertToSliderValue(double value);
|
int convertToSliderValue(double value);
|
||||||
double convertFromSliderValue(int sliderValue);
|
double convertFromSliderValue(int sliderValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user