Skip to content

Commit

Permalink
- Use searchClassNames & getClassInformation via direct scripting API.
Browse files Browse the repository at this point in the history
- Removed OMC_API.h/cpp files as not needed now.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24449 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Feb 5, 2015
1 parent 020116c commit 1cb536a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 115 deletions.
15 changes: 5 additions & 10 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -296,8 +296,7 @@ void SearchClassWidget::searchClasses()
{
// Remove the searched classes first
int i = 0;
while(i < mpLibraryTreeWidget->topLevelItemCount())
{
while(i < mpLibraryTreeWidget->topLevelItemCount()) {
qDeleteAll(mpLibraryTreeWidget->topLevelItem(i)->takeChildren());
delete mpLibraryTreeWidget->topLevelItem(i);
i = 0; //Restart iteration
Expand All @@ -306,22 +305,18 @@ void SearchClassWidget::searchClasses()
return;
/* search classes in OMC */
QStringList searchedClasses = mpMainWindow->getOMCProxy()->searchClassNames(mpSearchClassTextBox->text(),
mpFindInModelicaTextCheckBox->isChecked() ? "true" : "false");
if (searchedClasses.isEmpty())
{
mpFindInModelicaTextCheckBox->isChecked());
if (searchedClasses.isEmpty()) {
mpNoModelicaClassFoundLabel->setVisible(true);
return;
}
else
{
} else {
mpNoModelicaClassFoundLabel->setVisible(false);
}
/* Load the searched classes */
int progressValue = 0;
mpMainWindow->getProgressBar()->setRange(0, searchedClasses.size());
mpMainWindow->showProgressBar();
for (int j = 0 ; j < searchedClasses.size() ; j++)
{
for (int j = 0 ; j < searchedClasses.size() ; j++) {
mpMainWindow->getStatusBar()->showMessage(QString(Helper::loading).append(": ").append(searchedClasses[j]));
LibraryTreeNode *pNewLibraryTreeNode;
QVariantMap info = mpMainWindow->getOMCProxy()->getClassInformation(searchedClasses[j]);
Expand Down
39 changes: 16 additions & 23 deletions OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -53,12 +53,9 @@ void* omc_Main_init(void *threadData, void *args);
void* omc_Main_readSettings(void *threadData, void *args);
}

#include "OMC_API.h"
#include "OpenModelicaScriptingAPIQt.h"

#endif


#include <stdexcept>
#include <stdlib.h>
#include <iostream>
Expand Down Expand Up @@ -1042,12 +1039,9 @@ QStringList OMCProxy::getClassNames(QString className, bool recursive, bool qual
\param findInText - tells to look for the searchText inside Modelica Text also.
\return the list of searched classes.
*/
QStringList OMCProxy::searchClassNames(QString searchText, QString findInText)
QStringList OMCProxy::searchClassNames(QString searchText, bool findInText)
{
sendCommand("searchClassNames(\"" + searchText + "\", findInText=" + findInText + ")");
QString result = StringHandler::removeFirstLastCurlBrackets(getResult());
QStringList list = result.split(",", QString::SkipEmptyParts);
return list;
return mpOMCInterface->searchClassNames(searchText, findInText);
}

/*!
Expand Down Expand Up @@ -1084,26 +1078,25 @@ QVariantMap OMCProxy::getClassInformation(QString className)
res["dimensions"] = lst[11];
return res;
#else
/* TODO: Let this function return the struct directly; once we skip CORBA */
threadData_t *threadData = mpOMCInterface->threadData;
OMC::API::getClassInformation_result r = OMC::API::getClassInformation(threadData, mpOMCInterface->st, className);
OMCInterface::getClassInformation_res classInformation = mpOMCInterface->getClassInformation(className);
QVariantMap res;
res["restriction"] = r.restriction;
res["comment"] = r.comment;
res["partialPrefix"] = r.partialPrefix;
res["finalPrefix"] = r.finalPrefix;
res["encapsulatedPrefix"] = r.encapsulatedPrefix;
res["restriction"] = classInformation.res1;
res["comment"] = classInformation.res2;
res["partialPrefix"] = classInformation.res3;
res["finalPrefix"] = classInformation.res4;
res["encapsulatedPrefix"] = classInformation.res5;
/*
Since now we set the fileName via loadString() & parseString() so this API might return us className/<interactive>.
We only set the fileName field if returned value is really a file path.
*/
res["fileName"] = r.fileName.endsWith(".mo") ? r.fileName : "";
res["fileReadOnly"] = r.fileReadOnly;
res["lineNumberStart"] = (long long) r.lineNumberStart;
res["columnNumberStart"] = (long long) r.columnNumberStart;
res["lineNumberEnd"] = (long long) r.lineNumberEnd;
res["columnNumberEnd"] = (long long) r.columnNumberEnd;
res["dimensions"] = r.dimensions;
res["fileName"] = classInformation.res6.endsWith(".mo") ? classInformation.res6 : "";
res["fileReadOnly"] = classInformation.res7;
res["lineNumberStart"] = (long long) classInformation.res8;
res["columnNumberStart"] = (long long) classInformation.res9;
res["lineNumberEnd"] = (long long) classInformation.res10;
res["columnNumberEnd"] = (long long) classInformation.res11;
res["dimensions"] = "";
//res["dimensions"] = classInformation.res12;
return res;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -127,7 +127,7 @@ class OMCProxy : public QObject
void loadUserLibraries(QSplashScreen *pSplashScreen);
QStringList getClassNames(QString className = QString("AllLoadedClasses"), bool recursive = false, bool qualified = "false",
bool sort = false, bool builtin = false, bool showProtected = "true");
QStringList searchClassNames(QString searchText, QString findInText = QString("false"));
QStringList searchClassNames(QString searchText, bool findInText = "false");
QVariantMap getClassInformation(QString className);
bool isPackage(QString className);
bool isBuiltinType(QString typeName);
Expand Down
43 changes: 0 additions & 43 deletions OMEdit/OMEditGUI/OMC/OMC_API.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions OMEdit/OMEditGUI/OMC/OMC_API.h

This file was deleted.

6 changes: 2 additions & 4 deletions OMEdit/OMEditGUI/OMEditGUI.pro
Expand Up @@ -112,8 +112,7 @@ SOURCES += main.cpp \
Debugger/Attach/ProcessListModel.cpp \
CrashReport/CrashReportDialog.cpp \
OMC/Parser/OMCOutputParser.cpp \
OMC/Parser/OMCOutputLexer.cpp \
OMC/OMC_API.cpp
OMC/Parser/OMCOutputLexer.cpp

HEADERS += Util/backtrace.h \
Util/Helper.h \
Expand Down Expand Up @@ -172,8 +171,7 @@ HEADERS += Util/backtrace.h \
Debugger/Attach/ProcessListModel.h \
CrashReport/CrashReportDialog.h \
OMC/Parser/OMCOutputParser.h \
OMC/Parser/OMCOutputLexer.h \
OMC/OMC_API.h
OMC/Parser/OMCOutputLexer.h

# Windows libraries and includes
win32 {
Expand Down

0 comments on commit 1cb536a

Please sign in to comment.