mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-13 10:49:11 +00:00
A little refactoring.
This commit is contained in:
parent
97e2b3d1e4
commit
4a923a0dc7
4 changed files with 21 additions and 23 deletions
|
@ -167,25 +167,25 @@ void ExpressionEditor::onUnLinkItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionEditor::addNode( int slotCount )
|
||||||
|
{
|
||||||
|
QGraphicsItem *item = new ExpressionNode( slotCount );
|
||||||
|
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||||
|
m_scene->addItem( item );
|
||||||
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode1()
|
void ExpressionEditor::onAddNode1()
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = new ExpressionNode( 1 );
|
addNode( 1 );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
|
||||||
m_scene->addItem( item );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode2()
|
void ExpressionEditor::onAddNode2()
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = new ExpressionNode( 2 );
|
addNode( 2 );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
|
||||||
m_scene->addItem( item );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode3()
|
void ExpressionEditor::onAddNode3()
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = new ExpressionNode( 3 );
|
addNode( 3 );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
|
||||||
m_scene->addItem( item );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ private Q_SLOTS:
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
void onLinkItems();
|
void onLinkItems();
|
||||||
void onUnLinkItems();
|
void onUnLinkItems();
|
||||||
|
void addNode( int slotCount );
|
||||||
void onAddNode1();
|
void onAddNode1();
|
||||||
void onAddNode2();
|
void onAddNode2();
|
||||||
void onAddNode3();
|
void onAddNode3();
|
||||||
|
|
|
@ -97,19 +97,13 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExpressionNode::ExpressionNode( int nodes, QGraphicsItem *parent ) :
|
ExpressionNode::ExpressionNode( int slotCount, QGraphicsItem *parent ) :
|
||||||
QGraphicsItem( parent )
|
QGraphicsItem( parent )
|
||||||
{
|
{
|
||||||
m_w = 100;
|
m_w = 100;
|
||||||
m_h = 100;
|
m_h = 100;
|
||||||
|
|
||||||
// Out nodes
|
createSlots( slotCount );
|
||||||
m_links.push_back( NULL );
|
|
||||||
|
|
||||||
for( int i = 0; i < nodes; i++ )
|
|
||||||
m_links.push_back( NULL );
|
|
||||||
|
|
||||||
createSlots();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionNode::~ExpressionNode()
|
ExpressionNode::~ExpressionNode()
|
||||||
|
@ -223,10 +217,14 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
||||||
QGraphicsItem::mouseMoveEvent( e );
|
QGraphicsItem::mouseMoveEvent( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionNode::createSlots()
|
void ExpressionNode::createSlots( int count)
|
||||||
{
|
{
|
||||||
int nodes = m_links.count();
|
// Out nodes
|
||||||
|
m_links.push_back( NULL );
|
||||||
|
|
||||||
|
for( int i = 0; i < count; i++ )
|
||||||
|
m_links.push_back( NULL );
|
||||||
|
|
||||||
// First create the "Out" slot
|
// First create the "Out" slot
|
||||||
NodeSlotInfo info;
|
NodeSlotInfo info;
|
||||||
info.tw = 25.0;
|
info.tw = 25.0;
|
||||||
|
@ -243,10 +241,9 @@ void ExpressionNode::createSlots()
|
||||||
info.text = "Out";
|
info.text = "Out";
|
||||||
|
|
||||||
m_slots.push_back( new NodeSlot( info ) );
|
m_slots.push_back( new NodeSlot( info ) );
|
||||||
nodes--;
|
|
||||||
|
|
||||||
// Then the rest of them
|
// Then the rest of them
|
||||||
for( int i = 0; i < nodes; i++ )
|
for( int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
x = m_w - info.wh;
|
x = m_w - info.wh;
|
||||||
y = 30 + i * 20.0;
|
y = 30 + i * 20.0;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class NodeSlot;
|
||||||
class ExpressionNode : public QGraphicsItem
|
class ExpressionNode : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpressionNode( int nodes = 3, QGraphicsItem *parent = NULL );
|
ExpressionNode( int slotCount = 3, QGraphicsItem *parent = NULL );
|
||||||
~ExpressionNode();
|
~ExpressionNode();
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
@ -53,7 +53,7 @@ protected:
|
||||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createSlots();
|
void createSlots( int count = 3 );
|
||||||
void paintSlots( QPainter *painter );
|
void paintSlots( QPainter *painter );
|
||||||
|
|
||||||
qreal m_w;
|
qreal m_w;
|
||||||
|
|
Loading…
Reference in a new issue