mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 23:36:18 +00:00
Set the number of slots and their names from the data loaded from XMLs.
This commit is contained in:
parent
48b46dcc8c
commit
d027afbaeb
4 changed files with 23 additions and 29 deletions
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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++ )
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
|
||||
QString name() const{ return m_name; }
|
||||
|
||||
void setSlotNames( const QList< QString > &l );
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||
|
||||
|
|
Loading…
Reference in a new issue