Skip to content

Commit

Permalink
Fixes for #6127
Browse files Browse the repository at this point in the history
- add a line to remove the modifier
- do not disable any item as it doesn't work properly
- remove class comment quotes
- TODO! use of setPlaceholderText to grey out the default doesn't work yet
  • Loading branch information
adrpo committed Oct 21, 2020
1 parent 7dc23f4 commit 7fa329c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp
Expand Up @@ -313,6 +313,7 @@ void Parameter::createValueWidget()
QString constrainedByClassName = "$Any";
QString replaceable = "", replaceableText = "";
QStringList enumerationLiterals, replaceableChoices;

switch (mValueType) {
case Parameter::Boolean:
mpValueComboBox = new QComboBox;
Expand Down Expand Up @@ -347,24 +348,29 @@ void Parameter::createValueWidget()
mpValueComboBox->setEditable(true);
if (!mDefaultValue.isEmpty()) {
mpValueComboBox->addItem(mDefaultValue, mDefaultValue);
mpValueComboBox->lineEdit()->setPlaceholderText(mDefaultValue);
}
else {
if (mValueType == Parameter::ReplaceableClass) {
QString str = (pOMCProxy->getClassInformation(className)).comment;
if (!str.isEmpty()) {
str = " \"" + str + "\"";
str = " - " + str;
}
replaceableText = className + str;
mpValueComboBox->addItem(replaceableText, replaceableText);
mpValueComboBox->lineEdit()->setPlaceholderText(replaceableText);
}
else {
replaceable = "redeclare " + className + " " + mpComponent->getName();
mpValueComboBox->addItem(replaceable, replaceable);
mpValueComboBox->lineEdit()->setPlaceholderText(replaceable);
}
}

if (constrainedByClassName.contains("$Any")) {
constrainedByClassName = className;
}

replaceableChoices = pOMCProxy->getAllSubtypeOf(constrainedByClassName, mpComponent->getComponentInfo()->getParentClassName());
for (i = 0 ; i < replaceableChoices.size(); i++) {
if (className != replaceableChoices[i]) // filter out the default
Expand All @@ -375,7 +381,7 @@ void Parameter::createValueWidget()
replaceable = "redeclare " + mpComponent->getComponentInfo()->getRestriction() + " " + mpComponent->getName() + " = " + replaceableChoices[i];
QString str = (pOMCProxy->getClassInformation(replaceableChoices[i])).comment;
if (!str.isEmpty()) {
str = " \"" + str + "\"";
str = " - " + str;
}
replaceableText = replaceableChoices[i] + str;
mpValueComboBox->addItem(replaceableText, replaceable);
Expand All @@ -389,13 +395,8 @@ void Parameter::createValueWidget()
}
}

QStandardItemModel *model = qobject_cast<QStandardItemModel *>(mpValueComboBox->model());
if (model != NULL)
{
QStandardItem *item = model->item(0);
if (item != NULL)
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
// add a way to remove the modifiers
mpValueComboBox->addItem("[remove modifier]", "");

connect(mpValueComboBox, SIGNAL(currentIndexChanged(int)), SLOT(valueComboBoxChanged(int)));
}
Expand Down

0 comments on commit 7fa329c

Please sign in to comment.