A root node can now be set. The root node is where the evaluation will start.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
cc071e5048
commit
cbca49fcc0
4 changed files with 46 additions and 4 deletions
|
@ -35,7 +35,14 @@
|
||||||
class ExpressionEditorPvt
|
class ExpressionEditorPvt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
ExpressionEditorPvt()
|
||||||
|
{
|
||||||
|
m_root = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ExpressionStore store;
|
ExpressionStore store;
|
||||||
|
ExpressionNode *m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
||||||
|
@ -101,12 +108,15 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
a = menu.addAction( "Change slot count" );
|
a = menu.addAction( "Change slot count" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( node->isValue() )
|
if( node->isValue() )
|
||||||
{
|
{
|
||||||
a = menu.addAction( "Change value" );
|
a = menu.addAction( "Change value" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeValue() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeValue() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = menu.addAction( "Set as root" );
|
||||||
|
connect( a, SIGNAL( triggered() ), this, SLOT( onSetRoot() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -273,6 +283,19 @@ void ExpressionEditor::onChangeValue()
|
||||||
node->setValue( newValue );
|
node->setValue( newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionEditor::onSetRoot()
|
||||||
|
{
|
||||||
|
QList< QGraphicsItem* > l = m_scene->selectedItems();
|
||||||
|
ExpressionNode *node = static_cast< ExpressionNode* >( l[ 0 ] );
|
||||||
|
|
||||||
|
if( m_pvt->m_root != NULL )
|
||||||
|
m_pvt->m_root->setRoot( false );
|
||||||
|
|
||||||
|
m_pvt->m_root = node;
|
||||||
|
node->setRoot( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpressionEditor::addExpression( const ExpressionInfo *info )
|
void ExpressionEditor::addExpression( const ExpressionInfo *info )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = findTopLevelItem( info->category );
|
QTreeWidgetItem *item = findTopLevelItem( info->category );
|
||||||
|
|
|
@ -47,6 +47,7 @@ private Q_SLOTS:
|
||||||
void onItemDblClicked( QTreeWidgetItem *item );
|
void onItemDblClicked( QTreeWidgetItem *item );
|
||||||
void onChangeSlotCount();
|
void onChangeSlotCount();
|
||||||
void onChangeValue();
|
void onChangeValue();
|
||||||
|
void onSetRoot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addExpression( const ExpressionInfo *info );
|
void addExpression( const ExpressionInfo *info );
|
||||||
|
|
|
@ -107,6 +107,7 @@ QGraphicsItem( parent )
|
||||||
|
|
||||||
m_variable = false;
|
m_variable = false;
|
||||||
m_isValue = false;
|
m_isValue = false;
|
||||||
|
m_isRoot = false;
|
||||||
|
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
||||||
|
@ -139,9 +140,18 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
header.setHeight( m_hh );
|
header.setHeight( m_hh );
|
||||||
|
|
||||||
// Draw filled rectangle, header
|
// Draw filled rectangle, header
|
||||||
c.setRed( 44 );
|
if( !m_isRoot )
|
||||||
c.setGreen( 169 );
|
{
|
||||||
c.setBlue( 232 );
|
c.setRed( 44 );
|
||||||
|
c.setGreen( 169 );
|
||||||
|
c.setBlue( 232 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c.setRed( 255 );
|
||||||
|
c.setGreen( 0 );
|
||||||
|
c.setBlue( 0 );
|
||||||
|
}
|
||||||
br.setColor( c );
|
br.setColor( c );
|
||||||
br.setStyle( Qt::SolidPattern );
|
br.setStyle( Qt::SolidPattern );
|
||||||
p.setColor( c );
|
p.setColor( c );
|
||||||
|
@ -270,6 +280,12 @@ void ExpressionNode::setValue( const QString &value )
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionNode::setRoot( bool b )
|
||||||
|
{
|
||||||
|
m_isRoot = b;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < m_links.count(); i++ )
|
for( int i = 0; i < m_links.count(); i++ )
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
bool isValue() const{ return m_isValue; }
|
bool isValue() const{ return m_isValue; }
|
||||||
void setIsValue( bool b ){ m_isValue = b; }
|
void setIsValue( bool b ){ m_isValue = b; }
|
||||||
|
void setRoot( bool b );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||||
|
@ -84,6 +85,7 @@ private:
|
||||||
|
|
||||||
QString m_value;
|
QString m_value;
|
||||||
bool m_isValue;
|
bool m_isValue;
|
||||||
|
bool m_isRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue