Skip to content
Permalink
Browse files
[layertree] Use writePath() for embedded groups (absolute vs relative…
… path)
  • Loading branch information
wonder-sk committed May 27, 2014
1 parent 48ee84b commit 9cd70c563a3ffb520fe8d239ef2229a4e39b33b2
Showing with 21 additions and 0 deletions.
  1. +19 −0 src/core/qgsproject.cpp
  2. +2 −0 src/core/qgsproject.h
@@ -999,6 +999,24 @@ void QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup* group )
}
}

void QgsProject::updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup* group )
{
foreach ( QgsLayerTreeNode* node, group->children() )
{
if ( QgsLayerTree::isGroup( node ) )
{
if ( !node->customProperty( "embedded_project" ).toString().isEmpty() )
{
// may change from absolute path to relative path
QString newPath = writePath( node->customProperty( "embedded_project" ).toString() );
node->setCustomProperty( "embedded_project", newPath );
}
else
updateEmbeddedGroupsProjectPath( QgsLayerTree::toGroup( node ) );
}
}
}


bool QgsProject::read( QDomNode & layerNode )
{
@@ -1080,6 +1098,7 @@ bool QgsProject::write()
// write layer tree - make sure it is without embedded subgroups
QgsLayerTreeNode* clonedRoot = mRootGroup->clone();
QgsLayerTreeUtils::removeChildrenOfEmbeddedGroups( QgsLayerTree::toGroup( clonedRoot ) );
updateEmbeddedGroupsProjectPath( QgsLayerTree::toGroup( clonedRoot ) ); // convert absolute paths to relative paths if required
clonedRoot->writeXML( qgisNode );
delete clonedRoot;

@@ -357,6 +357,8 @@ class CORE_EXPORT QgsProject : public QObject

void loadEmbeddedNodes( QgsLayerTreeGroup* group );

void updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup* group );

signals:
//! emitted when project is being read
void readProject( const QDomDocument & );

0 comments on commit 9cd70c5

Please sign in to comment.