mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c23dd354b9
commit
932ee3da94
2 changed files with 26 additions and 5 deletions
|
@ -124,16 +124,36 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
|
|
||||||
minMinutes = TIME_INITIAL_MAX;
|
minMinutes = TIME_INITIAL_MAX;
|
||||||
|
|
||||||
QAction *escAction = new QAction(this);
|
QAction *action = NULL;
|
||||||
escAction->setShortcut(Qt::Key_Escape);
|
|
||||||
escAction->setShortcutContext(Qt::ApplicationShortcut);
|
|
||||||
addAction(escAction);
|
|
||||||
|
|
||||||
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);
|
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()
|
void DivePlannerGraphics::keyEscAction()
|
||||||
{
|
{
|
||||||
if (scene()->selectedItems().count()){
|
if (scene()->selectedItems().count()){
|
||||||
|
|
|
@ -78,6 +78,7 @@ protected:
|
||||||
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
||||||
private slots:
|
private slots:
|
||||||
void keyEscAction();
|
void keyEscAction();
|
||||||
|
void keyDeleteAction();
|
||||||
void increaseTime();
|
void increaseTime();
|
||||||
void increaseDepth();
|
void increaseDepth();
|
||||||
void okClicked();
|
void okClicked();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue