Expression Editor is now a QMainWindow subclass. Also added an expression tree, with some sample nodes.
This commit is contained in:
parent
1b913a76c1
commit
79e205c6d8
3 changed files with 110 additions and 30 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
||||||
QWidget( parent )
|
QMainWindow( parent )
|
||||||
{
|
{
|
||||||
m_ui.setupUi( this );
|
m_ui.setupUi( this );
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ 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() ) );
|
||||||
|
connect( m_ui.tree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) );
|
||||||
|
|
||||||
m_nodeCount = 0;
|
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;
|
QString n = name;
|
||||||
name = "node #";
|
n += " #";
|
||||||
name += QString::number( m_nodeCount );
|
n += QString::number( m_nodeCount );
|
||||||
m_nodeCount++;
|
m_nodeCount++;
|
||||||
|
|
||||||
QGraphicsItem *item = new ExpressionNode( name, slotCount );
|
QGraphicsItem *item = new ExpressionNode( n, slotCount );
|
||||||
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
|
||||||
m_scene->addItem( item );
|
m_scene->addItem( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode1()
|
void ExpressionEditor::onAddNode1()
|
||||||
{
|
{
|
||||||
addNode( 1 );
|
addNode( "node", 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode2()
|
void ExpressionEditor::onAddNode2()
|
||||||
{
|
{
|
||||||
addNode( 2 );
|
addNode( "node", 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEditor::onAddNode3()
|
void ExpressionEditor::onAddNode3()
|
||||||
{
|
{
|
||||||
addNode( 3 );
|
addNode( "node", 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
|
||||||
|
{
|
||||||
|
QString name = item->text( 0 );
|
||||||
|
addNode( name, 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class ExpressionEditor : public QWidget
|
class ExpressionEditor : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -39,10 +39,11 @@ private Q_SLOTS:
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
void onLinkItems();
|
void onLinkItems();
|
||||||
void onUnLinkItems();
|
void onUnLinkItems();
|
||||||
void addNode( int slotCount );
|
void addNode( const QString &name, int slotCount );
|
||||||
void onAddNode1();
|
void onAddNode1();
|
||||||
void onAddNode2();
|
void onAddNode2();
|
||||||
void onAddNode3();
|
void onAddNode3();
|
||||||
|
void onItemDblClicked( QTreeWidgetItem *item );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,105 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ExpressionEditor</class>
|
<class>ExpressionEditor</class>
|
||||||
<widget class="QWidget" name="ExpressionEditor">
|
<widget class="QMainWindow" name="ExpressionEditor">
|
||||||
<property name="windowModality">
|
|
||||||
<enum>Qt::ApplicationModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>724</width>
|
<width>800</width>
|
||||||
<height>522</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Expression Editor</string>
|
<string>Expression Editor</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGraphicsView" name="view"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QDockWidget" name="dockWidget">
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGraphicsView" name="view">
|
<widget class="QTreeWidget" name="tree">
|
||||||
<property name="verticalScrollBarPolicy">
|
<column>
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
<property name="text">
|
||||||
|
<string>Expressions</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalScrollBarPolicy">
|
</column>
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Logical</string>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>and</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>or</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Mathematical</string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>add</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>sub</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Value</string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>integer</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>string</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>boolean</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue