mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-27 19:10:52 +00:00
Slot count can now be changed.
This commit is contained in:
parent
79e205c6d8
commit
8314fd5c6b
4 changed files with 51 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "expr_link_dlg.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
|
||||
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
|
||||
QMainWindow( parent )
|
||||
|
@ -70,6 +71,12 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
|||
a = menu.addAction( "Remove" );
|
||||
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 )
|
||||
{
|
||||
a = menu.addAction( "Link" );
|
||||
|
@ -203,4 +210,22 @@ void ExpressionEditor::onItemDblClicked( QTreeWidgetItem *item )
|
|||
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 onAddNode3();
|
||||
void onItemDblClicked( QTreeWidgetItem *item );
|
||||
void onChangeSlotCount();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -115,9 +115,7 @@ QGraphicsItem( parent )
|
|||
ExpressionNode::~ExpressionNode()
|
||||
{
|
||||
clearLinks();
|
||||
|
||||
qDeleteAll( m_slots );
|
||||
m_slots.clear();
|
||||
clearSlots();
|
||||
}
|
||||
|
||||
QRectF ExpressionNode::boundingRect() const
|
||||
|
@ -176,6 +174,28 @@ QPointF ExpressionNode::slotPos( int slot ) const
|
|||
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
|
||||
{
|
||||
if( m_links[ 0 ] == NULL )
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
QPointF slotPos( int slot ) const;
|
||||
|
||||
int slotCount() const{ return m_slots.count(); }
|
||||
void changeSlotCount( int count );
|
||||
void clearSlots();
|
||||
|
||||
bool slotEmpty( int slot ) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue