mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 01:48:44 +00:00
We can select multiple items
--HG-- branch : dfighter-tools
This commit is contained in:
parent
cc7e93c96e
commit
e2ea5a74b8
2 changed files with 10 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue