#include "SUPERVGUI_ManagePortsDlg.h"
#include "SUPERVGUI_CanvasNode.h"
#include "SUPERVGUI_CanvasPort.h"
+#include "SUPERVGUI_CanvasControlNode.h"
#include "SUPERVGUI.h"
#include <qlayout.h>
connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
myNode->getMain()->lockedGraph( true );
+
+ // asv : 11.01.05 : if a node is a loop node, then only INPUT ports can be added/removed
+ if ( myNode->getNodeType() == SUPERV::LoopNode ) {
+ myOutList->setEnabled( false );
+ anAddOutputBtn->setEnabled( false );
+ aDeleteOutputBtn->setEnabled( false );
+ anUpOutputBtn->setEnabled( false );
+ aDownOutputBtn->setEnabled( false );
+ }
+
}
/**
SUPERV_INode aINode = myNode->getInlineNode();
if ( !SUPERV_isNull( aINode ) ) {
int i;
+ const bool isLoop = ( myNode->getNodeType() == SUPERV::LoopNode );
// 1.1 delete all ports (delete CanvasPorts, they delete SUPERV_Ports)
QObjectList* oldPorts = myNode->queryList("SUPERVGUI_CanvasPort");
QObjectListIt it( *oldPorts ); // iterate over the old ports
QObject *obj;
+ // asv : 11.01.05 : fix for a bug: for Loop node, removal of an Input Port
+ // automatically removes the corresponding Output Port. So for Loops the
+ // oldPorts list should be filtered to include only Input Ports.
+ // But I'll filter Gate-s as well..
+ QObjectList portsToRemove;
while ( (obj = it.current()) != 0 ) {
++it;
- if ( !((SUPERVGUI_CanvasPort*)obj)->getEngine()->IsGate() ) // never do anything with Gate ports
- ((SUPERVGUI_CanvasPort*)obj)->remove();
+ SUPERV::Port_var aPort = ((SUPERVGUI_CanvasPort*)obj)->getEngine();
+ if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) )
+ portsToRemove.append( obj );
}
delete oldPorts; // delete the list, not the objects
+
+ // portsToRemove list contains:
+ // for Loop node: all INPUT ports except Gates
+ // for other Inline: all INPUT and OUTPUT ports except Gates
+ it = QObjectListIt( portsToRemove );
+ while ( (obj = it.current()) != 0 ) {
+ ++it;
+ ((SUPERVGUI_CanvasPort*)obj)->remove();
+ }
// 1.2 create new ports in INode and CanvasPort in myNode
PortListItem* item;
item = (PortListItem*)myInList->item( i );
aPort = aINode->InPort( item->PortName.latin1(), item->PortType.latin1() );
myNode->createPort( aPort.in() );
+ // asv : 11.01.05 : for Loop nodes do the same as in SUPERVGUI_CanvasStartNode::addInputPort()
+ if ( isLoop ) {
+ SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode;
+ aStartLoopNode->merge();
+ aStartLoopNode->getCoupled()->merge();
+ }
}
- for ( i = 0; i < myOutList->count(); i++ ) {
+ // creating Out-ports, except LoopNode-s
+ for ( i = 0; i < myOutList->count() && !isLoop; i++ ) {
item = (PortListItem*)myOutList->item( i );
aPort = aINode->OutPort( item->PortName.latin1(), item->PortType.latin1() );
myNode->createPort( aPort.in() );
}
}
+/**
+ * called on 'X' button press - remove selected port item
+ */
void SUPERVGUI_ManagePortsDlg::removePort( QListBox* theLB ) {
if ( !theLB )
return;
delete theLB->item( i );
}
+/**
+ * called on up/down key press - move the selected list box item from position 'from' to position 'to'
+ */
void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const int to ) {
if ( !theLB )
return;
connect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
}
+/**
+ * move the selected item UP
+ */
void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) {
if ( !theLB )
return;
moveItem( theLB, i, i-1 );
}
+/**
+ * move the selected item DOWN
+ */
void SUPERVGUI_ManagePortsDlg::moveDown( QListBox* theLB ) {
if ( !theLB )
return;
/*!
* Port parameters dialog definition (taken from SUPERVGUI_Node.cxx without change)
*/
-
SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames)
: QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
myPortsNames( thePortsNames )