From a9cd53878646dbb8916d1197cff526d3a5ef87a5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 16:17:41 +0200 Subject: [PATCH] Instead of mouse move event, use the itemChange handler to move the links. --HG-- branch : dfighter-tools --- .../src/plugins/gui_editor/expression_node.cpp | 16 ++++++++++++---- .../src/plugins/gui_editor/expression_node.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index 8f3425a37..8a0ef774b 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -101,7 +101,7 @@ private: ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) : QGraphicsItem( parent ) { - setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); + setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsScenePositionChanges ); m_w = 100; m_h = 100; @@ -323,7 +323,17 @@ QString ExpressionNode::build() const return result; } -void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) +QVariant ExpressionNode::itemChange( GraphicsItemChange change, const QVariant &value ) +{ + if( change == ItemScenePositionHasChanged ) + { + onNodeMove(); + } + + return QGraphicsItem::itemChange( change, value ); +} + +void ExpressionNode::onNodeMove() { for( int i = 0; i < m_links.count(); i++ ) { @@ -333,8 +343,6 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e ) link->nodeMoved(); } - - QGraphicsItem::mouseMoveEvent( e ); } void ExpressionNode::createSlots( int count) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index c2fa739de..1e0290344 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -68,9 +68,10 @@ public: QString build() const; protected: - void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); + QVariant itemChange( GraphicsItemChange change, const QVariant &value ); private: + void onNodeMove(); void createSlots( int count = 3 ); void paintSlots( QPainter *painter );