X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/504545c59ab0cd99f782cbb2afd8c2a983c9adfc..78540e49213ed1a03687d55063816659c9142eba:/src/kitemviews/kitemlistselectionmanager.cpp diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp index 5d7b08eeb..d16c5e2d3 100644 --- a/src/kitemviews/kitemlistselectionmanager.cpp +++ b/src/kitemviews/kitemlistselectionmanager.cpp @@ -23,8 +23,6 @@ #include "kitemlistselectionmanager.h" -#include "kitemmodelbase.h" - KItemListSelectionManager::KItemListSelectionManager(QObject* parent) : QObject(parent), m_currentItem(-1), @@ -237,6 +235,9 @@ void KItemListSelectionManager::itemsInserted(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 += inc; + if (m_currentItem >= m_model->count()) { + m_currentItem = -1; + } emit currentChanged(m_currentItem, previousCurrent); } @@ -330,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. @@ -347,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()) {