┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Krutzler <[email protected]>2018-01-21 13:39:41 -0700
committerNathaniel Graham <[email protected]>2018-01-21 13:43:30 -0700
commitbba44ae907b4faaf115d33fb0a3c50cd96ee2cb6 (patch)
tree5d7535e05c05011144b1274f0ae057d8c5839987 /src
parent6cf74d2fdd36c5322c2db3278aea9c9d47b77889 (diff)
Fix renamed file reclaims focus
Summary: After renaming a file and then selecting another file immediately the just selected file stays selected. BUG: 388555 Test Plan: Steps to reproduce: $ mkdir /tmp/test $ cd /tmp/test $ touch a.tmp b.tmp $ dolphin /tmp/test In dolphin: * select a.tmp * <F2> * type aaa * select b.tmp immediately Expected result: * a.tmp renamed to aaa.tmp * b.tmp stays selected, aaa.tmp stays unselected Reviewers: ngraham, michaelh, #dolphin, elvisangelaccio Reviewed By: ngraham, michaelh, #dolphin, elvisangelaccio Subscribers: emateli, elvisangelaccio, #dolphin Differential Revision: https://phabricator.kde.org/D9711
Diffstat (limited to 'src')
-rw-r--r--src/views/dolphinview.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 10382c57d..e40e49d6e 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1356,17 +1356,21 @@ void DolphinView::updateViewState()
{
if (m_currentItemUrl != QUrl()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
- const int currentIndex = m_model->index(m_currentItemUrl);
- if (currentIndex != -1) {
- selectionManager->setCurrentItem(currentIndex);
- // scroll to current item and reset the state
- if (m_scrollToCurrentItem) {
- m_view->scrollToItem(currentIndex);
- m_scrollToCurrentItem = false;
+ // if there is a selection already, leave it that way
+ if (!selectionManager->hasSelection()) {
+ const int currentIndex = m_model->index(m_currentItemUrl);
+ if (currentIndex != -1) {
+ selectionManager->setCurrentItem(currentIndex);
+
+ // scroll to current item and reset the state
+ if (m_scrollToCurrentItem) {
+ m_view->scrollToItem(currentIndex);
+ m_scrollToCurrentItem = false;
+ }
+ } else {
+ selectionManager->setCurrentItem(0);
}
- } else {
- selectionManager->setCurrentItem(0);
}
m_currentItemUrl = QUrl();
@@ -1384,26 +1388,29 @@ void DolphinView::updateViewState()
if (!m_selectedUrls.isEmpty()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
- if (m_clearSelectionBeforeSelectingNewItems) {
- selectionManager->clearSelection();
- m_clearSelectionBeforeSelectingNewItems = false;
- }
+ // if there is a selection already, leave it that way
+ if (!selectionManager->hasSelection()) {
+ if (m_clearSelectionBeforeSelectingNewItems) {
+ selectionManager->clearSelection();
+ m_clearSelectionBeforeSelectingNewItems = false;
+ }
- KItemSet selectedItems = selectionManager->selectedItems();
+ KItemSet selectedItems = selectionManager->selectedItems();
- QList<QUrl>::iterator it = m_selectedUrls.begin();
- while (it != m_selectedUrls.end()) {
- const int index = m_model->index(*it);
- if (index >= 0) {
- selectedItems.insert(index);
- it = m_selectedUrls.erase(it);
- } else {
- ++it;
+ QList<QUrl>::iterator it = m_selectedUrls.begin();
+ while (it != m_selectedUrls.end()) {
+ const int index = m_model->index(*it);
+ if (index >= 0) {
+ selectedItems.insert(index);
+ it = m_selectedUrls.erase(it);
+ } else {
+ ++it;
+ }
}
- }
- selectionManager->beginAnchoredSelection(selectionManager->currentItem());
- selectionManager->setSelectedItems(selectedItems);
+ selectionManager->beginAnchoredSelection(selectionManager->currentItem());
+ selectionManager->setSelectedItems(selectedItems);
+ }
}
}