Skip to content

Commit

Permalink
[composer] Fix labels truncating text
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 30, 2013
1 parent 3b6a303 commit 0437dbb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
13 changes: 4 additions & 9 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -64,7 +64,7 @@ void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem*
painter->save();

double penWidth = pen().widthF();
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, mTextBoxWidth - 2 * penWidth - 2 * mMargin, mTextBoxHeight - 2 * penWidth - 2 * mMargin );
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, rect().width() - 2 * penWidth - 2 * mMargin, rect().height() - 2 * penWidth - 2 * mMargin );

if ( mHtmlState )
{
Expand Down Expand Up @@ -221,20 +221,15 @@ void QgsComposerLabel::adjustSizeToText()
double textWidth = textWidthMillimeters( mFont, displayText() );
double fontAscent = fontAscentMillimeters( mFont );

mTextBoxWidth = textWidth + 2 * mMargin + 2 * pen().widthF() + 1;
mTextBoxHeight = fontAscent + 2 * mMargin + 2 * pen().widthF() + 1;

double width = mTextBoxWidth;
double height = mTextBoxHeight;

sizeChangedByRotation( width, height );
double width = textWidth + 2 * mMargin + 2 * pen().widthF() + 1;
double height = fontAscent + 2 * mMargin + 2 * pen().widthF() + 1;

//keep alignment point constant
double xShift = 0;
double yShift = 0;
itemShiftAdjustSize( width, height, xShift, yShift );

QgsComposerItem::setSceneRect( QRectF( pos().x() + xShift, pos().y() + yShift, width, height ) );
setSceneRect( QRectF( pos().x() + xShift, pos().y() + yShift, width, height ) );
}

QFont QgsComposerLabel::font() const
Expand Down
5 changes: 0 additions & 5 deletions src/core/composer/qgscomposerlabel.h
Expand Up @@ -133,11 +133,6 @@ class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
/**Replaces replace '$CURRENT_DATE<(FORMAT)>' with the current date (e.g. $CURRENT_DATE(d 'June' yyyy)*/
void replaceDateText( QString& text ) const;

/**Width of the text box. This is different to rectangle().width() in case there is rotation*/
double mTextBoxWidth;
/**Height of the text box. This is different to rectangle().height() in case there is rotation*/
double mTextBoxHeight;

QgsFeature* mExpressionFeature;
QgsVectorLayer* mExpressionLayer;
QMap<QString, QVariant> mSubstitutions;
Expand Down

0 comments on commit 0437dbb

Please sign in to comment.