default: break;
}
}
-
- const bool selectSingleItem = itemCount == 1 &&
+
+ const bool selectSingleItem = m_selectionBehavior != NoSelection &&
+ itemCount == 1 &&
(key == Qt::Key_Home || key == Qt::Key_End ||
key == Qt::Key_Up || key == Qt::Key_Down ||
key == Qt::Key_Left || key == Qt::Key_Right);
switch (key) {
case Qt::Key_Home:
index = 0;
+ m_keyboardAnchorIndex = index;
+ m_keyboardAnchorPos = keyboardAnchorPos(index);
break;
case Qt::Key_End:
index = itemCount - 1;
+ m_keyboardAnchorIndex = index;
+ m_keyboardAnchorPos = keyboardAnchorPos(index);
break;
case Qt::Key_Left:
}
case Qt::Key_Space:
- 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);
+ 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;
}
if (m_selectionManager->currentItem() != index) {
- if (controlPressed) {
- m_selectionManager->endAnchoredSelection();
- }
-
- m_selectionManager->setCurrentItem(index);
+ switch (m_selectionBehavior) {
+ case NoSelection:
+ m_selectionManager->setCurrentItem(index);
+ break;
- if (!shiftOrControlPressed || m_selectionBehavior == SingleSelection) {
+ case SingleSelection:
+ m_selectionManager->setCurrentItem(index);
m_selectionManager->clearSelection();
m_selectionManager->setSelected(index, 1);
- }
+ break;
- if (!shiftPressed) {
- m_selectionManager->beginAnchoredSelection(index);
+ case MultiSelection:
+ if (controlPressed) {
+ m_selectionManager->endAnchoredSelection();
+ }
+
+ m_selectionManager->setCurrentItem(index);
+
+ if (!shiftOrControlPressed) {
+ m_selectionManager->clearSelection();
+ m_selectionManager->setSelected(index, 1);
+ }
+
+ if (!shiftPressed) {
+ m_selectionManager->beginAnchoredSelection(index);
+ }
+ break;
}
m_view->scrollToItem(index);
m_pressedMousePos = transform.map(event->pos());
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
- if (m_pressedIndex >= 0) {
- emit itemPressed(m_pressedIndex, event->button());
- }
+ emit mouseButtonPressed(m_pressedIndex, event->buttons());
if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) {
m_selectionManager->endAnchoredSelection();
return false;
}
- if (m_pressedIndex >= 0) {
- emit itemReleased(m_pressedIndex, event->button());
- }
+ emit mouseButtonReleased(m_pressedIndex, event->buttons());
const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
if (isAboveSelectionToggle) {
{
Q_UNUSED(event);
Q_UNUSED(transform);
+
+ m_view->setAutoScroll(false);
+
+ KItemListWidget* widget = hoveredWidget();
+ if (widget) {
+ widget->setHovered(false);
+ emit itemUnhovered(widget->index());
+ }
return false;
}
return false;
}
+ event->acceptProposedAction();
+
KItemListWidget* oldHoveredWidget = hoveredWidget();
const QPointF pos = transform.map(event->pos());
}
m_autoActivationTimer->stop();
+ m_view->setAutoScroll(false);
const QPointF pos = transform.map(event->pos());
const int index = m_view->itemAt(pos);