From 88fa6272582e82825a9ce48319661c4301653db3 Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Fri, 6 Feb 2015 14:19:04 +0300 Subject: Delete dives using delete key Allow users to delete dives using the delete key. [Dirk Hohndel: small whitespace fix; removed an unnecessary include file] Signed-off-by: Grace Karanja Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index d4e744237..ec54af906 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -84,6 +84,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec header()->setStretchLastSection(true); + + installEventFilter(this); } DiveListView::~DiveListView() @@ -343,6 +345,10 @@ bool DiveListView::eventFilter(QObject *, QEvent *event) if (event->type() != QEvent::KeyPress) return false; QKeyEvent *keyEv = static_cast(event); + if (keyEv->key() == Qt::Key_Delete) { + contextMenuIndex = currentIndex(); + deleteDive(); + } if (keyEv->key() != Qt::Key_Escape) return false; return true; -- cgit v1.2.3-70-g09d2