Skip to content

Commit

Permalink
- Fixed the tooltip exception
Browse files Browse the repository at this point in the history
- Updated the unparseStrings function. If the string contains quotes inside it then it raises the exception. For more info http://www.openmodelica.org/index.php?option=com_agora&task=topic&id=345&Itemid=87

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9507 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jul 19, 2011
1 parent c324b4c commit 5c72233
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 50 deletions.
6 changes: 0 additions & 6 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -268,16 +268,10 @@ bool Component::parseAnnotationString(Component *item, QString value, bool libra

foreach(ShapeAnnotation *shape, mpShapesList)
{
qDebug() << "in parseannotation "<< getName() <<mpShapesList.size()<<shape->getShapeAnnotation();
mpShapesList.removeOne(shape);
delete shape;
}

/* if(!item->getName().isEmpty())
{
qDebug() << "in parseannotation "<< getName() <<mpShapesList.size();
}*/
value = StringHandler::removeFirstLastCurlBrackets(value);
if (value.isEmpty())
{
Expand Down
52 changes: 29 additions & 23 deletions OMEdit/OMEditGUI/LibraryWidget.cpp
Expand Up @@ -202,33 +202,35 @@ void ModelicaTree::removeChildNodes(ModelicaTreeNode *item)
void ModelicaTree::addNode(QString name, int type, QString parentName, QString parentStructure)
{
ModelicaTreeNode *newTreePost;


QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(parentStructure + name);

mpParentLibraryWidget->mpParentMainWindow->mpStatusBar->showMessage(QString("Loading: ")
.append(parentStructure + name));
if (parentName.isEmpty())
{
QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(parentStructure + name);
if(info[2].contains("interactive"))
{
info[2]="";
}
QString toolt = "Name: " + name + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + parentStructure + name + "\n" + "Type: " + info[0] ;
newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name, toolt , type, this);

newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name, StringHandler::createTooltip(info, name, parentStructure + name), type, this);

// if(info[2].contains("interactive"))
// {
// info[2]="";
// }
// QString toolt = "Name: " + name + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + parentStructure + name + "\n" + "Type: " + info[0] ;
// newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name, toolt , type, this);
insertTopLevelItem(0, newTreePost);

}
else
{
QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(parentStructure + name);
if(info[2].contains("interactive"))
{
info[2]="";
}
newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name, StringHandler::createTooltip(info, name, parentStructure + name), type);
// QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(parentStructure + name);
// if(info[2].contains("interactive"))
// {
// info[2]="";
// }

QString toolt = "Name: " + name + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + parentStructure + name + "\n" + "Type: " + info[0] ;
newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name,toolt, type);
// QString toolt = "Name: " + name + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + parentStructure + name + "\n" + "Type: " + info[0] ;
// newTreePost = new ModelicaTreeNode(name, parentName, parentStructure + name,toolt, type);
ModelicaTreeNode *treeNode = getNode(StringHandler::removeLastDot(parentStructure));
treeNode->addChild(newTreePost);
}
Expand Down Expand Up @@ -662,8 +664,9 @@ void LibraryTree::addModelicaStandardLibrary()
{
foreach (QString lib, libs) {
QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(lib);
QString toolt = "Name: " + lib + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + lib + "\n" + "Type: " + info[0] ;
LibraryTreeNode *newTreePost = new LibraryTreeNode(lib, QString(""),lib , toolt, this);
LibraryTreeNode *newTreePost = new LibraryTreeNode(lib, QString(""),lib , StringHandler::createTooltip(info, lib, lib), this);
// QString toolt = "Name: " + lib + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + lib + "\n" + "Type: " + info[0] ;
// LibraryTreeNode *newTreePost = new LibraryTreeNode(lib, QString(""),lib , toolt, this);
int classType = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassRestriction(lib);
newTreePost->mType = classType;
newTreePost->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
Expand Down Expand Up @@ -771,10 +774,12 @@ void LibraryTree::addClass(QList<LibraryTreeNode *> *tempPackageNodesList,
.append(parentStructure + className));
QString lib = QString(parentStructure + className);
QStringList info = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassInformation(lib);
QString toolt = "Name: " + className + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + lib + "\n" + "Type: " + info[0] ;
LibraryTreeNode *newTreePost = new LibraryTreeNode(className, parentClassName,
lib,toolt,(QTreeWidget*)0);
// QString toolt = "Name: " + className + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + lib + "\n" + "Type: " + info[0] ;
// LibraryTreeNode *newTreePost = new LibraryTreeNode(className, parentClassName,
// lib,toolt,(QTreeWidget*)0);

LibraryTreeNode *newTreePost = new LibraryTreeNode(className, parentClassName, lib, StringHandler::createTooltip(info, className, lib),
(QTreeWidget*)0);
// If Loaded class is package show treewidgetitem expand indicator
// Remove if using load once library feature
int classType = mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->getClassRestriction(parentStructure +
Expand Down Expand Up @@ -1307,8 +1312,9 @@ void SearchMSLWidget::searchMSL()
foreach (QString foundedItem, foundedItemsList)
{
QStringList info = mpParentMainWindow->mpOMCProxy->getClassInformation(foundedItem);
QString toolt = "Name: " + foundedItem + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + foundedItem + "\n" + "Type: " + info[0] ;
LibraryTreeNode *newTreePost = new LibraryTreeNode(foundedItem, QString(""), foundedItem,toolt, mpSearchedItemsTree);
// QString toolt = "Name: " + foundedItem + "\n" + "Description: " + info[1] + "\n" + "Location: " + info[2] + "\n" + "Path: " + foundedItem + "\n" + "Type: " + info[0] ;
// LibraryTreeNode *newTreePost = new LibraryTreeNode(foundedItem, QString(""), foundedItem,toolt, mpSearchedItemsTree);
LibraryTreeNode *newTreePost = new LibraryTreeNode(foundedItem, QString(""), foundedItem, StringHandler::createTooltip(info, StringHandler::getLastWordAfterDot(foundedItem), foundedItem), mpSearchedItemsTree);
newTreePost->mType = mpParentMainWindow->mpOMCProxy->getClassRestriction(foundedItem);
mpSearchedItemsTree->insertTopLevelItem(0, newTreePost);

Expand Down
9 changes: 0 additions & 9 deletions OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -518,19 +518,10 @@ QStringList OMCProxy::getClassInformation(QString modelName)
{
sendCommand("getClassInformation(" + modelName + ")");
QString result = getResult();
QStringList emp;
emp << "" << "" << "" << "" << "";
if(result=="")
{ return emp;}
else
{
QStringList list = StringHandler::unparseStrings(result);
return list;
}
}



//! Gets the list of classes from OMC recursively.
//! @param className is the name of the class whose sub classes are retrieved.
QStringList OMCProxy::getClassNamesRecursive(QString className)
Expand Down
4 changes: 1 addition & 3 deletions OMEdit/OMEditGUI/ProjectTabWidget.cpp
Expand Up @@ -2904,9 +2904,7 @@ void ProjectTabWidget::saveProjectTab(int index, bool saveAs)
QString oldModelName = pCurrentTab->mModelName;
QString oldModelNameStructure = pCurrentTab->mModelNameStructure;
ModelicaTreeNode *node = pCurrentTab->mpParentProjectTabWidget->mpParentMainWindow->mpLibrary->mpModelicaTree->getNode(pCurrentTab->mModelNameStructure);
pCurrentTab->mpParentProjectTabWidget->mpParentMainWindow->mpLibrary->updateNodeText(oldModelName, oldModelNameStructure, node);


pCurrentTab->mpParentProjectTabWidget->mpParentMainWindow->mpLibrary->updateNodeText(oldModelName, oldModelNameStructure, node);
}

//! Saves the model in the active project tab to a model file.
Expand Down
3 changes: 0 additions & 3 deletions OMEdit/OMEditGUI/ShapeAnnotation.cpp
Expand Up @@ -289,9 +289,6 @@ void ShapeAnnotation::doUnSelect()
//! @see moveRight()
void ShapeAnnotation::moveUp()
{



//qDebug() << "in update R22:: " <<mExtent<<mapFromScene(mapToScene(this->pos()));
// QPointF point = mExtent.at(0);
// point.ry()++;
Expand Down
31 changes: 27 additions & 4 deletions OMEdit/OMEditGUI/StringHandler.cpp
Expand Up @@ -157,10 +157,6 @@ QString StringHandler::getSubStringFromDots(QString value)
return list.at(list.count() - 1);
}





//! Removes the last dot from the string.
//! @param value is the string which is parsed.
QString StringHandler::removeLastDot(QString value)
Expand Down Expand Up @@ -408,6 +404,15 @@ QStringList StringHandler::unparseStrings(QString value)
while (value.at(i) != '"') {
CONSUME_CHAR(value,res,i);
i++;
/* if we have unexpected double quotes then, however omc should return \" */
/* remove this block once fixed in omc */
if (value[i] == '"' && value[i+1] != ',') {
if (value[i+1] != '}') {
CONSUME_CHAR(value,res,i);
i++;
}
}
/* remove this block once fixed in omc */
}
i++;
if (value[i] == '}') {
Expand Down Expand Up @@ -500,3 +505,21 @@ QString StringHandler::getOpenFileName(QWidget* parent, const QString &caption,
}
return QString();
}

QString StringHandler::createTooltip(QStringList info, QString name, QString path)
{
if (info.size() < 3)
return path;
else
{
QString tooltip = QString("Type: ").append(info[0]).append("\n")
.append("Name: ").append(name).append("\n")
.append("Description: ").append(info[1]).append("\n");
if (QString(info[2]).compare("<interactive>") == 0)
tooltip.append("Location: ").append("\n");
else
tooltip.append("Location: ").append(info[2]).append("\n");
tooltip.append("Path: ").append(path);
return tooltip;
}
}
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/StringHandler.h
Expand Up @@ -69,7 +69,7 @@ class StringHandler
static bool unparseBool(QString value);
static QString getSaveFileName(QWidget* parent = 0, const QString &caption = QString(), QString * dir = 0, const QString & filter = QString(), QString * selectedFilter = 0, const QString &defaultSuffix = QString());
static QString getOpenFileName(QWidget* parent = 0, const QString &caption = QString(), QString * dir = 0, const QString & filter = QString(), QString * selectedFilter = 0);

static QString createTooltip(QStringList info, QString name, QString path);
protected:
static QString mLastOpenDir;
};
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/mainwindow.cpp
Expand Up @@ -1032,7 +1032,6 @@ void MainWindow::importModelfromOMNotebook()
{
mpProjectTabs->openModel(nodes.at(i).toElement().text());
}
//qDebug() << nodes.at(i).nodeName() << nodes.at(i).toElement().text();
progressBar.setValue(value++);
}
progressBar.hide();
Expand Down

0 comments on commit 5c72233

Please sign in to comment.