summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:28:39 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:28:39 -0300
commit52fd769efb1678d64d2a09b0b022e0484bf2d1b8 (patch)
tree0fd93a2035087635d06dcca4fe9c2af3b0527f63 /qt-ui
parent932ee3da94856401477f1b3f1d58c26841f2bce8 (diff)
downloadsubsurface-52fd769efb1678d64d2a09b0b022e0484bf2d1b8.tar.gz
Added 'up' and 'down' actions on the dive planner.
Added 'up' and 'down' keyboard actions on the dive planner, you need to select the handlers with ctrl + click, then press up to make the handler go 1m up, or down, to make the handler go 1m down. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp35
-rw-r--r--qt-ui/diveplanner.h2
2 files changed, 37 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 6a721adf0..083ddcfe8 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -135,11 +135,46 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
ADD_ACTION(Qt::Key_Escape, keyEscAction());
ADD_ACTION(Qt::Key_Delete, keyDeleteAction());
+ ADD_ACTION(Qt::Key_Up, keyUpAction());
+ ADD_ACTION(Qt::Key_Down, keyDownAction());
#undef ADD_ACTION
setRenderHint(QPainter::Antialiasing);
}
+void DivePlannerGraphics::keyDownAction()
+{
+ if(scene()->selectedItems().count()){
+ Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){
+ if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){
+ if (handler->mm / 1000 >= depthLine->maximum())
+ continue;
+
+ handler->mm += 1000;
+ double ypos = depthLine->posAtValue(handler->mm / 1000);
+ handler->setPos(handler->pos().x(), ypos);
+ }
+ }
+ createDecoStops();
+ }
+}
+
+void DivePlannerGraphics::keyUpAction()
+{
+ Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){
+ if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){
+ if (handler->mm / 1000 <= 0)
+ continue;
+
+ handler->mm -= 1000;
+ double ypos = depthLine->posAtValue(handler->mm / 1000);
+ handler->setPos(handler->pos().x(), ypos);
+ }
+ }
+ createDecoStops();
+}
+
+
void DivePlannerGraphics::keyDeleteAction()
{
if(scene()->selectedItems().count()){
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index c6869feb4..5ea9f0dab 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -79,6 +79,8 @@ protected:
private slots:
void keyEscAction();
void keyDeleteAction();
+ void keyUpAction();
+ void keyDownAction();
void increaseTime();
void increaseDepth();
void okClicked();