Only allow variable nodes to have their number of slots changed.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
89aaa52703
commit
142d82d788
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 )
|
||||||
{
|
{
|
||||||
|
@ -100,10 +91,18 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
||||||
|
|
||||||
if( m_selectionCount == 1 )
|
if( m_selectionCount == 1 )
|
||||||
|
{
|
||||||
|
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" );
|
a = menu.addAction( "Change slot count" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) );
|
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