summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorChristopher Ham <christopher.ham@nokia.com>2011-01-28 02:55:57 (GMT)
committerChristopher Ham <christopher.ham@nokia.com>2011-01-28 03:01:46 (GMT)
commit57ddd7c69705dfbf3d06b8a0157e5e706120c818 (patch)
tree9294462282fe188902201e221ab75a2893722a5d /src/declarative/graphicsitems
parentcb6b9ee680f792750d0cb265ea59ff3ff4643562 (diff)
downloadQt-57ddd7c69705dfbf3d06b8a0157e5e706120c818.zip
Qt-57ddd7c69705dfbf3d06b8a0157e5e706120c818.tar.gz
Qt-57ddd7c69705dfbf3d06b8a0157e5e706120c818.tar.bz2
Fix MaximumLineCount in Text and add tests
Fixed MaximumLineCount not truncating when wrapMode was not set. Visual autotests were added to test various possible options for maximumLineCount. Task-number: QTBUG-12305 Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index d424e30..1e0988d 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -366,6 +366,8 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
if (maximumLineCountValid) {
layout.beginLayout();
+ if (!lineWidth)
+ lineWidth = INT_MAX;
int y = 0;
int linesLeft = maximumLineCount;
while (linesLeft > 0) {
@@ -374,34 +376,28 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
break;
visibleCount++;
-
- if (lineWidth) {
- if (--linesLeft == 0) {
- line.setLineWidth(q->width()*2); // Set out more than is required, but not too much.
- if (line.naturalTextWidth() > lineWidth)
- line.setLineWidth(lineWidth - elideWidth);
- visibleTextLength += line.textLength(); // Used to catch new lines that are shorter than the layout width.
-
- if (visibleTextLength < text.length()) {
- truncate = true;
- if (elideMode==QDeclarativeText::ElideRight) {
- // Need to correct for alignment
- int x = line.naturalTextWidth();
- if (hAlign == QDeclarativeText::AlignRight) {
- x = q->width()-elideWidth;
- } else if (hAlign == QDeclarativeText::AlignHCenter) {
- x = (q->width()+line.naturalTextWidth()-elideWidth)/2;
- }
- elidePos = QPointF(x, y + fm.ascent());
+ line.setLineWidth(lineWidth);
+ visibleTextLength += line.textLength();
+
+ if (--linesLeft == 0) {
+ if (visibleTextLength < text.length()) {
+ truncate = true;
+ if (elideMode==QDeclarativeText::ElideRight && q->widthValid()) {
+ // Need to correct for alignment
+ line.setLineWidth(lineWidth-elideWidth);
+ int x = line.naturalTextWidth();
+ if (hAlign == QDeclarativeText::AlignRight) {
+ x = q->width()-elideWidth;
+ } else if (hAlign == QDeclarativeText::AlignHCenter) {
+ x = (q->width()+line.naturalTextWidth()-elideWidth)/2;
}
+ elidePos = QPointF(x, y + fm.ascent());
+ elideText = true;
}
- } else {
- line.setLineWidth(lineWidth);
- visibleTextLength += line.textLength();
}
-
- y += line.height();
}
+
+ y += line.height();
}
layout.endLayout();