Blob Blame History Raw
qt-bugs@ issue : none
Qt Software task ID : none
bugs.kde.org number : none
applied: no
author: Aurélien Gâteau <agateau@kde.org>

Do not deduce scrollbar extent twice if scrollbar policy is
Qt::ScrollBarAlwaysOn.

This patch has been merged in master but won't be in 4.5.
http://qt.gitorious.org/qt/qt/merge_requests/432

--- src/gui/itemviews/qlistview.cpp
+++ src/gui/itemviews/qlistview.cpp
@@ -1969,10 +1969,16 @@ void QListViewPrivate::prepareItemsLayout()
     int frameAroundContents = 0;
     if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
         frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
-    int verticalMargin = vbarpolicy==Qt::ScrollBarAlwaysOff ? 0 :
-        q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->verticalScrollBar()) + frameAroundContents;
-    int horizontalMargin =  hbarpolicy==Qt::ScrollBarAlwaysOff ? 0 :
-        q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->horizontalScrollBar()) + frameAroundContents;
+
+    // maximumViewportSize() already takes scrollbar into account if policy is
+    // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
+    // is Qt::ScrollBarAsNeeded
+    int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
+        ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->verticalScrollBar()) + frameAroundContents
+        : 0;
+    int horizontalMargin =  hbarpolicy==Qt::ScrollBarAsNeeded
+        ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->horizontalScrollBar()) + frameAroundContents
+        : 0;
 
     layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);