Added unlinking support.

This commit is contained in:
dfighter1985 2014-09-14 15:36:41 +02:00
parent 8513711d66
commit 624578c024
4 changed files with 22 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -39,6 +39,7 @@ private Q_SLOTS:
void onDeleteSelection();
void onSelectionChanged();
void onLinkItems();
void onUnLinkItems();
private:

View file

@ -58,6 +58,8 @@ void ExpressionLink::unlink()
m_from = NULL;
m_to = NULL;
delete this;
}
void ExpressionLink::nodeMoved()

View file

@ -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;