Skip to content

Commit

Permalink
Add modified displayUnit to unit selector, ticket:4081
Browse files Browse the repository at this point in the history
This way a display unit modified for a model instance is considered
if it can be converted to the base unit.
  • Loading branch information
rfranke committed Oct 20, 2016
1 parent 02e5b67 commit 6e2a856
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions OMEdit/OMEditGUI/Component/ComponentProperties.cpp
Expand Up @@ -896,6 +896,15 @@ void ComponentParameters::fetchComponentModifiers()
if (modifiersIterator.key().compare(parameterName + ".displayUnit") == 0) {
QString displayUnit = StringHandler::removeFirstLastQuotes(modifiersIterator.value());
int index = pParameter->getUnitComboBox()->findText(displayUnit, Qt::MatchExactly);
if (index < 0) {
// add modifier as additional display unit if compatible
index = pParameter->getUnitComboBox()->count() - 1;
if (index > -1 &&
(pOMCProxy->convertUnits(pParameter->getUnitComboBox()->itemText(0), displayUnit)).unitsCompatible) {
pParameter->getUnitComboBox()->addItem(displayUnit);
index ++;
}
}
if (index > -1) {
pParameter->getUnitComboBox()->setCurrentIndex(index);
pParameter->setDisplayUnit(displayUnit);
Expand Down

0 comments on commit 6e2a856

Please sign in to comment.