Add serial number to nodes.
This commit is contained in:
parent
035f824a93
commit
171e383b14
4 changed files with 16 additions and 4 deletions
|
@ -40,6 +40,8 @@ QWidget( parent )
|
||||||
m_ui.view->setScene( m_scene );
|
m_ui.view->setScene( m_scene );
|
||||||
|
|
||||||
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
|
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
|
||||||
|
|
||||||
|
m_nodeCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionEditor::~ExpressionEditor()
|
ExpressionEditor::~ExpressionEditor()
|
||||||
|
@ -169,7 +171,12 @@ void ExpressionEditor::onUnLinkItems()
|
||||||
|
|
||||||
void ExpressionEditor::addNode( int slotCount )
|
void ExpressionEditor::addNode( int slotCount )
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = new ExpressionNode( slotCount );
|
QString name;
|
||||||
|
name = "node #";
|
||||||
|
name += QString::number( m_nodeCount );
|
||||||
|
m_nodeCount++;
|
||||||
|
|
||||||
|
QGraphicsItem *item = new ExpressionNode( name, slotCount );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||||
m_scene->addItem( item );
|
m_scene->addItem( item );
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ private:
|
||||||
QGraphicsScene *m_scene;
|
QGraphicsScene *m_scene;
|
||||||
|
|
||||||
int m_selectionCount;
|
int m_selectionCount;
|
||||||
|
int m_nodeCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -97,13 +97,15 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExpressionNode::ExpressionNode( int slotCount, QGraphicsItem *parent ) :
|
ExpressionNode::ExpressionNode( const QString &name, int slotCount, QGraphicsItem *parent ) :
|
||||||
QGraphicsItem( parent )
|
QGraphicsItem( parent )
|
||||||
{
|
{
|
||||||
m_w = 100;
|
m_w = 100;
|
||||||
m_h = 100;
|
m_h = 100;
|
||||||
m_hh = 20.0;
|
m_hh = 20.0;
|
||||||
|
|
||||||
|
m_name = name;
|
||||||
|
|
||||||
if( slotCount > 3 )
|
if( slotCount > 3 )
|
||||||
m_h = m_h + 20.0 * ( slotCount - 3 );
|
m_h = m_h + 20.0 * ( slotCount - 3 );
|
||||||
|
|
||||||
|
@ -147,7 +149,7 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
// Draw header text
|
// Draw header text
|
||||||
p.setColor( Qt::black );
|
p.setColor( Qt::black );
|
||||||
painter->setPen( p );
|
painter->setPen( p );
|
||||||
painter->drawText( header, Qt::AlignCenter, "Something" );
|
painter->drawText( header, Qt::AlignCenter, m_name );
|
||||||
|
|
||||||
if( option->state & QStyle::State_Selected )
|
if( option->state & QStyle::State_Selected )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ class NodeSlot;
|
||||||
class ExpressionNode : public QGraphicsItem
|
class ExpressionNode : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpressionNode( int slotCount = 3, QGraphicsItem *parent = NULL );
|
ExpressionNode( const QString &name, int slotCount = 3, QGraphicsItem *parent = NULL );
|
||||||
~ExpressionNode();
|
~ExpressionNode();
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
@ -62,6 +62,8 @@ private:
|
||||||
|
|
||||||
QList< NodeSlot* > m_slots;
|
QList< NodeSlot* > m_slots;
|
||||||
QList< ExpressionLink* > m_links;
|
QList< ExpressionLink* > m_links;
|
||||||
|
|
||||||
|
QString m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue