diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-01-19 01:40:49 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-01-19 01:40:49 (GMT) |
commit | ebd4bc73c46c2962742a682b6a391fb68c482aec (patch) | |
tree | 3045a1af9e65ca6500437d4e90ccfd3637fb6976 /src/declarative/graphicsitems/qdeclarativetextedit.cpp | |
parent | 9c1e67d83f6175f339e6771be05ee60ba72426b3 (diff) | |
parent | 5d9738ed88da269033333299c16558882d346514 (diff) | |
download | Qt-ebd4bc73c46c2962742a682b6a391fb68c482aec.zip Qt-ebd4bc73c46c2962742a682b6a391fb68c482aec.tar.gz Qt-ebd4bc73c46c2962742a682b6a391fb68c482aec.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 4a421b4..280c8c3 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -335,22 +335,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); } /*! @@ -1480,8 +1493,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; |