mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Expression Editor is now a QMainWindow subclass. Also added an expression tree, with some sample nodes.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
65382b45b7
commit
7f2091d6c9
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,33 +1,104 @@
|
||||||
<?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>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<item row="0" column="0">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<widget class="QGraphicsView" name="view">
|
<item row="0" column="0">
|
||||||
<property name="verticalScrollBarPolicy">
|
<widget class="QGraphicsView" name="view"/>
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
<property name="horizontalScrollBarPolicy">
|
</widget>
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
<widget class="QMenuBar" name="menubar">
|
||||||
</property>
|
<property name="geometry">
|
||||||
</widget>
|
<rect>
|
||||||
</item>
|
<x>0</x>
|
||||||
</layout>
|
<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">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTreeWidget" name="tree">
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Expressions</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Logical</string>
|
||||||
|
</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>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Loading…
Reference in a new issue