Commit
f688bcd1f1 fixed slow scrolling with xf86-input-libinput on DolphinView.
However the commit also exposed a bug in the Dolphin scrolling
algorithm, which was previously hidden. This resulted in slow
scrolling in dock panels (Places and Folders), with both
xf86-input-evdev and xf86-input-libinput drivers, as well as libinput on
Wayland.
KItemListContainer::updateScrollOffsetScrollBar() relied on the view's
itemSize() method to compute the scrollbar's singleStep, but this QSize
was invalid for the dock panels' views.
We use a new itemSizeHint() method instead, which is always valid and
also adapts to the current icon size set in the view.
BUG: 365968
FIXED-IN: 16.12.0
REVIEW: 129409
if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_verticalSmoothScroller;
scrollOffsetScrollBar = verticalScrollBar();
- singleStep = view->itemSize().height();
+ singleStep = view->itemSizeHint().height();
// We cannot use view->size().height() because this height might
// include the header widget, which is not part of the scrolled area.
pageStep = view->verticalPageStep();
return m_itemSize;
}
+QSizeF KItemListView::itemSizeHint() const
+{
+ return m_sizeHintResolver->maxSizeHint();
+}
+
const KItemListStyleOption& KItemListView::styleOption() const
{
return m_styleOption;
/**
* @return The basic size of all items. The size of an item may be larger than
- * the basic size (see KItemListView::itemSizeHint() and KItemListView::itemRect()).
+ * the basic size (see KItemListView::itemRect()).
*/
QSizeF itemSize() const;
+ /**
+ * @return The size hint of all items. It is provided by the KItemListSizeHintResolver.
+ */
+ QSizeF itemSizeHint() const;
+
const KItemListStyleOption& styleOption() const;
virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
m_itemListView(itemListView),
m_logicalHeightHintCache(),
m_logicalWidthHint(0.0),
+ m_logicalHeightHint(0.0),
m_needsResolving(false)
{
}
{
}
+QSizeF KItemListSizeHintResolver::maxSizeHint()
+{
+ updateCache();
+ return QSizeF(m_logicalWidthHint, m_logicalHeightHint);
+}
+
QSizeF KItemListSizeHintResolver::sizeHint(int index)
{
updateCache();
{
if (m_needsResolving) {
m_itemListView->calculateItemSizeHints(m_logicalHeightHintCache, m_logicalWidthHint);
+ // Set logical height as the max cached height (if the cache is not empty).
+ if (m_logicalHeightHintCache.isEmpty()) {
+ m_logicalHeightHint = 0.0;
+ } else {
+ m_logicalHeightHint = *std::max_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
+ }
m_needsResolving = false;
}
}
public:
KItemListSizeHintResolver(const KItemListView* itemListView);
virtual ~KItemListSizeHintResolver();
+ QSizeF maxSizeHint();
QSizeF sizeHint(int index);
void itemsInserted(const KItemRangeList& itemRanges);
const KItemListView* m_itemListView;
mutable QVector<qreal> m_logicalHeightHintCache;
mutable qreal m_logicalWidthHint;
+ mutable qreal m_logicalHeightHint;
bool m_needsResolving;
};