Skip to content

Commit

Permalink
Fetch the class extends modifiers of the element recursively (#11232)
Browse files Browse the repository at this point in the history
Fixes #10864
  • Loading branch information
adeas31 committed Sep 21, 2023
1 parent 7f15e88 commit aa84bb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp
Expand Up @@ -1293,7 +1293,7 @@ void ElementParameters::setUpDialog()
createTabsGroupBoxesAndParameters(mpElement->getModel());
fetchElementExtendsModifiers(mpElement->getModel());
fetchElementModifiers();
fetchClassExtendsModifiers();
fetchClassExtendsModifiers(mpElement);
// Apply the default modifiers that are given in the redeclaration of the replaceable class or component.
applyModifiers(mDefaultElementModifier, true);
// Apply the modifiers that are given in the constainedBy of the replaceable class or component.
Expand Down Expand Up @@ -1461,7 +1461,7 @@ void ElementParameters::fetchElementExtendsModifiers(ModelInstance::Model *pMode
if (pElement->isExtend() && pElement->getModel()) {
auto pExtend = dynamic_cast<ModelInstance::Extend*>(pElement);
/* Issue #10811
* Go deep the in the extends hierarchy and then apply the values in bottom to top order.
* Go deep in the extends hierarchy and then apply the values in bottom to top order.
*/
fetchElementExtendsModifiers(pExtend->getModel());
foreach (auto modifier, pExtend->getModifier().getModifiers()) {
Expand All @@ -1487,25 +1487,29 @@ void ElementParameters::fetchElementModifiers()
/*!
* \brief ElementParameters::fetchClassExtendsModifiers
* If the Element is inherited then fetch the class extends modifiers and apply modifier values on the appropriate Parameters.
* \param pModelElement
*/
void ElementParameters::fetchClassExtendsModifiers()
void ElementParameters::fetchClassExtendsModifiers(ModelInstance::Element *pModelElement)
{
ModelInstance::Model *pClassModelInstance = mpGraphicsView->getModelWidget()->getModelInstance();
QList<ModelInstance::Element*> elements = pClassModelInstance->getElements();
foreach (auto pElement, elements) {
if (pElement->isExtend() && pElement->getModel()) {
auto pExtend = dynamic_cast<ModelInstance::Extend*>(pElement);
if (pExtend->getModel()->getName().compare(mpElement->getParentModel()->getName()) == 0) {
foreach (auto modifier, pExtend->getModifier().getModifiers()) {
if (modifier.getName().compare(mpElement->getName()) == 0) {
foreach (auto subModifier, modifier.getModifiers()) {
Parameter *pParameter = findParameter(subModifier.getName());
applyFinalStartFixedAndDisplayUnitModifiers(pParameter, subModifier, false);
}
break;
/* Issue #10864
* Fetch the class extends modifiers recursively.
*/
if (pModelElement && pModelElement->getParentModel()) {
auto pExtend = pModelElement->getParentModel()->getParentElement();
if (pExtend && pExtend->isExtend()) {
bool hasParentElement = pExtend->getParentModel() && pExtend->getParentModel()->getParentElement();
foreach (auto modifier, pExtend->getModifier().getModifiers()) {
if (modifier.getName().compare(mpElement->getName()) == 0) {
foreach (auto subModifier, modifier.getModifiers()) {
Parameter *pParameter = findParameter(subModifier.getName());
applyFinalStartFixedAndDisplayUnitModifiers(pParameter, subModifier, hasParentElement);
}
break;
}
}
if (hasParentElement) {
fetchClassExtendsModifiers(pExtend);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Element/ElementProperties.h
Expand Up @@ -229,7 +229,7 @@ class ElementParameters : public QDialog
void createTabsGroupBoxesAndParameters(ModelInstance::Model *pModelInstance);
void fetchElementExtendsModifiers(ModelInstance::Model *pModelInstance);
void fetchElementModifiers();
void fetchClassExtendsModifiers();
void fetchClassExtendsModifiers(ModelInstance::Element *pModelElement);
void applyModifiers(const ModelInstance::Modifier modifiers, bool defaultValue);
Parameter* findParameter(LibraryTreeItem *pLibraryTreeItem, const QString &parameter, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive) const;
Parameter* findParameter(const QString &parameter, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive) const;
Expand Down

0 comments on commit aa84bb0

Please sign in to comment.