Skip to content

Commit 991c06b

Browse files
committed
Use listFile when file is encrypted
1 parent 94bcd98 commit 991c06b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,14 +2308,20 @@ void LibraryTreeModel::readLibraryTreeItemClassTextFromText(LibraryTreeItem *pLi
23082308
QString LibraryTreeModel::readLibraryTreeItemClassTextFromFile(LibraryTreeItem *pLibraryTreeItem)
23092309
{
23102310
QString contents = "";
2311-
QFile file(pLibraryTreeItem->getFileName());
2312-
if (!file.open(QIODevice::ReadOnly)) {
2313-
QMessageBox::critical(MainWindow::instance(), QString(Helper::applicationName).append(" - ").append(Helper::error),
2314-
GUIMessages::getMessage(GUIMessages::ERROR_OPENING_FILE).arg(pLibraryTreeItem->getFileName())
2315-
.arg(file.errorString()), Helper::ok);
2316-
} else {
2317-
contents = QString(file.readAll());
2318-
file.close();
2311+
QFileInfo fileInfo(pLibraryTreeItem->getFileName());
2312+
// if the file is encrypted use listFile
2313+
if (fileInfo.suffix().compare("moc") == 0) {
2314+
contents = MainWindow::instance()->getOMCProxy()->listFile(pLibraryTreeItem->getNameStructure());
2315+
} else { // else read the file contents
2316+
QFile file(pLibraryTreeItem->getFileName());
2317+
if (!file.open(QIODevice::ReadOnly)) {
2318+
QMessageBox::critical(MainWindow::instance(), QString(Helper::applicationName).append(" - ").append(Helper::error),
2319+
GUIMessages::getMessage(GUIMessages::ERROR_OPENING_FILE).arg(pLibraryTreeItem->getFileName())
2320+
.arg(file.errorString()), Helper::ok);
2321+
} else {
2322+
contents = QString(file.readAll());
2323+
file.close();
2324+
}
23192325
}
23202326
return contents;
23212327
}

0 commit comments

Comments
 (0)