]> cloud.milkyroute.net Git - dolphin.git/commitdiff
base scrolling on the smallest item
authorMarco Martin <notmart@gmail.com>
Mon, 29 Jan 2018 10:52:23 +0000 (11:52 +0100)
committerMarco Martin <notmart@gmail.com>
Mon, 29 Jan 2018 10:54:12 +0000 (11:54 +0100)
Summary:
CCBUG: 386379

after recent highdpi patches on scrolling that delegated it
completely to the scrollbar, based upon the scrollbar singleStep
setted to the tallest of the items in the view.
tough this makes scrolling way too fast, and on folders where just
few filenames are longer than most we can get a single scrolling
step almost double the number of lines configured in the
mouse kcm.
Using the shortest item instead of the tallest mitigates this problem
making it a bit more usable

Test Plan:
tested on different folders in different view modes both with
mouse and touchpad

Reviewers: #dolphin, broulik, ngraham

Reviewed By: #dolphin, ngraham

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10102

src/kitemviews/kitemlistcontainer.cpp
src/kitemviews/kitemlistview.cpp
src/kitemviews/private/kitemlistsizehintresolver.cpp
src/kitemviews/private/kitemlistsizehintresolver.h

index 8e64ee493314e8c2cef595dd0756f0690e289d38..c1eae53bd6a8c628cefe917c5859be572d7bd939 100644 (file)
@@ -35,7 +35,6 @@
 #include <QStyle>
 #include <QStyleOption>
 
-
 /**
  * Replaces the default viewport of KItemListContainer by a
  * non-scrollable viewport. The scrolling is done in an optimized
index 71091033c9bd1542ecd3920c71fce58365c74fdf..dbeb571a40d7732fc16733642deb04738ffd74d4 100644 (file)
@@ -342,7 +342,7 @@ QSizeF KItemListView::itemSize() const
 
 QSizeF KItemListView::itemSizeHint() const
 {
-    return m_sizeHintResolver->maxSizeHint();
+    return m_sizeHintResolver->minSizeHint();
 }
 
 const KItemListStyleOption& KItemListView::styleOption() const
index 02f1865b349c80caa7fd5a2f32b8301f32794b8d..5c121c6670d8fbba2981d3a6c9e504acbecbda70 100644 (file)
@@ -26,6 +26,7 @@ KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView* itemLi
     m_logicalHeightHintCache(),
     m_logicalWidthHint(0.0),
     m_logicalHeightHint(0.0),
+    m_minHeightHint(0.0),
     m_needsResolving(false)
 {
 }
@@ -40,6 +41,12 @@ QSizeF KItemListSizeHintResolver::maxSizeHint()
     return QSizeF(m_logicalWidthHint, m_logicalHeightHint);
 }
 
+QSizeF KItemListSizeHintResolver::minSizeHint()
+{
+    updateCache();
+    return QSizeF(m_logicalWidthHint, m_minHeightHint);
+}
+
 QSizeF KItemListSizeHintResolver::sizeHint(int index)
 {
     updateCache();
@@ -161,6 +168,7 @@ void KItemListSizeHintResolver::updateCache()
             m_logicalHeightHint = 0.0;
         } else {
             m_logicalHeightHint = *std::max_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
+            m_minHeightHint = *std::min_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
         }
         m_needsResolving = false;
     }
index 841e9ca1001adcee51c1e825c62df6dbb0755cf4..fa92b8682221bb53962a192de1c90275b5d3eadf 100644 (file)
@@ -37,6 +37,7 @@ public:
     KItemListSizeHintResolver(const KItemListView* itemListView);
     virtual ~KItemListSizeHintResolver();
     QSizeF maxSizeHint();
+    QSizeF minSizeHint();
     QSizeF sizeHint(int index);
 
     void itemsInserted(const KItemRangeList& itemRanges);
@@ -52,6 +53,7 @@ private:
     mutable QVector<qreal> m_logicalHeightHintCache;
     mutable qreal m_logicalWidthHint;
     mutable qreal m_logicalHeightHint;
+    mutable qreal m_minHeightHint;
     bool m_needsResolving;
 };