Load embedded group from qgz project

This commit is contained in:
Blottiere Paul 2019-11-06 01:04:02 +01:00
parent 9a9778af41
commit 35c2a9a6f3

View File

@ -2563,8 +2563,16 @@ bool QgsProject::createEmbeddedLayer( const QString &layerId, const QString &pro
QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers, QgsProject::ReadFlags flags ) QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers, QgsProject::ReadFlags flags )
{ {
QString qgsProjectFile = projectFilePath;
QgsProjectArchive archive;
if ( projectFilePath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) )
{
archive.unzip( projectFilePath );
qgsProjectFile = archive.projectFile();
}
// open project file, get layer ids in group, add the layers // open project file, get layer ids in group, add the layers
QFile projectFile( projectFilePath ); QFile projectFile( qgsProjectFile );
if ( !projectFile.open( QIODevice::ReadOnly ) ) if ( !projectFile.open( QIODevice::ReadOnly ) )
{ {
return nullptr; return nullptr;