Skip to content
Permalink
Browse files

use QTextCodec::codecForLocale() where "System" is not available (lik…

…e android)
  • Loading branch information
jef-n committed Jan 25, 2012
1 parent a30eb37 commit 747e497e0b704a5864a76e53c9e124acfb46ddbe
@@ -46,7 +46,7 @@ QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WFlags
cmbEncodings->addItems( QgsVectorDataProvider::availableEncodings() );

QSettings settings;
QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
QString enc = settings.value( "/UI/encoding", "System" ).toString();

restoreGeometry( settings.value( "/Windows/OpenVectorLayer/geometry" ).toByteArray() );

@@ -49,7 +49,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl

mEncodingComboBox->addItems( QgsVectorDataProvider::availableEncodings() );

QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
QString enc = settings.value( "/UI/encoding", "System" ).toString();
int idx = mEncodingComboBox->findText( enc );
if ( idx < 0 )
{
@@ -31,7 +31,7 @@ QgsVectorDataProvider::QgsVectorDataProvider( QString uri )
, mFetchFeaturesWithoutGeom( true )
{
QSettings settings;
setEncoding( settings.value( "/UI/encoding", QString( "System" ) ).toString() );
setEncoding( settings.value( "/UI/encoding", "System" ).toString() );
}


@@ -151,7 +151,7 @@ int QgsVectorDataProvider::capabilities() const

void QgsVectorDataProvider::setEncoding( const QString& e )
{
QTextCodec* ncodec = QTextCodec::codecForName( e.toLocal8Bit().data() );
QTextCodec* ncodec = QTextCodec::codecForName( e.toLocal8Bit().constData() );
if ( ncodec )
{
mEncoding = ncodec;
@@ -160,6 +160,10 @@ void QgsVectorDataProvider::setEncoding( const QString& e )
{
QgsMessageLog::logMessage( tr( "Codec %1 not found. Falling back to system locale" ).arg( e ) );
mEncoding = QTextCodec::codecForName( "System" );

if ( !mEncoding )
mEncoding = QTextCodec::codecForLocale();

Q_ASSERT( mEncoding );
}
}
@@ -187,17 +187,19 @@ QgsVectorFileWriter::QgsVectorFileWriter(
QgsDebugMsg( "Created data source" );

// use appropriate codec
mCodec = QTextCodec::codecForName( fileEncoding.toLocal8Bit().data() );
mCodec = QTextCodec::codecForName( fileEncoding.toLocal8Bit().constData() );
if ( !mCodec )
{
QSettings settings;
QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
QgsDebugMsg( "error finding QTextCodec for " + fileEncoding );
mCodec = QTextCodec::codecForName( enc.toLocal8Bit().data() );

QSettings settings;
QString enc = settings.value( "/UI/encoding", "System" ).toString();
mCodec = QTextCodec::codecForName( enc.toLocal8Bit().constData() );
if ( !mCodec )
{
QgsDebugMsg( "error finding QTextCodec for " + enc );
mCodec = QTextCodec::codecForLocale();
Q_ASSERT( mCodec );
}
}

@@ -44,7 +44,7 @@ QgsEncodingFileDialog::QgsEncodingFileDialog( QWidget * parent,
if ( encoding.isEmpty() )
{
QSettings settings;
enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
enc = settings.value( "/UI/encoding", "System" ).toString();
}

// The specified decoding is added if not existing alread, and then set current.
@@ -59,9 +59,10 @@ QgsShapeFile::QgsShapeFile( QString name, QString encoding )
geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"
<< "MULTILINESTRING" << "MULTIPOLYGON" << "GEOMETRYCOLLECTION";

codec = QTextCodec::codecForName( encoding.toLocal8Bit().data() );
codec = QTextCodec::codecForName( encoding.toLocal8Bit().constData() );
if ( !codec )
codec = QTextCodec::codecForLocale();
Q_ASSERT( codec );
}

QgsShapeFile::~QgsShapeFile()

0 comments on commit 747e497

Please sign in to comment.
You can’t perform that action at this time.