summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-19 10:32:48 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-11-19 11:14:47 (GMT)
commit8e4b3acf5f162d0b71b5c00e37715cf77ed261af (patch)
tree97d1c3c6ae7753e505dff26ad033b7d1855ac9ea /src
parent27c55c8a274e0a6ab5cce5903be00688fe877ebe (diff)
downloadQt-8e4b3acf5f162d0b71b5c00e37715cf77ed261af.zip
Qt-8e4b3acf5f162d0b71b5c00e37715cf77ed261af.tar.gz
Qt-8e4b3acf5f162d0b71b5c00e37715cf77ed261af.tar.bz2
Fixed Multi-length strings not implemented for float functions
Task-number: QTBUG-5963 Reviewed-by: Oswald Buddenhagen Reviewed-by: Eskil (cherry picked from commit a73e660fd05bafc402d63d71e811a621e46f452d)
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontmetrics.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 06f1193..ecb7663 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -1367,10 +1367,13 @@ qreal QFontMetricsF::rightBearing(QChar ch) const
*/
qreal QFontMetricsF::width(const QString &text) const
{
+ int pos = text.indexOf(QLatin1Char('\x9c'));
+ int len = (pos != -1) ? pos : text.length();
+
QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
- return layout.width(0, text.length()).toReal();
+ return layout.width(0, len).toReal();
}
/*!
@@ -1587,7 +1590,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
*/
QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *tabArray) const
{
- return boundingRect(QRectF(), flags, text, tabStops, tabArray).size();
+ return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
}
/*!
@@ -1642,7 +1645,20 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
*/
QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const
{
- QStackTextEngine engine(text, QFont(d.data()));
+ QString _text = text;
+ if (!(flags & Qt::TextLongestVariant)) {
+ int posA = 0;
+ int posB = _text.indexOf(QLatin1Char('\x9c'));
+ while (posB >= 0) {
+ QString portion = _text.mid(posA, posB - posA);
+ if (size(flags, portion).width() <= width)
+ return portion;
+ posA = posB + 1;
+ posB = _text.indexOf(QLatin1Char('\x9c'), posA);
+ }
+ _text = _text.mid(posA);
+ }
+ QStackTextEngine engine(_text, QFont(d.data()));
return engine.elidedText(mode, QFixed::fromReal(width), flags);
}