// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
// -------------------------------------------------------------------------
+
+#include <iostream>
+
+
+
+
+
#include <cpPipelineEditor/Canvas.h>
+#include <cpPipelineEditor/FilterBlock.h>
+#include <cpPipelineEditor/FunctorBlock.h>
+#include <cpPipelineEditor/WidgetBlock.h>
#include <QDragEnterEvent>
#include <QTreeWidget>
{
}
+// -------------------------------------------------------------------------
+cpPipelineEditor::Block* cpPipelineEditor::Canvas::
+createBlock( const std::string& name )
+{
+ QString str = name.c_str( );
+ QStringList tokens = str.split( "@" );
+ std::string block_type = tokens.back( ).toStdString( );
+ Block* new_block = NULL;
+ if( block_type == "Filters" )
+ new_block = new FilterBlock( NULL, this->m_Scene );
+ else if( block_type == "Functors" )
+ new_block = new FunctorBlock( NULL, this->m_Scene );
+ else if( block_type == "Widgets" )
+ new_block = new WidgetBlock( NULL, this->m_Scene );
+ return( new_block );
+}
+
// -------------------------------------------------------------------------
void cpPipelineEditor::Canvas::
dragEnterEvent( QDragEnterEvent* event )
// Process dropped data
QList< QTreeWidgetItem* > items = tree->selectedItems( );
- for(
- QList< QTreeWidgetItem* >::const_iterator iIt = items.begin( );
- iIt != items.end( );
- ++iIt
- )
+ for( QTreeWidgetItem* item : items )
{
- /* TODO
- auto parent = ( *iIt )->parent( );
- if( parent != NULL )
- this->addFilter(
- parent->text( 0 ).toStdString( ),
- ( *iIt )->text( 0 ).toStdString( ),
- p
- );
- */
+ std::string name = "";
+ QTreeWidgetItem* p = item;
+ while( p != NULL )
+ {
+ name += p->text( 0 ).toStdString( ) + "@";
+ p = p->parent( );
+
+ } // elihw
+ name.resize( name.size( ) - 1 );
+
+ // Create block
+ Block* b = this->createBlock( name );
} // rof
}