Skip to content

Commit

Permalink
Open exported atlas PDF in non-single file mode when only one feature…
Browse files Browse the repository at this point in the history
… exported
  • Loading branch information
nirvn committed Jul 6, 2023
1 parent 5532002 commit 836b1e3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,16 +1293,27 @@ bool QgisMobileapp::printAtlasFeatures( const QString &layoutName, const QList<l

layoutToPrint->atlas()->setFilterExpression( QStringLiteral( "$id IN (%1)" ).arg( ids.join( ',' ) ), error );
layoutToPrint->atlas()->setFilterFeatures( true );
layoutToPrint->atlas()->updateFeatures();

const QString destination = mProject->homePath() + '/' + layoutToPrint->name() + '-' + QDateTime::currentDateTime().toString( QStringLiteral( "yyyyMMdd_hhmmss" ) ) + QStringLiteral( ".pdf" );
QString destination;
const bool destinationSingleFile = layoutToPrint->customProperty( QStringLiteral( "singleFile" ), true ).toBool();
if ( !destinationSingleFile && ids.size() == 1 )
{
layoutToPrint->atlas()->first();
destination = mProject->homePath() + '/' + layoutToPrint->atlas()->currentFilename() + QStringLiteral( ".pdf" );
}
else
{
destination = mProject->homePath() + '/' + layoutToPrint->name() + '-' + QDateTime::currentDateTime().toString( QStringLiteral( "yyyyMMdd_hhmmss" ) ) + QStringLiteral( ".pdf" );
}
const bool success = printAtlas( layoutToPrint, destination );

layoutToPrint->atlas()->setFilterExpression( priorFilterExpression, error );
layoutToPrint->atlas()->setFilterFeatures( priorFilterFeatures );

if ( success )
{
if ( layoutToPrint->customProperty( QStringLiteral( "singleFile" ), true ).toBool() )
if ( destinationSingleFile || ids.size() == 1 )
{
PlatformUtilities::instance()->open( destination );
}
Expand Down

0 comments on commit 836b1e3

Please sign in to comment.