Skip to content

Commit

Permalink
Removed isProtectedClass and getNamedAnnotation(DocumentationClass) s…
Browse files Browse the repository at this point in the history
…ince its part of getClassInformation now.
  • Loading branch information
adeas31 committed Nov 26, 2015
1 parent ac53ae4 commit b84ec72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
41 changes: 16 additions & 25 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -298,8 +298,6 @@ LibraryTreeItem::LibraryTreeItem()
setFileName("");
setReadOnly(false);
setIsSaved(false);
setIsProtected(false);
setIsDocumentationClass(false);
setSaveContentsType(LibraryTreeItem::SaveInOneFile);
setToolTip("");
setIcon(QIcon());
Expand Down Expand Up @@ -337,8 +335,6 @@ LibraryTreeItem::LibraryTreeItem(LibraryType type, QString text, QString nameStr
setReadOnly(!StringHandler::isFileWritAble(fileName));
}
setIsSaved(isSaved);
setIsProtected(false);
setIsDocumentationClass(false);
if (isFilePathValid()) {
QFileInfo fileInfo(getFileName());
// if item has file name as package.mo and is top level then its save folder structure
Expand Down Expand Up @@ -398,6 +394,21 @@ bool LibraryTreeItem::isFilePathValid() {
return QFile::exists(mFileName);
}

/*!
* \brief LibraryTreeItem::isDocumentationClass
* Returns true if class OR if any of its parent contains DocumentationClass annotation.
* \return
*/
bool LibraryTreeItem::isDocumentationClass()
{
if (mClassInformation.isDocumentationClass) {
return true;
} else if (isTopLevel()) {
return false;
}
return mpParentLibraryTreeItem->isDocumentationClass();
}

/*!
* \brief LibraryTreeItem::updateAttributes
* Updates the LibraryTreeItem icon, text and tooltip.
Expand Down Expand Up @@ -1121,13 +1132,7 @@ LibraryTreeItem* LibraryTreeModel::createLibraryTreeItem(QString name, LibraryTr
OMCInterface::getClassInformation_res classInformation = pOMCProxy->getClassInformation(nameStructure);
pLibraryTreeItem = new LibraryTreeItem(LibraryTreeItem::Modelica, name, nameStructure, classInformation, "", isSaved, pParentLibraryTreeItem);
pLibraryTreeItem->setSystemLibrary(pParentLibraryTreeItem == mpRootLibraryTreeItem ? isSystemLibrary : pParentLibraryTreeItem->isSystemLibrary());
pLibraryTreeItem->setIsProtected(pOMCProxy->isProtectedClass(pParentLibraryTreeItem->getNameStructure(), name));
if (pParentLibraryTreeItem->isDocumentationClass()) {
pLibraryTreeItem->setIsDocumentationClass(true);
} else {
bool isDocumentationClass = pOMCProxy->getDocumentationClassAnnotation(nameStructure);
pLibraryTreeItem->setIsDocumentationClass(isDocumentationClass);
}

int row = pParentLibraryTreeItem->getChildren().size();
QModelIndex index = libraryTreeItemIndex(pParentLibraryTreeItem);
beginInsertRows(index, row, row);
Expand Down Expand Up @@ -1169,7 +1174,6 @@ LibraryTreeItem* LibraryTreeModel::createLibraryTreeItem(LibraryTreeItem::Librar
pMainWindow->getStatusBar()->showMessage(QString(Helper::loading).append(": ").append(name));
OMCInterface::getClassInformation_res classInformation;
pLibraryTreeItem = new LibraryTreeItem(type, name, name, classInformation, "", isSaved, mpRootLibraryTreeItem);
pLibraryTreeItem->setIsDocumentationClass(false);
int row = mpRootLibraryTreeItem->getChildren().size();
QModelIndex index = libraryTreeItemIndex(mpRootLibraryTreeItem);
beginInsertRows(index, row, row);
Expand Down Expand Up @@ -1204,12 +1208,6 @@ LibraryTreeItem* LibraryTreeModel::createNonExistingLibraryTreeItem(QString name
OMCInterface::getClassInformation_res classInformation;
pLibraryTreeItem = new LibraryTreeItem(LibraryTreeItem::Modelica, name, nameStructure, classInformation, "", false, pParentLibraryTreeItem);
pLibraryTreeItem->setSystemLibrary(pParentLibraryTreeItem->isSystemLibrary());
pLibraryTreeItem->setIsProtected(false);
if (pParentLibraryTreeItem->isDocumentationClass()) {
pLibraryTreeItem->setIsDocumentationClass(true);
} else {
pLibraryTreeItem->setIsDocumentationClass(false);
}
pLibraryTreeItem->setNonExisting(true);
addNonExistingLibraryTreeItem(pLibraryTreeItem);
return pLibraryTreeItem;
Expand All @@ -1228,13 +1226,6 @@ void LibraryTreeModel::createNonExistingLibraryTreeItem(LibraryTreeItem *pLibrar
pLibraryTreeItem->setFileName("");
pLibraryTreeItem->setClassInformation(pOMCProxy->getClassInformation(pLibraryTreeItem->getNameStructure()));
pLibraryTreeItem->setIsSaved(isSaved);
pLibraryTreeItem->setIsProtected(pOMCProxy->isProtectedClass(pParentLibraryTreeItem->getNameStructure(), pLibraryTreeItem->getName()));
if (pParentLibraryTreeItem->isDocumentationClass()) {
pLibraryTreeItem->setIsDocumentationClass(true);
} else {
bool isDocumentationClass = pOMCProxy->getDocumentationClassAnnotation(pLibraryTreeItem->getNameStructure());
pLibraryTreeItem->setIsDocumentationClass(isDocumentationClass);
}
pLibraryTreeItem->updateAttributes();
int row = pParentLibraryTreeItem->getChildren().size();
QModelIndex index = libraryTreeItemIndex(pParentLibraryTreeItem);
Expand Down
8 changes: 2 additions & 6 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -104,10 +104,8 @@ class LibraryTreeItem : public QObject
bool isReadOnly() {return mReadOnly;}
void setIsSaved(bool isSaved) {mIsSaved = isSaved;}
bool isSaved() {return mIsSaved;}
void setIsProtected(bool isProtected) {mIsProtected = isProtected;}
bool isProtected() {return mIsProtected;}
void setIsDocumentationClass(bool documentationClass) {mDocumentationClass = documentationClass;}
bool isDocumentationClass() {return mDocumentationClass;}
bool isProtected() {return mClassInformation.isProtectedClass;}
bool isDocumentationClass();
StringHandler::ModelicaClasses getRestriction() {return StringHandler::getModelicaClassType(mClassInformation.restriction);}
bool isConnector() {return (getRestriction() == StringHandler::ExpandableConnector || getRestriction() == StringHandler::Connector);}
bool isPartial() {return mClassInformation.partialPrefix;}
Expand Down Expand Up @@ -163,8 +161,6 @@ class LibraryTreeItem : public QObject
QString mFileName;
bool mReadOnly;
bool mIsSaved;
bool mIsProtected;
bool mDocumentationClass;
SaveContentsType mSaveContentsType;
QString mToolTip;
QIcon mIcon;
Expand Down
2 changes: 0 additions & 2 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -2681,8 +2681,6 @@ void ModelWidget::refresh()
OMCProxy *pOMCProxy = mpModelWidgetContainer->getMainWindow()->getOMCProxy();
pOMCProxy->setSourceFile(mpLibraryTreeItem->getNameStructure(), mpLibraryTreeItem->getFileName());
mpLibraryTreeItem->setClassInformation(pOMCProxy->getClassInformation(mpLibraryTreeItem->getNameStructure()));
bool isDocumentationClass = mpModelWidgetContainer->getMainWindow()->getOMCProxy()->getDocumentationClassAnnotation(mpLibraryTreeItem->getNameStructure());
mpLibraryTreeItem->setIsDocumentationClass(isDocumentationClass);
mpLibraryTreeItem->updateAttributes();
// mpModelWidgetContainer->getMainWindow()->getLibraryWidget()->loadLibraryComponent(mpLibraryTreeItem);
/* remove everything from the icon view */
Expand Down

0 comments on commit b84ec72

Please sign in to comment.