diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 12:28:55 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 12:32:08 (GMT) |
commit | 93ba0035f4eadfaf7217d95f18a442d418a064b8 (patch) | |
tree | 2ea6c77de4486534b12359a6201554bf01f4d2a9 /src/gui/itemviews/qlistview.cpp | |
parent | c53ea2745dc2ff57cc4c046d3cb4933c87d07838 (diff) | |
download | Qt-93ba0035f4eadfaf7217d95f18a442d418a064b8.zip Qt-93ba0035f4eadfaf7217d95f18a442d418a064b8.tar.gz Qt-93ba0035f4eadfaf7217d95f18a442d418a064b8.tar.bz2 |
QListView:: visualRect would return incorrect values
Especially when the widget was not yet shown. Sometimes the rectangle
for an item would get truncated to the size of the viewport.
That should not happen: we only want to expand it to take the whole
height or width of the viewport.
Task-number: 243335
Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/itemviews/qlistview.cpp')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 3e9db3b..de2f493 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1715,8 +1715,7 @@ QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const QRect result = extend ? commonListView->mapToViewport(rect) : rect; int dx = -q->horizontalOffset(); int dy = -q->verticalOffset(); - result.adjust(dx, dy, dx, dy); - return result; + return result.adjusted(dx, dy, dx, dy); } QModelIndex QListViewPrivate::closestIndex(const QRect &target, @@ -2287,15 +2286,14 @@ QRect QListModeViewBase::mapToViewport(const QRect &rect) const if (isWrapping()) return rect; // If the listview is in "listbox-mode", the items are as wide as the view. + // But we don't shrink the items. QRect result = rect; - QSize vsize = viewport()->size(); - QSize csize = contentsSize; if (flow() == QListView::TopToBottom) { result.setLeft(spacing()); - result.setWidth(qMax(csize.width(), vsize.width()) - 2 * spacing()); + result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing())); } else { // LeftToRight result.setTop(spacing()); - result.setHeight(qMax(csize.height(), vsize.height()) - 2 * spacing()); + result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing())); } return result; } |