Skip to content
Permalink
Browse files

Fix layer group dialog for qgz file, fixing wms exclude layer feature

  • Loading branch information
tcoupin committed Jul 23, 2018
1 parent 5bca317 commit 80607369ba8f0b021525d3ef382ce102543e1774
Showing with 35 additions and 4 deletions.
  1. +35 −4 src/app/qgsprojectlayergroupdialog.cpp
@@ -20,6 +20,7 @@
#include "qgslayertreemodel.h"
#include "qgslayertreeutils.h"
#include "qgssettings.h"
#include "qgsziputils.h"

#include <QDomDocument>
#include <QFileDialog>
@@ -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() )
@@ -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();

0 comments on commit 8060736

Please sign in to comment.
You can’t perform that action at this time.