From 836b1e390174c27a88f574e125cc72981c49adcc Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 6 Jul 2023 12:24:08 +0700 Subject: [PATCH] Open exported atlas PDF in non-single file mode when only one feature exported --- src/core/qgismobileapp.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/qgismobileapp.cpp b/src/core/qgismobileapp.cpp index ab8aa7cf12..99bf92d15d 100644 --- a/src/core/qgismobileapp.cpp +++ b/src/core/qgismobileapp.cpp @@ -1293,8 +1293,19 @@ bool QgisMobileapp::printAtlasFeatures( const QString &layoutName, const QListatlas()->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 ); @@ -1302,7 +1313,7 @@ bool QgisMobileapp::printAtlasFeatures( const QString &layoutName, const QListcustomProperty( QStringLiteral( "singleFile" ), true ).toBool() ) + if ( destinationSingleFile || ids.size() == 1 ) { PlatformUtilities::instance()->open( destination ); }