From 7f2091d6c98917bb8596a9719c093e5ba097e321 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 14 Sep 2014 21:00:40 +0200 Subject: [PATCH] Expression Editor is now a QMainWindow subclass. Also added an expression tree, with some sample nodes. --HG-- branch : dfighter-tools --- .../plugins/gui_editor/expression_editor.cpp | 28 +++-- .../plugins/gui_editor/expression_editor.h | 5 +- .../plugins/gui_editor/expression_editor.ui | 107 +++++++++++++++--- 3 files changed, 110 insertions(+), 30 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 62e034255..54f878afa 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -30,16 +30,17 @@ #include ExpressionEditor::ExpressionEditor( QWidget *parent ) : -QWidget( parent ) +QMainWindow( parent ) { m_ui.setupUi( this ); - + m_selectionCount = 0; m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect( m_ui.tree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) ); m_nodeCount = 0; } @@ -169,30 +170,37 @@ void ExpressionEditor::onUnLinkItems() } } -void ExpressionEditor::addNode( int slotCount ) +void ExpressionEditor::addNode( const QString &name, int slotCount ) { - QString name; - name = "node #"; - name += QString::number( m_nodeCount ); + QString n = name; + n += " #"; + n += QString::number( m_nodeCount ); m_nodeCount++; - QGraphicsItem *item = new ExpressionNode( name, slotCount ); + QGraphicsItem *item = new ExpressionNode( n, slotCount ); item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable ); m_scene->addItem( item ); } void ExpressionEditor::onAddNode1() { - addNode( 1 ); + addNode( "node", 1 ); } void ExpressionEditor::onAddNode2() { - addNode( 2 ); + addNode( "node", 2 ); } void ExpressionEditor::onAddNode3() { - addNode( 3 ); + addNode( "node", 3 ); } +void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item ) +{ + QString name = item->text( 0 ); + addNode( name, 3 ); +} + + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 553f8efd3..5b17d091d 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -24,7 +24,7 @@ class QGraphicsScene; -class ExpressionEditor : public QWidget +class ExpressionEditor : public QMainWindow { Q_OBJECT public: @@ -39,10 +39,11 @@ private Q_SLOTS: void onSelectionChanged(); void onLinkItems(); void onUnLinkItems(); - void addNode( int slotCount ); + void addNode( const QString &name, int slotCount ); void onAddNode1(); void onAddNode2(); void onAddNode3(); + void onItemDblClicked( QTreeWidgetItem *item ); private: diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui index 80480ad39..db71014bf 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.ui +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -1,33 +1,104 @@ ExpressionEditor - - - Qt::ApplicationModal - + 0 0 - 724 - 522 + 800 + 600 Expression Editor - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOn - - - - + + + + + + + + + + + 0 + 0 + 800 + 21 + + + + + + + 1 + + + + + + + + Expressions + + + + + Logical + + + + and + + + + + or + + + + + + Mathematical + + + + add + + + + + sub + + + + + + Value + + + + integer + + + + + string + + + + + boolean + + + + + + + +