From 624578c02469d1b426bee80969cdfd1f2ced1db2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 15:36:41 +0200 Subject: [PATCH] Added unlinking support. --- .../plugins/gui_editor/expression_editor.cpp | 17 +++++++++++++++++ .../src/plugins/gui_editor/expression_editor.h | 1 + .../src/plugins/gui_editor/expression_link.cpp | 2 ++ .../src/plugins/gui_editor/expression_node.h | 3 ++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index c4d5c1948..1c4a1ecda 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -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(); + } +} + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 70d2ad572..00d347993 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -39,6 +39,7 @@ private Q_SLOTS: void onDeleteSelection(); void onSelectionChanged(); void onLinkItems(); + void onUnLinkItems(); private: diff --git a/code/studio/src/plugins/gui_editor/expression_link.cpp b/code/studio/src/plugins/gui_editor/expression_link.cpp index 66ddffd7f..537d4891f 100644 --- a/code/studio/src/plugins/gui_editor/expression_link.cpp +++ b/code/studio/src/plugins/gui_editor/expression_link.cpp @@ -58,6 +58,8 @@ void ExpressionLink::unlink() m_from = NULL; m_to = NULL; + + delete this; } void ExpressionLink::nodeMoved() diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 704804b55..4fb92cbf4 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -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;