aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquicktext.cpp37
-rw-r--r--src/quick/items/qquicktext_p_p.h6
-rw-r--r--tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml2
-rw-r--r--tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml2
-rw-r--r--tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp8
5 files changed, 26 insertions, 29 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index fd8ffe501b..656440f2d3 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -386,7 +386,7 @@ void QQuickTextPrivate::updateSize()
return;
}
- QFontMetrics fm(font);
+ QFontMetricsF fm(font);
if (text.isEmpty()) {
qreal fontHeight = fm.height();
q->setImplicitSize(0, fontHeight);
@@ -399,16 +399,16 @@ void QQuickTextPrivate::updateSize()
qreal naturalWidth = 0;
- int dy = q->height();
- QSize size(0, 0);
- QSize previousSize = layedOutTextRect.size();
+ qreal dy = q->height();
+ QSizeF size(0, 0);
+ QSizeF previousSize = layedOutTextRect.size();
#if defined(Q_OS_MAC)
layoutThread = QThread::currentThread();
#endif
//setup instance of QTextLayout for all cases other than richtext
if (!richText) {
- QRect textRect = setupTextLayout(&naturalWidth);
+ QRectF textRect = setupTextLayout(&naturalWidth);
layedOutTextRect = textRect;
size = textRect.size();
dy -= size.height();
@@ -436,12 +436,12 @@ void QQuickTextPrivate::updateSize()
doc->setTextWidth(q->width());
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
- dy -= (int)doc->size().height();
- QSize dsize = doc->size().toSize();
- layedOutTextRect = QRect(QPoint(0,0), dsize);
- size = QSize(int(doc->idealWidth()),dsize.height());
+ dy -= doc->size().height();
+ QSizeF dsize = doc->size();
+ layedOutTextRect = QRectF(QPointF(0,0), dsize);
+ size = QSizeF(doc->idealWidth(),dsize.height());
}
- int yoff = 0;
+ qreal yoff = 0;
if (q->heightValid()) {
if (vAlign == QQuickText::AlignBottom)
@@ -601,13 +601,13 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height,
#endif
}
-QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine) const
+QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const
{
if (nextLine) {
nextLine->setLineWidth(INT_MAX);
return layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- lineWidth,
+ QFixed::fromReal(lineWidth),
0,
line.textStart(),
line.textLength() + nextLine->textLength());
@@ -630,7 +630,7 @@ QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTex
already absolutely positioned horizontally).
*/
-QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
+QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
{
Q_Q(QQuickText);
layout.setCacheEnabled(true);
@@ -673,8 +673,9 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
return QRect(0, 0, 0, height);
}
- const int lineWidth = q->widthValid() ? q->width() : INT_MAX;
+ const qreal lineWidth = q->widthValid() ? q->width() : FLT_MAX;
const qreal maxHeight = q->heightValid() ? q->height() : FLT_MAX;
+
const bool customLayout = isLineLaidOutConnected();
const bool wasTruncated = truncated;
@@ -783,7 +784,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
height = preLayoutHeight;
elideText = layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- lineWidth,
+ QFixed::fromReal(lineWidth),
0,
line.textStart(),
line.textLength());
@@ -941,7 +942,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
if (truncated != wasTruncated)
emit q->truncatedChanged();
- return QRect(qRound(br.x()), qRound(br.y()), qCeil(br.width()), qCeil(br.height()));
+ return br;
}
void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height)
@@ -1897,7 +1898,7 @@ QRectF QQuickText::boundingRect() const
{
Q_D(const QQuickText);
- QRect rect = d->layedOutTextRect;
+ QRectF rect = d->layedOutTextRect;
if (d->style != Normal)
rect.adjust(-1, 0, 1, 2);
@@ -1915,7 +1916,7 @@ QRectF QQuickText::boundingRect() const
break;
}
- return QRectF(rect);
+ return rect;
}
/*! \internal */
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index e060cc1cd2..d0770e6962 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -82,9 +82,9 @@ public:
QTextDocument *textDocument();
bool isLineLaidOutConnected();
void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height);
- QString elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const;
+ QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const;
- QRect layedOutTextRect;
+ QRectF layedOutTextRect;
qreal lineHeight;
@@ -156,7 +156,7 @@ public:
void ensureDoc();
- QRect setupTextLayout(qreal *const naturalWidth);
+ QRectF setupTextLayout(qreal *const naturalWidth);
void setupCustomLineGeometry(QTextLine &line, qreal &height, int lineOffset = 0);
bool isLinkActivatedConnected();
QString anchorAt(const QPointF &pos);
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml
index d26576eacd..6b9dc71fbc 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml
+++ b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml
@@ -7,7 +7,7 @@ Item {
Text {
id: myText
objectName: "myText"
- width: 100
+ width: 60
font.pixelSize: 15
font.family: "Helvetica"
}
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml
index 0da9bc353a..21f1b20619 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml
+++ b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml
@@ -7,7 +7,7 @@ Item {
Text {
id: myText
objectName: "myText"
- width: 100
+ width: 60
height: 36
font.pixelSize: 15
font.family: "Helvetica"
diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
index c28de8b53c..5f13f6211d 100644
--- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
@@ -295,11 +295,10 @@ void tst_qquicktext::width()
layout.endLayout();
- metricWidth = qCeil(layout.boundingRect().width());
+ metricWidth = layout.boundingRect().width();
} else {
QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
+ metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
}
QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
@@ -2422,9 +2421,6 @@ void tst_qquicktext::multilengthStrings()
QCOMPARE(myText->contentWidth(), mediumWidth);
QCOMPARE(myText->contentHeight(), mediumHeight);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue);
-#endif
QCOMPARE(myText->truncated(), true);
myText->setSize(QSizeF(shortWidth, shortHeight));