Dear all,

This patch allows the user to delete dives using the delete key.


-
Grace K
From f0fa09d24263101c9c156e647eb1cc124e96acf7 Mon Sep 17 00:00:00 2001
From: Grace Karanja <[email protected]>
Date: Fri, 6 Feb 2015 14:15:22 +0300
Subject: [PATCH] Delete dives using delete key

Allow users to delete dives using the delete key.

Signed-off-by: Grace Karanja <[email protected]>
---
 qt-ui/divelistview.cpp | 6 ++++++
 qt-ui/divelistview.h   | 1 +
 2 files changed, 7 insertions(+)

diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index d4e7442..a889af8 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<QKeyEvent *>(event);
+        if (keyEv->key() == Qt::Key_Delete) {
+                contextMenuIndex = currentIndex();
+                deleteDive();
+        }
 	if (keyEv->key() != Qt::Key_Escape)
 		return false;
 	return true;
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index a6522fa..f375d27 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -13,6 +13,7 @@
 
 #include <QTreeView>
 #include <QLineEdit>
+#include <QKeyEvent>
 #include "models.h"
 
 class DiveListView : public QTreeView {
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to