diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-02-07 11:57:42 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-07 06:36:05 +0100 |
commit | 51b7425329e0fa221c319e8d75595c19f664aedb (patch) | |
tree | 48c2d03edc05da74296a25540f1b8df52389b7ee /src/quick/items/qquicktextinput.cpp | |
parent | ce3dee765c858a0b573d468ef8fee6b838e576d1 (diff) |
Add contentWidth and contentHeight properties to Text elements.
For Text and TextEdit this is a rename of paintedWidth and paintedHeight
both of which remain as synonyms of the content properties for
compatability. For TextInput this is a new property.
Task-number: QTBUG-23691
Task-number: QTBUG-15160
Change-Id: Idbdc72fad34922be21b649ca45fc39b5e533ed1a
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 39dcc119e0..f8882286ef 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -2251,6 +2251,32 @@ bool QQuickTextInput::canRedo() const return d->canRedo; } +/*! + \qmlproperty real QtQuick2::TextInput::contentWidth + + Returns the width of the text, including the width past the width + which is covered due to insufficient wrapping if \l wrapMode is set. +*/ + +qreal QQuickTextInput::contentWidth() const +{ + Q_D(const QQuickTextInput); + return d->boundingRect.width(); +} + +/*! + \qmlproperty real QtQuick2::TextInput::contentHeight + + Returns the height of the text, including the height past the height + that is covered if the text does not fit within the set height. +*/ + +qreal QQuickTextInput::contentHeight() const +{ + Q_D(const QQuickTextInput); + return d->boundingRect.height(); +} + void QQuickTextInput::moveCursorSelection(int position) { Q_D(QQuickTextInput); @@ -2675,6 +2701,8 @@ void QQuickTextInputPrivate::updateLayout() if (!q->isComponentComplete()) return; + const QRectF previousRect = boundingRect; + QTextOption option = m_textLayout.textOption(); option.setTextDirection(layoutDirection()); option.setFlags(QTextOption::IncludeTrailingSpaces); @@ -2709,6 +2737,8 @@ void QQuickTextInputPrivate::updateLayout() q->update(); q->setImplicitSize(qCeil(boundingRect.width()), qCeil(boundingRect.height())); + if (previousRect != boundingRect) + emit q->contentSizeChanged(); } #ifndef QT_NO_CLIPBOARD |