@@ -243,7 +243,9 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
243
243
}
244
244
245
245
// standerd item height
246
- double itemHeight = qMax ( mSymbolHeight , fontAscentMillimeters ( mItemFont ) );
246
+
247
+ double textHeight = fontHeightCharacterMM ( mItemFont , QChar ( ' 0' ) );
248
+ double itemHeight = qMax ( mSymbolHeight , textHeight );
247
249
248
250
QStandardItem* currentItem;
249
251
@@ -278,6 +280,7 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
278
280
{
279
281
symbolNg = symbolV2Item->symbolV2 ();
280
282
}
283
+ QgsComposerRasterSymbolItem* rasterItem = dynamic_cast <QgsComposerRasterSymbolItem*>( currentItem );
281
284
282
285
if ( symbol ) // item with symbol?
283
286
{
@@ -292,12 +295,22 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
292
295
realItemHeight = qMax ( realSymbolHeight, itemHeight );
293
296
currentXCoord += mIconLabelSpace ;
294
297
}
298
+ else if ( rasterItem )
299
+ {
300
+ if ( p )
301
+ {
302
+ p->setBrush ( rasterItem->color () );
303
+ p->drawRect ( QRectF ( currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2 , mSymbolWidth , mSymbolHeight ) );
304
+ }
305
+ currentXCoord += mSymbolWidth ;
306
+ currentXCoord += mIconLabelSpace ;
307
+ }
295
308
else // item with icon?
296
309
{
297
310
QIcon symbolIcon = currentItem->icon ();
298
311
if ( !symbolIcon.isNull () && p )
299
312
{
300
- symbolIcon.paint ( p, currentXCoord, currentYCoord, mSymbolWidth , mSymbolHeight );
313
+ symbolIcon.paint ( p, currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2 , mSymbolWidth , mSymbolHeight );
301
314
currentXCoord += mSymbolWidth ;
302
315
currentXCoord += mIconLabelSpace ;
303
316
}
@@ -307,7 +320,7 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
307
320
if ( p )
308
321
{
309
322
p->setPen ( QColor ( 0 , 0 , 0 ) );
310
- drawText ( p, currentXCoord, currentYCoord + fontAscentMillimeters ( mItemFont ) + ( realItemHeight - fontAscentMillimeters ( mItemFont ) ) / 2 , currentItem->text (), mItemFont );
323
+ drawText ( p, currentXCoord, currentYCoord + textHeight + ( realItemHeight - textHeight ) / 2 , currentItem->text (), mItemFont );
311
324
currentXCoord += textWidthMillimeters ( mItemFont , currentItem->text () );
312
325
}
313
326
currentXCoord += mBoxSpace ;
0 commit comments