mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
Added unlinking support.
This commit is contained in:
parent
13b41d2fa6
commit
1df2e53239
4 changed files with 22 additions and 1 deletions
|
@ -65,6 +65,9 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
a = menu.addAction( "Link" );
|
a = menu.addAction( "Link" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onLinkItems() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onLinkItems() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = menu.addAction( "Unlink" );
|
||||||
|
connect( a, SIGNAL( triggered() ), this, SLOT( onUnLinkItems() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.exec( e->globalPos() );
|
menu.exec( e->globalPos() );
|
||||||
|
@ -150,4 +153,18 @@ void ExpressionEditor::onLinkItems()
|
||||||
m_scene->addItem( link );
|
m_scene->addItem( link );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionEditor::onUnLinkItems()
|
||||||
|
{
|
||||||
|
QList< QGraphicsItem* > l = m_scene->selectedItems();
|
||||||
|
|
||||||
|
for( int i = 0; i < l.count(); i++ )
|
||||||
|
{
|
||||||
|
ExpressionNode *node = dynamic_cast< ExpressionNode* >( l[ i ] );
|
||||||
|
if( node == NULL )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
node->clearLinks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ private Q_SLOTS:
|
||||||
void onDeleteSelection();
|
void onDeleteSelection();
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
void onLinkItems();
|
void onLinkItems();
|
||||||
|
void onUnLinkItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ void ExpressionLink::unlink()
|
||||||
|
|
||||||
m_from = NULL;
|
m_from = NULL;
|
||||||
m_to = NULL;
|
m_to = NULL;
|
||||||
|
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionLink::nodeMoved()
|
void ExpressionLink::nodeMoved()
|
||||||
|
|
|
@ -47,13 +47,14 @@ public:
|
||||||
|
|
||||||
void getSlots( QList< SlotInfo > &l );
|
void getSlots( QList< SlotInfo > &l );
|
||||||
|
|
||||||
|
void clearLinks();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createSlots();
|
void createSlots();
|
||||||
void paintSlots( QPainter *painter );
|
void paintSlots( QPainter *painter );
|
||||||
void clearLinks();
|
|
||||||
|
|
||||||
qreal m_w;
|
qreal m_w;
|
||||||
qreal m_h;
|
qreal m_h;
|
||||||
|
|
Loading…
Reference in a new issue