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);
}
}
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
emit mouseButtonPressed(m_pressedIndex, event->buttons());
+ if ((event->buttons() & (Qt::XButton1 | Qt::XButton2)) && m_pressedIndex < 0) {
+ // Do not select items when clicking the empty part of the view with
+ // the back/forward buttons, see https://bugs.kde.org/show_bug.cgi?id=327412.
+ // Note that clicking an item with these buttons selects it, see comment in
+ // DolphinView::slotMouseButtonPressed(int, Qt::MouseButtons).
+ return true;
+ }
+
if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) {
m_selectionManager->endAnchoredSelection();
m_selectionManager->setCurrentItem(m_pressedIndex);
oldHoveredWidget->setHovered(false);
emit itemUnhovered(oldHoveredWidget->index());
}
+ }
- if (newHoveredWidget) {
- bool droppingBetweenItems = false;
- if (m_model->sortRole().isEmpty()) {
- // The model supports inserting items between other items.
- droppingBetweenItems = (m_view->showDropIndicator(pos) >= 0);
- }
+ if (newHoveredWidget) {
+ bool droppingBetweenItems = false;
+ if (m_model->sortRole().isEmpty()) {
+ // The model supports inserting items between other items.
+ droppingBetweenItems = (m_view->showDropIndicator(pos) >= 0);
+ }
- const int index = newHoveredWidget->index();
- if (!droppingBetweenItems && m_model->supportsDropping(index)) {
+ const int index = newHoveredWidget->index();
+ if (!droppingBetweenItems) {
+ if (m_model->supportsDropping(index)) {
// Something has been dragged on an item.
m_view->hideDropIndicator();
- newHoveredWidget->setHovered(true);
- emit itemHovered(index);
+ if (!newHoveredWidget->isHovered()) {
+ newHoveredWidget->setHovered(true);
+ emit itemHovered(index);
+ }
- if (m_autoActivationTimer->interval() >= 0) {
+ if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0) {
m_autoActivationTimer->setProperty("index", index);
m_autoActivationTimer->start();
}
}
+ } else {
+ m_autoActivationTimer->stop();
+ if (newHoveredWidget && newHoveredWidget->isHovered()) {
+ newHoveredWidget->setHovered(false);
+ emit itemUnhovered(index);
+ }
}
+ } else {
+ m_view->hideDropIndicator();
}
return false;