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);
|
||||
}
|
||||
|
|
|
@ -95,11 +95,15 @@ private:
|
|||
QGraphicsSimpleTextItem *text;
|
||||
};
|
||||
|
||||
class DiveHandler : public QGraphicsEllipseItem{
|
||||
class DiveHandler : public QObject, public QGraphicsEllipseItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveHandler();
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
|
||||
public slots:
|
||||
void selfRemove();
|
||||
};
|
||||
|
||||
class Ruler : public QGraphicsLineItem{
|
||||
|
@ -118,7 +122,6 @@ public:
|
|||
qreal posAtValue(qreal value);
|
||||
void setColor(const QColor& color);
|
||||
void setTextColor(const QColor& color);
|
||||
|
||||
private:
|
||||
Qt::Orientation orientation;
|
||||
QList<QGraphicsLineItem*> ticks;
|
||||
|
@ -210,6 +213,8 @@ private:
|
|||
|
||||
int minMinutes; // this holds the minimum duration of the dive.
|
||||
int dpMaxTime; // this is the time of the dive calculated by the deco.
|
||||
|
||||
friend class DiveHandler;
|
||||
};
|
||||
|
||||
#include "ui_diveplanner.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue