@@ -4796,54 +4796,54 @@ bool LibraryWidget::saveModelicaLibraryTreeItemFolder(LibraryTreeItem *pLibraryT
47964796 } else {
47974797 return false ;
47984798 }
4799- }
4800- // read the package.order file if it already exists and rename any removed classes as class.bak-mo
4801- QFileInfo fileInfo (pLibraryTreeItem->getFileName ());
4802- QFile file (QString (" %1/package.order" ).arg (fileInfo.absoluteDir ().absolutePath ()));
4803- if (file.open (QIODevice::ReadOnly)) {
4804- QTextStream textStream (&file);
4805- while (!textStream.atEnd ()) {
4806- QString currentLine = textStream.readLine ();
4807- if (!currentLine.isEmpty ()) { // ignore empty lines in package.order
4808- bool classExists = false ;
4809- for (int i = 0 ; i < pLibraryTreeItem->childrenSize (); i++) {
4810- // Issue #12567. Compare case insensitive on Windows as `a` and `A` means the same thing.
4811- #ifdef Q_OS_WIN
4812- if (pLibraryTreeItem->child (i)->getName ().compare (currentLine, Qt::CaseInsensitive) == 0 ) {
4813- #else // #ifdef Q_OS_WIN
4814- if (pLibraryTreeItem->child (i)->getName ().compare (currentLine) == 0 ) {
4815- #endif // #ifdef Q_OS_WIN
4816- classExists = true ;
4817- break ;
4818- }
4819- }
4820- if (!classExists) {
4821- if (QDir ().exists (QString (" %1/%2" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine))) {
4822- if (OptionsDialog::instance ()->getGeneralSettingsPage ()->getCreateBackupFileCheckbox ()->isChecked ()) {
4823- QFile::rename (QString (" %1/%2/package.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine),
4824- QString (" %1/%2/package.bak-mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4825- } else {
4826- Utilities::removeDirectoryRecursively (QString (" %1/%2" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4799+ // read the package.order file if it already exists and rename any removed classes as class.bak-mo
4800+ QFileInfo fileInfo (pLibraryTreeItem->getFileName ());
4801+ QFile file (QString (" %1/package.order" ).arg (fileInfo.absoluteDir ().absolutePath ()));
4802+ if (file.open (QIODevice::ReadOnly)) {
4803+ QTextStream textStream (&file);
4804+ while (!textStream.atEnd ()) {
4805+ QString currentLine = textStream.readLine ();
4806+ if (!currentLine.isEmpty ()) { // ignore empty lines in package.order
4807+ bool classExists = false ;
4808+ for (int i = 0 ; i < pLibraryTreeItem->childrenSize (); i++) {
4809+ // Issue #12567. Compare case insensitive on Windows as `a` and `A` means the same thing.
4810+ #ifdef Q_OS_WIN
4811+ if (pLibraryTreeItem->child (i)->getName ().compare (currentLine, Qt::CaseInsensitive) == 0 ) {
4812+ #else // #ifdef Q_OS_WIN
4813+ if (pLibraryTreeItem->child (i)->getName ().compare (currentLine) == 0 ) {
4814+ #endif // #ifdef Q_OS_WIN
4815+ classExists = true ;
4816+ break ;
48274817 }
4828- } else {
4829- if (OptionsDialog::instance ()->getGeneralSettingsPage ()->getCreateBackupFileCheckbox ()->isChecked ()) {
4830- QFile::rename (QString (" %1/%2.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine),
4831- QString (" %1/%2.bak-mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4818+ }
4819+ if (!classExists) {
4820+ if (QDir ().exists (QString (" %1/%2" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine))) {
4821+ if (OptionsDialog::instance ()->getGeneralSettingsPage ()->getCreateBackupFileCheckbox ()->isChecked ()) {
4822+ QFile::rename (QString (" %1/%2/package.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine),
4823+ QString (" %1/%2/package.bak-mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4824+ } else {
4825+ Utilities::removeDirectoryRecursively (QString (" %1/%2" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4826+ }
48324827 } else {
4833- QFile::remove (QString (" %1/%2.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4828+ if (OptionsDialog::instance ()->getGeneralSettingsPage ()->getCreateBackupFileCheckbox ()->isChecked ()) {
4829+ QFile::rename (QString (" %1/%2.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine),
4830+ QString (" %1/%2.bak-mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4831+ } else {
4832+ QFile::remove (QString (" %1/%2.mo" ).arg (fileInfo.absoluteDir ().absolutePath ()).arg (currentLine));
4833+ }
48344834 }
48354835 }
48364836 }
48374837 }
4838+ file.close ();
48384839 }
4839- file.close ();
4840+ // create a package.order file
4841+ /* Ticket #4152. package.order should contain constants and classes.*/
4842+ QStringList childClasses = MainWindow::instance ()->getOMCProxy ()->getClassNames (pLibraryTreeItem->getNameStructure (), false , false , false , false , true , true );
4843+ const QString classesOrder = childClasses.isEmpty () ? " " : childClasses.join (" \n " ) + " \n " ;
4844+ // create a new package.order file
4845+ saveFile (QString (" %1/package.order" ).arg (fileInfo.absoluteDir ().absolutePath ()), classesOrder);
48404846 }
4841- // create a package.order file
4842- /* Ticket #4152. package.order should contain constants and classes.*/
4843- QStringList childClasses = MainWindow::instance ()->getOMCProxy ()->getClassNames (pLibraryTreeItem->getNameStructure (), false , false , false , false , true , true );
4844- const QString contents = childClasses.isEmpty () ? " " : childClasses.join (" \n " ) + " \n " ;
4845- // create a new package.order file
4846- saveFile (QString (" %1/package.order" ).arg (fileInfo.absoluteDir ().absolutePath ()), contents);
48474847 return true ;
48484848}
48494849
0 commit comments