Skip to content

Commit

Permalink
Added code to fix bug #2755 also for Qt<4.6
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13658 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 5, 2010
1 parent e8fbe55 commit 3f3efa0
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,9 @@ void QgsComposerMap::drawCanvasItems( QPainter* painter, const QStyleOptionGraph
{
return;
}

QGraphicsItem* currentItem = 0;

#if QT_VERSION >= 0x40600 //Qt 4.6 provides the items in visibility order
for ( int i = itemList.size() - 1; i >= 0; --i )
{
currentItem = itemList.at( i );
Expand All @@ -1427,6 +1428,42 @@ void QgsComposerMap::drawCanvasItems( QPainter* painter, const QStyleOptionGraph
}
drawCanvasItem( currentItem, painter, itemStyle );
}
#else //Qt <4.6 provides the items in random order
QMultiMap<int, QGraphicsItem*> topLevelItems;
QMultiMap<QGraphicsItem*, QGraphicsItem*> childItems; //QMultiMap<parentItem, childItem>

for ( int i = 0; i < itemList.size(); ++i )
{
currentItem = itemList.at( i );
//don't draw mapcanvasmap (has z value -10)
if ( !currentItem || currentItem->zValue() == -10 )
{
continue;
}
if ( currentItem->parentItem() )
{
childItems.insert( currentItem->parentItem(), currentItem );
}
else
{
topLevelItems.insert( currentItem->zValue(), currentItem );
}
}

QMultiMap<int, QGraphicsItem*>::iterator topLevelIt = topLevelItems.begin();
for ( ; topLevelIt != topLevelItems.end(); ++topLevelIt )
{
drawCanvasItem( topLevelIt.value(), painter, itemStyle );
//Draw children. They probably should be sorted according to z-order, but we don't do it because this code is only
//there for backward compatibility. And currently, having several embedded children is not used in QGIS
QMap<QGraphicsItem*, QGraphicsItem*>::iterator childIt = childItems.find( topLevelIt.value() );
while ( childIt != childItems.end() && childIt.key() == topLevelIt.value() )
{
drawCanvasItem( childIt.value(), painter, itemStyle );
++childIt;
}
}
#endif
}

void QgsComposerMap::drawCanvasItem( QGraphicsItem* item, QPainter* painter, const QStyleOptionGraphicsItem* itemStyle )
Expand Down

0 comments on commit 3f3efa0

Please sign in to comment.