]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 10 Mar 2017 18:47:09 +0000 (13:47 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 10 Mar 2017 18:47:09 +0000 (13:47 -0500)
libs/cpPipelineEditor/Canvas.cxx
libs/cpPipelineEditor/Canvas.h

index 2a8023a53ea28ded764922e40364078498d7b545..27312460d8b060d6a9d15e9fc8ae632db8add566 100644 (file)
@@ -4,6 +4,9 @@
 
 #include <cpPipelineEditor/Canvas.h>
 
+#include <QDragEnterEvent>
+#include <QTreeWidget>
+
 // -------------------------------------------------------------------------
 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$
index 2cd7201e1b0a6eda83a7197e2e3b56060ca903d4..373dcd8b7bdc6edad29ac1ff8d2e20fb33aa6259 100644 (file)
@@ -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;
   };