summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 08:47:06 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 09:02:05 (GMT)
commit7b9fd32139d1e381f45a0655dafbfc98dc9aca39 (patch)
tree5d48ab2bc651c8266a244d817035b65a21b56098 /src/gui/itemviews
parent3dbfc6d7e87909dabb02e454997daa99d7e064c3 (diff)
downloadQt-7b9fd32139d1e381f45a0655dafbfc98dc9aca39.zip
Qt-7b9fd32139d1e381f45a0655dafbfc98dc9aca39.tar.gz
Qt-7b9fd32139d1e381f45a0655dafbfc98dc9aca39.tar.bz2
Fix QItemDelegate::textRectangle
The textRectangle should contain all pixels in the text, including those which are only partially covered, so the width and height should never be rounded down. Adding support for fractional font metrics on Mac made this bug visible. Fixes test failure in itemdelegate autotest. Reviewed-by: Olivier
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 7d8e103..25ea4c9 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -69,6 +69,7 @@
#include <qdebug.h>
#include <qlocale.h>
#include <qdialog.h>
+#include <qmath.h>
#include <limits.h>
@@ -1148,7 +1149,8 @@ QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect,
d->textLayout.setTextOption(d->textOption);
d->textLayout.setFont(font);
d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));
- const QSize size = d->doTextLayout(rect.width()).toSize();
+ QSizeF fpSize = d->doTextLayout(rect.width());
+ const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height()));
// ###: textRectangle should take style option as argument
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
return QRect(0, 0, size.width() + 2 * textMargin, size.height());