From 9b83d15be44d698c26b55bf8cbc126321f5a4e9b Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Thu, 11 Aug 2011 14:20:12 +0200 Subject: Test signal emission on selection changes This commit adds a unit test that changes the selection in various ways, verifies the result and checks that the selection manager's selectionChanged signal has been emitted correctly. The test is data-driven, so I hope that most further testing needs can be fulfilled by adding new test data. Moreover, I changed selectedItems() such that the anchored selection is only taken into account if anchor and current item are different. The reason is that in some situation the anchor should not be selected initially (i.e., if an already selected item is Control-clicked). If the anchor should be selected from the beginning, it must be selected manually. --- src/kitemviews/kitemlistselectionmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/kitemviews/kitemlistselectionmanager.cpp') diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp index cfe847b69..e0ec4060c 100644 --- a/src/kitemviews/kitemlistselectionmanager.cpp +++ b/src/kitemviews/kitemlistselectionmanager.cpp @@ -81,7 +81,7 @@ QSet KItemListSelectionManager::selectedItems() const { QSet selectedItems = m_selectedItems; - if (m_isAnchoredSelectionActive) { + if (m_isAnchoredSelectionActive && (m_anchorItem != m_currentItem)) { const int from = qMin(m_anchorItem, m_currentItem); const int to = qMax(m_anchorItem, m_currentItem); @@ -95,7 +95,7 @@ QSet KItemListSelectionManager::selectedItems() const bool KItemListSelectionManager::hasSelection() const { - return !m_selectedItems.isEmpty() || m_isAnchoredSelectionActive; + return !m_selectedItems.isEmpty() || (m_isAnchoredSelectionActive && (m_anchorItem != m_currentItem)); } void KItemListSelectionManager::setSelected(int index, int count, SelectionMode mode) -- cgit v1.3