Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kitemlistcontainer.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include "kitemlistcontainer.h" | 22 | #include "kitemlistcontainer.h" | ||
23 | 23 | | |||
24 | #include "kitemlistcontroller.h" | 24 | #include "kitemlistcontroller.h" | ||
25 | #include "kitemlistview.h" | 25 | #include "kitemlistview.h" | ||
26 | #include "private/kitemlistsmoothscroller.h" | 26 | #include "private/kitemlistsmoothscroller.h" | ||
27 | 27 | | |||
28 | #include <QApplication> | 28 | #include <QApplication> | ||
29 | #include <QFontMetrics> | ||||
29 | #include <QGraphicsScene> | 30 | #include <QGraphicsScene> | ||
30 | #include <QGraphicsView> | 31 | #include <QGraphicsView> | ||
31 | #include <QScrollBar> | 32 | #include <QScrollBar> | ||
32 | #include <QStyleOption> | 33 | #include <QStyleOption> | ||
33 | 34 | | |||
34 | /** | 35 | /** | ||
35 | * Replaces the default viewport of KItemListContainer by a | 36 | * Replaces the default viewport of KItemListContainer by a | ||
36 | * non-scrollable viewport. The scrolling is done in an optimized | 37 | * non-scrollable viewport. The scrolling is done in an optimized | ||
▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | 250 | { | |||
255 | KItemListSmoothScroller* smoothScroller = nullptr; | 256 | KItemListSmoothScroller* smoothScroller = nullptr; | ||
256 | QScrollBar* scrollOffsetScrollBar = nullptr; | 257 | QScrollBar* scrollOffsetScrollBar = nullptr; | ||
257 | int singleStep = 0; | 258 | int singleStep = 0; | ||
258 | int pageStep = 0; | 259 | int pageStep = 0; | ||
259 | int maximum = 0; | 260 | int maximum = 0; | ||
260 | if (view->scrollOrientation() == Qt::Vertical) { | 261 | if (view->scrollOrientation() == Qt::Vertical) { | ||
261 | smoothScroller = m_verticalSmoothScroller; | 262 | smoothScroller = m_verticalSmoothScroller; | ||
262 | scrollOffsetScrollBar = verticalScrollBar(); | 263 | scrollOffsetScrollBar = verticalScrollBar(); | ||
263 | singleStep = view->itemSizeHint().height(); | 264 | | ||
265 | // Don't scroll super fast when using a wheel mouse: | ||||
266 | // We want to consider one "line" to be the text label which has a | ||||
267 | // roughly fixed height rather than using the height of the icon which | ||||
anthonyfieroni: I always think that we have that step in library, i have in mind that in system settings has a… | |||||
ngraham: See https://bugs.kde.org/show_bug.cgi?id=403842 | |||||
Note that in D25683 I have used QApplication::wheelScrollLines() which to me seems to be the right method to use for this. ahiemstra: Note that in D25683 I have used `QApplication::wheelScrollLines()` which to me seems to be the… | |||||
268 | // may be very tall | ||||
269 | const QFontMetrics metrics(font()); | ||||
270 | singleStep = metrics.height() * QApplication::wheelScrollLines(); | ||||
271 | | ||||
264 | // We cannot use view->size().height() because this height might | 272 | // We cannot use view->size().height() because this height might | ||
265 | // include the header widget, which is not part of the scrolled area. | 273 | // include the header widget, which is not part of the scrolled area. | ||
266 | pageStep = view->verticalPageStep(); | 274 | pageStep = view->verticalPageStep(); | ||
267 | 275 | | |||
268 | // However, the total height of the view must be considered for the | 276 | // However, the total height of the view must be considered for the | ||
269 | // maximum value of the scroll bar. Note that the view's scrollOffset() | 277 | // maximum value of the scroll bar. Note that the view's scrollOffset() | ||
270 | // refers to the offset of the top part of the view, which might be | 278 | // refers to the offset of the top part of the view, which might be | ||
271 | // hidden behind the header. | 279 | // hidden behind the header. | ||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |
I always think that we have that step in library, i have in mind that in system settings has a scroll speed, now i don't see, somethings changed and i did not notice :)