Only allow variable nodes to have their number of slots changed.

This commit is contained in:
dfighter1985 2014-09-16 03:45:26 +02:00
parent cce83f371d
commit 52fa0b4fa9
3 changed files with 18 additions and 11 deletions

View file

@ -84,15 +84,6 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
QMenu menu; QMenu menu;
QAction *a = NULL; 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 ) if( m_selectionCount > 0 )
{ {
@ -101,8 +92,16 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
if( m_selectionCount == 1 ) if( m_selectionCount == 1 )
{ {
a = menu.addAction( "Change slot count" ); QList< QGraphicsItem* > l = m_scene->selectedItems();
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) ); 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 else
if( m_selectionCount == 2 ) if( m_selectionCount == 2 )
@ -219,6 +218,7 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() ); ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() );
node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
node->setSlotNames( info->slotNames ); node->setSlotNames( info->slotNames );
node->setVariable( info->variable );
m_scene->addItem( node ); m_scene->addItem( node );
} }

View file

@ -105,6 +105,8 @@ QGraphicsItem( parent )
m_h = 100; m_h = 100;
m_hh = 20.0; m_hh = 20.0;
m_variable = false;
m_name = name; m_name = name;
if( slotCount > 3 ) if( slotCount > 3 )

View file

@ -55,6 +55,9 @@ public:
void setSlotNames( const QList< QString > &l ); void setSlotNames( const QList< QString > &l );
void setVariable( bool b ){ m_variable = b; }
bool variable() const{ return m_variable; }
protected: protected:
void mouseMoveEvent( QGraphicsSceneMouseEvent *e ); void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
@ -70,6 +73,8 @@ private:
QList< ExpressionLink* > m_links; QList< ExpressionLink* > m_links;
QString m_name; QString m_name;
bool m_variable;
}; };
#endif #endif