Skip to content

Commit

Permalink
Fixed the ModelFile attribute of meta-model editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 17, 2015
1 parent b0489b2 commit 3fdd91d
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 129 deletions.
17 changes: 10 additions & 7 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -39,11 +39,11 @@
#include "Component.h"
#include "ComponentProperties.h"

Component::Component(QString annotation, QString name, QString className, ComponentInfo *pComponentInfo,
Component::Component(QString annotation, QString name, QString className, QString fileName, ComponentInfo *pComponentInfo,
StringHandler::ModelicaClasses type, QString transformation, QPointF position, bool inheritedComponent,
QString inheritedClassName, OMCProxy *pOMCProxy, GraphicsView *pGraphicsView, Component *pParent)
: QGraphicsItem(pParent), mName(name), mClassName(className), mpComponentInfo(pComponentInfo), mType(type), mpOMCProxy(pOMCProxy),
mpGraphicsView(pGraphicsView), mpParentComponent(pParent)
: QGraphicsItem(pParent), mName(name), mClassName(className), mFileName(fileName), mpComponentInfo(pComponentInfo), mType(type),
mpOMCProxy(pOMCProxy), mpGraphicsView(pGraphicsView), mpParentComponent(pParent)
{
setZValue(3000);
mIsLibraryComponent = false;
Expand Down Expand Up @@ -1063,7 +1063,7 @@ void Component::duplicate()
{
QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
if (mpGraphicsView->addComponent(mClassName, scenePos() + gridStep)) {
if (mpGraphicsView->addComponent(mClassName, mFileName, scenePos() + gridStep)) {
if (mType == StringHandler::Connector) {
if (mpGraphicsView->getViewType() == StringHandler::Diagram) {
duplicateHelper(mpGraphicsView);
Expand Down Expand Up @@ -1437,12 +1437,15 @@ void Component::viewDocumentation()
mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getDocumentationDockWidget()->show();
}

//! Slot that opens up the TLM component attributes dialog.
/*!
* \brief Component::showTLMAttributes
* Slot that opens up the SubModelAttributes Dialog.
*/
void Component::showTLMAttributes()
{
MainWindow *pMainWindow = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow();
TLMComponentAttributes *pTLMComponentAttributes = new TLMComponentAttributes(this, pMainWindow);
pTLMComponentAttributes->show();
SubModelAttributes *pTLMComponentAttributes = new SubModelAttributes(this, pMainWindow);
pTLMComponentAttributes->exec();
}

/*! Event when mouse is double clicked on a component.
Expand Down
8 changes: 5 additions & 3 deletions OMEdit/OMEditGUI/Component/Component.h
Expand Up @@ -74,9 +74,9 @@ class Component : public QObject, public QGraphicsItem
Extend, /* Inherited Component. */
Port /* Port Component. */
};
Component(QString annotation, QString name, QString className, ComponentInfo *pComponentInfo, StringHandler::ModelicaClasses type,
QString transformation, QPointF position, bool inheritedComponent, QString inheritedClassName, OMCProxy *pOMCProxy,
GraphicsView *pGraphicsView, Component *pParent = 0);
Component(QString annotation, QString name, QString className, QString fileName, ComponentInfo *pComponentInfo,
StringHandler::ModelicaClasses type, QString transformation, QPointF position, bool inheritedComponent, QString inheritedClassName,
OMCProxy *pOMCProxy, GraphicsView *pGraphicsView, Component *pParent = 0);
Component(QString annotation, QString className, StringHandler::ModelicaClasses type, Component *pParent);
Component(QString annotation, QString transformationString, ComponentInfo *pComponentInfo, StringHandler::ModelicaClasses type,
Component *pParent);
Expand All @@ -102,6 +102,7 @@ class Component : public QObject, public QGraphicsItem
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QString getName();
QString getClassName();
QString getFileName() {return mFileName;}
StringHandler::ModelicaClasses getType();
OMCProxy* getOMCProxy();
GraphicsView* getGraphicsView();
Expand Down Expand Up @@ -140,6 +141,7 @@ class Component : public QObject, public QGraphicsItem
private:
QString mName;
QString mClassName;
QString mFileName;
ComponentInfo *mpComponentInfo;
StringHandler::ModelicaClasses mType;
OMCProxy *mpOMCProxy;
Expand Down
34 changes: 18 additions & 16 deletions OMEdit/OMEditGUI/Component/ComponentProperties.cpp
Expand Up @@ -1177,29 +1177,31 @@ void ComponentAttributes::updateComponentAttributes()
}

/*!
\class TLMComponentAttributes
\brief A dialog for displaying TLM components attributes
*/
* \class SubModelAttributes
* \brief A dialog for displaying SubModel attributes.
*/
/*!
\param pComponent - pointer to Component
\param pMainWindow - pointer to MainWindow
*/
TLMComponentAttributes::TLMComponentAttributes(Component *pComponent, MainWindow *pMainWindow)
* \brief SubModelAttributes::SubModelAttributes
* \param pComponent - pointer to Component
* \param pMainWindow - pointer to MainWindow
*/
SubModelAttributes::SubModelAttributes(Component *pComponent, MainWindow *pMainWindow)
: QDialog(pMainWindow, Qt::WindowTitleHint)
{
setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("TLM Component Attributes")));
setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("SubModel Attributes")));
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
setMinimumWidth(250);
mpComponent = pComponent;
mpMainWindow = pMainWindow;
setUpDialog();
initializeDialog();
}

/*!
Creates the Dialog and set up attributes .
*/
void TLMComponentAttributes::setUpDialog()
* \brief SubModelAttributes::setUpDialog
* Creates the Dialog and set up attributes.
*/
void SubModelAttributes::setUpDialog()
{
// Create the name label and text box
mpNameLabel = new Label(Helper::name);
Expand Down Expand Up @@ -1228,20 +1230,20 @@ void TLMComponentAttributes::setUpDialog()
pMainLayout->addWidget(mpStartCommandTextBox, 1, 1);
pMainLayout->addWidget(mpModelFileLabel, 2, 0);
pMainLayout->addWidget(mpModelFileTextBox, 2, 1);
pMainLayout->addWidget(mpButtonBox, 3, 0, 1, 3, Qt::AlignRight);
pMainLayout->addWidget(mpButtonBox, 3, 0, 1, 2, Qt::AlignRight);
setLayout(pMainLayout);
}

/*!
Initialize the fields with default values.
*/
void TLMComponentAttributes::initializeDialog()
void SubModelAttributes::initializeDialog()
{
// get component Name
mpNameTextBox->setText(mpComponent->getName());
mpNameTextBox->setCursorPosition(0);
mpStartCommandTextBox->setText("StartTLMOpenModelica");
mpModelFileTextBox->setText(mpComponent->getClassName()+".mo");
QFileInfo fileInfo(mpComponent->getFileName());
mpModelFileTextBox->setText(fileInfo.fileName());
}

TLMInterfacePointInfo::TLMInterfacePointInfo(QString name, QString className, QString interfaceName)
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Component/ComponentProperties.h
Expand Up @@ -196,11 +196,11 @@ public slots:
void updateComponentAttributes();
};

class TLMComponentAttributes : public QDialog
class SubModelAttributes : public QDialog
{
Q_OBJECT
public:
TLMComponentAttributes(Component *pComponent, MainWindow *pMainWindow);
SubModelAttributes(Component *pComponent, MainWindow *pMainWindow);
void setUpDialog();
void initializeDialog();
private:
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -2094,7 +2094,7 @@ void LibraryTreeWidget::startDrag(Qt::DropActions supportedActions)
}
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << pLibraryTreeNode->getNameStructure();
dataStream << pLibraryTreeNode->getNameStructure() << pLibraryTreeNode->getFileName();
QMimeData *mimeData = new QMimeData;
mimeData->setData(Helper::modelicaComponentFormat, itemData);
qreal adjust = 35;
Expand Down

0 comments on commit 3fdd91d

Please sign in to comment.