Skip to content
Permalink
Browse files

[composer] Fix labels truncating text

  • Loading branch information
nyalldawson committed Dec 30, 2013
1 parent 3b6a303 commit 0437dbb02906fe644ebc096a7b16864f33107028
Showing with 4 additions and 14 deletions.
  1. +4 −9 src/core/composer/qgscomposerlabel.cpp
  2. +0 −5 src/core/composer/qgscomposerlabel.h
@@ -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 )
{
@@ -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
@@ -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;

0 comments on commit 0437dbb

Please sign in to comment.
You can’t perform that action at this time.