]> Creatis software - cpPlugins.git/blob - libs/cpPipelineEditor/Canvas.cxx
27312460d8b060d6a9d15e9fc8ae632db8add566
[cpPlugins.git] / libs / cpPipelineEditor / Canvas.cxx
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #include <cpPipelineEditor/Canvas.h>
6
7 #include <QDragEnterEvent>
8 #include <QTreeWidget>
9
10 // -------------------------------------------------------------------------
11 cpPipelineEditor::Canvas::
12 Canvas( QWidget* parent )
13   : Superclass( parent )
14 {
15   this->m_Scene = new QGraphicsScene( this );
16   this->setScene( this->m_Scene );
17   this->setRenderHint( QPainter::Antialiasing );
18   this->setAcceptDrops( true );
19 }
20
21 // -------------------------------------------------------------------------
22 cpPipelineEditor::Canvas::
23 ~Canvas( )
24 {
25 }
26
27 // -------------------------------------------------------------------------
28 void cpPipelineEditor::Canvas::
29 dragEnterEvent( QDragEnterEvent* event )
30 {
31   const QMimeData* mime = event->mimeData( );
32   if( mime->hasFormat( "application/x-qabstractitemmodeldatalist" ) )
33     event->acceptProposedAction( );
34 }
35
36 // -------------------------------------------------------------------------
37 void cpPipelineEditor::Canvas::
38 dragLeaveEvent( QDragLeaveEvent* event )
39 {
40 }
41
42 // -------------------------------------------------------------------------
43 void cpPipelineEditor::Canvas::
44 dragMoveEvent( QDragMoveEvent* event )
45 {
46 }
47
48 // -------------------------------------------------------------------------
49 void cpPipelineEditor::Canvas::
50 dropEvent( QDropEvent* event )
51 {
52   // Get dropped data
53   const QMimeData* mime = event->mimeData( );
54   if( !( mime->hasFormat( "application/x-qabstractitemmodeldatalist" ) ) )
55     return;
56   event->acceptProposedAction( );
57   QTreeWidget* tree = dynamic_cast< QTreeWidget* >( event->source( ) );
58   if( tree == NULL )
59     return;
60
61   // Process dropped data
62   QList< QTreeWidgetItem* > items = tree->selectedItems( );
63   for(
64     QList< QTreeWidgetItem* >::const_iterator iIt = items.begin( );
65     iIt != items.end( );
66     ++iIt
67     )
68   {
69     /* TODO
70        auto parent = ( *iIt )->parent( );
71        if( parent != NULL )
72        this->addFilter(
73        parent->text( 0 ).toStdString( ),
74        ( *iIt )->text( 0 ).toStdString( ),
75        p
76        );
77     */
78
79   } // rof
80 }
81
82 // eof - $RCSfile$