Skip to content
Permalink
Browse files
Don't leave space for empty title. Semi fixes #3484
  • Loading branch information
NathanW2 committed Feb 11, 2012
1 parent beb2f38 commit f73526ab0996ff67f472d945906d4548baa9e3c2
Showing with 15 additions and 12 deletions.
  1. +15 −12 src/core/composer/qgscomposerlegend.cpp
@@ -97,24 +97,27 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )

int numLayerItems = rootItem->rowCount();
QStandardItem* currentLayerItem = 0;
double currentYCoordinate = mBoxSpace;

//font metrics

//draw title
double currentItemMaxX = 0; //maximum x-coordinate for current item
double currentYCoordinate = 0;
if ( painter )
{
painter->setPen( QColor( 0, 0, 0 ) );
QStringList lines = splitStringForWrapping( mTitle );
for ( QStringList::Iterator titlePart = lines.begin(); titlePart != lines.end(); ++titlePart )
if ( !mTitle.isEmpty() )
{
currentYCoordinate += fontAscentMillimeters( mTitleFont );
drawText( painter, mBoxSpace, currentYCoordinate, *titlePart, mTitleFont );
currentItemMaxX = 2 * mBoxSpace + textWidthMillimeters( mTitleFont, *titlePart );
maxXCoord = qMax( maxXCoord, currentItemMaxX );
if ( titlePart != lines.end() )
currentYCoordinate += mlineSpacing;
currentYCoordinate = mBoxSpace;

painter->setPen( QColor( 0, 0, 0 ) );
QStringList lines = splitStringForWrapping( mTitle );
for ( QStringList::Iterator titlePart = lines.begin(); titlePart != lines.end(); ++titlePart )
{
currentYCoordinate += fontAscentMillimeters( mTitleFont );
drawText( painter, mBoxSpace, currentYCoordinate, *titlePart, mTitleFont );
currentItemMaxX = 2 * mBoxSpace + textWidthMillimeters( mTitleFont, *titlePart );
maxXCoord = qMax( maxXCoord, currentItemMaxX );
if ( titlePart != lines.end() )
currentYCoordinate += mlineSpacing;
}
}
}

0 comments on commit f73526a

Please sign in to comment.