Skip to content
Permalink
Browse files

[composer] Update atlas filename expression when the expression actua…

…lly changes
  • Loading branch information
nyalldawson committed Jan 1, 2014
1 parent 5a91aa7 commit 8b60d8f4ca43a919d42b24cad0311d4be6cc8004
Showing with 30 additions and 16 deletions.
  1. +26 −15 src/core/composer/qgsatlascomposition.cpp
  2. +4 −1 src/core/composer/qgsatlascomposition.h
@@ -115,21 +115,7 @@ int QgsAtlasComposition::updateFeatures()
mTransform.setSourceCrs( coverage_crs );
mTransform.setDestCRS( destination_crs );

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

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( tr( "Filename parsing error: %1" ).arg( mFilenameExpr->parserErrorString() ).toLocal8Bit().data() );
}

// prepare the filename expression
mFilenameExpr->prepare( fields );
}
updateFilenameExpression();

// select all features with all attributes
QgsFeatureIterator fit = mCoverageLayer->getFeatures();
@@ -539,4 +525,29 @@ void QgsAtlasComposition::setHideCoverage( bool hide )

}

void QgsAtlasComposition::setFilenamePattern( const QString& pattern )
{
mFilenamePattern = pattern;
updateFilenameExpression();
}

void QgsAtlasComposition::updateFilenameExpression()
{
const QgsFields& fields = mCoverageLayer->pendingFields();

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( tr( "Filename parsing error: %1" ).arg( mFilenameExpr->parserErrorString() ).toLocal8Bit().data() );
}

// prepare the filename expression
mFilenameExpr->prepare( fields );
}
}


@@ -58,7 +58,7 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
void setMargin( float margin ) { mMargin = margin; }

QString filenamePattern() const { return mFilenamePattern; }
void setFilenamePattern( const QString& pattern ) { mFilenamePattern = pattern; }
void setFilenamePattern( const QString& pattern );

QgsVectorLayer* coverageLayer() const { return mCoverageLayer; }
void setCoverageLayer( QgsVectorLayer* lmap );
@@ -121,6 +121,9 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
void statusMsgChanged( QString message );

private:
/**Updates the filename expression*/
void updateFilenameExpression();

QgsComposition* mComposition;

bool mEnabled;

0 comments on commit 8b60d8f

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