mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 13:01:41 +00:00
We can select multiple items
This commit is contained in:
parent
b300bb1ee7
commit
8f72f2d12f
2 changed files with 10 additions and 11 deletions
|
@ -28,7 +28,7 @@ QWidget( parent )
|
||||||
{
|
{
|
||||||
m_ui.setupUi( this );
|
m_ui.setupUi( this );
|
||||||
|
|
||||||
m_selection = NULL;
|
m_hasSelection = false;
|
||||||
|
|
||||||
m_scene = new QGraphicsScene( this );
|
m_scene = new QGraphicsScene( this );
|
||||||
m_ui.view->setScene( m_scene );
|
m_ui.view->setScene( m_scene );
|
||||||
|
@ -51,7 +51,7 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
a = menu.addAction( "Add rect" );
|
a = menu.addAction( "Add rect" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) );
|
||||||
|
|
||||||
if( m_selection != NULL )
|
if( m_hasSelection )
|
||||||
{
|
{
|
||||||
a = menu.addAction( "Remove" );
|
a = menu.addAction( "Remove" );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
|
||||||
|
@ -69,19 +69,19 @@ void ExpressionEditor::onAddRect()
|
||||||
|
|
||||||
void ExpressionEditor::onDeleteSelection()
|
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()
|
void ExpressionEditor::onSelectionChanged()
|
||||||
{
|
{
|
||||||
QList< QGraphicsItem* > l = m_scene->selectedItems();
|
QList< QGraphicsItem* > l = m_scene->selectedItems();
|
||||||
if( l.isEmpty() )
|
if( l.isEmpty() )
|
||||||
{
|
m_hasSelection = false;
|
||||||
m_selection = NULL;
|
else
|
||||||
return;
|
m_hasSelection = true;
|
||||||
}
|
|
||||||
|
|
||||||
m_selection = l[ 0 ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "ui_expression_editor.h"
|
#include "ui_expression_editor.h"
|
||||||
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
class QGraphicsItem;
|
|
||||||
|
|
||||||
class ExpressionEditor : public QWidget
|
class ExpressionEditor : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -44,7 +43,7 @@ private:
|
||||||
Ui::ExpressionEditor m_ui;
|
Ui::ExpressionEditor m_ui;
|
||||||
QGraphicsScene *m_scene;
|
QGraphicsScene *m_scene;
|
||||||
|
|
||||||
QGraphicsItem *m_selection;
|
bool m_hasSelection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue