Salome HOME
0022825: EDF GUI regression: Issue with accent in the OB
authorvsr <vsr@opencascade.com>
Thu, 18 Dec 2014 16:20:39 +0000 (19:20 +0300)
committervsr <vsr@opencascade.com>
Thu, 18 Dec 2014 16:20:39 +0000 (19:20 +0300)
Temporarily rollback unicode support (as it is incomplete causing regressions)

src/PyConsole/PyConsole_Editor.cxx
src/SalomeApp/SalomeApp_DataObject.cxx
src/VTKViewer/VTKViewer_FramedTextActor.cxx

index aeb61f965e0cc5dd56d67116a539bd09eb3d5050..ecbb7ba78b2da9f52ceaebcced8712ecbd934b47 100644 (file)
 #include <QTextStream>
 #include <QChar>
 
+//VSR: uncomment below macro to support unicode text properly in SALOME
+//     current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+  QString fromUtf8( const char* txt )
+  {
+#ifdef PAL22528_UNICODE
+    return QString::fromUtf8( txt );
+#else
+    return QString( txt );
+#endif
+  }
+}
+
 static QString READY_PROMPT = ">>> ";
 static QString DOTS_PROMPT  = "... ";
 
@@ -140,8 +156,8 @@ void staticCallbackStdout( void* data, char* c )
 {
   if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
     PyConsole_Editor* e = (PyConsole_Editor*)data;
-    e->putLog( QString::fromUtf8(c) );
-    QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), false ) );
+    e->putLog( fromUtf8(c) );
+    QApplication::postEvent( e, new PrintEvent( fromUtf8(c), false ) );
   }
 }
 
@@ -149,8 +165,8 @@ void staticCallbackStderr( void* data, char* c )
 {
   if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
     PyConsole_Editor* e = (PyConsole_Editor*)data;
-    e->putLog( QString::fromUtf8(c) );
-    QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), true ) );
+    e->putLog( fromUtf8(c) );
+    QApplication::postEvent( e, new PrintEvent( fromUtf8(c), true ) );
   }
 }
 
index 468473a47773e2c0cff1b4e33b5103088cdd0424..0125dbc216bc815a2fe135c50054724bb8452282 100644 (file)
 #include <QObject>
 #include <QVariant>
 
+//VSR: uncomment below macro to support unicode text properly in SALOME
+//     current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+  QString fromUtf8( const char* txt )
+  {
+#ifdef PAL22528_UNICODE
+    return QString::fromUtf8( txt );
+#else
+    return QString( txt );
+#endif
+  }
+
+  QString fromUtf8( const std::string& txt )
+  {
+    return fromUtf8( txt.c_str() );
+  }
+}
+
 /*!
   \class SalomeApp_DataObject
   \brief Implementation of the data object for use in CORBA-based
@@ -82,12 +103,12 @@ QString SalomeApp_DataObject::name() const
 {
   QString str;
   if ( myObject )
-    str = QString::fromUtf8( myObject->GetName().c_str() );
+    str = fromUtf8( myObject->GetName() );
   
   if ( str.isEmpty() ) {
     _PTR(SObject) refObj = referencedObject();
     if ( refObj )
-      str = QString::fromUtf8( refObj->GetName().c_str() );
+      str = fromUtf8( refObj->GetName() );
   }
   
   if ( isReference() ) {
@@ -164,7 +185,7 @@ QPixmap SalomeApp_DataObject::icon( const int id ) const
       _PTR(AttributePixMap) aPixAttr ( anAttr );
       if ( aPixAttr->HasPixMap() ) {
         QString componentType = componentDataType();
-        QString pixmapID      = QString::fromUtf8(aPixAttr->GetPixMap().c_str());
+        QString pixmapID      = fromUtf8( aPixAttr->GetPixMap() );
         // select a plugin within a component
         QStringList plugin_pixmap = pixmapID.split( "::", QString::KeepEmptyParts );
         if ( plugin_pixmap.size() == 2 ) {
@@ -517,7 +538,7 @@ QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const
   {
     _PTR(AttributeString) strAttr = attr;
     std::string str = strAttr->Value();
-    QString aStrings = QString::fromUtf8( str.c_str() );
+    QString aStrings = fromUtf8( str );
     
     //Special case to show NoteBook variables in the "Value" column of the OB 
     if ( LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() ) )
index 3de2711f132fc6dafbcc4a588d52f31457de9589..9dfe19d9b808c7f45323cd37eb4eb1fae7ec463b 100644 (file)
 #define TEXT_MARGIN    4
 #define OFFSET_SPACING 2
 
+//VSR: uncomment below macro to support unicode text properly in SALOME
+//     current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+  QString fromUtf8( const char* txt )
+  {
+#ifdef PAL22528_UNICODE
+    return QString::fromUtf8( txt );
+#else
+    return QString( txt );
+#endif
+  }
+  const char* toUtf8( const QString& txt )
+  {
+#ifdef PAL22528_UNICODE
+    return txt.toUtf8().constData();
+#else
+    return txt.toLatin1().constData();
+#endif
+  }
+}
+
 //==================================================================
 vtkStandardNewMacro(VTKViewer_FramedTextActor);
 
@@ -268,7 +292,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText)
 {
   // remove whitespaces from from the start and the end
   // additionally, consider a case of multi-string text
-  QString aString(QString::fromUtf8(theText));
+  QString aString(fromUtf8(theText));
 
   QStringList aTrimmedStringList;
   QStringList aStringList = aString.split("\n");
@@ -276,7 +300,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText)
   while(anIter.hasNext())
     aTrimmedStringList.append(anIter.next().trimmed());
 
-  myTextActor->SetInput(aTrimmedStringList.join("\n").toUtf8().constData());
+  myTextActor->SetInput(toUtf8(aTrimmedStringList.join("\n")));
   Modified();
 }