summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2011-01-26 16:22:13 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2011-01-26 16:22:13 (GMT)
commit8533384ded9323a0b38490ed65793abd9a62d46f (patch)
tree6faac6d1c32bebb1df0294332033bc44dc0d8ae5 /src/declarative/graphicsitems/qdeclarativetextedit.cpp
parent834c8617dc130126c0ce5213bda36b9f62717b1e (diff)
parent5498dcd7b10e147734a3414cab824b8b435aa3d9 (diff)
downloadQt-8533384ded9323a0b38490ed65793abd9a62d46f.zip
Qt-8533384ded9323a0b38490ed65793abd9a62d46f.tar.gz
Qt-8533384ded9323a0b38490ed65793abd9a62d46f.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index d326ff7..19c0f2d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -326,22 +326,35 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format)
QFont QDeclarativeTextEdit::font() const
{
Q_D(const QDeclarativeTextEdit);
- return d->font;
+ return d->sourceFont;
}
void QDeclarativeTextEdit::setFont(const QFont &font)
{
Q_D(QDeclarativeTextEdit);
+ if (d->sourceFont == font)
+ return;
+
+ d->sourceFont = font;
+ QFont oldFont = d->font;
d->font = font;
+ if (d->font.pointSizeF() != -1) {
+ // 0.5pt resolution
+ qreal size = qRound(d->font.pointSizeF()*2.0);
+ d->font.setPointSizeF(size/2.0);
+ }
- clearCache();
- d->document->setDefaultFont(d->font);
- if(d->cursor){
- d->cursor->setHeight(QFontMetrics(d->font).height());
- moveCursorDelegate();
+ if (oldFont != d->font) {
+ clearCache();
+ d->document->setDefaultFont(d->font);
+ if(d->cursor){
+ d->cursor->setHeight(QFontMetrics(d->font).height());
+ moveCursorDelegate();
+ }
+ updateSize();
+ update();
}
- updateSize();
- update();
+ emit fontChanged(d->sourceFont);
}
/*!
@@ -1354,8 +1367,12 @@ void QDeclarativeTextEdit::updateSize()
int dy = height();
// ### assumes that if the width is set, the text will fill to edges
// ### (unless wrap is false, then clipping will occur)
- if (widthValid() && d->document->textWidth() != width())
- d->document->setTextWidth(width());
+ if (widthValid()) {
+ if (d->document->textWidth() != width())
+ d->document->setTextWidth(width());
+ } else {
+ d->document->setTextWidth(-1);
+ }
dy -= (int)d->document->size().height();
int nyoff;