@@ -117,6 +117,19 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
117
117
118
118
currentYCoordinate += mBoxSpace ;
119
119
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
+
120
133
if ( painter )
121
134
{
122
135
painter->restore ();
@@ -129,19 +142,6 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
129
142
}
130
143
}
131
144
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
-
145
145
return size;
146
146
}
147
147
@@ -295,9 +295,11 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
295
295
{
296
296
p->setPen ( QColor ( 0 , 0 , 0 ) );
297
297
drawText ( p, currentXCoord, currentYCoord + fontAscentMillimeters ( mItemFont ) + ( realItemHeight - fontAscentMillimeters ( mItemFont ) ) / 2 , currentItem->text (), mItemFont );
298
+ currentXCoord += textWidthMillimeters ( mItemFont , currentItem->text () );
298
299
}
300
+ currentXCoord += mBoxSpace ;
299
301
300
- maxXCoord = std::max ( maxXCoord, currentXCoord + textWidthMillimeters ( mItemFont , currentItem-> text () ) + mBoxSpace );
302
+ maxXCoord = std::max ( maxXCoord, currentXCoord );
301
303
302
304
currentYCoord += realItemHeight;
303
305
}
0 commit comments