Skip to content

Commit

Permalink
- Add the automatically loaded libraries to Libraries Browser.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25167 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 19, 2015
1 parent 654278c commit 7c36997
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
31 changes: 5 additions & 26 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -1119,11 +1119,9 @@ void MainWindow::showOpenTransformationFileDialog()
void MainWindow::loadSystemLibrary()
{
QAction *pAction = qobject_cast<QAction*>(sender());
if (pAction)
{
if (pAction) {
/* check if library is already loaded. */
if (mpOMCProxy->existClass(pAction->text()))
{
if (mpOMCProxy->existClass(pAction->text())) {
QMessageBox *pMessageBox = new QMessageBox(this);
pMessageBox->setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::information));
pMessageBox->setIcon(QMessageBox::Information);
Expand All @@ -1133,31 +1131,12 @@ void MainWindow::loadSystemLibrary()
.append(GUIMessages::getMessage(GUIMessages::DELETE_AND_LOAD).arg(pAction->text())));
pMessageBox->setStandardButtons(QMessageBox::Ok);
pMessageBox->exec();
}
/* if library is not loaded then load it. */
else
{
} else { /* if library is not loaded then load it. */
mpProgressBar->setRange(0, 0);
showProgressBar();
mpStatusBar->showMessage(QString(Helper::loading).append(": ").append(pAction->text()));
if (mpOMCProxy->loadModel(pAction->text()))
{
/* since few libraries load dependent libraries automatically. So if the dependent library is not loaded then load it. */
QStringList systemLibs = mpOMCProxy->getClassNames();
foreach (QString systemLib, systemLibs)
{
LibraryTreeNode* pLoadedLibraryTreeNode = mpLibraryTreeWidget->getLibraryTreeNode(systemLib);
if (!pLoadedLibraryTreeNode)
{
LibraryTreeNode *pLibraryTreeNode = mpLibraryTreeWidget->addLibraryTreeNode(systemLib,
mpOMCProxy->getClassRestriction(pAction->text()), "");
pLibraryTreeNode->setSystemLibrary(true);
/* since LibraryTreeWidget::addLibraryTreeNode clears the status bar message, so we should set it one more time. */
mpStatusBar->showMessage(tr("Parsing").append(": ").append(systemLib));
// create library tree nodes
mpLibraryTreeWidget->createLibraryTreeNodes(pLibraryTreeNode);
}
}
if (mpOMCProxy->loadModel(pAction->text())) {
mpLibraryTreeWidget->loadDependentLibraries(mpOMCProxy->getClassNames());
}
mpStatusBar->clearMessage();
hideProgressBar();
Expand Down
18 changes: 18 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1134,6 +1134,24 @@ bool LibraryTreeWidget::isSimulationAllowed(LibraryTreeNode *pLibraryTreeNode)
return false;
}
}
/*!
* \brief Since few libraries load dependent libraries automatically. So if the dependent library is not added then add it.
* \param libraries
*/
void LibraryTreeWidget::loadDependentLibraries(QStringList libraries)
{
foreach (QString library, libraries) {
LibraryTreeNode* pLoadedLibraryTreeNode = getLibraryTreeNode(library);
if (!pLoadedLibraryTreeNode) {
LibraryTreeNode *pLibraryTreeNode = addLibraryTreeNode(library, mpMainWindow->getOMCProxy()->getClassRestriction(library), "");
pLibraryTreeNode->setSystemLibrary(true);
/* since LibraryTreeWidget::addLibraryTreeNode clears the status bar message, so we should set it one more time. */
mpMainWindow->getStatusBar()->showMessage(tr("Parsing").append(": ").append(library));
// create library tree nodes
createLibraryTreeNodes(pLibraryTreeNode);
}
}
}

bool LibraryTreeWidget::saveModelicaLibraryTreeNode(LibraryTreeNode *pLibraryTreeNode)
{
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -184,6 +184,7 @@ class LibraryTreeWidget : public QTreeWidget
bool saveLibraryTreeNode(LibraryTreeNode *pLibraryTreeNode);
LibraryTreeNode* findParentLibraryTreeNodeSavedInSameFile(LibraryTreeNode *pLibraryTreeNode, QFileInfo fileInfo);
bool isSimulationAllowed(LibraryTreeNode *pLibraryTreeNode);
void loadDependentLibraries(QStringList libraries);
private:
MainWindow *mpMainWindow;
bool mIsSearchTree;
Expand Down

0 comments on commit 7c36997

Please sign in to comment.