]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When the current item is removed, make -1 the current index temporarily
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 25 Apr 2012 07:20:11 +0000 (09:20 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 25 Apr 2012 07:20:23 +0000 (09:20 +0200)
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/kitemlistcontroller.cpp
src/kitemviews/kitemlistselectionmanager.cpp
src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
src/kitemviews/private/kitemlistkeyboardsearchmanager.h

index 1f93a6357e34f4373acb5825b81745e6c2684c01..1c35072e528654599ceb37a3a2711ae6e88068ee 100644 (file)
@@ -60,6 +60,8 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
 {
     connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)),
             this, SLOT(slotChangeCurrentItem(QString,bool)));
+    connect(m_selectionManager, SIGNAL(currentChanged(int,int)),
+            m_keyboardManager, SLOT(slotCurrentChanged(int,int)));
 
     m_autoActivationTimer = new QTimer(this);
     m_autoActivationTimer->setSingleShot(true);
index 79c3370b47016980d0d950c8184eacbe3055458f..383914df01e9964d60bf009db7af636bd52fd55e 100644 (file)
@@ -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
index 41ca34be46e06e054699b27819fea720f5254d95..da8f72b7ee67995c7e66d2cc0988a9a4ba30dc58 100644 (file)
@@ -78,3 +78,13 @@ void KItemListKeyboardSearchManager::cancelSearch()
 {
     m_searchedString.clear();
 }
+
+void KItemListKeyboardSearchManager::slotCurrentChanged(int current, int previous)
+{
+    Q_UNUSED(previous);
+
+    if (current < 0) {
+        // The current item has been removed. We should cancel the search.
+        cancelSearch();
+    }
+}
index 3f13ff4459400839971ecf24f7f5ab2664544691..3731548c96f802fb3f72203c05dc7f8b9ba5aab6 100644 (file)
@@ -60,6 +60,10 @@ public:
 
     void cancelSearch();
 
+public slots:
+
+    void slotCurrentChanged(int current, int previous);
+
 signals:
     /**
      * Is emitted if the current item should be changed corresponding