Salome HOME
Support of non-ASCII filenames (to some extent)
authorRenaud Barate <renaud.barate@edf.fr>
Thu, 10 Jul 2014 09:57:17 +0000 (11:57 +0200)
committerRenaud Barate <renaud.barate@edf.fr>
Thu, 10 Jul 2014 09:57:17 +0000 (11:57 +0200)
Non-ASCII filenames can be used to load and save schemas.
Function SaveAs still strips the accents.
Windows compatibility is not tested yet.

src/genericgui/GenericGui.cxx

index 9dd62d4d632859a0404b1148983f2ba23f8c61c0..31d51b7829fc966fbd946d939a9fc95e6610ec93 100644 (file)
@@ -1291,7 +1291,7 @@ void GenericGui::loadSchema(const std::string& filename,bool edit, bool arrangeL
     {
       DEBTRACE(logger->getStr());
     }
-  QString fn=QString::fromStdString(filename);
+  QString fn=QString::fromUtf8(filename.c_str());
   if(edit)
     createContext(proc, fn, "", true);
   else
@@ -1331,11 +1331,11 @@ void GenericGui::onImportSchema()
       if (!fi.exists() && fi.suffix() != "xml")
         fn += ".xml";
 
-      DEBTRACE("file loaded : " <<fn.toStdString());
+      DEBTRACE("file loaded : " <<fn.toUtf8().constData());
       YACS::ENGINE::Proc *proc = 0;
 
       try {
-         proc = _loader->load(fn.toLatin1());
+         proc = _loader->load(fn.toUtf8().constData());
       }
       catch (...) {
       }
@@ -1529,12 +1529,12 @@ void GenericGui::onExportSchema()
     }
   if (fn.isEmpty()) return;
 
-  DEBTRACE("GenericGui::onExportSchema: " << fn.toStdString());
+  DEBTRACE("GenericGui::onExportSchema: " << fn.toUtf8().constData());
   //to be sure that all pending changes are effective
   _parent->setFocus();
   QtGuiContext::getQtCurrent()->setFileName(fn);
   VisitorSaveGuiSchema aWriter(proc);
-  aWriter.openFileSchema( fn.toStdString() );
+  aWriter.openFileSchema( fn.toUtf8().constData() );
   aWriter.visitProc();
   aWriter.closeFileSchema();
   QtGuiContext::getQtCurrent()->setNotSaved(false);
@@ -1555,10 +1555,10 @@ void GenericGui::onExportSchemaAs()
   QString fn = getSaveFileName(fo);
   if (fn.isEmpty()) return;
 
-  DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toStdString());
+  DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toUtf8().constData());
   QtGuiContext::getQtCurrent()->setFileName(fn);
   VisitorSaveGuiSchema aWriter(proc);
-  aWriter.openFileSchema(fn.toStdString());
+  aWriter.openFileSchema(fn.toUtf8().constData());
   aWriter.visitProc();
   aWriter.closeFileSchema();
   _isSaved = true;