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