From 1b79f6573aa3b01d97ca4f100ba9ee0c809a4243 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 25 Jan 2016 17:41:08 -0500 Subject: [PATCH] ... --- lib/cpPipelineEditor/Canvas.cxx | 43 +++++++++++++++++++++++++++++++++ lib/cpPipelineEditor/Canvas.h | 2 +- lib/cpPipelineEditor/Editor.cxx | 25 +++++++++++++++++++ lib/cpPipelineEditor/Editor.h | 5 ++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lib/cpPipelineEditor/Canvas.cxx b/lib/cpPipelineEditor/Canvas.cxx index 29897fb..b8027d9 100644 --- a/lib/cpPipelineEditor/Canvas.cxx +++ b/lib/cpPipelineEditor/Canvas.cxx @@ -44,6 +44,49 @@ editor( ) const return( this->m_Editor ); } +// ------------------------------------------------------------------------- +void cpPipelineEditor::Canvas:: +keyPressEvent( QKeyEvent* event ) +{ + static const int del_key = 16777223; + if( event->key( ) == del_key ) + { + auto _items = this->items( ); + auto i = _items.begin( ); + while( i != _items.end( ) ) + { + if( ( *i )->isSelected( ) ) + { + Block* b = dynamic_cast< Block* >( *i ); + Connection* c = dynamic_cast< Connection* >( *i ); + if( b != NULL ) + { + if( this->m_Editor->deleteFilter( b->namePort( ).toStdString( ) ) ) + delete b; + } + else if( c != NULL ) + { + if( + this->m_Editor->deleteConnection( + c->port1( )->block( )->namePort( ).toStdString( ), + c->port2( )->block( )->namePort( ).toStdString( ), + c->port1( )->name( ).toStdString( ), + c->port2( )->name( ).toStdString( ) + ) + ) + delete c; + + } // fi + i = _items.end( ); + } + else + i++; + + } // elihw + + } // fi +} + // ------------------------------------------------------------------------- void cpPipelineEditor::Canvas:: wheelEvent( QWheelEvent* event ) diff --git a/lib/cpPipelineEditor/Canvas.h b/lib/cpPipelineEditor/Canvas.h index c327a69..eb57a23 100644 --- a/lib/cpPipelineEditor/Canvas.h +++ b/lib/cpPipelineEditor/Canvas.h @@ -27,9 +27,9 @@ namespace cpPipelineEditor protected: /* TODO - void keyPressEvent( QKeyEvent* event ); void timerEvent( QTimerEvent* event ); */ + void keyPressEvent( QKeyEvent* event ); void wheelEvent( QWheelEvent* event ); void dragEnterEvent( QDragEnterEvent* event ); diff --git a/lib/cpPipelineEditor/Editor.cxx b/lib/cpPipelineEditor/Editor.cxx index f74ce6e..736fecc 100644 --- a/lib/cpPipelineEditor/Editor.cxx +++ b/lib/cpPipelineEditor/Editor.cxx @@ -127,6 +127,31 @@ createFilter( const std::string& filter, const QPointF& pnt ) return( "" ); } +// ------------------------------------------------------------------------- +bool cpPipelineEditor::Editor:: +deleteFilter( const std::string& name ) +{ + std::cout << name << std::endl; +#error delete filter + return( false ); +} + +// ------------------------------------------------------------------------- +bool cpPipelineEditor::Editor:: +deleteConnection( + const std::string& src, const std::string& des, + const std::string& in, const std::string& out + ) +{ + std::cout + << src << " " + << des << " " + << in << " " + << out << std::endl; +#error delete connection + return( false ); +} + // ------------------------------------------------------------------------- void cpPipelineEditor::Editor:: install( QGraphicsScene* s ) diff --git a/lib/cpPipelineEditor/Editor.h b/lib/cpPipelineEditor/Editor.h index ca273b2..bceeecd 100644 --- a/lib/cpPipelineEditor/Editor.h +++ b/lib/cpPipelineEditor/Editor.h @@ -57,6 +57,11 @@ namespace cpPipelineEditor const std::string& filter, const QPointF& pnt = QPointF( qreal( 0 ), qreal( 0 ) ) ); + bool deleteFilter( const std::string& name ); + bool deleteConnection( + const std::string& src, const std::string& des, + const std::string& in, const std::string& out + ); void install( QGraphicsScene* s ); bool eventFilter( QObject* o, QEvent* e ); -- 2.47.1