summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2013-11-22 23:15:30 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-15 14:10:25 (GMT)
commit31015df188e0a88317205b212f317302a235cb9b (patch)
tree05b249505691465f102e6530c4ae73753754f624 /src
parent032baf26784c2ee45bec3f9bfe81f6e7158491d3 (diff)
downloadQt-31015df188e0a88317205b212f317302a235cb9b.zip
Qt-31015df188e0a88317205b212f317302a235cb9b.tar.gz
Qt-31015df188e0a88317205b212f317302a235cb9b.tar.bz2
Correct wordwrapped text handling in QListView icon mode
Currently a QListView with wordwrapping activated will wrap the text only to the width of the icon even if the grid size is bigger. With this patch the option rect is now updated to match the grid size if valid and the style uses it to determine the correct size when wrapping [ChangeLog][QtWidgets][QTBUG-4714] Use the grid size for wordwrapping when available in icon mode Task-number: QTBUG-4714 Change-Id: I2cb63809d3ee8bd262f38bc11de91df9ff5cf237 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> (cherry picked from qtbase/a761be2fb2191215426f904cb03df0e966214531)
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemviews/qlistview.cpp5
-rw-r--r--src/gui/styles/qcommonstyle.cpp5
2 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 06b977a..cd88314 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -939,6 +939,11 @@ QStyleOptionViewItem QListView::viewOptions() const
} else {
option.decorationPosition = QStyleOptionViewItem::Left;
}
+
+ if (d->gridSize().isValid()) {
+ option.rect.setSize(d->gridSize());
+ }
+
return option;
}
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 1e5b7a9..1645152 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -862,7 +862,10 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, in
break;
case QStyleOptionViewItem::Top:
case QStyleOptionViewItem::Bottom:
- bounds.setWidth(wrapText ? option->decorationSize.width() : QFIXED_MAX);
+ if (wrapText)
+ bounds.setWidth(bounds.isValid() ? bounds.width() - 2 * textMargin : option->decorationSize.width());
+ else
+ bounds.setWidth(QFIXED_MAX);
break;
default:
break;