diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 6 |
2 files changed, 8 insertions, 18 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d081d0d96..b7a3f0153 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -544,8 +544,7 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent *event) DiveHandler::DiveHandler() : QGraphicsEllipseItem() { setRect(-5, -5, 10, 10); - setFlag(QGraphicsItem::ItemIgnoresTransformations); - setFlag(QGraphicsItem::ItemIsSelectable); + setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); setBrush(Qt::white); setZValue(2); } @@ -587,21 +586,12 @@ void DiveHandler::changeGas() plannerModel->setData(index, action->text()); } -void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event) +QVariant DiveHandler::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { - if (event->button() != Qt::LeftButton) - return; - - if (event->modifiers().testFlag(Qt::ControlModifier)) { - setSelected(true); + if (change == ItemPositionHasChanged && scene()) { + emit moved(); } - // mousePressEvent 'grabs' the mouse and keyboard, annoying. - ungrabMouse(); - - /* hack. Sometimes the keyboard is grabbed, sometime it's not, - so, let's force a grab and release, to get rid of a warning. */ - grabKeyboard(); - ungrabKeyboard(); + return QGraphicsItem::itemChange(change, value); } Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent), diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 0166e433b..b68605537 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -139,9 +139,10 @@ public: DiveHandler(); protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); +signals: + void moved(); private: int parentIndex(); public @@ -161,7 +162,6 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); - bool isPointOutOfBoundaries(const QPointF &point); qreal fromPercent(qreal percent, Qt::Orientation orientation); public slots: |