Skip to content

Commit d9d7048

Browse files
author
mhugent
committed
Fix minimum size of composer legend
git-svn-id: http://svn.osgeo.org/qgis/trunk@13493 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 62bbe6b commit d9d7048

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/core/composer/qgscomposerlegend.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
117117

118118
currentYCoordinate += mBoxSpace;
119119

120+
size.setHeight( currentYCoordinate );
121+
size.setWidth( maxXCoord );
122+
123+
//adjust box if width or height is to small
124+
if ( painter && currentYCoordinate > rect().height() )
125+
{
126+
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
127+
}
128+
if ( painter && maxXCoord > rect().width() )
129+
{
130+
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
131+
}
132+
120133
if ( painter )
121134
{
122135
painter->restore();
@@ -129,19 +142,6 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
129142
}
130143
}
131144

132-
size.setHeight( currentYCoordinate );
133-
size.setWidth( maxXCoord );
134-
135-
//adjust box if width or height is to small
136-
if ( painter && currentYCoordinate > rect().width() )
137-
{
138-
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
139-
}
140-
if ( painter && maxXCoord > rect().height() )
141-
{
142-
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
143-
}
144-
145145
return size;
146146
}
147147

@@ -295,9 +295,11 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
295295
{
296296
p->setPen( QColor( 0, 0, 0 ) );
297297
drawText( p, currentXCoord, currentYCoord + fontAscentMillimeters( mItemFont ) + ( realItemHeight - fontAscentMillimeters( mItemFont ) ) / 2, currentItem->text(), mItemFont );
298+
currentXCoord += textWidthMillimeters( mItemFont, currentItem->text() );
298299
}
300+
currentXCoord += mBoxSpace;
299301

300-
maxXCoord = std::max( maxXCoord, currentXCoord + textWidthMillimeters( mItemFont, currentItem->text() ) + mBoxSpace );
302+
maxXCoord = std::max( maxXCoord, currentXCoord );
301303

302304
currentYCoord += realItemHeight;
303305
}

0 commit comments

Comments
 (0)