From: Peter Penz Date: Sun, 22 Feb 2009 14:07:46 +0000 (+0000) Subject: clear the selection when Escape has been pressed (= same behavior like in Konqueror... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e4f376d25a133894383f6f032cc69aad739698c6 clear the selection when Escape has been pressed (= same behavior like in Konqueror for KDE 3) BUG: 185184 svn path=/trunk/KDE/kdebase/apps/; revision=929983 --- diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index 5ef86a29d..d65e9aa57 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -393,7 +393,8 @@ void DolphinColumnWidget::keyPressEvent(QKeyEvent* event) 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(); @@ -401,6 +402,17 @@ void DolphinColumnWidget::keyPressEvent(QKeyEvent* event) 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) { diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 770bab1f7..f40accdde 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -314,7 +314,10 @@ bool DolphinView::hasSelection() const 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 @@ -866,8 +869,16 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) 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(event); + if (keyEvent->key() == Qt::Key_Escape) { + clearSelection(); + } } break;