Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix layer group dialog for qgz file, fixing wms exclude layer feature
  • Loading branch information
tcoupin committed Jul 23, 2018
1 parent 5bca317 commit 8060736
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/app/qgsprojectlayergroupdialog.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgslayertreemodel.h"
#include "qgslayertreeutils.h"
#include "qgssettings.h"
#include "qgsziputils.h"

#include <QDomDocument>
#include <QFileDialog>
Expand Down Expand Up @@ -54,7 +55,7 @@ QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget *parent, const Q
QgsSettings settings;

mProjectFileWidget->setStorageMode( QgsFileWidget::GetFile );
mProjectFileWidget->setFilter( tr( "QGIS files" ) + QStringLiteral( " (*.qgs *.QGS)" ) );
mProjectFileWidget->setFilter( tr( "QGIS files" ) + QStringLiteral( " (*.qgs *.QGS *.qgz *.QGZ)" ) );
mProjectFileWidget->setDialogTitle( tr( "Select Project File" ) );
mProjectFileWidget->setDefaultRoot( settings.value( QStringLiteral( "/qgis/last_embedded_project_path" ), QDir::homePath() ).toString() );
if ( !projectFile.isEmpty() )
Expand Down Expand Up @@ -168,10 +169,40 @@ void QgsProjectLayerGroupDialog::changeProjectFile()
}

QDomDocument projectDom;
if ( !projectDom.setContent( &projectFile ) )
{
return;
if ( QgsZipUtils::isZipFile( mProjectFileWidget->filePath() ) ){
QgsProjectArchive archive;

// unzip the archive
if ( !archive.unzip( mProjectFileWidget->filePath() ) )
{
return;
}

// test if zip provides a .qgs file
if ( archive.projectFile().isEmpty() )
{
return;
}

projectFile.setFileName(archive.projectFile());
if ( !projectFile.exists() )
{
return;
}

if ( !projectDom.setContent( &projectFile ) )
{
return;
}
} else {
if ( !projectDom.setContent( &projectFile ) )
{
return;
}
}




mRootGroup->removeAllChildren();

Expand Down

0 comments on commit 8060736

Please sign in to comment.