X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3696213ccbbe27e9ef3fc85eb97dd32fd669066f..09a0a44a073cf6396f0a28dc3847d081c4dab24e:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 2ae4a1f25..2f1bdc551 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -243,6 +243,20 @@ bool KItemListController::keyPressEvent(QKeyEvent *event) const bool horizontalScrolling = m_view->scrollOrientation() == Qt::Horizontal; + if (m_view->layoutDirection() == Qt::RightToLeft) { + // swap left and right arrow keys + switch (key) { + case Qt::Key_Left: + key = Qt::Key_Right; + break; + case Qt::Key_Right: + key = Qt::Key_Left; + break; + default: + break; + } + } + // Handle the expanding/collapsing of items // expand / collapse all selected directories if (m_view->supportsItemExpanding() && m_model->isExpandable(index) && (key == Qt::Key_Right || key == Qt::Key_Left)) { @@ -299,34 +313,6 @@ bool KItemListController::keyPressEvent(QKeyEvent *event) } } - if (m_view->layoutDirection() == Qt::RightToLeft) { - if (horizontalScrolling) { - // swap up and down arrow keys - switch (key) { - case Qt::Key_Up: - key = Qt::Key_Down; - break; - case Qt::Key_Down: - key = Qt::Key_Up; - break; - default: - break; - } - } else if (!m_view->supportsItemExpanding()) { - // swap left and right arrow keys - switch (key) { - case Qt::Key_Left: - key = Qt::Key_Right; - break; - case Qt::Key_Right: - key = Qt::Key_Left; - break; - default: - break; - } - } - } - const bool selectSingleItem = m_selectionBehavior != NoSelection && itemCount == 1 && navigationPressed; if (selectSingleItem) { @@ -535,9 +521,9 @@ void KItemListController::slotChangeCurrentItem(const QString &text, bool search return; } int index; - if (searchFromNextItem) { - const int currentIndex = m_selectionManager->currentItem(); - index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count()); + // In selection mode, always use the current (underlined) item, or the next item, for search start position. + if (m_selectionBehavior == NoSelection || m_selectionMode || m_selectionManager->hasSelection()) { + index = m_model->indexForKeyboardSearch(text, searchFromNextItem ? m_selectionManager->currentItem() + 1 : m_selectionManager->currentItem()); } else { index = m_model->indexForKeyboardSearch(text, 0); }