┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistselectionmanager.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-10 15:21:26 +0200
committerFrank Reininghaus <[email protected]>2011-08-10 15:21:26 +0200
commita03f7dcd22ae9e2a60f5998e23762dbf2d14b41e (patch)
tree6fe4bfd70c42cabb4d2d4cf27641d2bebc879efb /src/kitemviews/kitemlistselectionmanager.cpp
parent6d6fe76dcf46ae71e31d730981118cdcddb16f8b (diff)
Implement beginAnchoredSelection() and endAnchoredSelection().
Unit test included.
Diffstat (limited to 'src/kitemviews/kitemlistselectionmanager.cpp')
-rw-r--r--src/kitemviews/kitemlistselectionmanager.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp
index 26ce1b2f7..18fa2f660 100644
--- a/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/src/kitemviews/kitemlistselectionmanager.cpp
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2011 by Peter Penz <[email protected]> *
+ * Copyright (C) 2011 by Frank Reininghaus <[email protected]> *
* *
* Based on the Itemviews NG project from Trolltech Labs: *
* http://qt.gitorious.org/qt-labs/itemviews-ng *
@@ -149,11 +150,22 @@ void KItemListSelectionManager::clearSelection()
void KItemListSelectionManager::beginAnchoredSelection(int anchor)
{
- Q_UNUSED(anchor);
+ m_isAnchoredSelectionActive = true;
+ setAnchorItem(anchor);
}
void KItemListSelectionManager::endAnchoredSelection()
{
+ if (m_isAnchoredSelectionActive) {
+ const int from = qMin(m_anchorItem, m_currentItem);
+ const int to = qMax(m_anchorItem, m_currentItem);
+
+ for (int index = from; index <= to; index++) {
+ m_selectedItems.insert(index);
+ }
+
+ m_isAnchoredSelectionActive = false;
+ }
}
void KItemListSelectionManager::setAnchorItem(int anchor)