┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-11 14:20:12 +0200
committerFrank Reininghaus <[email protected]>2011-08-11 14:23:53 +0200
commit9b83d15be44d698c26b55bf8cbc126321f5a4e9b (patch)
tree20f0ae54a5562cd5a58fad653d9c03c168f5b582 /src/kitemviews
parent01ff60edeea76f77a5c4684d1f674efb81418faa (diff)
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.
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistselectionmanager.cpp4
1 files changed, 2 insertions, 2 deletions
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<int> KItemListSelectionManager::selectedItems() const
{
QSet<int> 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<int> 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)