DolphinController* controller = m_view->m_controller;
controller->handleKeyPressEvent(event);
- if (event->key() == Qt::Key_Right) {
+ switch (event->key()) {
+ case Qt::Key_Right: {
// Special key handling for the column: A Key_Right should
// open a new column for the currently selected folder.
const QModelIndex index = currentIndex();
if (!item.isNull() && item.isDir()) {
controller->emitItemTriggered(item);
}
+ break;
+ }
+
+ case Qt::Key_Escape:
+ selectionModel()->setCurrentIndex(selectionModel()->currentIndex(),
+ QItemSelectionModel::Current |
+ QItemSelectionModel::Clear);
+ break;
+
+ default:
+ break;
}
if (m_toolTipManager != 0) {
void DolphinView::clearSelection()
{
- itemView()->selectionModel()->clear();
+ QItemSelectionModel* selModel = itemView()->selectionModel();
+ const QModelIndex currentIndex = selModel->currentIndex();
+ selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current |
+ QItemSelectionModel::Clear);
}
KFileItemList DolphinView::selectedItems() const
break;
case QEvent::KeyPress:
- if ((watched == itemView()) && (m_toolTipManager != 0)) {
- m_toolTipManager->hideTip();
+ if (watched == itemView()) {
+ if (m_toolTipManager != 0) {
+ m_toolTipManager->hideTip();
+ }
+
+ // clear the selection when Escape has been pressed
+ QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
+ if (keyEvent->key() == Qt::Key_Escape) {
+ clearSelection();
+ }
}
break;