X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d34036152b86d86d1dabe2d719d5abe1e6f205a5..2df2d4ea7ee63a43a327b4ffb1c5cddd176aff91:/src/dolphinviewautoscroller.cpp diff --git a/src/dolphinviewautoscroller.cpp b/src/dolphinviewautoscroller.cpp index 4e7af7f59..ea9b1a2d6 100644 --- a/src/dolphinviewautoscroller.cpp +++ b/src/dolphinviewautoscroller.cpp @@ -54,6 +54,17 @@ bool DolphinViewAutoScroller::isActive() const return m_timer->isActive(); } +void DolphinViewAutoScroller::handleCurrentIndexChange(const QModelIndex& current, + const QModelIndex& previous) +{ + // When the autoscroller is inactive and a key has been pressed, it must be + // assured that the current item stays visible. The check whether the previous + // item is valid is important because of #197951. + if (current.isValid() && previous.isValid() && !isActive()) { + m_itemView->scrollTo(current); + } +} + bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event) { if (watched == m_itemView->viewport()) { @@ -167,12 +178,12 @@ int DolphinViewAutoScroller::calculateScrollIncrement(int cursorPos, int rangeSi const int autoScrollBorder = 64; if (cursorPos < autoScrollBorder) { - inc = -minSpeed + fabs(cursorPos - autoScrollBorder) * (cursorPos - autoScrollBorder) / speedLimiter; + inc = -minSpeed + qAbs(cursorPos - autoScrollBorder) * (cursorPos - autoScrollBorder) / speedLimiter; if (inc < -maxSpeed) { inc = -maxSpeed; } } else if (cursorPos > rangeSize - autoScrollBorder) { - inc = minSpeed + fabs(cursorPos - rangeSize + autoScrollBorder) * (cursorPos - rangeSize + autoScrollBorder) / speedLimiter; + inc = minSpeed + qAbs(cursorPos - rangeSize + autoScrollBorder) * (cursorPos - rangeSize + autoScrollBorder) / speedLimiter; if (inc > maxSpeed) { inc = maxSpeed; }