aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:16:42 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:16:42 -0300
commit932ee3da94856401477f1b3f1d58c26841f2bce8 (patch)
treefd9559cd2c187d3ae99532c46afaae7690876a65 /qt-ui/diveplanner.cpp
parentc23dd354b9811956407da6d2eca3edbcc4999127 (diff)
downloadsubsurface-932ee3da94856401477f1b3f1d58c26841f2bce8.tar.gz
Added a 'delete' action, with the keyboard.
Added a delete action from the keyboard, there's also a possibility to add the same action from the menu, but I frankly don't like much the idea. so, to delete a handler now, you need to select it ( ctrl + click ) then press the delete button. Multiple delection is also possible. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 016a47e04..6a721adf0 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -124,16 +124,36 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
minMinutes = TIME_INITIAL_MAX;
- QAction *escAction = new QAction(this);
- escAction->setShortcut(Qt::Key_Escape);
- escAction->setShortcutContext(Qt::ApplicationShortcut);
- addAction(escAction);
+ QAction *action = NULL;
- connect(escAction, SIGNAL(triggered(bool)), this, SLOT(keyEscAction()));
+#define ADD_ACTION( SHORTCUT, Slot ) \
+ action = new QAction(this); \
+ action->setShortcut( SHORTCUT ); \
+ action->setShortcutContext(Qt::ApplicationShortcut); \
+ addAction(action); \
+ connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot ))
+
+ ADD_ACTION(Qt::Key_Escape, keyEscAction());
+ ADD_ACTION(Qt::Key_Delete, keyDeleteAction());
+#undef ADD_ACTION
setRenderHint(QPainter::Antialiasing);
}
+void DivePlannerGraphics::keyDeleteAction()
+{
+ if(scene()->selectedItems().count()){
+ Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){
+ if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){
+ handles.removeAll(handler);
+ scene()->removeItem(handler);
+ delete i;
+ }
+ }
+ createDecoStops();
+ }
+}
+
void DivePlannerGraphics::keyEscAction()
{
if (scene()->selectedItems().count()){