mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Added unlinking support.
This commit is contained in:
parent
8513711d66
commit
624578c024
4 changed files with 22 additions and 1 deletions
|
@ -65,6 +65,9 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
|||
a = menu.addAction( "Link" );
|
||||
connect( a, SIGNAL( triggered() ), this, SLOT( onLinkItems() ) );
|
||||
}
|
||||
|
||||
a = menu.addAction( "Unlink" );
|
||||
connect( a, SIGNAL( triggered() ), this, SLOT( onUnLinkItems() ) );
|
||||
}
|
||||
|
||||
menu.exec( e->globalPos() );
|
||||
|
@ -150,4 +153,18 @@ void ExpressionEditor::onLinkItems()
|
|||
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 onSelectionChanged();
|
||||
void onLinkItems();
|
||||
void onUnLinkItems();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ void ExpressionLink::unlink()
|
|||
|
||||
m_from = NULL;
|
||||
m_to = NULL;
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ExpressionLink::nodeMoved()
|
||||
|
|
|
@ -47,13 +47,14 @@ public:
|
|||
|
||||
void getSlots( QList< SlotInfo > &l );
|
||||
|
||||
void clearLinks();
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||
|
||||
private:
|
||||
void createSlots();
|
||||
void paintSlots( QPainter *painter );
|
||||
void clearLinks();
|
||||
|
||||
qreal m_w;
|
||||
qreal m_h;
|
||||
|
|
Loading…
Reference in a new issue