add updadeGeometry for methods that need to update the geometry of the

widget

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=734745
This commit is contained in:
Alexis Ménard 2007-11-09 19:28:28 +00:00
parent ac1d1b0cdf
commit ae2d05c3c3

View File

@ -47,18 +47,21 @@ qreal Label::heightForWidth(qreal w) const
{ {
//FIXME: this looks a bit odd? //FIXME: this looks a bit odd?
QFontMetricsF m(d->textFont); QFontMetricsF m(d->textFont);
return m.boundingRect(QRectF(0, 0, w, 9999), d->alignment | Qt::TextWordWrap, d->text).height(); //return m.boundingRect(QRectF(0, 0, w, 9999), d->alignment | Qt::TextWordWrap, d->text).height();
return 0;
} }
QSizeF Label::sizeHint() const QSizeF Label::sizeHint() const
{ {
QFontMetricsF m(d->textFont); QFontMetricsF m(d->textFont);
return m.boundingRect(QRectF(0, 0, d->maximumWidth, 9999), d->alignment | Qt::TextWordWrap, d->text).size(); return m.boundingRect(QRectF(0,0,9999,9999), d->alignment | Qt::TextWordWrap, d->text).size();
//return m.boundingRect(QRectF(0, 0, d->maximumWidth, 9999), d->alignment | Qt::TextWordWrap, d->text).size();
} }
void Label::setText(const QString& text) void Label::setText(const QString& text)
{ {
d->text = text; d->text = text;
updateGeometry();
} }
QString Label::text() const QString Label::text() const
@ -79,6 +82,7 @@ Qt::Alignment Label::alignment() const
void Label::setPen(const QPen& pen) void Label::setPen(const QPen& pen)
{ {
d->textPen = pen; d->textPen = pen;
updateGeometry();
} }
QPen Label::pen() const QPen Label::pen() const
@ -99,6 +103,7 @@ int Label::maximumWidth() const
void Label::setFont(const QFont& font) void Label::setFont(const QFont& font)
{ {
d->textFont = font; d->textFont = font;
updateGeometry();
} }
QFont Label::font() const QFont Label::font() const