mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Enable a context menu to remove dive handlers.
This commit enables a context menu to remove dive handlers, because it was hard to find that ctrl+click selected it, then a delete button press removed it. it's better now. :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3302ee11c1
commit
cec30c27d9
2 changed files with 31 additions and 7 deletions
|
@ -673,11 +673,13 @@ void DivePlannerGraphics::mousePressEvent(QMouseEvent* event)
|
|||
}
|
||||
|
||||
QPointF mappedPos = mapToScene(event->pos());
|
||||
Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())) {
|
||||
if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) {
|
||||
activeDraggedHandler = h;
|
||||
activeDraggedHandler->setBrush(Qt::red);
|
||||
originalHandlerPos = activeDraggedHandler->pos();
|
||||
if (event->button() == Qt::LeftButton){
|
||||
Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())) {
|
||||
if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) {
|
||||
activeDraggedHandler = h;
|
||||
activeDraggedHandler->setBrush(Qt::red);
|
||||
originalHandlerPos = activeDraggedHandler->pos();
|
||||
}
|
||||
}
|
||||
}
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
|
@ -703,8 +705,25 @@ DiveHandler::DiveHandler(): QGraphicsEllipseItem()
|
|||
setZValue(2);
|
||||
}
|
||||
|
||||
void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
|
||||
{
|
||||
QMenu m;
|
||||
m.addAction(QObject::tr("Remove this Point"), this, SLOT(selfRemove()));
|
||||
m.exec(event->screenPos());
|
||||
}
|
||||
|
||||
void DiveHandler::selfRemove()
|
||||
{
|
||||
setSelected(true);
|
||||
DivePlannerGraphics *view = qobject_cast<DivePlannerGraphics*>(scene()->views().first());
|
||||
view->keyDeleteAction();
|
||||
}
|
||||
|
||||
void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
setSelected(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue