mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 12:50:53 +00:00
Instead of mouse move event, use the itemChange handler to move the links.
This commit is contained in:
parent
fee6b431a0
commit
7b5bed2442
2 changed files with 14 additions and 5 deletions
|
@ -101,7 +101,7 @@ private:
|
||||||
ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) :
|
ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) :
|
||||||
QGraphicsItem( parent )
|
QGraphicsItem( parent )
|
||||||
{
|
{
|
||||||
setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsScenePositionChanges );
|
||||||
|
|
||||||
m_w = 100;
|
m_w = 100;
|
||||||
m_h = 100;
|
m_h = 100;
|
||||||
|
@ -323,7 +323,17 @@ QString ExpressionNode::build() const
|
||||||
return result;
|
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++ )
|
for( int i = 0; i < m_links.count(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -333,8 +343,6 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
||||||
|
|
||||||
link->nodeMoved();
|
link->nodeMoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem::mouseMoveEvent( e );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionNode::createSlots( int count)
|
void ExpressionNode::createSlots( int count)
|
||||||
|
|
|
@ -68,9 +68,10 @@ public:
|
||||||
QString build() const;
|
QString build() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void onNodeMove();
|
||||||
void createSlots( int count = 3 );
|
void createSlots( int count = 3 );
|
||||||
void paintSlots( QPainter *painter );
|
void paintSlots( QPainter *painter );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue