summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-09 05:58:35 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-09 05:58:35 (GMT)
commit4a40a67827c8f259876e906a5a9afd2159ca9028 (patch)
tree06f82400d11677979a425d6392dd3241769737dd /src/declarative
parent475abec27948923ae6de74db53b137f19c661601 (diff)
downloadQt-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')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h6
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h6
4 files changed, 18 insertions, 15 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) {
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index 7a09b2f..871c833 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -97,9 +97,9 @@ public:
ElideNone = Qt::ElideNone };
enum WrapMode { NoWrap = QTextOption::NoWrap,
- WordWrap = QTextOption::WordWrap
-// WrapAnywhere = QTextOption::WrapAnywhere,
-// WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
+ WordWrap = QTextOption::WordWrap,
+ WrapAnywhere = QTextOption::WrapAnywhere,
+ WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
};
QString text() const;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 1db5ffe..6f1f6ac 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -370,6 +370,9 @@ void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment)
\list
\o NoWrap - no wrapping will be performed.
\o WordWrap - wrapping is done on word boundaries.
+ \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.
@@ -1039,11 +1042,7 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign));
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
-
- if (wrapMode == QDeclarativeTextEdit::WordWrap)
- opt.setWrapMode(QTextOption::WordWrap);
- else
- opt.setWrapMode(QTextOption::NoWrap);
+ opt.setWrapMode(QTextOption::WrapMode(wrapMode));
if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment())
return;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 3ac2b42..605b620 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -110,9 +110,9 @@ public:
};
enum WrapMode { NoWrap = QTextOption::NoWrap,
- WordWrap = QTextOption::WordWrap
-// WrapAnywhere = QTextOption::WrapAnywhere,
-// WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
+ WordWrap = QTextOption::WordWrap,
+ WrapAnywhere = QTextOption::WrapAnywhere,
+ WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
};
QString text() const;