mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-05 23:09:04 +00:00
Only allow variable nodes to have their number of slots changed.
This commit is contained in:
parent
d027afbaeb
commit
754393064d
3 changed files with 18 additions and 11 deletions
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue