┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-26 18:39:32 +0200
committerFrank Reininghaus <[email protected]>2011-08-26 18:39:32 +0200
commitea765ba5737074dcffc67be20d33a7f01890dd7f (patch)
tree186a9788ce9a3870586d69bcc65904b01484c72a /src/kitemviews
parentb43316297edb9e84b894ef60ed2ea10c440d47e3 (diff)
Simplify KItemListSelectionManager
1. The anchorChanged() signal is not needed. 2. The only place where setAnchorItem() is called is in beginAnchoredSelection() -> merge both functions.
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistselectionmanager.cpp28
-rw-r--r--src/kitemviews/kitemlistselectionmanager.h10
2 files changed, 2 insertions, 36 deletions
diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp
index 764227004..3c7b94965 100644
--- a/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/src/kitemviews/kitemlistselectionmanager.cpp
@@ -160,8 +160,7 @@ void KItemListSelectionManager::beginAnchoredSelection(int anchor)
{
if (anchor >= 0 && m_model && anchor < m_model->count()) {
m_isAnchoredSelectionActive = true;
- setAnchorItem(anchor);
- Q_ASSERT(m_anchorItem >= 0);
+ m_anchorItem = anchor;
}
}
@@ -181,24 +180,6 @@ void KItemListSelectionManager::endAnchoredSelection()
m_isAnchoredSelectionActive = false;
}
-void KItemListSelectionManager::setAnchorItem(int anchor)
-{
- if (!m_isAnchoredSelectionActive) {
- return;
- }
-
- if (anchor < 0 || (m_model && anchor >= m_model->count())) {
- // Index is out of range
- return;
- }
-
- if (m_anchorItem != anchor) {
- const int previous = m_anchorItem;
- m_anchorItem = anchor;
- emit anchorChanged(m_anchorItem, previous);
- }
-}
-
int KItemListSelectionManager::anchorItem() const
{
return m_anchorItem;
@@ -247,9 +228,8 @@ void KItemListSelectionManager::itemsInserted(const KItemRangeList& itemRanges)
// Update the anchor item
if (m_anchorItem < 0) {
- setAnchorItem(0);
+ m_anchorItem = 0;
} else {
- const int previousAnchor = m_anchorItem;
int inc = 0;
foreach (const KItemRange& itemRange, itemRanges) {
if (m_anchorItem < itemRange.index) {
@@ -258,7 +238,6 @@ void KItemListSelectionManager::itemsInserted(const KItemRangeList& itemRanges)
inc += itemRange.count;
}
m_anchorItem += inc;
- emit anchorChanged(m_anchorItem, previousAnchor);
}
// Update the selections
@@ -312,7 +291,6 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges)
// Update the anchor item
if (m_anchorItem >= 0) {
- const int previousAnchor = m_anchorItem;
int anchorItem = m_anchorItem;
foreach (const KItemRange& itemRange, itemRanges) {
if (anchorItem < itemRange.index) {
@@ -328,8 +306,6 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges)
if (m_anchorItem < 0) {
m_isAnchoredSelectionActive = false;
}
-
- emit anchorChanged(m_anchorItem, previousAnchor);
}
// Update the selections
diff --git a/src/kitemviews/kitemlistselectionmanager.h b/src/kitemviews/kitemlistselectionmanager.h
index f8c33bb79..2761940f5 100644
--- a/src/kitemviews/kitemlistselectionmanager.h
+++ b/src/kitemviews/kitemlistselectionmanager.h
@@ -61,16 +61,7 @@ public:
void beginAnchoredSelection(int anchor);
void endAnchoredSelection();
-
- /**
- * Sets the anchor to \a anchor and emits anchorChanged() if the
- * anchor differs from the current anchor value. If no anchor selection is active (see
- * KItemListSelectionManager::beginAnchoredSelection()) or the index
- * is not within the available model items the anchor will not be modified.
- */
- void setAnchorItem(int anchor);
int anchorItem() const;
-
bool isAnchoredSelectionActive() const;
KItemModelBase* model() const;
@@ -78,7 +69,6 @@ public:
signals:
void currentChanged(int current, int previous);
void selectionChanged(const QSet<int>& current, const QSet<int>& previous);
- void anchorChanged(int anchor, int previous);
private:
void setModel(KItemModelBase* model);