From c3bd4b44e4c172d06e8ae4822d9f467a8d272562 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 25 Apr 2012 09:20:11 +0200 Subject: When the current item is removed, make -1 the current index temporarily This fixes two problems: 1. KItemListKeyboardSearchManger can cancel the current search when a new folder is opened (note that this action removes the current item from the view). 2. The view can underline the new current item (which is the item that used to be below the removed item). Note that this did not work before because the view did not receive a currentChanged() signal in this case and therefore did not update the "current item" status of the new current item. CCBUG: 297488 CCBUG: 298782 REVIEW: 104709 (cherry picked from commit 68ce395a192362969783615e50a8004d3029eb7e) --- src/kitemviews/kitemlistselectionmanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/kitemviews/kitemlistselectionmanager.cpp') diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp index 79c3370b4..383914df0 100644 --- a/src/kitemviews/kitemlistselectionmanager.cpp +++ b/src/kitemviews/kitemlistselectionmanager.cpp @@ -291,12 +291,15 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges) // Calling setCurrentItem() would trigger the selectionChanged signal, but we want to // emit it only once in this function -> change the current item manually and emit currentChanged m_currentItem = indexAfterRangesRemoving(m_currentItem, itemRanges); - if (m_currentItem < 0) { - m_currentItem = qMin(previousCurrent, m_model->count() - 1); - } if (m_currentItem != previousCurrent) { emit currentChanged(m_currentItem, previousCurrent); } + + if (m_currentItem < 0) { + // The current item has been removed. + m_currentItem = qMin(previousCurrent, m_model->count() - 1); + emit currentChanged(m_currentItem, -1); + } } // Update the anchor item -- cgit v1.3