┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontroller.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-10-07 09:31:45 +0200
committerFrank Reininghaus <[email protected]>2013-10-07 09:31:45 +0200
commitb4efdc620e8ce7571b45d7bfe22f30271871b9f9 (patch)
tree30f3c5e35a8f3c923c8a12b887d3421b465e3aa5 /src/kitemviews/kitemlistcontroller.cpp
parent9f24c02a752584fc3ef82063d42262f91b493eae (diff)
parent5bfb5031a593fbd7e0a60bd8ca869671c712db9d (diff)
Merge remote-tracking branch 'origin/KDE/4.11'
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 4629b29f1..9335ab816 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -375,19 +375,6 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
break;
}
- case Qt::Key_Space:
- if (m_selectionBehavior == MultiSelection) {
- if (controlPressed) {
- m_selectionManager->endAnchoredSelection();
- m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle);
- m_selectionManager->beginAnchoredSelection(index);
- } else {
- const int current = m_selectionManager->currentItem();
- m_selectionManager->setSelected(current);
- }
- }
- break;
-
case Qt::Key_Menu: {
// Emit the signal itemContextMenuRequested() in case if at least one
// item is selected. Otherwise the signal viewContextMenuRequested() will be emitted.
@@ -418,6 +405,25 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
m_keyboardManager->cancelSearch();
break;
+ case Qt::Key_Space:
+ if (m_selectionBehavior == MultiSelection) {
+ if (controlPressed) {
+ // Toggle the selection state of the current item.
+ m_selectionManager->endAnchoredSelection();
+ m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->beginAnchoredSelection(index);
+ break;
+ } else {
+ // Select the current item if it is not selected yet.
+ const int current = m_selectionManager->currentItem();
+ if (!m_selectionManager->isSelected(current)) {
+ m_selectionManager->setSelected(current);
+ break;
+ }
+ }
+ }
+ // Fall through to the default case and add the Space to the current search string.
+
default:
m_keyboardManager->addKeys(event->text());
// Make sure unconsumed events get propagated up the chain. #302329
@@ -474,9 +480,13 @@ void KItemListController::slotChangeCurrentItem(const QString& text, bool search
}
if (index >= 0) {
m_selectionManager->setCurrentItem(index);
- m_selectionManager->clearSelection();
- m_selectionManager->setSelected(index, 1);
- m_selectionManager->beginAnchoredSelection(index);
+
+ if (m_selectionBehavior != NoSelection) {
+ m_selectionManager->clearSelection();
+ m_selectionManager->setSelected(index, 1);
+ m_selectionManager->beginAnchoredSelection(index);
+ }
+
m_view->scrollToItem(index);
}
}