+ this->_deselectPort( );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+dragMoveEvent( QGraphicsSceneDragDropEvent* event )
+{
+ this->_selectPort( event->pos( ) );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+dragLeaveEvent( QGraphicsSceneDragDropEvent* event )
+{
+ this->_deselectPort( );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+dropEvent( QGraphicsSceneDragDropEvent* event )
+{
+ // Get vertices and directionality
+ bool ok;
+ qulonglong address =
+ event->mimeData( )->data( "source_node" ).toULongLong( &ok );
+ Node* src = reinterpret_cast< Node* >( address );
+ if( src == NULL )
+ return;
+ Node* des = this;
+ if( src->m_SelectedPortIsInput )
+ {
+ des = src;
+ src = this;
+
+ } // fi
+
+ // Discard if a loop is detected
+ if( src == des )
+ return;
+
+ // Get edge data
+ const QRectF* srcPort = src->m_SelectedPort;
+ const QRectF* desPort = des->m_SelectedPort;
+ std::string srcName = src->m_Object->GetName( );
+ std::string desName = des->m_Object->GetName( );
+ std::string srcPortName = src->toolTip( ).toStdString( );
+ std::string desPortName = des->toolTip( ).toStdString( );
+
+ Edge* e = new Edge( src, des, srcPort, desPort );
+ src->addEdge( e );
+ des->addEdge( e );
+ if( this->m_Canvas != NULL )
+ this->m_Canvas->scene( )->addItem( e );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+_selectPort( const QPointF& pos )
+{
+ if( this->m_DraggingPort )
+ return;
+
+ const QRectF* prevPort = this->m_SelectedPort;
+
+ // Check ports
+ std::map< std::string, QRectF >* ports[] =
+ { &( this->m_InputPorts ), &( this->m_OutputPorts ) };
+ bool found = false;
+ for( unsigned int pId = 0; pId < 2 && !found; ++pId )
+ {
+ for(
+ auto i = ports[ pId ]->begin( );
+ i != ports[ pId ]->end( ) && !found;
+ ++i
+ )
+ {
+ if( i->second.contains( pos ) )
+ {
+ this->setToolTip( i->first.c_str( ) );
+ this->m_SelectedPort = &( i->second );
+ this->m_SelectedPortIsInput = ( pId == 0 );
+ found = true;
+
+ } // fi
+
+ } // rof
+
+ } // rof
+ if( !found )
+ {
+ this->setToolTip( this->m_Object->GetName( ) );
+ this->m_SelectedPort = NULL;
+
+ } // fi
+ if( prevPort != this->m_SelectedPort )
+ this->update( );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+_deselectPort( )
+{
+ if( !( this->m_DraggingPort ) )
+ {
+ this->m_SelectedPort = NULL;
+ this->update( );
+
+ } // fi