summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-05-11 03:09:49 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-05-11 03:18:19 (GMT)
commitaa40b01fcda22e654790aaf93a6b14f947cdea72 (patch)
tree234ca2fb319dea1f12c679ed7030a4b82f540caa
parentcd70183a86f3586eb34c15f11af03746f28f4acc (diff)
downloadQt-aa40b01fcda22e654790aaf93a6b14f947cdea72.zip
Qt-aa40b01fcda22e654790aaf93a6b14f947cdea72.tar.gz
Qt-aa40b01fcda22e654790aaf93a6b14f947cdea72.tar.bz2
Round ideal width up to prevent incorrect word wrapping on Mac OS X
QTBUG-10539
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index d095dbe..6d86e58 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -46,6 +46,8 @@
#include <private/qdeclarativeglobal_p.h>
#include <qdeclarativeinfo.h>
+#include <QtCore/qmath.h>
+
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
@@ -1107,7 +1109,7 @@ void QDeclarativeTextEdit::updateSize()
setBaselineOffset(fm.ascent() + yoff + d->textMargin);
//### need to comfirm cost of always setting these
- int newWidth = (int)d->document->idealWidth();
+ int newWidth = qCeil(d->document->idealWidth());
d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well?
int cursorWidth = 1;
if(d->cursor)
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 8cc0e3f..b92024f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -202,7 +202,7 @@ void tst_qdeclarativetextedit::width()
QFont f;
QFontMetricsF fm(f);
qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = floor(metricWidth);
+ metricWidth = ceil(metricWidth);
QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + standard.at(i) + "\" }";
QDeclarativeComponent texteditComponent(&engine);
@@ -219,7 +219,7 @@ void tst_qdeclarativetextedit::width()
document.setHtml(richText.at(i));
document.setDocumentMargin(0);
- int documentWidth = document.idealWidth();
+ int documentWidth = ceil(document.idealWidth());
QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + richText.at(i) + "\" }";
QDeclarativeComponent texteditComponent(&engine);