Skip to content

Commit

Permalink
Do not add parameter to Initialization group unless explicitly defined (
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Mar 2, 2023
1 parent ef60d40 commit 544556c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp
Expand Up @@ -169,9 +169,8 @@ Parameter::Parameter(ModelInstance::Component *pComponent, ElementParameters *pE
mConnectorSizing = dialogAnnotation.isConnectorSizing();

QString start = "";
bool isParameter = (mpModelInstanceComponent->getPrefixes()->getVariability().compare(QStringLiteral("parameter")) == 0);
// If mShowStartAttribute is not set then check for start modifier
if (!mShowStartAndFixed) {
if (!mShowStartAndFixed && !isParameter()) {
start = mpModelInstanceComponent->getModifier().getModifierValue(QStringList() << "start");
mShowStartAndFixed = !start.isEmpty();
}
Expand All @@ -180,7 +179,7 @@ Parameter::Parameter(ModelInstance::Component *pComponent, ElementParameters *pE
*/
if (mShowStartAndFixed && mGroup.isEmpty()) {
mGroup = "Initialization";
} else if (mGroup.isEmpty() && (isParameter || mpModelInstanceComponent->getAnnotation()->hasDialogAnnotation() || mpModelInstanceComponent->getPrefixes()->getReplaceable())) {
} else if (mGroup.isEmpty() && (isParameter() || mpModelInstanceComponent->getAnnotation()->hasDialogAnnotation() || mpModelInstanceComponent->getPrefixes()->getReplaceable())) {
mGroup = "Parameters";
}

Expand Down Expand Up @@ -274,6 +273,13 @@ Parameter::Parameter(ModelInstance::Component *pComponent, ElementParameters *pE
update();
}

bool Parameter::isParameter() const
{
if (mpModelInstanceComponent) {
return mpModelInstanceComponent->getPrefixes()->getVariability().compare(QStringLiteral("parameter")) == 0;
}
}

/*!
* \brief Parameter::updateNameLabel
* Updates the name label.
Expand Down Expand Up @@ -1265,7 +1271,7 @@ void ElementParameters::fetchElementExtendsModifiers(ModelInstance::Model *pMode
if (subModifier.getName().compare(QStringLiteral("start")) == 0 || subModifier.getName().compare(QStringLiteral("fixed")) == 0) {
QString startOrFixed = subModifier.getValueWithoutQuotes();
if (!startOrFixed.isEmpty()) {
if (!pParameter->isGroupDefined()) {
if (!pParameter->isGroupDefined() && !pParameter->isParameter()) {
pParameter->setGroup("Initialization");
}
pParameter->setShowStartAndFixed(true);
Expand Down Expand Up @@ -1315,7 +1321,7 @@ void ElementParameters::fetchElementModifiers()
if (subModifier.getName().compare(QStringLiteral("start")) == 0 || subModifier.getName().compare(QStringLiteral("fixed")) == 0) {
QString startOrFixed = subModifier.getValueWithoutQuotes();
if (!startOrFixed.isEmpty()) {
if (!pParameter->isGroupDefined()) {
if (!pParameter->isGroupDefined() && !pParameter->isParameter()) {
pParameter->setGroup("Initialization");
}
pParameter->setShowStartAndFixed(true);
Expand Down Expand Up @@ -1370,7 +1376,7 @@ void ElementParameters::fetchClassExtendsModifiers()
if (subSubModifier.getName().compare(QStringLiteral("start")) == 0 || subSubModifier.getName().compare(QStringLiteral("fixed")) == 0) {
QString startOrFixed = subSubModifier.getValueWithoutQuotes();
if (!startOrFixed.isEmpty()) {
if (!pParameter->isGroupDefined()) {
if (!pParameter->isGroupDefined() && !pParameter->isParameter()) {
pParameter->setGroup("Initialization");
}
pParameter->setShowStartAndFixed(true);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Element/ElementProperties.h
Expand Up @@ -58,6 +58,7 @@ class Parameter : public QObject
Parameter(ModelInstance::Component *pComponent, ElementParameters *pElementParameters);
Element* getElement() {return mpElement;}
ModelInstance::Component* getModelInstanceComponent() {return mpModelInstanceComponent;}
bool isParameter() const;
void setTab(QString tab) {mTab = tab;}
StringAnnotation getTab() {return mTab;}
void setGroup(QString group) {mGroup = group;}
Expand Down

0 comments on commit 544556c

Please sign in to comment.