A little refactoring.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
42cd76c768
commit
40b4bce729
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()
|
||||
{
|
||||
QGraphicsItem *item = new ExpressionNode( 1 );
|
||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||
m_scene->addItem( item );
|
||||
addNode( 1 );
|
||||
}
|
||||
|
||||
void ExpressionEditor::onAddNode2()
|
||||
{
|
||||
QGraphicsItem *item = new ExpressionNode( 2 );
|
||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||
m_scene->addItem( item );
|
||||
addNode( 2 );
|
||||
}
|
||||
|
||||
void ExpressionEditor::onAddNode3()
|
||||
{
|
||||
QGraphicsItem *item = new ExpressionNode( 3 );
|
||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||
m_scene->addItem( item );
|
||||
addNode( 3 );
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ private Q_SLOTS:
|
|||
void onSelectionChanged();
|
||||
void onLinkItems();
|
||||
void onUnLinkItems();
|
||||
void addNode( int slotCount );
|
||||
void onAddNode1();
|
||||
void onAddNode2();
|
||||
void onAddNode3();
|
||||
|
|
|
@ -97,19 +97,13 @@ private:
|
|||
|
||||
|
||||
|
||||
ExpressionNode::ExpressionNode( int nodes, QGraphicsItem *parent ) :
|
||||
ExpressionNode::ExpressionNode( int slotCount, QGraphicsItem *parent ) :
|
||||
QGraphicsItem( parent )
|
||||
{
|
||||
m_w = 100;
|
||||
m_h = 100;
|
||||
|
||||
// Out nodes
|
||||
m_links.push_back( NULL );
|
||||
|
||||
for( int i = 0; i < nodes; i++ )
|
||||
m_links.push_back( NULL );
|
||||
|
||||
createSlots();
|
||||
createSlots( slotCount );
|
||||
}
|
||||
|
||||
ExpressionNode::~ExpressionNode()
|
||||
|
@ -223,10 +217,14 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *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
|
||||
NodeSlotInfo info;
|
||||
info.tw = 25.0;
|
||||
|
@ -243,10 +241,9 @@ void ExpressionNode::createSlots()
|
|||
info.text = "Out";
|
||||
|
||||
m_slots.push_back( new NodeSlot( info ) );
|
||||
nodes--;
|
||||
|
||||
// Then the rest of them
|
||||
for( int i = 0; i < nodes; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
x = m_w - info.wh;
|
||||
y = 30 + i * 20.0;
|
||||
|
|
|
@ -30,7 +30,7 @@ class NodeSlot;
|
|||
class ExpressionNode : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
ExpressionNode( int nodes = 3, QGraphicsItem *parent = NULL );
|
||||
ExpressionNode( int slotCount = 3, QGraphicsItem *parent = NULL );
|
||||
~ExpressionNode();
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
@ -53,7 +53,7 @@ protected:
|
|||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||
|
||||
private:
|
||||
void createSlots();
|
||||
void createSlots( int count = 3 );
|
||||
void paintSlots( QPainter *painter );
|
||||
|
||||
qreal m_w;
|
||||
|
|
Loading…
Reference in a new issue