Skip to content

Commit

Permalink
Also load .qgz files
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 11, 2018
1 parent d1fa150 commit bf2542e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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 ),
Expand Down
5 changes: 3 additions & 2 deletions src/server/qgsserver.cpp
Expand Up @@ -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++ )
{
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 6 additions & 5 deletions tests/bench/main.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bf2542e

Please sign in to comment.