Skip to content

Commit

Permalink
Do not update the unit drop down for default values (#10741)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed May 26, 2023
1 parent c4f7afe commit fb52ea8
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp
Expand Up @@ -328,7 +328,7 @@ void Parameter::setValueWidget(QString value, bool defaultValue, QString fromUni
* then we assume its an expression and don't do any conversions.
* So just show the unit in the unit drop down list
*/
if (!unitComboBoxChanged) {
if (!unitComboBoxChanged && !defaultValue) {
enableDisableUnitComboBox(value);
}
if (Utilities::isValueLiteralConstant(value)) {
Expand Down Expand Up @@ -696,18 +696,18 @@ void Parameter::createValueWidget()
*/
void Parameter::enableDisableUnitComboBox(const QString &value)
{
// Do not do anything when the value is empty OR parameter is not enabled
if (value.isEmpty() || !mEnable) {
// Do not do anything when the value is empty
if (value.isEmpty()) {
return;
}
/* Enable/disable the unit combobox based on the literalConstant
* Set the display unit as current when value is literalConstant otherwise use unit
* ticket:5618 Disable the unit drop down when we have a symbolic parameter
*/
bool literalConstant = Utilities::isValueLiteralConstant(value);
mpUnitComboBox->setEnabled(literalConstant);
mpUnitComboBox->setEnabled(mEnable && literalConstant);
/* ticket:5976 don't change the unit combobox when the literalConstant is true
* We only want to disbale and switch to display unit when literalConstant is false and we got a symbolic or expression parameter.
* We only want to disbale and switch to unit when literalConstant is false and we got a symbolic or expression parameter.
*/
if (!literalConstant) {
bool state = mpUnitComboBox->blockSignals(true);
Expand Down Expand Up @@ -925,15 +925,7 @@ void Parameter::valueCheckBoxChanged(bool toggle)
*/
void Parameter::valueTextBoxEdited(const QString &text)
{
// if we don't have the text we use the default value otherwise the text
QString value;
if (text.isEmpty()) {
value = mDefaultValue;
} else {
value = text;
}

enableDisableUnitComboBox(value);
enableDisableUnitComboBox(text);
}

void Parameter::showFixedMenu()
Expand Down

0 comments on commit fb52ea8

Please sign in to comment.