diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-09 05:58:35 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-09 05:58:35 (GMT) |
commit | 4a40a67827c8f259876e906a5a9afd2159ca9028 (patch) | |
tree | 06f82400d11677979a425d6392dd3241769737dd /src/declarative/graphicsitems/qdeclarativetext.cpp | |
parent | 475abec27948923ae6de74db53b137f19c661601 (diff) | |
download | Qt-4a40a67827c8f259876e906a5a9afd2159ca9028.zip Qt-4a40a67827c8f259876e906a5a9afd2159ca9028.tar.gz Qt-4a40a67827c8f259876e906a5a9afd2159ca9028.tar.bz2 |
Enable other wrapping modes.
WrapAnywhere - Text can be wrapped at any point on a line, even if it
occurs in the middle of a word.
WrapAtWordBoundaryOrAnywhere - If possible, wrapping occurs at a word
boundary; otherwise it will occur at the appropriate point on the line,
even in the middle of a word.
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetext.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetext.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 1f53b75..1730ee4 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -330,6 +330,9 @@ void QDeclarativeText::setVAlign(VAlignment align) \o WordWrap - wrapping is done on word boundaries. If the text cannot be word-wrapped to the specified width it will be partially drawn outside of the item's bounds. If this is undesirable then enable clipping on the item (Item::clip). + \o WrapAnywhere - Text can be wrapped at any point on a line, even if it occurs in the middle of a word. + \o WrapAtWordBoundaryOrAnywhere - If possible, wrapping occurs at a word boundary; otherwise it + will occur at the appropriate point on the line, even in the middle of a word. \endlist The default is NoWrap. @@ -554,10 +557,7 @@ void QDeclarativeTextPrivate::updateSize() singleline = false; // richtext can't elide or be optimized for single-line case doc->setDefaultFont(font); QTextOption option((Qt::Alignment)int(hAlign | vAlign)); - if (wrapMode == QDeclarativeText::WordWrap) - option.setWrapMode(QTextOption::WordWrap); - else - option.setWrapMode(QTextOption::NoWrap); + option.setWrapMode(QTextOption::WrapMode(wrapMode)); doc->setDefaultTextOption(option); if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid()) doc->setTextWidth(q->width()); @@ -642,6 +642,10 @@ QSize QDeclarativeTextPrivate::setupTextLayout(QTextLayout *layout) if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid()) lineWidth = q->width(); + QTextOption textOption = layout->textOption(); + textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); + layout->setTextOption(textOption); + layout->beginLayout(); while (1) { |