Skip to content

Commit

Permalink
Another fix for embedded groups and drawing order. Deactivated the se…
Browse files Browse the repository at this point in the history
…rver method for now as it still needs to be adapted
  • Loading branch information
mhugent committed Nov 21, 2012
1 parent 49cadd5 commit d673606
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
18 changes: 8 additions & 10 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
27 changes: 16 additions & 11 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -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" ) );
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.