[composer] Default to setting a map for new legend items

It's friendlier for users, who may not realise they need to set
a map before they can filter legends.
This commit is contained in:
Nyall Dawson 2014-10-21 20:47:55 +11:00
parent 2b36dea1f7
commit 58c34ae361

View File

@ -845,6 +845,11 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
else
{
QgsComposerLegend* newLegend = new QgsComposerLegend( composition() );
QList<const QgsComposerMap*> mapItemList = composition()->composerMapItems();
if ( mapItemList.size() > 0 )
{
newLegend->setComposerMap( mapItemList.at( 0 ) );
}
newLegend->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) );
composition()->addComposerLegend( newLegend );
newLegend->updateLegend();