Skip to content
Permalink
Browse files
Re-enable embedded groups
  • Loading branch information
mhugent committed Apr 5, 2014
1 parent 3df34a8 commit cd01a87fb721891db99ddab8e476ec9884f7c6b5
@@ -17,6 +17,7 @@

#include "qgsserverprojectparser.h"
#include "qgsapplication.h"
#include "qgsconfigcache.h"
#include "qgsconfigparserutils.h"
#include "qgscrscache.h"
#include "qgsdatasourceuri.h"
@@ -111,6 +111,10 @@ class QgsServerProjectParser

void addValueRelationLayersForElement( const QDomElement& layerElem, bool useCache = true ) const;

/**Returns the text of the <id> element for a layer element
@return id or a null string in case of error*/
QString layerId( const QDomElement& layerElem ) const;

private:

/**Content of project file*/
@@ -136,10 +140,6 @@ class QgsServerProjectParser

QgsServerProjectParser(); //forbidden

/**Returns the text of the <id> element for a layer element
@return id or a null string in case of error*/
QString layerId( const QDomElement& layerElem ) const;

/**Returns a complete string set with all the restricted layer names (layers/groups that are not to be published)*/
QSet<QString> findRestrictedLayers() const;

@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgswmsprojectparser.h"
#include "qgsconfigcache.h"
#include "qgsconfigparserutils.h"
#include "qgslogger.h"
#include "qgsmaplayer.h"
@@ -179,32 +180,32 @@ QList<QgsMapLayer*> QgsWMSProjectParser::mapLayerFromStyle( const QString& lName
{
if ( legendIt->attribute( "embedded" ) == "1" )
{
#if 0 //todo: fixme
QString project = convertToAbsolutePath( legendIt->attribute( "project" ) );
QgsProjectParser* p = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
QString project = mProjectParser.convertToAbsolutePath( legendIt->attribute( "project" ) );
QgsWMSProjectParser* p = dynamic_cast<QgsWMSProjectParser*>( QgsConfigCache::instance()->wmsConfiguration( project ) );
if ( p )
{
const QHash< QString, QDomElement >& pLayerByName = p->mProjectLayerElementsByName;
QgsServerProjectParser& pp = p->mProjectParser;
const QHash< QString, QDomElement >& pLayerByName = pp.projectLayerElementsByName();
QHash< QString, QDomElement >::const_iterator pLayerNameIt = pLayerByName.find( lName );
if ( pLayerNameIt != pLayerByName.constEnd() )
{
p->addJoinLayersForElement( pLayerNameIt.value(), useCache );
p->addValueRelationLayersForElement( pLayerNameIt.value(), useCache );
layerList.push_back( p->createLayerFromElement( pLayerNameIt.value(), useCache ) );
pp.addJoinLayersForElement( pLayerNameIt.value(), useCache );
pp.addValueRelationLayersForElement( pLayerNameIt.value(), useCache );
layerList.push_back( pp.createLayerFromElement( pLayerNameIt.value(), useCache ) );
break;
}

QList<QDomElement>::const_iterator pLegendGroupIt = p->mLegendGroupElements.constBegin();
for ( ; pLegendGroupIt != p->mLegendGroupElements.constEnd(); ++pLegendGroupIt )
const QList<QDomElement>& legendGroupElements = pp.legendGroupElements();
QList<QDomElement>::const_iterator pLegendGroupIt = legendGroupElements.constBegin();
for ( ; pLegendGroupIt != legendGroupElements.constEnd(); ++pLegendGroupIt )
{
if ( pLegendGroupIt->attribute( "name" ) == lName )
{
p->addLayersFromGroup( *pLegendGroupIt, layerList, useCache );
pp.addLayersFromGroup( *pLegendGroupIt, layerList, useCache );
break;
}
}
}
#endif //0
}
}

@@ -666,15 +667,13 @@ void QgsWMSProjectParser::addDrawingOrder( QDomElement groupElem, bool useDrawin
}

int embedDrawingOrder = groupElem.attribute( "drawingOrder", "-1" ).toInt();
//todo: fixme
QgsWMSProjectParser* p = 0; //dynamic_cast<QgsWMSProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project, QgsConfigCache::WMS ) );
QgsWMSProjectParser* p = dynamic_cast<QgsWMSProjectParser*>( QgsConfigCache::instance()->wmsConfiguration( project ) );
if ( !p )
{
return;
}

//todo: fixme
QDomDocument* doc = 0; //p->mXMLDoc;
const QDomDocument* doc = p->mProjectParser.xmlDocument();
if ( !doc )
{
return;
@@ -785,16 +784,15 @@ void QgsWMSProjectParser::addLayers( QDomDocument &doc,

if ( currentChildElem.attribute( "embedded" ) == "1" )
{
//todo: fixme
#if 0
//add layers from other project files and embed into this group
QString project = convertToAbsolutePath( currentChildElem.attribute( "project" ) );
QString project = mProjectParser.convertToAbsolutePath( currentChildElem.attribute( "project" ) );
QgsDebugMsg( QString( "Project path: %1" ).arg( project ) );
QString embeddedGroupName = currentChildElem.attribute( "name" );
QgsProjectParser* p = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
QgsWMSProjectParser* p = dynamic_cast<QgsWMSProjectParser*>( QgsConfigCache::instance()->wmsConfiguration( project ) );
if ( p )
{
QList<QDomElement> embeddedGroupElements = p->mLegendGroupElements;
QgsServerProjectParser& pp = p->mProjectParser;
const QList<QDomElement>& embeddedGroupElements = pp.legendGroupElements();
QStringList pIdDisabled = p->identifyDisabledLayers();

QDomElement embeddedGroupElem;
@@ -808,16 +806,15 @@ void QgsWMSProjectParser::addLayers( QDomDocument &doc,
}

QMap<QString, QgsMapLayer *> pLayerMap;
QList<QDomElement> embeddedProjectLayerElements = p->mProjectLayerElements;
const QList<QDomElement>& embeddedProjectLayerElements = pp.projectLayerElements();
foreach ( const QDomElement &elem, embeddedProjectLayerElements )
{
p->addJoinLayersForElement( elem );
pLayerMap.insert( layerId( elem ), p->createLayerFromElement( elem ) );
pp.addJoinLayersForElement( elem );
pLayerMap.insert( pp.layerId( elem ), pp.createLayerFromElement( elem ) );
}

p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled, version, fullProjectSettings );
}
#endif //0
}
else //normal (not embedded) legend group
{
@@ -1096,15 +1093,15 @@ void QgsWMSProjectParser::addOWSLayers( QDomDocument &doc,

if ( currentChildElem.attribute( "embedded" ) == "1" )
{
#if 0 //todo: fixme
//add layers from other project files and embed into this group
QString project = mProjectParser.convertToAbsolutePath( currentChildElem.attribute( "project" ) );
QgsDebugMsg( QString( "Project path: %1" ).arg( project ) );
QString embeddedGroupName = currentChildElem.attribute( "name" );
QgsProjectParser* p = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
QgsWMSProjectParser* p = dynamic_cast<QgsWMSProjectParser*>( QgsConfigCache::instance()->wmsConfiguration( project ) );
if ( p )
{
QList<QDomElement> embeddedGroupElements = p->mLegendGroupElements;
QgsServerProjectParser& pp = p->mProjectParser;
const QList<QDomElement>& embeddedGroupElements = pp.legendGroupElements();
QStringList pIdDisabled = p->identifyDisabledLayers();

QDomElement embeddedGroupElem;
@@ -1118,16 +1115,15 @@ void QgsWMSProjectParser::addOWSLayers( QDomDocument &doc,
}

QMap<QString, QgsMapLayer *> pLayerMap;
QList<QDomElement> embeddedProjectLayerElements = p->mProjectLayerElements;
const QList<QDomElement>& embeddedProjectLayerElements = pp.projectLayerElements();
foreach ( const QDomElement &elem, embeddedProjectLayerElements )
{
p->addJoinLayersForElement( elem );
pLayerMap.insert( layerId( elem ), p->createLayerFromElement( elem ) );
pp.addJoinLayersForElement( elem );
pLayerMap.insert( pp.layerId( elem ), pp.createLayerFromElement( elem ) );
}

p->addOWSLayers( doc, parentElem, embeddedGroupElem, pLayerMap, pIdDisabled, strHref, combinedBBox, group );
}
#endif //0 //todo: fixme
}
else //normal (not embedded) legend group
{

0 comments on commit cd01a87

Please sign in to comment.