Implement support of UTF-8

This commit is contained in:
vsr 2014-12-12 18:27:05 +03:00
parent 4b00e015b7
commit 282f829c20
17 changed files with 57 additions and 64 deletions

View File

@ -1236,7 +1236,8 @@ void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
ObjectList::iterator it = pipeTShapeGroupObjects.begin();
for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
getGeomEngine()->AddInStudy(theStudy, (*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
CORBA::String_var sname = (*it)->GetName();
getGeomEngine()->AddInStudy(theStudy, (*it), sname.in(), theFather);
}
}

View File

@ -435,7 +435,7 @@ EntityGUI_FieldDlg::StepTable::StepTable (int stepID, int dataType,
if ( vals->length() == nbRows * nbComps )
for ( int iV = 0, iR = 0; iR < nbRows; ++iR )
for ( int iC = 1; iC < nbColumns; ++iC )
setItem( iR, iC, new QTableWidgetItem( vals[ iV++ ].in() ));
setItem( iR, iC, new QTableWidgetItem( QString::fromUtf8( vals[ iV++ ].in() ) ) );
}
break;
}
@ -753,7 +753,7 @@ void EntityGUI_FieldDlg::StepTable::setValues(GEOM::GEOM_FieldStep_var& step)
vals->length( nbRows * nbComps );
for ( int iV = 0, iR = 0; iR < nbRows; ++iR )
for ( int iC = 1; iC < nbColumns; ++iC )
vals[ iV++ ] = item( iR, iC )->text().toLatin1().constData();
vals[ iV++ ] = item( iR, iC )->text().toUtf8().constData();
ss->SetValues( vals );
}
}
@ -1012,13 +1012,13 @@ void EntityGUI_FieldDlg::Init()
myIsCreation = false;
CORBA::String_var fName = myField->GetName();
myMainFrame->ResultName->setText( fName.in() );
myMainFrame->ResultName->setText( QString::fromUtf8( fName.in() ) );
myShape = myField->GetShape();
CORBA::String_var sName;
if ( !myShape->_is_nil() )
sName = myShape->GetName();
myShapeName->setText( sName.in() ? sName.in() : "");
myShapeName->setText( QString::fromUtf8( sName.in() ? sName.in() : "" ) );
myTypeCombo->setCurrentIndex( myField->GetDataType() );
@ -1414,7 +1414,7 @@ void EntityGUI_FieldDlg::showCurStep()
{
GEOM::string_array_var compNames = myField->GetComponents();
for ( int iC = 0; iC < compNames->length(); ++iC )
headers << compNames[ iC ].in();
headers << QString::fromUtf8( compNames[ iC ].in() );
}
else
{
@ -1870,11 +1870,11 @@ bool EntityGUI_FieldDlg::execute()
GEOM::string_array_var compNames = new GEOM::string_array();
compNames->length( nbComps );
for ( int iC = 0; iC < nbComps; ++iC )
compNames[ iC ] = columnNames[ iC+1 ].toLatin1().constData();
compNames[ iC ] = columnNames[ iC+1 ].toUtf8().constData();
GEOM::GEOM_IFieldOperations_var anOper = GEOM::GEOM_IFieldOperations::_narrow(getOperation());
myField = anOper->CreateField( myShape,
aName.toLatin1().constData(),
aName.toUtf8().constData(),
GEOM::field_data_type( getDataType() ),
CORBA::Short( getDim() ),
compNames );
@ -1882,7 +1882,7 @@ bool EntityGUI_FieldDlg::execute()
return false;
SALOMEDS::SObject_wrap aSO =
getGeomEngine()->AddInStudy( aStudyDS, myField, aName.toLatin1().constData(), myShape );
getGeomEngine()->AddInStudy( aStudyDS, myField, aName.toUtf8().constData(), myShape );
if ( !aSO->_is_nil() ) {
myField->UnRegister();
CORBA::String_var entry = aSO->GetID();
@ -1891,13 +1891,13 @@ bool EntityGUI_FieldDlg::execute()
}
else // update field name
{
myField->SetName( aName.toLatin1().constData() );
myField->SetName( aName.toUtf8().constData() );
CORBA::String_var entry = myField->GetStudyEntry();
if ( entry.in() ) {
SALOMEDS::SObject_wrap SO = aStudyDS->FindObjectID( entry.in() );
if ( !SO->_is_nil() ) {
aBuilder->SetName(SO, aName.toLatin1().constData());
aBuilder->SetName(SO, aName.toUtf8().constData());
}
}
}
@ -1918,7 +1918,7 @@ bool EntityGUI_FieldDlg::execute()
step = myField->AddStep( tbl->getStepID(), tbl->getStamp() );
SALOMEDS::SObject_wrap aSO =
getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), myField );
getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toUtf8().constData(), myField );
if ( /*!myIsCreation &&*/ !aSO->_is_nil() ) {
step->UnRegister();
CORBA::String_var entry = aSO->GetID();
@ -1933,7 +1933,7 @@ bool EntityGUI_FieldDlg::execute()
if ( entry.in() ) {
SALOMEDS::SObject_wrap SO = aStudyDS->FindObjectID( entry.in() );
if ( !SO->_is_nil() )
aBuilder->SetName( SO, stepName.toLatin1().constData() );
aBuilder->SetName( SO, stepName.toUtf8().constData() );
}
}

View File

@ -144,7 +144,7 @@ int GEOMBase::GetNameOfSelectedIObjects( const SALOME_ListIO& IObjects,
_PTR(GenericAttribute) anAttr;
if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) {
_PTR(AttributeName) aNameAttr ( anAttr );
name = aNameAttr->Value().c_str();
name = QString::fromUtf8( aNameAttr->Value().c_str() );
}
}
}
@ -626,7 +626,7 @@ bool GEOMBase::SelectionByNameInDialogs( QWidget* widget, const QString& objectU
/* Create a SALOME_InteractiveObject with a SALOME::SObject */
Handle(SALOME_InteractiveObject) IO = new SALOME_InteractiveObject( listSO[0]->GetID().c_str(),
"GEOM",
objectUserName.toLatin1().constData() );
objectUserName.toUtf8().constData() );
/* Add as a selected object */
/* Clear any previous selection : */
@ -769,7 +769,7 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr object )
_PTR(GenericAttribute) anAttr;
if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
_PTR(AttributeName) aNameAttr( anAttr );
name = aNameAttr->Value().c_str();
name = QString::fromUtf8( aNameAttr->Value().c_str() );
}
}
@ -870,7 +870,7 @@ void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object )
if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) {
QString name = GetName( object );
GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ),
object, name.toLatin1().data(), father.in() );
object, name.toUtf8().data(), father.in() );
}
}
}

View File

@ -181,7 +181,7 @@ void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView
QString entry = getEntry( object );
getDisplayer()->Erase( new SALOME_InteractiveObject(
entry.toLatin1().constData(),
"GEOM", strdup( GEOMBase::GetName( object ).toLatin1().constData() ) ), true, updateView );
"GEOM", strdup( GEOMBase::GetName( object ).toUtf8().constData() ) ), true, updateView );
}
}
@ -220,7 +220,7 @@ void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
QString entry = getEntry( object );
getDisplayer()->Redisplay(new SALOME_InteractiveObject
(entry.toLatin1().constData(), "GEOM", strdup(GEOMBase::GetName(object).toLatin1().constData())), false);
(entry.toLatin1().constData(), "GEOM", strdup(GEOMBase::GetName(object).toUtf8().constData())), false);
}
if ( withChildren ) {
@ -238,7 +238,7 @@ void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
if ( !aChild->_is_nil() ) {
QString entry = getEntry( aChild );
getDisplayer()->Redisplay( new SALOME_InteractiveObject(
entry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( aChild ).toLatin1().constData() ) ), false );
entry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( aChild ).toUtf8().constData() ) ), false );
}
}
}
@ -479,7 +479,7 @@ void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const std::list
QString anEntry = getEntry( anObj );
if ( anEntry != "" )
aListOfIO.Append( new SALOME_InteractiveObject(
anEntry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( anObj ).toLatin1().constData() ) ) );
anEntry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( anObj ).toUtf8().constData() ) ) );
}
getDisplayer()->LocalSelection( aListOfIO, modes );
@ -885,7 +885,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
}
}
anEntryList << addInStudy( obj, aName.toLatin1().constData() );
anEntryList << addInStudy( obj, aName.toUtf8().constData() );
// updateView=false
if( isDisplayResult() )
display( obj, false );

View File

@ -2780,7 +2780,7 @@ void GEOM_Displayer::readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldSte
{
GEOM::string_array_var aValues = aGeomStringFieldStep->GetValues();
for( size_t i = 0, n = aValues->length(); i < n; i++ )
aFieldStepData << QString( aValues[i] );
aFieldStepData << QString::fromUtf8( aValues[i].in() );
}
}

View File

@ -2014,8 +2014,8 @@ void GeometryGUI::updateCreationInfo()
QString plugin_name;
for ( size_t i = 0; i < info->params.length(); ++i ) {
myCreationInfoWdg->addParam( info->params[i].name.in(),
info->params[i].value.in() );
myCreationInfoWdg->addParam( QString::fromUtf8( info->params[i].name.in() ),
QString::fromUtf8( info->params[i].value.in() ) );
QString value = info->params[i].name.in();
if( value == PLUGIN_NAME ) {
plugin_name = info->params[i].value.in();
@ -3220,10 +3220,10 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name)
if ( obj->FindAttribute(anAttr, "AttributeName") ) {
_PTR(AttributeName) aName (anAttr);
aName->SetValue( name.toLatin1().data() ); // rename the SObject
aName->SetValue( name.toUtf8().data() ); // rename the SObject
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
if (!CORBA::is_nil(anObj)) {
anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
}
result = true;

View File

@ -668,7 +668,7 @@ void GEOMToolsGUI::OnEdgeWidth()
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
GEOMToolsGUI_LineWidthDlg* Dlg =
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "EDGE_WIDTH_TLT" );
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), tr("EDGE_WIDTH_TLT") );
QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), QVariant() );
int aWidth = v.isValid() ? v.toInt() : SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "edge_width", 1 );
@ -711,7 +711,7 @@ void GEOMToolsGUI::OnIsosWidth() {
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
GEOMToolsGUI_LineWidthDlg* Dlg =
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), tr("ISOS_WIDTH_TLT") );
QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), QVariant() );
int aWidth = v.isValid() ? v.toInt() : SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "isolines_width", 1 );
@ -851,7 +851,7 @@ void GEOMToolsGUI::OnCreateFolder()
_PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry()));
if ( !aFatherSO ) return;
GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toLatin1().constData(),
GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toUtf8().constData(),
_CAST(SObject, aFatherSO)->GetSObject() );
app->updateObjectBrowser( false );
}

View File

@ -53,7 +53,7 @@ GEOMToolsGUI_LineWidthDlg::GEOMToolsGUI_LineWidthDlg (QWidget* parent, const QSt
setObjectName("GEOMToolsGUI_LineWidthDlg");
setModal(true);
setWindowTitle(tr(title.toLatin1().constData()));
setWindowTitle(title);
setSizeGripEnabled(TRUE);
QGridLayout* MyDialogLayout = new QGridLayout(this);
MyDialogLayout->setSpacing(6);

View File

@ -375,7 +375,7 @@ void GEOMToolsGUI_MarkerDlg::browse()
filters << tr( "Texture files (*.dat)" ) << tr( "All files (*)" );
QString aFileName = SUIT_Session::session()->activeApplication()->getFileName( true, QString(), filters.join( ";;" ), tr( "LOAD_TEXTURE_TLT" ), this );
if ( !aFileName.isEmpty() ) {
addTexture( myOperation->LoadTexture( aFileName.toLatin1().constData() ), true );
addTexture( myOperation->LoadTexture( aFileName.toUtf8().constData() ), true );
}
}

View File

@ -112,15 +112,11 @@ GEOM::string_array* GEOM_Field_i::GetComponents()
if ( !comps.IsNull() )
{
compArr->length( comps->Length() );
std::string entry;
int i, i0, nb;
for ( i = i0 = comps->Lower(), nb = comps->Upper(); i <= nb; ++i )
{
const TCollection_ExtendedString& anEntry = comps->Value( i );
entry.resize( anEntry.LengthOfCString() );
char* pstr = &entry[0];
anEntry.ToUTF8CString( pstr );
compArr[ i-i0 ] = CORBA::string_dup( entry.c_str() );
compArr[ i-i0 ] = CORBA::string_dup( TCollection_AsciiString( anEntry ).ToCString() );
}
}
return compArr._retn();
@ -494,15 +490,11 @@ GEOM::string_array* GEOM_StringFieldStep_i::GetValues()
if ( !values.IsNull() )
{
resArray->length( values->Length() );
std::string entry;
int i, i0, nb;
for ( i = i0 = values->Lower(), nb = values->Upper(); i <= nb; ++i )
{
const TCollection_ExtendedString& anEntry = values->Value( i );
entry.resize( anEntry.LengthOfCString() );
char* pstr = &entry[0];
anEntry.ToUTF8CString( pstr );
resArray[ i-i0 ] = CORBA::string_dup( entry.c_str() );
resArray[ i-i0 ] = CORBA::string_dup( TCollection_AsciiString( anEntry ).ToCString() );
}
}
return resArray._retn();

View File

@ -1342,7 +1342,7 @@ bool GroupGUI_GroupDlg::execute(ObjectList& objects)
_PTR(SObject) SO (study->studyDS()->FindObjectIOR(objIOR.toLatin1().constData()));
if (SO) {
_PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
aBuilder->SetName(SO, getNewObjectName().toLatin1().constData());
aBuilder->SetName(SO, getNewObjectName().toUtf8().constData());
}
}
}

View File

@ -562,7 +562,7 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
aGroup->SetPrimitivesAspect( anAspectText3d );
aGroup->Text( aString.toLatin1().constData(), aVertex, 14 );
aGroup->Text( aString.toUtf8().constData(), aVertex, 14 );
}
}
else

View File

@ -642,7 +642,7 @@ bool RepairGUI_GlueDlg::onAcceptLocal()
if (aName.isEmpty())
aName = GEOMBase::GetDefaultName(getPrefix(*it));
}
addInStudy(*it, aName.toLatin1().data());
addInStudy(*it, aName.toUtf8().data());
display(*it, false);
}

View File

@ -363,7 +363,7 @@ bool RepairGUI_LimitToleranceDlg::onAcceptLocal()
if (aName.isEmpty())
aName = GEOMBase::GetDefaultName(getPrefix(*it));
}
addInStudy(*it, aName.toLatin1().data());
addInStudy(*it, aName.toUtf8().data());
display(*it, false);
}

View File

@ -711,7 +711,7 @@ bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
}
if ( !anErrorObjNames.empty() )
MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toLatin1().data() );
MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toUtf8().data() );
return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
}

View File

@ -241,7 +241,7 @@ void XAOPlugin_ExportDlg::processObject()
{
QListWidgetItem* item = new QListWidgetItem();
item->setData(Qt::UserRole, QVariant(i));
item->setText(fields[i]->GetName());
item->setText(QString::fromUtf8(fields[i]->GetName()));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Checked);
lstFields->addItem(item);

View File

@ -330,7 +330,7 @@ QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEO
GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]);
QString stepName = (tr("XAOPLUGIN_STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() );
SALOMEDS::SObject_wrap aSOField =
getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), theField );
getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toUtf8().constData(), theField );
}
aSO->UnRegister();