Skip to content

Commit

Permalink
Don't leave space for empty title. Semi fixes #3484
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Feb 11, 2012
1 parent beb2f38 commit f73526a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit f73526a

Please sign in to comment.