Set the number of slots and their names from the data loaded from XMLs.

This commit is contained in:
dfighter1985 2014-09-16 03:38:21 +02:00
parent 8b0f7ddeaf
commit cce83f371d
4 changed files with 23 additions and 29 deletions

View file

@ -205,37 +205,21 @@ void ExpressionEditor::onUnLinkItems()
}
}
void ExpressionEditor::addNode( const QString &name, int slotCount )
void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
{
QString name = item->text( 0 );
const ExpressionInfo *info = m_pvt->store.getInfo( name );
QString n = name;
n += " #";
n += QString::number( m_nodeCount );
m_nodeCount++;
QGraphicsItem *item = new ExpressionNode( n, slotCount );
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
m_scene->addItem( item );
}
void ExpressionEditor::onAddNode1()
{
addNode( "node", 1 );
}
void ExpressionEditor::onAddNode2()
{
addNode( "node", 2 );
}
void ExpressionEditor::onAddNode3()
{
addNode( "node", 3 );
}
void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
{
QString name = item->text( 0 );
addNode( name, 3 );
ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() );
node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
node->setSlotNames( info->slotNames );
m_scene->addItem( node );
}
void ExpressionEditor::onChangeSlotCount()

View file

@ -23,6 +23,7 @@
#include "ui_expression_editor.h"
class QGraphicsScene;
class QGraphicsItem;
class ExpressionEditorPvt;
class ExpressionInfo;
@ -43,10 +44,6 @@ private Q_SLOTS:
void onSelectionChanged();
void onLinkItems();
void onUnLinkItems();
void addNode( const QString &name, int slotCount );
void onAddNode1();
void onAddNode2();
void onAddNode3();
void onItemDblClicked( QTreeWidgetItem *item );
void onChangeSlotCount();

View file

@ -90,6 +90,7 @@ public:
}
QString text() const{ return m_info.text; }
void setText( const QString &text ){ m_info.text = text; }
private:
NodeSlotInfo m_info;
@ -229,6 +230,16 @@ ExpressionLink* ExpressionNode::link( int slot ) const
return m_links[ slot ];
}
void ExpressionNode::setSlotNames( const QList< QString > &l )
{
int c = l.count();
for( int i = 0; i < c; i++ )
{
// "Out" slot is at position 0, so set the names with an offset of 1
m_slots[ i + 1 ]->setText( l[ i ] );
}
}
void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
{
for( int i = 0; i < m_links.count(); i++ )

View file

@ -53,6 +53,8 @@ public:
QString name() const{ return m_name; }
void setSlotNames( const QList< QString > &l );
protected:
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );