return;
}
- QFontMetrics fm(font);
+ QFontMetricsF fm(font);
if (text.isEmpty()) {
qreal fontHeight = fm.height();
q->setImplicitSize(0, fontHeight);
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();
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)
#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());
already absolutely positioned horizontally).
*/
-QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
+QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
{
Q_Q(QQuickText);
layout.setCacheEnabled(true);
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;
height = preLayoutHeight;
elideText = layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- lineWidth,
+ QFixed::fromReal(lineWidth),
0,
line.textStart(),
line.textLength());
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)
{
Q_D(const QQuickText);
- QRect rect = d->layedOutTextRect;
+ QRectF rect = d->layedOutTextRect;
if (d->style != Normal)
rect.adjust(-1, 0, 1, 2);
break;
}
- return QRectF(rect);
+ return rect;
}
/*! \internal */
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;
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);
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) + "\" }";
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));