summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-25 14:28:55 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-25 14:32:08 +0200
commit93ba0035f4eadfaf7217d95f18a442d418a064b8 (patch)
tree2ea6c77de4486534b12359a6201554bf01f4d2a9 /src
parentc53ea2745dc2ff57cc4c046d3cb4933c87d07838 (diff)
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')
-rw-r--r--src/gui/itemviews/qlistview.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 3e9db3b73..de2f49372 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;
}