Skip to content
Permalink
Browse files
[Atlas] Add i18n to error messages
  • Loading branch information
Hugo Mercier committed Feb 6, 2013
1 parent 198a699 commit 4e39c3deb082a3015cb813b7b4d5a02b2ef380a7
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/core/composer/qgsatlascomposition.cpp
@@ -95,14 +95,14 @@ void QgsAtlasComposition::beginRender()

const QgsFields& fields = mCoverageLayer->pendingFields();

if ( mFilenamePattern.size() > 0 )
if ( !mSingleFile && mFilenamePattern.size() > 0 )
{
mFilenameExpr = std::auto_ptr<QgsExpression>( new QgsExpression( mFilenamePattern ) );
// expression used to evaluate each filename
// test for evaluation errors
if ( mFilenameExpr->hasParserError() )
{
throw std::runtime_error( "Filename parsing error: " + mFilenameExpr->parserErrorString().toStdString() );
throw std::runtime_error( tr("Filename parsing error: %1").arg(mFilenameExpr->parserErrorString()).toLocal8Bit().data() );
}

// prepare the filename expression
@@ -117,7 +117,7 @@ void QgsAtlasComposition::beginRender()
filterExpression = std::auto_ptr<QgsExpression>(new QgsExpression( mFeatureFilter ));
if ( filterExpression->hasParserError() )
{
throw std::runtime_error( "Feature filter parser error: " + filterExpression->parserErrorString().toStdString() );
throw std::runtime_error( tr("Feature filter parser error: %1").arg( filterExpression->parserErrorString() ).toLocal8Bit().data() );
}
}

@@ -132,7 +132,7 @@ void QgsAtlasComposition::beginRender()
QVariant result = filterExpression->evaluate( &feat, mCoverageLayer->pendingFields() );
if ( filterExpression->hasEvalError() )
{
throw std::runtime_error( "Feature filter eval error: " + filterExpression->evalErrorString().toStdString() );
throw std::runtime_error( tr("Feature filter eval error: %1").arg( filterExpression->evalErrorString()).toLocal8Bit().data() );
}

// skip this feature if the filter evaluation if false
@@ -215,10 +215,14 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
// retrieve the next feature, based on its id
mCoverageLayer->getFeatures( QgsFeatureRequest().setFilterFid( mFeatureIds[ featureI ] ) ).nextFeature( mCurrentFeature );

if ( mFilenamePattern.size() > 0 )
if ( !mSingleFile && mFilenamePattern.size() > 0 )
{
QgsExpression::setSpecialColumn( "$feature", QVariant(( int )featureI + 1 ) );
QVariant filenameRes = mFilenameExpr->evaluate( &mCurrentFeature );
if ( mFilenameExpr->hasEvalError() )
{
throw std::runtime_error( tr("Filename eval error: %1").arg( mFilenameExpr->evalErrorString() ).toLocal8Bit().data() );
}

mCurrentFilename = filenameRes.toString();
}

0 comments on commit 4e39c3d

Please sign in to comment.