Salome HOME
Update copyrights
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFileSelector.cpp
index 85b1772b0a036a417398a0e56e08bc68901189e3..6eae3c861174cd9bc943d06178cad69fcab6c36b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <ModelAPI_AttributeString.h>
@@ -66,6 +65,7 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent,
   aMainLay->addWidget(aTitleLabel, 0, 0);
   myPathField = new QLineEdit(this);
   aMainLay->addWidget(myPathField, 1, 0);
+
   QPushButton* aSelectPathBtn = new QPushButton("...", this);
   aSelectPathBtn->setToolTip(tr("Select file..."));
   aSelectPathBtn->setMaximumWidth(20);
@@ -94,7 +94,7 @@ bool ModuleBase_WidgetFileSelector::storeValueCustom()
   DataPtr aData = myFeature->data();
   AttributeStringPtr aStringAttr = aData->string(attributeID());
   QString aWidgetValue = myPathField->text();
-  aStringAttr->setValue(aWidgetValue.toStdString());
+  aStringAttr->setValue(aWidgetValue.toStdWString());
   updateObject(myFeature);
   return true;
 }
@@ -107,11 +107,13 @@ bool ModuleBase_WidgetFileSelector::restoreValueCustom()
   DataPtr aData = myFeature->data();
   AttributeStringPtr aStringAttr = aData->string(attributeID());
 
-  bool isBlocked = myPathField->blockSignals(true);
-  QString aNewText = QString::fromStdString(aStringAttr->value());
-  if( myPathField->text() != aNewText )
-    myPathField->setText( aNewText );
-  myPathField->blockSignals(isBlocked);
+  std::wstring aUtfStr = aStringAttr->valueW();
+  QString aNewText = QString::fromStdWString(aUtfStr);
+  if (myPathField->text() != aNewText) {
+    bool isBlocked = myPathField->blockSignals(true);
+    myPathField->setText(aNewText);
+    myPathField->blockSignals(isBlocked);
+  }
 
   return true;
 }
@@ -162,7 +164,7 @@ void ModuleBase_WidgetFileSelector::onPathSelectionBtn()
       if (!aFileName.isEmpty()) {
         if (myType == WFS_SAVE)
           aFileName = applyExtension(aFileName, mySelectedFilter);
-        myPathField->setText(aFileName);
+        myPathField->setText(aFileName.toUtf8());
         myDefaultPath = QFileInfo(aFileName).absolutePath();
         emit focusOutWidget(this);
       }