From 171e383b147be56810f9557e8b5f412485126b39 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 17:04:42 +0200 Subject: [PATCH] Add serial number to nodes. --- code/studio/src/plugins/gui_editor/expression_editor.cpp | 9 ++++++++- code/studio/src/plugins/gui_editor/expression_editor.h | 1 + code/studio/src/plugins/gui_editor/expression_node.cpp | 6 ++++-- code/studio/src/plugins/gui_editor/expression_node.h | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index c821ceb6d..dc164d361 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -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 ); } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 91bb5d851..553f8efd3 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -50,6 +50,7 @@ private: QGraphicsScene *m_scene; int m_selectionCount; + int m_nodeCount; }; #endif diff --git a/code/studio/src/plugins/gui_editor/expression_node.cpp b/code/studio/src/plugins/gui_editor/expression_node.cpp index c12ca3ea5..3098c6290 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.cpp +++ b/code/studio/src/plugins/gui_editor/expression_node.cpp @@ -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 ) { diff --git a/code/studio/src/plugins/gui_editor/expression_node.h b/code/studio/src/plugins/gui_editor/expression_node.h index 6df38d583..0b7242f5d 100644 --- a/code/studio/src/plugins/gui_editor/expression_node.h +++ b/code/studio/src/plugins/gui_editor/expression_node.h @@ -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