mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
3a2ceed33d
commit
e1dcd8eac3
2 changed files with 8 additions and 18 deletions
|
@ -544,8 +544,7 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent *event)
|
||||||
DiveHandler::DiveHandler() : QGraphicsEllipseItem()
|
DiveHandler::DiveHandler() : QGraphicsEllipseItem()
|
||||||
{
|
{
|
||||||
setRect(-5, -5, 10, 10);
|
setRect(-5, -5, 10, 10);
|
||||||
setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable);
|
|
||||||
setBrush(Qt::white);
|
setBrush(Qt::white);
|
||||||
setZValue(2);
|
setZValue(2);
|
||||||
}
|
}
|
||||||
|
@ -587,21 +586,12 @@ void DiveHandler::changeGas()
|
||||||
plannerModel->setData(index, action->text());
|
plannerModel->setData(index, action->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
QVariant DiveHandler::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (event->button() != Qt::LeftButton)
|
if (change == ItemPositionHasChanged && scene()) {
|
||||||
return;
|
emit moved();
|
||||||
|
|
||||||
if (event->modifiers().testFlag(Qt::ControlModifier)) {
|
|
||||||
setSelected(true);
|
|
||||||
}
|
}
|
||||||
// mousePressEvent 'grabs' the mouse and keyboard, annoying.
|
return QGraphicsItem::itemChange(change, value);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent),
|
Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent),
|
||||||
|
|
|
@ -139,9 +139,10 @@ public:
|
||||||
DiveHandler();
|
DiveHandler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||||
|
signals:
|
||||||
|
void moved();
|
||||||
private:
|
private:
|
||||||
int parentIndex();
|
int parentIndex();
|
||||||
public
|
public
|
||||||
|
@ -161,7 +162,6 @@ protected:
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
virtual void mousePressEvent(QMouseEvent *event);
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||||
bool isPointOutOfBoundaries(const QPointF &point);
|
|
||||||
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
|
|
Loading…
Add table
Reference in a new issue