diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-05-23 19:50:09 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 07:26:53 -0700 |
commit | e1dcd8eac32e2e7d606f5bc82106cde07984b42a (patch) | |
tree | a485f8111917ba8ab9ae84e6d6eed3b46ea01d12 /qt-ui/diveplanner.cpp | |
parent | 3a2ceed33d5fcb706a1790fa80fad322dba33556 (diff) | |
download | subsurface-e1dcd8eac32e2e7d606f5bc82106cde07984b42a.tar.gz |
Change how the handler handlers itself.
This patch adds a itemChange method, that emits a 'changed'
signal when the handler is moved. I'll use that signal on
the profile to call the correct method.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 |
1 files changed, 5 insertions, 15 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), |