]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/Port.cxx
...
[cpPlugins.git] / lib / cpBaseQtApplication / Port.cxx
index bdd9aea75819aad334ad54894dda32e894a2add4..e61bd284ef999d1857b50e7e798929cc056a834c 100644 (file)
@@ -126,9 +126,9 @@ isConnected( Port* other )
 \r
 // -------------------------------------------------------------------------\r
 cpBaseQtApplication::InputPort::\r
-InputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+InputPort( QGraphicsItem* parent, bool multiple, QGraphicsScene* scene )\r
   : Superclass( parent, scene ),\r
-    m_Connection( NULL )\r
+    m_IsMultiple( multiple )\r
 {\r
 }\r
 \r
@@ -136,8 +136,7 @@ InputPort( QGraphicsItem* parent, QGraphicsScene* scene )
 cpBaseQtApplication::InputPort::\r
 ~InputPort( )\r
 {\r
-  if( this->m_Connection != NULL )\r
-    delete this->m_Connection;\r
+   this->m_Connection.clear( );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -156,7 +155,7 @@ _updateLabels( )
 void cpBaseQtApplication::InputPort::\r
 setExtend( bool extend )\r
 {\r
-  if( this->m_Connection == NULL )\r
+  if( this->m_Connection.size( ) == 0 )\r
   {\r
     this->m_IsExtended = extend;\r
     this->m_ExtendedLabel->setVisible( extend );\r
@@ -169,20 +168,19 @@ setExtend( bool extend )
 bool cpBaseQtApplication::InputPort::\r
 isConnected( Port* other )\r
 {\r
-  if( this->m_Connection != NULL )\r
-    return(\r
-      this->m_Connection->port1( ) == other &&\r
-      this->m_Connection->port2( ) == this\r
-      );\r
-  else\r
-    return( false );\r
+  bool conn = false;\r
+  auto i = this->m_Connection.begin( );\r
+  for( ; i != this->m_Connection.end( ); ++i )\r
+    conn |= ( ( *i )->port1( ) == other && ( *i )->port2( ) == this );\r
+  return( conn );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
 void cpBaseQtApplication::InputPort::\r
 setConnection( Connection* c )\r
 {\r
-  this->m_Connection = c;\r
+  if( this->m_IsMultiple || this->m_Connection.size( ) == 0 )\r
+    this->m_Connection.push_back( c );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -191,10 +189,14 @@ itemChange( GraphicsItemChange change, const QVariant& value )
 {\r
   if( change == ItemScenePositionHasChanged )\r
   {\r
-    if( this->m_Connection != NULL )\r
+    for(\r
+      auto i = this->m_Connection.begin( );\r
+      i != this->m_Connection.end( );\r
+      ++i\r
+      )\r
     {\r
-      this->m_Connection->updatePosFromPorts( );\r
-      this->m_Connection->updatePath( );\r
+      ( *i )->updatePosFromPorts( );\r
+      ( *i )->updatePath( );\r
 \r
     } // fi\r
 \r