Skip to content

Commit

Permalink
ticket:3884
Browse files Browse the repository at this point in the history
Apply the default prefixes to Component.
  • Loading branch information
adeas31 committed May 3, 2016
1 parent feca221 commit bff7de7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
27 changes: 27 additions & 0 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -248,6 +248,33 @@ void ComponentInfo::fetchParameterValue(OMCProxy *pOMCProxy, QString className)
mParameterValue = pOMCProxy->getParameterValue(className, mName);
}

/*!
* \brief ComponentInfo::applyDefaultPrefixes
* Applies the default prefixes.
* \param defaultPrefixes
*/
void ComponentInfo::applyDefaultPrefixes(QString defaultPrefixes)
{
if (defaultPrefixes.contains("inner")) {
mIsInner = true;
}
if (defaultPrefixes.contains("outer")) {
mIsOuter = true;
}
if (defaultPrefixes.contains("replaceable")) {
mIsReplaceable = true;
}
if (defaultPrefixes.contains("constant")) {
mVariability = "constant";
}
if (defaultPrefixes.contains("parameter")) {
mVariability = "parameter";
}
if (defaultPrefixes.contains("discrete")) {
mVariability = "discrete";
}
}

/*!
* \brief ComponentInfo::setArrayIndex
* Sets the array index
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Component/Component.h
Expand Up @@ -70,6 +70,7 @@ class ComponentInfo : public QObject
void parseComponentInfoString(QString value);
void fetchModifiers(OMCProxy *pOMCProxy, QString className);
void fetchParameterValue(OMCProxy *pOMCProxy, QString className);
void applyDefaultPrefixes(QString defaultPrefixes);
void setClassName(QString className) {mClassName = className;}
QString getClassName() const {return mClassName;}
void setName(QString name) {mName = name;}
Expand Down
6 changes: 4 additions & 2 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -308,12 +308,14 @@ bool GraphicsView::addComponent(QString className, QPointF position)
}
}
}
ComponentInfo *pComponentInfo = new ComponentInfo;
pComponentInfo->applyDefaultPrefixes(defaultPrefix);
// if dropping an item on the diagram layer
if (mViewType == StringHandler::Diagram) {
// if item is a class, model, block, connector or record. then we can drop it to the graphicsview
if ((type == StringHandler::Class) || (type == StringHandler::Model) || (type == StringHandler::Block) ||
(type == StringHandler::ExpandableConnector) || (type == StringHandler::Connector) || (type == StringHandler::Record)) {
addComponentToView(name, pLibraryTreeItem, "", position, dialogAnnotation, new ComponentInfo());
addComponentToView(name, pLibraryTreeItem, "", position, dialogAnnotation, pComponentInfo);
return true;
} else {
QMessageBox::information(pMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::information),
Expand All @@ -324,7 +326,7 @@ bool GraphicsView::addComponent(QString className, QPointF position)
} else if (mViewType == StringHandler::Icon) { // if dropping an item on the icon layer
// if item is a connector. then we can drop it to the graphicsview
if (type == StringHandler::Connector || type == StringHandler::ExpandableConnector) {
addComponentToView(name, pLibraryTreeItem, "", position, dialogAnnotation, new ComponentInfo());
addComponentToView(name, pLibraryTreeItem, "", position, dialogAnnotation, pComponentInfo);
return true;
} else {
QMessageBox::information(pMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::information),
Expand Down

0 comments on commit bff7de7

Please sign in to comment.