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.
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
}
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);
}
}
const bool newSearch = m_searchedString.isEmpty();
+ // Do not start a new search if the user pressed Space. Only add
+ // it to the search string if a search is in progress already.
+ if (newSearch && keys == QLatin1String(" ")) {
+ return;
+ }
+
if (!keys.isEmpty()) {
m_searchedString.append(keys);
<< "b1"
<< "c1" << "c2" << "c3" << "c4" << "c5"
<< "d1" << "d2" << "d3" << "d4"
- << "e1" << "e2" << "e3" << "e4" << "e5" << "e6" << "e7";
+ << "e" << "e 2" << "e 3" << "e 4" << "e 5" << "e 6" << "e 7";
m_testDir->createFiles(files);
m_model->loadDirectory(m_testDir->url());
<< qMakePair(KeyPress(Qt::Key_Home), ViewState(0, QSet<int>() << 0))
<< qMakePair(KeyPress(Qt::Key_Space, Qt::ControlModifier), ViewState(0, QSet<int>()))
<< qMakePair(KeyPress(Qt::Key_Enter), ViewState(0, QSet<int>(), true))
- << qMakePair(KeyPress(Qt::Key_Space, Qt::ControlModifier), ViewState(0, QSet<int>() << 0));
+ << qMakePair(KeyPress(Qt::Key_Space, Qt::ControlModifier), ViewState(0, QSet<int>() << 0))
+ << qMakePair(KeyPress(Qt::Key_Space, Qt::ControlModifier), ViewState(0, QSet<int>()))
+ << qMakePair(KeyPress(Qt::Key_Space), ViewState(0, QSet<int>() << 0))
+ << qMakePair(KeyPress(Qt::Key_E), ViewState(13, QSet<int>() << 13))
+ << qMakePair(KeyPress(Qt::Key_Space), ViewState(14, QSet<int>() << 14))
+ << qMakePair(KeyPress(Qt::Key_3), ViewState(15, QSet<int>() << 15))
+ << qMakePair(KeyPress(Qt::Key_Home), ViewState(0, QSet<int>() << 0))
+ << qMakePair(KeyPress(Qt::Key_Escape), ViewState(0, QSet<int>()));
// Next, we test combinations of key presses which only work for a
// particular number of columns and either enabled or disabled grouping.