Skip to content
Permalink
Browse files

More drawing order related changes...

  • Loading branch information
mhugent committed Nov 20, 2012
1 parent 32e981d commit 49cadd5fcda30b754cf80d889563801d3fae285f
Showing with 33 additions and 7 deletions.
  1. +1 −1 src/app/legend/qgslegend.cpp
  2. +28 −5 src/mapserver/qgsprojectparser.cpp
  3. +4 −1 src/mapserver/qgsprojectparser.h
@@ -1182,7 +1182,7 @@ QList<DrawingOrderInfo> QgsLegend::drawingOrder()
}
else if ( lgroup )
{
if ( lgroup->isEmbedded() )
if ( lgroup->isEmbedded() && !(lgroup->parent()) )
{
QList<QgsLegendLayer*> groupLayers = lgroup->legendLayers();
QList<QgsLegendLayer*>::const_iterator groupLayerIt = groupLayers.constBegin();
@@ -2246,7 +2246,7 @@ QgsRectangle QgsProjectParser::layerBoundingBoxInProjectCRS( const QDomElement&
}

void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder, QMap<int, QString>& orderedLayerList, int& nEmbeddedGroupLayers,
bool embedded ) const
bool embedded, int embeddedOrder ) const
{
if ( elem.isNull() )
{
@@ -2255,9 +2255,17 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,

if ( elem.tagName() == "legendlayer" )
{
if ( useDrawingOrder )
if ( useDrawingOrder || embeddedOrder != -1 )
{
int order = elem.attribute( "drawingOrder", "-1" ).toInt();
int order = -1;
if( embedded )
{
order = embeddedOrder;
}
else
{
order = drawingOrder( elem );
}
orderedLayerList.insertMulti( order + nEmbeddedGroupLayers, elem.attribute( "name" ) );
}
else
@@ -2278,6 +2286,7 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,
//load layers / elements from project file
QString project = convertToAbsolutePath( elem.attribute( "project" ) );
QString embeddedGroupName = elem.attribute( "name" );
int embedDrawingOrder = elem.attribute( "drawingOrder", "-1" ).toInt();
QgsProjectParser* p = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
if ( p )
{
@@ -2286,7 +2295,7 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,
{
if ( groupElem.attribute( "name" ) == embeddedGroupName )
{
addDrawingOrder( groupElem, false, orderedLayerList, nEmbeddedGroupLayers, true );
addDrawingOrder( groupElem, false, orderedLayerList, nEmbeddedGroupLayers, true, embedDrawingOrder );
break;
}
}
@@ -2298,7 +2307,8 @@ void QgsProjectParser::addDrawingOrder( QDomElement elem, bool useDrawingOrder,
QDomElement childElem;
for ( int i = 0; i < childList.size(); ++i )
{
addDrawingOrder( childList.at( i ).toElement(), useDrawingOrder, orderedLayerList, nEmbeddedGroupLayers, false );
addDrawingOrder( childList.at( i ).toElement(), useDrawingOrder, orderedLayerList, nEmbeddedGroupLayers,
embedded, embeddedOrder );
}
}
}
@@ -2687,3 +2697,16 @@ void QgsProjectParser::drawAnnotationRectangle( QPainter* p, const QDomElement&

p->drawRect( QRectF( xPos, yPos, itemWidth, itemHeight ) );
}

int QgsProjectParser::drawingOrder( const QDomElement& elem )
{
QDomElement e = elem;
while( !e.isNull() )
{
if( e.hasAttribute( "drawingOrder" ) )
{
return e.attribute( "drawingOrder" ).toInt();
}
e = e.parentNode().toElement();
}
}
@@ -209,7 +209,7 @@ class QgsProjectParser: public QgsConfigParser
void addDrawingOrder( QDomElement& parentElem, QDomDocument& doc ) const;
/**Adds drawing order info from layer element or group element (recursive)*/
void addDrawingOrder( QDomElement elem, bool useDrawingOrder, QMap<int, QString>& orderedLayerList, int& nEmbeddedGroupLayers,
bool embedded = false ) const;
bool embedded = false, int embeddedOrder = -1 ) const;
/**Returns project layers by id*/
void projectLayerMap( QMap<QString, QgsMapLayer*>& layerMap ) const;

@@ -245,6 +245,9 @@ class QgsProjectParser: public QgsConfigParser
@param itemWidth item width in pixels in the QGIS project (screen pixels)
@param itemHeight item height in pixels in the QGIS project (screen pixels)*/
static void drawAnnotationRectangle( QPainter* p, const QDomElement& elem, double scaleFactor, double xPos, double yPos, int itemWidth, int itemHeight );

/**Returns the drawing order attribute of the element or of one parent. Returns -1 if the element and all the parents don't have drawing order attribute*/
static int drawingOrder( const QDomElement& elem );
};

#endif // QGSPROJECTPARSER_H

0 comments on commit 49cadd5

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