const QPointF pos = transform.map(event->pos());
const std::optional<int> index = m_view->itemAt(pos);
+ if (event->button() & (Qt::ForwardButton | Qt::BackButton)) {
+ // "Forward" and "Back" are reserved for quickly navigating through the
+ // history. Double-clicking those buttons should be interpreted as two
+ // separate button presses. We arrive here for the second click, which
+ // we now react to just as we would for a singular click
+ Q_EMIT mouseButtonPressed(index.value_or(-1), event->button());
+ return false;
+ }
+
+ if (!index.has_value()) {
+ Q_EMIT doubleClickViewBackground(event->button());
+ return false;
+ }
+
// Expand item if desired - See Bug 295573
if (m_mouseDoubleClickAction != ActivateItemOnly) {
if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index.value_or(-1))) {
}
}
- if (event->button() & Qt::RightButton) {
+ if (event->button() & ~Qt::LeftButton) {
return false;
}
const bool emitItemActivated = index.has_value() && index.value() < m_model->count() && !m_view->isAboveExpansionToggle(index.value(), pos);
if (emitItemActivated) {
+ if (!QApplication::keyboardModifiers()) {
+ m_selectionManager->clearSelection(); // The user does not want to manage/manipulate the item currently, only activate it.
+ }
Q_EMIT itemActivated(index.value());
}
return false;
// or we just keep going for double-click activation
if (m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) {
if (!pressedItemAlreadySelected) {
- // An unselected item was clicked directly while deselecting multiple other items so we select it.
- m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
+ // An unselected item was clicked directly while deselecting multiple other items so we mark it "current".
m_selectionManager->setCurrentItem(m_pressedIndex.value());
m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
+ if (!leftClick) {
+ // We select the item here because this press is not meant to directly activate the item.
+ // We do not want to select items unless the user wants to edit them.
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
+ }
}
return true; // event handled, don't create rubber band
}
break;
case SingleSelection:
- m_selectionManager->setSelected(m_pressedIndex.value());
+ if (!leftClick || shiftOrControlPressed
+ || (!m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) && !m_singleClickActivationEnforced)) {
+ m_selectionManager->setSelected(m_pressedIndex.value());
+ }
break;
case MultiSelection:
}
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
// Select the pressed item and start a new anchored selection
- m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);
+ if (!leftClick || shiftOrControlPressed
+ || (!m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) && !m_singleClickActivationEnforced)) {
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);
+ }
m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
}
break;