From 142d82d78838799a732e26e05a63196e19a8ace3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 16 Sep 2014 03:45:26 +0200 Subject: [PATCH] Only allow variable nodes to have their number of slots changed. --HG-- branch : dfighter-tools --- .../plugins/gui_editor/expression_editor.cpp | 22 +++++++++---------- .../plugins/gui_editor/expression_node.cpp | 2 ++ .../src/plugins/gui_editor/expression_node.h | 5 +++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 81bd22373..df83a6732 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -84,15 +84,6 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) QMenu menu; QAction *a = NULL; - QMenu *mm = menu.addMenu( "Add node" ); - a = mm->addAction( "1 slot" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode1() ) ); - - a = mm->addAction( "2 slots" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode2() ) ); - - a = mm->addAction( "3 slots" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onAddNode3() ) ); if( m_selectionCount > 0 ) { @@ -101,8 +92,16 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) if( m_selectionCount == 1 ) { - a = menu.addAction( "Change slot count" ); - connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); + QList< QGraphicsItem* > l = m_scene->selectedItems(); + ExpressionNode *node = dynamic_cast< ExpressionNode* >( l[ 0 ] ); + if( node != NULL ) + { + if( node->variable() ) + { + a = menu.addAction( "Change slot count" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); + } + } } else if( m_selectionCount == 2 ) @@ -219,6 +218,7 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() ); node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); node->setSlotNames( info->slotNames ); + node->setVariable( info->variable ); m_scene->addItem( node ); } diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index bb2eb451f..8c736c919 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -105,6 +105,8 @@ QGraphicsItem( parent ) m_h = 100; m_hh = 20.0; + m_variable = false; + m_name = name; if( slotCount > 3 ) diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index e43e717bb..ebf2c9fd5 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -55,6 +55,9 @@ public: void setSlotNames( const QList< QString > &l ); + void setVariable( bool b ){ m_variable = b; } + bool variable() const{ return m_variable; } + protected: void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); @@ -70,6 +73,8 @@ private: QList< ExpressionLink* > m_links; QString m_name; + + bool m_variable; }; #endif