Skip to content
Permalink
Browse files

Another fix for embedded groups and drawing order. Deactivated the se…

…rver method for now as it still needs to be adapted
  • Loading branch information
mhugent committed Nov 21, 2012
1 parent 49cadd5 commit d67360621a96ea89d0065cf8822c879d85ff2597
Showing with 24 additions and 21 deletions.
  1. +8 −10 src/app/legend/qgslegend.cpp
  2. +16 −11 src/mapserver/qgsprojectparser.cpp
@@ -1182,7 +1182,7 @@ QList<DrawingOrderInfo> QgsLegend::drawingOrder()
}
else if ( lgroup )
{
if ( lgroup->isEmbedded() && !(lgroup->parent()) )
if ( lgroup->isEmbedded() && !( lgroup->parent() ) )
{
QList<QgsLegendLayer*> groupLayers = lgroup->legendLayers();
QList<QgsLegendLayer*>::const_iterator groupLayerIt = groupLayers.constBegin();
@@ -1245,36 +1245,35 @@ QList<QgsMapCanvasLayer> QgsLegend::canvasLayers()
{
layers.insertMulti( llayer->drawingOrder(), canvasLayer );
}
++nEntries;
}
else if ( lgroup )
{
if ( lgroup->isEmbedded() )
{
int groupDrawingOrder = lgroup->drawingOrder() + embeddedGroupChildren.size();
int groupDrawingOrder = lgroup->drawingOrder();
QList<QgsLegendLayer*> groupLayers = lgroup->legendLayers();
for ( int i = 0; i < groupLayers.size(); ++i )
for ( int i = groupLayers.size() - 1; i >= 0; --i )
{
QgsLegendLayer* ll = groupLayers.at( i );
if ( !ll )
if ( !ll || embeddedGroupChildren.contains( ll ) )
{
continue;
}

if ( mUpdateDrawingOrder )
{
layers.insertMulti( nEntries + embeddedGroupChildren.size(), ll->canvasLayer() );
layers.insertMulti( nEntries, ll->canvasLayer() );
}
else
{
layers.insertMulti( groupDrawingOrder + i, ll->canvasLayer() );
layers.insertMulti( groupDrawingOrder, ll->canvasLayer() );
}
embeddedGroupChildren.insert( ll );
++nEntries;
}
}
}
++it;
++nEntries;
}

return layers.values();
@@ -1315,10 +1314,9 @@ void QgsLegend::setDrawingOrder( const QList<DrawingOrderInfo>& order )
QList<QgsLegendLayer*>::iterator groupIt = groupLayers.begin();
for ( ; groupIt != groupLayers.end(); ++groupIt )
{
( *groupIt )->setDrawingOrder( i );
layers.push_back(( *groupIt )->canvasLayer() );
++i;
}
++i;
}
}
else
@@ -2255,16 +2255,16 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,

if ( elem.tagName() == "legendlayer" )
{
if ( useDrawingOrder || embeddedOrder != -1 )
if ( useDrawingOrder || embeddedOrder != -1 )
{
int order = -1;
if( embedded )
if ( embedded )
{
order = embeddedOrder;
order = embeddedOrder;
}
else
{
order = drawingOrder( elem );
order = drawingOrder( elem );
}
orderedLayerList.insertMulti( order + nEmbeddedGroupLayers, elem.attribute( "name" ) );
}
@@ -2316,6 +2316,10 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,

void QgsProjectParser::addDrawingOrder( QDomElement& parentElem, QDomDocument& doc ) const
{

return; //soon...

#if 0
if ( !mXMLDoc )
{
return;
@@ -2350,6 +2354,7 @@ void QgsProjectParser::addDrawingOrder( QDomElement& parentElem, QDomDocument& d
QDomText drawingOrderText = doc.createTextNode( layerList.join( "," ) );
layerDrawingOrderElem.appendChild( drawingOrderText );
parentElem.appendChild( layerDrawingOrderElem );
#endif //0
}

void QgsProjectParser::projectLayerMap( QMap<QString, QgsMapLayer*>& layerMap ) const
@@ -2700,13 +2705,13 @@ void QgsProjectParser::drawAnnotationRectangle( QPainter* p, const QDomElement&

int QgsProjectParser::drawingOrder( const QDomElement& elem )
{
QDomElement e = elem;
while( !e.isNull() )
QDomElement e = elem;
while ( !e.isNull() )
{
if ( e.hasAttribute( "drawingOrder" ) )
{
if( e.hasAttribute( "drawingOrder" ) )
{
return e.attribute( "drawingOrder" ).toInt();
}
e = e.parentNode().toElement();
return e.attribute( "drawingOrder" ).toInt();
}
e = e.parentNode().toElement();
}
}

0 comments on commit d673606

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