summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Reininghaus <frank78ac@googlemail.com>2012-04-25 07:01:17 (GMT)
committerFrank Reininghaus <frank78ac@googlemail.com>2012-04-25 07:01:17 (GMT)
commit68ce395a192362969783615e50a8004d3029eb7e (patch)
treede65b0d74f4234bf8b0b12a6a398c521f4aa73f6
parentd3b1312d3edc615b03fb17c1a5fa62ccb61cdabd (diff)
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. BUG: 297488 BUG: 298782 FIXED-IN: 4.8.3 REVIEW: 104709
-rw-r--r--dolphin/src/kitemviews/kitemlistcontroller.cpp2
-rw-r--r--dolphin/src/kitemviews/kitemlistkeyboardsearchmanager.cpp10
-rw-r--r--dolphin/src/kitemviews/kitemlistkeyboardsearchmanager_p.h4
-rw-r--r--dolphin/src/kitemviews/kitemlistselectionmanager.cpp9
4 files changed, 22 insertions, 3 deletions
diff --git a/dolphin/src/kitemviews/kitemlistcontroller.cpp b/dolphin/src/kitemviews/kitemlistcontroller.cpp
index 3dfb530..d7826a9 100644
--- a/dolphin/src/kitemviews/kitemlistcontroller.cpp
+++ b/dolphin/src/kitemviews/kitemlistcontroller.cpp
@@ -59,6 +59,8 @@ KItemListController::KItemListController(QObject* parent) :
{
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);
diff --git a/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager.cpp b/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager.cpp
index a11c61b..df523cd 100644
--- a/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager.cpp
+++ b/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager.cpp
@@ -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();
+ }
+}
diff --git a/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager_p.h b/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager_p.h
index 3f13ff4..3731548 100644
--- a/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager_p.h
+++ b/dolphin/src/kitemviews/kitemlistkeyboardsearchmanager_p.h
@@ -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
diff --git a/dolphin/src/kitemviews/kitemlistselectionmanager.cpp b/dolphin/src/kitemviews/kitemlistselectionmanager.cpp
index 79c3370..383914d 100644
--- a/dolphin/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/dolphin/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