mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-28 01:56:24 +00:00
Slot count can now be changed.
This commit is contained in:
parent
29176b7bc6
commit
580ded1bd4
4 changed files with 51 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "expr_link_dlg.h"
|
#include "expr_link_dlg.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
||||||
QMainWindow( parent )
|
QMainWindow( parent )
|
||||||
|
@ -70,6 +71,12 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
a = menu.addAction( "Remove" );
|
a = menu.addAction( "Remove" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
||||||
|
|
||||||
|
if( m_selectionCount == 1 )
|
||||||
|
{
|
||||||
|
a = menu.addAction( "Change slot count" );
|
||||||
|
connect( a, SIGNAL( triggered() ), this, SLOT( onChangeSlotCount() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
if( m_selectionCount == 2 )
|
if( m_selectionCount == 2 )
|
||||||
{
|
{
|
||||||
a = menu.addAction( "Link" );
|
a = menu.addAction( "Link" );
|
||||||
|
@ -203,4 +210,22 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
|
||||||
addNode( name, 3 );
|
addNode( name, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionEditor::onChangeSlotCount()
|
||||||
|
{
|
||||||
|
QList< QGraphicsItem* > l = m_scene->selectedItems();
|
||||||
|
ExpressionNode *node = static_cast< ExpressionNode* >( l[ 0 ] );
|
||||||
|
int oldc = node->slotCount();
|
||||||
|
|
||||||
|
int c = QInputDialog::getInt( this,
|
||||||
|
tr( "Change slot count" ),
|
||||||
|
tr( "Enter new slot count" ),
|
||||||
|
oldc,
|
||||||
|
1,
|
||||||
|
26 );
|
||||||
|
|
||||||
|
if( oldc == c )
|
||||||
|
return;
|
||||||
|
|
||||||
|
node->changeSlotCount( c );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ private Q_SLOTS:
|
||||||
void onAddNode2();
|
void onAddNode2();
|
||||||
void onAddNode3();
|
void onAddNode3();
|
||||||
void onItemDblClicked( QTreeWidgetItem *item );
|
void onItemDblClicked( QTreeWidgetItem *item );
|
||||||
|
void onChangeSlotCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -115,9 +115,7 @@ QGraphicsItem( parent )
|
||||||
ExpressionNode::~ExpressionNode()
|
ExpressionNode::~ExpressionNode()
|
||||||
{
|
{
|
||||||
clearLinks();
|
clearLinks();
|
||||||
|
clearSlots();
|
||||||
qDeleteAll( m_slots );
|
|
||||||
m_slots.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF ExpressionNode::boundingRect() const
|
QRectF ExpressionNode::boundingRect() const
|
||||||
|
@ -176,6 +174,28 @@ QPointF ExpressionNode::slotPos( int slot ) const
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpressionNode::changeSlotCount( int count )
|
||||||
|
{
|
||||||
|
clearSlots();
|
||||||
|
clearLinks();
|
||||||
|
m_links.clear();
|
||||||
|
|
||||||
|
if( count <= 3 )
|
||||||
|
m_h = 100.0;
|
||||||
|
else
|
||||||
|
m_h = 100.0 + 20.0 * ( count - 3 );
|
||||||
|
|
||||||
|
createSlots( count );
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpressionNode::clearSlots()
|
||||||
|
{
|
||||||
|
qDeleteAll( m_slots );
|
||||||
|
m_slots.clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool ExpressionNode::slotEmpty( int slot ) const
|
bool ExpressionNode::slotEmpty( int slot ) const
|
||||||
{
|
{
|
||||||
if( m_links[ 0 ] == NULL )
|
if( m_links[ 0 ] == NULL )
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
QPointF slotPos( int slot ) const;
|
QPointF slotPos( int slot ) const;
|
||||||
|
|
||||||
int slotCount() const{ return m_slots.count(); }
|
int slotCount() const{ return m_slots.count(); }
|
||||||
|
void changeSlotCount( int count );
|
||||||
|
void clearSlots();
|
||||||
|
|
||||||
bool slotEmpty( int slot ) const;
|
bool slotEmpty( int slot ) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue