Skip to content

Commit 67ee599

Browse files
committed
Check for the access annotation
before calling `listFile` and `getIconAnnotation` avoids unnecessary messages from OMC. Allow opening *.mol files from regular open dialog.
1 parent 532f7bb commit 67ee599

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,10 @@ QString LibraryTreeModel::readLibraryTreeItemClassTextFromFile(LibraryTreeItem *
21452145
QString contents = "";
21462146
QFileInfo fileInfo(pLibraryTreeItem->getFileName());
21472147
// if the file is encrypted use listFile
2148-
if (fileInfo.suffix().compare("moc") == 0) {
2148+
if ((fileInfo.suffix().compare("moc") == 0)
2149+
&& (pLibraryTreeItem->getAccess() >= LibraryTreeItem::packageText
2150+
|| (pLibraryTreeItem->getAccess() >= LibraryTreeItem::nonPackageText
2151+
&& pLibraryTreeItem->getRestriction() != StringHandler::Package))) {
21492152
contents = MainWindow::instance()->getOMCProxy()->listFile(pLibraryTreeItem->getNameStructure());
21502153
} else { // else read the file contents
21512154
QFile file(pLibraryTreeItem->getFileName());

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4855,7 +4855,9 @@ void ModelWidget::getModelIconDiagramShapes(StringHandler::ViewType viewType)
48554855
QString annotationString;
48564856
if (viewType == StringHandler::Icon) {
48574857
pGraphicsView = mpIconGraphicsView;
4858-
annotationString = pOMCProxy->getIconAnnotation(mpLibraryTreeItem->getNameStructure());
4858+
if (mpLibraryTreeItem->getAccess() >= LibraryTreeItem::icon) {
4859+
annotationString = pOMCProxy->getIconAnnotation(mpLibraryTreeItem->getNameStructure());
4860+
}
48594861
} else {
48604862
pGraphicsView = mpDiagramGraphicsView;
48614863
if (mpLibraryTreeItem->getAccess() >= LibraryTreeItem::diagram) {

OMEdit/OMEditGUI/Util/Helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ QString Helper::OpenModelicaVersion = "";
4545
QString Helper::OpenModelicaHome = "";
4646
QString Helper::OpenModelicaLibrary = "";
4747
QString Helper::OMCServerName = "OMEdit";
48-
QString Helper::omFileTypes = "Modelica Files (*.mo)";
48+
QString Helper::omFileTypes = "All Modelica Files (*.mo *.mol);;Modelica Files (*.mo);;Encrypted Modelica Libraries (*.mol)";
4949
QString Helper::omEncryptedFileTypes = "Encrypted Modelica Libraries (*.mol)";
5050
QString Helper::omnotebookFileTypes = "OMNotebook Files (*.onb *.onbz *.nb)";
5151
QString Helper::ngspiceNetlistFileTypes = "ngspice Netlist Files (*.cir *.sp *.spice)";

0 commit comments

Comments
 (0)