Skip to content

Commit

Permalink
ticket:4463 Added a dialog to display class version information.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jul 15, 2017
1 parent ae81be2 commit 9eba7c7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/FMI/ImportFMUDialog.cpp
Expand Up @@ -81,7 +81,7 @@ ImportFMUDialog::ImportFMUDialog(QWidget *pParent)
mpLogLevelComboBox->addItem(tr("Fatal"), QVariant(1));
mpLogLevelComboBox->addItem(tr("Error"), QVariant(2));
mpLogLevelComboBox->addItem(tr("Warning"), QVariant(3));
mpLogLevelComboBox->addItem(tr("Information"), QVariant(4));
mpLogLevelComboBox->addItem(Helper::information, QVariant(4));
mpLogLevelComboBox->addItem(tr("Verbose"), QVariant(5));
mpLogLevelComboBox->addItem(tr("Debug"), QVariant(6));
mpLogLevelComboBox->setCurrentIndex(3);
Expand Down
30 changes: 30 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -2555,6 +2555,10 @@ void LibraryTreeView::createActions()
mpViewDocumentationAction = new QAction(QIcon(":/Resources/icons/info-icon.svg"), Helper::viewDocumentation, this);
mpViewDocumentationAction->setStatusTip(Helper::viewDocumentationTip);
connect(mpViewDocumentationAction, SIGNAL(triggered()), SLOT(viewDocumentation()));
// information Action
mpInformationAction = new QAction(Helper::information, this);
mpInformationAction->setStatusTip(tr("Opens the class information dialog"));
connect(mpInformationAction, SIGNAL(triggered()), SLOT(openInformationDialog()));
// new Modelica Class Action
mpNewModelicaClassAction = new QAction(QIcon(":/Resources/icons/new.svg"), Helper::newModelicaClass, this);
mpNewModelicaClassAction->setStatusTip(Helper::createNewModelicaClass);
Expand Down Expand Up @@ -2776,6 +2780,7 @@ void LibraryTreeView::showContextMenu(QPoint point)
default:
menu.addAction(mpOpenClassAction);
menu.addAction(mpViewDocumentationAction);
menu.addAction(mpInformationAction);
if (!pLibraryTreeItem->isSystemLibrary()) {
menu.addSeparator();
menu.addAction(mpNewModelicaClassAction);
Expand Down Expand Up @@ -2888,6 +2893,31 @@ void LibraryTreeView::viewDocumentation()
}
}

/*!
* \brief LibraryTreeView::openInformationDialog
* Opens the dialog to display the class information like version, version date etc.
*/
void LibraryTreeView::openInformationDialog()
{
LibraryTreeItem *pLibraryTreeItem = getSelectedLibraryTreeItem();
if (pLibraryTreeItem) {
QDialog *pInformationDialog = new QDialog(MainWindow::instance());
pInformationDialog->setAttribute(Qt::WA_DeleteOnClose);
pInformationDialog->setWindowTitle(QString("%1 - %2 - %3").arg(Helper::applicationName, pLibraryTreeItem->getNameStructure(), Helper::information));
pInformationDialog->setMinimumWidth(300);
Label *pHeadingLabel = Utilities::getHeadingLabel(pLibraryTreeItem->getNameStructure());
pHeadingLabel->setElideMode(Qt::ElideMiddle);
QVBoxLayout *pLayout = new QVBoxLayout;
pLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
pLayout->addWidget(pHeadingLabel);
pLayout->addWidget(new Label(tr("Version : %1").arg(MainWindow::instance()->getOMCProxy()->getVersion(pLibraryTreeItem->getNameStructure()))));
pLayout->addWidget(new Label(tr("Version Date : %1").arg(MainWindow::instance()->getOMCProxy()->getVersionDateAnnotation(pLibraryTreeItem->getNameStructure()))));
pLayout->addWidget(new Label(tr("Version Build : %1").arg(MainWindow::instance()->getOMCProxy()->getVersionBuildAnnotation(pLibraryTreeItem->getNameStructure()))));
pInformationDialog->setLayout(pLayout);
pInformationDialog->exec();
}
}

/*!
* \brief LibraryTreeView::createNewModelicaClass
* Opens the create new ModelicaClassDialog for creating a new nested class in the selected LibraryTreeItem.
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -303,6 +303,7 @@ class LibraryTreeView : public QTreeView
LibraryWidget *mpLibraryWidget;
QAction *mpOpenClassAction;
QAction *mpViewDocumentationAction;
QAction *mpInformationAction;
QAction *mpNewModelicaClassAction;
QAction *mpSaveAction;
QAction *mpSaveAsAction;
Expand Down Expand Up @@ -344,6 +345,7 @@ public slots:
void showContextMenu(QPoint point);
void openClass();
void viewDocumentation();
void openInformationDialog();
void createNewModelicaClass();
void saveClass();
void saveAsClass();
Expand Down
12 changes: 12 additions & 0 deletions OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -2400,6 +2400,18 @@ QList<QString> OMCProxy::getDerivedUnits(QString baseUnit)
return result;
}

QString OMCProxy::getVersionDateAnnotation(QString className)
{
sendCommand("getNamedAnnotation(" + className + ", versionDate)");
return StringHandler::unparse(StringHandler::removeFirstLastCurlBrackets(getResult()));
}

QString OMCProxy::getVersionBuildAnnotation(QString className)
{
sendCommand("getNamedAnnotation(" + className + ", versionBuild)");
return StringHandler::removeFirstLastCurlBrackets(getResult());
}

/*!
Gets the DocumentationClass annotation.
\param className - the name of the class.
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -210,6 +210,8 @@ class OMCProxy : public QObject
QString getDerivedClassModifierValue(QString className, QString modifierName);
OMCInterface::convertUnits_res convertUnits(QString from, QString to);
QList<QString> getDerivedUnits(QString baseUnit);
QString getVersionDateAnnotation(QString className);
QString getVersionBuildAnnotation(QString className);
bool getDocumentationClassAnnotation(QString className);
QString getCommandLineOptionsAnnotation(QString className);
QList<QString> getAnnotationNamedModifiers(QString className, QString annotation);
Expand Down

0 comments on commit 9eba7c7

Please sign in to comment.