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>
This commit is contained in:
Tomaz Canabrava 2013-07-04 11:28:39 -03:00
parent 932ee3da94
commit 52fd769efb
2 changed files with 37 additions and 0 deletions

View file

@ -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()){

View file

@ -79,6 +79,8 @@ protected:
private slots:
void keyEscAction();
void keyDeleteAction();
void keyUpAction();
void keyDownAction();
void increaseTime();
void increaseDepth();
void okClicked();