Skip to content

Commit

Permalink
[WIP] Disable the diagram and text view for Access.icon and Access.do…
Browse files Browse the repository at this point in the history
…cumentation
  • Loading branch information
adeas31 committed Dec 1, 2017
1 parent 13fa5ac commit c72eace
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
21 changes: 16 additions & 5 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -456,11 +456,20 @@ void LibraryTreeItem::setClassInformation(OMCInterface::getClassInformation_res
setReadOnly(classInformation.fileReadOnly);
// handle the Access annotation
LibraryTreeItem::Access access = getAccess();
if (access == LibraryTreeItem::hide && mpModelWidget) {
QMdiSubWindow *pSubWindow = MainWindow::instance()->getModelWidgetContainer()->getMdiSubWindow(mpModelWidget);
if (pSubWindow) {
pSubWindow->close();
}
switch (access) {
case LibraryTreeItem::hide:
if (mpModelWidget) {
QMdiSubWindow *pSubWindow = MainWindow::instance()->getModelWidgetContainer()->getMdiSubWindow(mpModelWidget);
if (pSubWindow) {
pSubWindow->close();
}
}
break;
default:
break;
}
if (mpModelWidget) {
mpModelWidget->updateViewButtonsBasedOnAccess();
}
}
}
Expand Down Expand Up @@ -521,6 +530,8 @@ LibraryTreeItem::Access LibraryTreeItem::getAccess()
return LibraryTreeItem::packageText;
} else if (mClassInformation.access.compare("Access.packageDuplicate") == 0) {
return LibraryTreeItem::packageDuplicate;
} else if (mpParentLibraryTreeItem) { // if there is not override for Access annotation then look in the parent class.
return mpParentLibraryTreeItem->getAccess();
} else {
return LibraryTreeItem::all;
}
Expand Down
26 changes: 26 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -3613,6 +3613,7 @@ void ModelWidget::reDrawModelWidget()
// if (mpEditor) {
// mpEditor->getPlainTextEdit()->document()->clearUndoRedoStacks();
// }
updateViewButtonsBasedOnAccess();
// announce the change.
mpLibraryTreeItem->emitLoaded();
}
Expand Down Expand Up @@ -4540,6 +4541,29 @@ void ModelWidget::endMacro()
}
}

/*!
* \brief ModelWidget::updateViewButtonsBasedOnAccess
* Update the view buttons i.e., icon, diagram and text based on the Access annotation.
*/
void ModelWidget::updateViewButtonsBasedOnAccess()
{
if (mCreateModelWidgetComponents) {
LibraryTreeItem::Access access = mpLibraryTreeItem->getAccess();
switch (access) {
case LibraryTreeItem::icon:
case LibraryTreeItem::documentation:
mpIconViewToolButton->setChecked(true);
mpDiagramViewToolButton->setEnabled(false);
mpTextViewToolButton->setEnabled(false);
break;
default:
mpDiagramViewToolButton->setEnabled(true);
mpTextViewToolButton->setEnabled(true);
break;
}
}
}

/*!
* \brief ModelWidget::getModelInheritedClasses
* Gets the class inherited classes.
Expand Down Expand Up @@ -5549,6 +5573,7 @@ void ModelWidgetContainer::addModelWidget(ModelWidget *pModelWidget, bool checkP
pModelWidget->getDiagramViewToolButton()->setChecked(true);
}
}
pModelWidget->updateViewButtonsBasedOnAccess();
if (!checkPreferedView || pModelWidget->getLibraryTreeItem()->getLibraryType() != LibraryTreeItem::Modelica) {
return;
}
Expand Down Expand Up @@ -5581,6 +5606,7 @@ void ModelWidgetContainer::addModelWidget(ModelWidget *pModelWidget, bool checkP
}
}
}
pModelWidget->updateViewButtonsBasedOnAccess();
}

/*!
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.h
Expand Up @@ -413,6 +413,7 @@ class ModelWidget : public QWidget
bool writeVisualXMLFile(QString fileName, bool canWriteVisualXMLFile = false);
void beginMacro(const QString &text);
void endMacro();
void updateViewButtonsBasedOnAccess();
private:
ModelWidgetContainer *mpModelWidgetContainer;
LibraryTreeItem *mpLibraryTreeItem;
Expand Down

0 comments on commit c72eace

Please sign in to comment.