@@ -405,6 +405,40 @@ QList<QgsMapLayer*> QgsProjectParser::mapLayerFromStyle( const QString& lName, c
405405 }
406406 }
407407
408+ // Still not found. Probably it is a layer or a subgroup in an embedded group
409+ // go through all groups
410+ // check if they are embedded
411+ // if yes, request leaf layers and groups from project parser
412+ QList<QDomElement>::const_iterator legendIt = mLegendGroupElements .constBegin ();
413+ for ( ; legendIt != mLegendGroupElements .constEnd (); ++legendIt )
414+ {
415+ if ( legendIt->attribute ( " embedded" ) == " 1" )
416+ {
417+ QString project = convertToAbsolutePath ( legendIt->attribute ( " project" ) );
418+ QgsProjectParser* p = dynamic_cast <QgsProjectParser*>( QgsConfigCache::instance ()->searchConfiguration ( project ) );
419+ if ( p )
420+ {
421+ const QHash< QString, QDomElement >& pLayerByName = p->mProjectLayerElementsByName ;
422+ QHash< QString, QDomElement >::const_iterator pLayerNameIt = pLayerByName.find ( lName );
423+ if ( pLayerNameIt != pLayerByName.constEnd () )
424+ {
425+ layerList.push_back ( p->createLayerFromElement ( pLayerNameIt.value (), useCache ) );
426+ break ;
427+ }
428+
429+ QList<QDomElement>::const_iterator pLegendGroupIt = p->mLegendGroupElements .constBegin ();
430+ for ( ; pLegendGroupIt != p->mLegendGroupElements .constEnd (); ++pLegendGroupIt )
431+ {
432+ if ( pLegendGroupIt->attribute ( " name" ) == lName )
433+ {
434+ p->addLayersFromGroup ( *pLegendGroupIt, layerList, useCache );
435+ break ;
436+ }
437+ }
438+ }
439+ }
440+ }
441+
408442 return layerList;
409443}
410444
@@ -416,7 +450,7 @@ void QgsProjectParser::addLayersFromGroup( const QDomElement& legendGroupElem, Q
416450 // get group elements from project parser, find the group
417451 // iterate over layers and add them (embedding in embedded groups does not work)
418452 QString groupName = legendGroupElem.attribute ( " name" );
419- QString project = legendGroupElem.attribute ( " project" );
453+ QString project = convertToAbsolutePath ( legendGroupElem.attribute ( " project" ) );
420454 QgsProjectParser* p = dynamic_cast <QgsProjectParser*>( QgsConfigCache::instance ()->searchConfiguration ( project ) );
421455 if ( !p )
422456 {
0 commit comments