mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 21:11:39 +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;
|
QString n = name;
|
||||||
n += " #";
|
n += " #";
|
||||||
n += QString::number( m_nodeCount );
|
n += QString::number( m_nodeCount );
|
||||||
m_nodeCount++;
|
m_nodeCount++;
|
||||||
|
|
||||||
QGraphicsItem *item = new ExpressionNode( n, slotCount );
|
ExpressionNode *node = new ExpressionNode( n, info->slotNames.count() );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
node->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||||
m_scene->addItem( item );
|
node->setSlotNames( info->slotNames );
|
||||||
}
|
m_scene->addItem( node );
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onChangeSlotCount()
|
void ExpressionEditor::onChangeSlotCount()
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "ui_expression_editor.h"
|
#include "ui_expression_editor.h"
|
||||||
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
class QGraphicsItem;
|
||||||
class ExpressionEditorPvt;
|
class ExpressionEditorPvt;
|
||||||
class ExpressionInfo;
|
class ExpressionInfo;
|
||||||
|
|
||||||
|
@ -43,10 +44,6 @@ private Q_SLOTS:
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
void onLinkItems();
|
void onLinkItems();
|
||||||
void onUnLinkItems();
|
void onUnLinkItems();
|
||||||
void addNode( const QString &name, int slotCount );
|
|
||||||
void onAddNode1();
|
|
||||||
void onAddNode2();
|
|
||||||
void onAddNode3();
|
|
||||||
void onItemDblClicked( QTreeWidgetItem *item );
|
void onItemDblClicked( QTreeWidgetItem *item );
|
||||||
void onChangeSlotCount();
|
void onChangeSlotCount();
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString text() const{ return m_info.text; }
|
QString text() const{ return m_info.text; }
|
||||||
|
void setText( const QString &text ){ m_info.text = text; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NodeSlotInfo m_info;
|
NodeSlotInfo m_info;
|
||||||
|
@ -229,6 +230,16 @@ ExpressionLink* ExpressionNode::link( int slot ) const
|
||||||
return m_links[ slot ];
|
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 )
|
void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < m_links.count(); i++ )
|
for( int i = 0; i < m_links.count(); i++ )
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
|
|
||||||
QString name() const{ return m_name; }
|
QString name() const{ return m_name; }
|
||||||
|
|
||||||
|
void setSlotNames( const QList< QString > &l );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue