0022825: EDF GUI regression: Issue with accent in the OB

Temporarily rollback unicode support (as it is incomplete causing regressions)
This commit is contained in:
vsr 2014-12-18 19:24:03 +03:00
parent 11d09b7433
commit 9fed37edd4
5 changed files with 44 additions and 14 deletions

View File

@ -4829,7 +4829,7 @@ void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& ti
_PTR(Study) study = appStudy->studyDS(); _PTR(Study) study = appStudy->studyDS();
_PTR(SObject) obj = study->FindObjectID( io->getEntry() ); _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
if ( obj ) { if ( obj ) {
QString aName = QString( QString::fromUtf8(obj->GetName().c_str()) ); QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
aName.remove( (aName.length() - 1), 1 ); aName.remove( (aName.length() - 1), 1 );
title = aName; title = aName;
@ -6809,7 +6809,7 @@ void SMESHGUI::message( const QString& msg )
_PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() ); _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
QString name; QString name;
if ( obj ) if ( obj )
name = QString::fromUtf8(obj->GetName().c_str()); name = SMESH::fromUtf8(obj->GetName());
if ( name.isEmpty() ) if ( name.isEmpty() )
return; return;

View File

@ -519,7 +519,7 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
bool isUnique = false; bool isUnique = false;
while (!isUnique) { while (!isUnique) {
aName = theOperation + "_" + QString::number(++aNumber); aName = theOperation + "_" + QString::number(++aNumber);
isUnique = (aSet.count(aName.toUtf8().data()) == 0); isUnique = (aSet.count(std::string(SMESH::toUtf8(aName))) == 0);
} }
return aName; return aName;
@ -535,7 +535,7 @@ void SMESHGUI_GroupDlg::setDefaultName() const
do do
{ {
aResName = aPrefix + QString::number( i++ ); aResName = aPrefix + QString::number( i++ );
anObj = aStudy->FindObject( aResName.toUtf8().data() ); anObj = aStudy->FindObject( SMESH::toUtf8(aResName) );
} }
while ( anObj ); while ( anObj );
myName->setText(aResName); myName->setText(aResName);
@ -594,14 +594,14 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
myNameChanged = true; myNameChanged = true;
myName->blockSignals(true); myName->blockSignals(true);
myName->setText(QString::fromUtf8(theGroup->GetName())); myName->setText(SMESH::fromUtf8(theGroup->GetName()));
myName->blockSignals(false); myName->blockSignals(false);
myName->home(false); myName->home(false);
SALOMEDS::Color aColor = theGroup->GetColor(); SALOMEDS::Color aColor = theGroup->GetColor();
setGroupColor( aColor ); setGroupColor( aColor );
myMeshGroupLine->setText(QString::fromUtf8(theGroup->GetName())); myMeshGroupLine->setText(SMESH::fromUtf8(theGroup->GetName()));
int aType = 0; int aType = 0;
switch(theGroup->GetType()) { switch(theGroup->GetType()) {
@ -686,7 +686,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
{ {
myNameChanged = true; myNameChanged = true;
myName->blockSignals(true); myName->blockSignals(true);
myName->setText(QString::fromUtf8(theGroup->GetName())); myName->setText(SMESH::fromUtf8(theGroup->GetName()));
myName->blockSignals(false); myName->blockSignals(false);
} }
@ -1041,7 +1041,7 @@ bool SMESHGUI_GroupDlg::onApply()
if (myGeomObjects->length() == 1) { if (myGeomObjects->length() == 1) {
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
myName->text().toUtf8().data(), SMESH::toUtf8(myName->text()),
myGeomObjects[0]); myGeomObjects[0]);
} }
else { else {
@ -1083,11 +1083,11 @@ bool SMESHGUI_GroupDlg::onApply()
aNewGeomGroupName += myName->text(); aNewGeomGroupName += myName->text();
SALOMEDS::SObject_var aNewGroupSO = SALOMEDS::SObject_var aNewGroupSO =
geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar,
aNewGeomGroupName.toUtf8().data(), aMeshShape); SMESH::toUtf8(aNewGeomGroupName), aMeshShape);
} }
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
myName->text().toUtf8().data(), SMESH::toUtf8(myName->text()),
aGroupVar); aGroupVar);
} }
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom );
@ -1110,7 +1110,7 @@ bool SMESHGUI_GroupDlg::onApply()
return false; return false;
myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, myGroupOnFilter = myMesh->CreateGroupFromFilter(aType,
myName->text().toUtf8().data(), SMESH::toUtf8(myName->text()),
myFilter); myFilter);
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter );
@ -1151,7 +1151,7 @@ bool SMESHGUI_GroupDlg::onApply()
} }
else else
{ {
resultGroup->SetName(myName->text().toUtf8().data()); resultGroup->SetName(SMESH::toUtf8(myName->text()));
if ( aMeshGroupSO ) if ( aMeshGroupSO )
{ {
@ -1166,7 +1166,7 @@ bool SMESHGUI_GroupDlg::onApply()
if ( !anActor ) return false; if ( !anActor ) return false;
myActorsList.append( anActor ); myActorsList.append( anActor );
} }
anActor->setName(myName->text().toUtf8().data()); anActor->setName(SMESH::toUtf8(myName->text()));
QColor c; QColor c;
int delta; int delta;
switch ( myTypeId ) { switch ( myTypeId ) {

View File

@ -42,7 +42,7 @@ namespace SMESH
SMESH::SMESH_Group_var aGroup; SMESH::SMESH_Group_var aGroup;
try { try {
if ( !theMesh->_is_nil() ) if ( !theMesh->_is_nil() )
aGroup = theMesh->CreateGroup( theType, theGroupName.toUtf8().data() ); aGroup = theMesh->CreateGroup( theType, SMESH::toUtf8(theGroupName) );
} }
catch( const SALOME::SALOME_Exception& S_ex ) { catch( const SALOME::SALOME_Exception& S_ex ) {
SalomeApp_Tools::QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException( S_ex );

View File

@ -52,6 +52,10 @@
#include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Group)
//VSR: uncomment below macro to support unicode text properly in SALOME
// current commented out due to regressions
//#define PAL22528_UNICODE
namespace SMESH namespace SMESH
{ {
SUIT_Desktop* SUIT_Desktop*
@ -391,4 +395,27 @@ namespace SMESH
return n; return n;
} }
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() );
}
const char* toUtf8( const QString& txt )
{
#ifdef PAL22528_UNICODE
return txt.toUtf8().constData();
#else
return txt.toLatin1().constData();
#endif
}
} // end of namespace SMESH } // end of namespace SMESH

View File

@ -208,6 +208,9 @@ SMESHGUI_EXPORT
toStdStr( char* s ): toStrT< std::string >(s) {} toStdStr( char* s ): toStrT< std::string >(s) {}
}; };
QString fromUtf8( const char* txt );
QString fromUtf8( const std::string& txt );
const char* toUtf8( const QString& txt );
} }
#endif // SMESHGUI_UTILS_H #endif // SMESHGUI_UTILS_H