Skip to content

Commit

Permalink
Fix #11330 (Composer legend can be smaller than its content)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 21, 2014
1 parent 3546b32 commit fe9c5c4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -100,6 +100,14 @@ void QgsComposerLegend::paint( QPainter* painter, const QStyleOptionGraphicsItem

QgsLegendRenderer legendRenderer( mLegendModel2, mSettings );
legendRenderer.setLegendSize( rect().size() );

//adjust box if width or height is too small
QSizeF size = legendRenderer.minimumSize();
if ( size.height() > rect().height() )
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), size.height() ) );
if ( size.width() > rect().width() )
setSceneRect( QRectF( pos().x(), pos().y(), size.width(), rect().height() ) );

legendRenderer.drawLegend( painter );

painter->restore();
Expand All @@ -116,7 +124,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
{
QgsLegendRenderer legendRenderer( mLegendModel2, mSettings );
QSizeF size = legendRenderer.minimumSize();
if ( !painter )
if ( painter )
legendRenderer.drawLegend( painter );
return size;
}
Expand Down

2 comments on commit fe9c5c4

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonder-sk dammit... Now I've got no excuse for not fixing #11321!

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Thanks though... This fix is appreciated!)

Please sign in to comment.