From: Leonardo Flórez-Valencia Date: Fri, 10 Mar 2017 18:47:09 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=33a60875fc809468442cad68b96f59cb541e878f;p=cpPlugins.git ... --- diff --git a/libs/cpPipelineEditor/Canvas.cxx b/libs/cpPipelineEditor/Canvas.cxx index 2a8023a..2731246 100644 --- a/libs/cpPipelineEditor/Canvas.cxx +++ b/libs/cpPipelineEditor/Canvas.cxx @@ -4,6 +4,9 @@ #include +#include +#include + // ------------------------------------------------------------------------- cpPipelineEditor::Canvas:: Canvas( QWidget* parent ) @@ -21,4 +24,59 @@ cpPipelineEditor::Canvas:: { } +// ------------------------------------------------------------------------- +void cpPipelineEditor::Canvas:: +dragEnterEvent( QDragEnterEvent* event ) +{ + const QMimeData* mime = event->mimeData( ); + if( mime->hasFormat( "application/x-qabstractitemmodeldatalist" ) ) + event->acceptProposedAction( ); +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Canvas:: +dragLeaveEvent( QDragLeaveEvent* event ) +{ +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Canvas:: +dragMoveEvent( QDragMoveEvent* event ) +{ +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Canvas:: +dropEvent( QDropEvent* event ) +{ + // Get dropped data + const QMimeData* mime = event->mimeData( ); + if( !( mime->hasFormat( "application/x-qabstractitemmodeldatalist" ) ) ) + return; + event->acceptProposedAction( ); + QTreeWidget* tree = dynamic_cast< QTreeWidget* >( event->source( ) ); + if( tree == NULL ) + return; + + // Process dropped data + QList< QTreeWidgetItem* > items = tree->selectedItems( ); + for( + QList< QTreeWidgetItem* >::const_iterator iIt = items.begin( ); + iIt != items.end( ); + ++iIt + ) + { + /* TODO + auto parent = ( *iIt )->parent( ); + if( parent != NULL ) + this->addFilter( + parent->text( 0 ).toStdString( ), + ( *iIt )->text( 0 ).toStdString( ), + p + ); + */ + + } // rof +} + // eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Canvas.h b/libs/cpPipelineEditor/Canvas.h index 2cd7201..373dcd8 100644 --- a/libs/cpPipelineEditor/Canvas.h +++ b/libs/cpPipelineEditor/Canvas.h @@ -27,6 +27,12 @@ namespace cpPipelineEditor Canvas( QWidget* parent = NULL ); virtual ~Canvas( ); + protected: + virtual void dragEnterEvent( QDragEnterEvent* event ) override; + virtual void dragLeaveEvent( QDragLeaveEvent* event ) override; + virtual void dragMoveEvent( QDragMoveEvent* event ) override; + virtual void dropEvent( QDropEvent* event ) override; + protected: QGraphicsScene* m_Scene; };