File Fix-selection-when-navigating-back-with-size-sorting.patch of Package kdebase4

From 6100f66ae2ba5ae50c2fcc263b6faaa695d37948 Mon Sep 17 00:00:00 2001
From: Thomas Surrel <thomas.surrel@protonmail.com>
Date: Tue, 20 Nov 2018 12:10:15 +0100
Subject: Fix selection when navigating back, with size sorting.

Summary:
KItemListSelectionManager::itemsMoved (called when sorting by size)
was re-activating anchor selection regardless if we actually were
doing an anchored selection. This was leading to an incorrect
selection when navigating back.

BUG: 352296

Test Plan:
In any folder, sort by size then move to a subfolder. Navigate back
to the parent folder: only the parent folder should be selected.

Reviewers: #dolphin, elvisangelaccio

Reviewed By: #dolphin, elvisangelaccio

Subscribers: elvisangelaccio, broulik, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D17042
---
 dolphin/src/kitemviews/kitemlistselectionmanager.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dolphin/src/kitemviews/kitemlistselectionmanager.cpp b/dolphin/src/kitemviews/kitemlistselectionmanager.cpp
index f5e097c..d16c5e2 100644
--- a/dolphin/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/dolphin/src/kitemviews/kitemlistselectionmanager.cpp
@@ -331,6 +331,9 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
     // Store the current selection (needed in the selectionChanged() signal)
     const KItemSet previousSelection = selectedItems();
 
+    // Store whether we were doing an anchored selection
+    const bool wasInAnchoredSelection = isAnchoredSelectionActive();
+
     // endAnchoredSelection() adds all items between m_currentItem and
     // m_anchorItem to m_selectedItems. They can then be moved
     // individually later in this function.
@@ -348,7 +351,9 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
     }
 
     // Start a new anchored selection.
-    beginAnchoredSelection(m_currentItem);
+    if (wasInAnchoredSelection) {
+        beginAnchoredSelection(m_currentItem);
+    }
 
     // Update the selections
     if (!m_selectedItems.isEmpty()) {
-- 
cgit v1.1

openSUSE Build Service is sponsored by