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