From e2ea5a74b8ebaf539e9c29a90714fc52dc51dcfa Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 12 Sep 2014 19:47:28 +0200 Subject: [PATCH] We can select multiple items --HG-- branch : dfighter-tools --- .../plugins/gui_editor/expression_editor.cpp | 18 +++++++++--------- .../src/plugins/gui_editor/expression_editor.h | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 81ea74941..e4d749dcd 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -28,7 +28,7 @@ QWidget( parent ) { m_ui.setupUi( this ); - m_selection = NULL; + m_hasSelection = false; m_scene = new QGraphicsScene( this ); m_ui.view->setScene( m_scene ); @@ -51,7 +51,7 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e ) a = menu.addAction( "Add rect" ); connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) ); - if( m_selection != NULL ) + if( m_hasSelection ) { a = menu.addAction( "Remove" ); connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) ); @@ -69,19 +69,19 @@ void ExpressionEditor::onAddRect() void ExpressionEditor::onDeleteSelection() { - m_scene->removeItem( m_selection ); + QList< QGraphicsItem* > l = m_scene->selectedItems(); + QListIterator< QGraphicsItem* > itr( l ); + while( itr.hasNext() ) + m_scene->removeItem( itr.next() ); } void ExpressionEditor::onSelectionChanged() { QList< QGraphicsItem* > l = m_scene->selectedItems(); if( l.isEmpty() ) - { - m_selection = NULL; - return; - } - - m_selection = l[ 0 ]; + m_hasSelection = false; + else + m_hasSelection = true; } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 31fb64d73..b73f8029f 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -23,7 +23,6 @@ #include "ui_expression_editor.h" class QGraphicsScene; -class QGraphicsItem; class ExpressionEditor : public QWidget { @@ -44,7 +43,7 @@ private: Ui::ExpressionEditor m_ui; QGraphicsScene *m_scene; - QGraphicsItem *m_selection; + bool m_hasSelection; }; #endif