diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-16 19:13:13 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-17 11:49:16 (GMT) |
commit | 1aa43fc4af995374c577a951fd2054d696aa3b14 (patch) | |
tree | 45b78871f99212a3100d879d3a52cf5ee0b4c7a4 /src | |
parent | 8ab072aff0527d3ef3e44cf1ceba7dca985a6f94 (diff) | |
download | Qt-1aa43fc4af995374c577a951fd2054d696aa3b14.zip Qt-1aa43fc4af995374c577a951fd2054d696aa3b14.tar.gz Qt-1aa43fc4af995374c577a951fd2054d696aa3b14.tar.bz2 |
Fixes: ItemView text editor is not visible with empty text and icons
It was not visible wicause its height was 0
Task-number: 257481
Reviewed-by: mbm
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qitemdelegate.cpp | 6 | ||||
-rw-r--r-- | src/gui/styles/qcommonstyle.cpp | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index a285113..336ca79 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -861,6 +861,8 @@ void QItemDelegate::drawBackground(QPainter *painter, /*! \internal + + Code duplicated in QCommonStylePrivate::viewItemLayout */ void QItemDelegate::doLayout(const QStyleOptionViewItem &option, @@ -882,8 +884,10 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option, int w, h; textRect->adjust(-textMargin, 0, textMargin, 0); // add width padding - if (textRect->height() == 0 && !hasPixmap) + if (textRect->height() == 0 && (!hasPixmap || !hint)) { + //if there is no text, we still want to have a decent height for the item sizeHint and the editor size textRect->setHeight(option.fontMetrics.height()); + } QSize pm(0, 0); if (hasPixmap) { diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 29176c3..aba89bc 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -1182,8 +1182,14 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt } } -/* Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore - opt->rect and return rectangles in infinite space */ +/*! \internal + compute the position for the different component of an item (pixmap, text, checkbox) + + Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore + opt->rect and return rectangles in infinite space + + Code duplicated in QItemDelegate::doLayout +*/ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect, QRect *pixmapRect, QRect *textRect, bool sizehint) const { @@ -1204,8 +1210,10 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRe int y = opt->rect.top(); int w, h; - if (textRect->height() == 0 && !hasPixmap) + if (textRect->height() == 0 && (!hasPixmap || !sizehint)) { + //if there is no text, we still want to have a decent height for the item sizeHint and the editor size textRect->setHeight(opt->fontMetrics.height()); + } QSize pm(0, 0); if (hasPixmap) { |