From d84f3bfdff122d3de8b1ca1ae7906113221b5746 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 18 Dec 2014 19:20:39 +0300 Subject: [PATCH] 0022825: EDF GUI regression: Issue with accent in the OB Temporarily rollback unicode support (as it is incomplete causing regressions) --- src/PyConsole/PyConsole_Editor.cxx | 24 ++++++++++++++--- src/SalomeApp/SalomeApp_DataObject.cxx | 29 ++++++++++++++++++--- src/VTKViewer/VTKViewer_FramedTextActor.cxx | 28 ++++++++++++++++++-- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index aeb61f965..ecbb7ba78 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -113,6 +113,22 @@ #include #include +//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 ) ); } } diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 468473a47..0125dbc21 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -38,6 +38,27 @@ #include #include +//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( root() ) ) diff --git a/src/VTKViewer/VTKViewer_FramedTextActor.cxx b/src/VTKViewer/VTKViewer_FramedTextActor.cxx index 3de2711f1..9dfe19d9b 100644 --- a/src/VTKViewer/VTKViewer_FramedTextActor.cxx +++ b/src/VTKViewer/VTKViewer_FramedTextActor.cxx @@ -38,6 +38,30 @@ #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(); } -- 2.39.2