From bf2542e8eafeccdaab3c6e223a0ed6c892ccf3b1 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Mon, 11 Jun 2018 14:45:40 +0200 Subject: [PATCH] Also load .qgz files --- src/app/qgisapp.cpp | 3 ++- src/server/qgsserver.cpp | 5 +++-- tests/bench/main.cpp | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 2e8a6352dac..6888d28e1a0 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -5335,7 +5335,8 @@ void QgisApp::fileOpenAfterLaunch() return; } - if ( !projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) ) + if ( !projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) && + !projPath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) { messageBar()->pushMessage( autoOpenMsgTitle, tr( "Not valid project file: %1" ).arg( projPath ), diff --git a/src/server/qgsserver.cpp b/src/server/qgsserver.cpp index e7287fc5e69..b2da8135666 100644 --- a/src/server/qgsserver.cpp +++ b/src/server/qgsserver.cpp @@ -107,7 +107,8 @@ QFileInfo QgsServer::defaultProjectFile() QDir currentDir; fprintf( FCGI_stderr, "current directory: %s\n", currentDir.absolutePath().toUtf8().constData() ); QStringList nameFilterList; - nameFilterList << QStringLiteral( "*.qgs" ); + nameFilterList << QStringLiteral( "*.qgs" ) + << QStringLiteral( "*.qgz" ); QFileInfoList projectFiles = currentDir.entryInfoList( nameFilterList, QDir::Files, QDir::Name ); for ( int x = 0; x < projectFiles.size(); x++ ) { @@ -211,7 +212,7 @@ bool QgsServer::init() QgsApplication::authManager()->init( QgsApplication::pluginPath(), QgsApplication::qgisAuthDatabaseFilePath() ); QString defaultConfigFilePath; - QFileInfo projectFileInfo = defaultProjectFile(); //try to find a .qgs file in the server directory + QFileInfo projectFileInfo = defaultProjectFile(); //try to find a .qgs/.qgz file in the server directory if ( projectFileInfo.exists() ) { defaultConfigFilePath = projectFileInfo.absoluteFilePath(); diff --git a/tests/bench/main.cpp b/tests/bench/main.cpp index a07caac4f45..c765ad521d2 100644 --- a/tests/bench/main.cpp +++ b/tests/bench/main.cpp @@ -86,7 +86,7 @@ void usage( std::string const &appName ) << "\t[--help]\t\tthis text\n\n" << " FILES:\n" << " Files specified on the command line can include rasters,\n" - << " vectors, and QGIS project files (.qgs): \n" + << " vectors, and QGIS project files (.qgs or .qgz): \n" << " 1. Rasters - Supported formats include GeoTiff, DEM \n" << " and others supported by GDAL\n" << " 2. Vectors - Supported formats include ESRI Shapefiles\n" @@ -471,11 +471,11 @@ int main( int argc, char *argv[] ) ///////////////////////////////////////////////////////////////////// if ( myProjectFileName.isEmpty() ) { - // check for a .qgs + // check for a .qgs or .qgz for ( int i = 0; i < argc; i++ ) { QString arg = QDir::toNativeSeparators( QFileInfo( QFile::decodeName( argv[i] ) ).absoluteFilePath() ); - if ( arg.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) ) + if ( arg.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) || arg.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) { myProjectFileName = arg; break; @@ -525,8 +525,9 @@ int main( int argc, char *argv[] ) { QgsDebugMsg( QString( "Trying to load file : %1" ).arg( ( *myIterator ) ) ); QString myLayerName = *myIterator; - // don't load anything with a .qgs extension - these are project files - if ( !myLayerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) ) + // don't load anything with a .qgs or .qgz extension - these are project files + if ( !myLayerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) && + !myLayerName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) { fprintf( stderr, "Data files not yet supported\n" ); return 1;