Skip to content
Permalink
Browse files

Add a 'select all' action to model designer

  • Loading branch information
nyalldawson committed Mar 23, 2020
1 parent 4e1ebf0 commit 7bba9de2b999a97346f58e65b63376de0b6ed6c0
@@ -94,6 +94,11 @@ Returns list of selected component items.
QgsModelComponentGraphicItem *componentItemAt( QPointF position ) const;
%Docstring
Returns the topmost component item at a specified ``position``.
%End

void selectAll();
%Docstring
Selects all the components in the scene.
%End

void deselectAll();
@@ -142,6 +142,11 @@ QgsModelDesignerDialog::QgsModelDesignerDialog( QWidget *parent, Qt::WindowFlags
} );
mView->snapper()->setSnapToGrid( mActionSnappingEnabled->isChecked() );

connect( mActionSelectAll, &QAction::triggered, this, [ = ]
{
mScene->selectAll();
} );

mUndoAction = mUndoStack->createUndoAction( this );
mUndoAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionUndo.svg" ) ) );
mUndoAction->setShortcuts( QKeySequence::Undo );
@@ -222,6 +222,23 @@ QgsModelComponentGraphicItem *QgsModelGraphicsScene::componentItemAt( QPointF po
return nullptr;
}

void QgsModelGraphicsScene::selectAll()
{
//select all items in scene
QgsModelComponentGraphicItem *focusedItem = nullptr;
const QList<QGraphicsItem *> itemList = items();
for ( QGraphicsItem *graphicsItem : itemList )
{
if ( QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( graphicsItem ) )
{
componentItem->setSelected( true );
if ( !focusedItem )
focusedItem = componentItem;
}
}
emit selectedItemChanged( focusedItem );
}

void QgsModelGraphicsScene::deselectAll()
{
//we can't use QGraphicsScene::clearSelection, as that emits no signals
@@ -106,6 +106,11 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
*/
QgsModelComponentGraphicItem *componentItemAt( QPointF position ) const;

/**
* Selects all the components in the scene.
*/
void selectAll();

/**
* Clears any selected items in the scene.
*
@@ -87,9 +87,11 @@
<property name="title">
<string>&amp;Edit</string>
</property>
<addaction name="mActionSelectAll"/>
<addaction name="mActionSnapSelected"/>
<addaction name="separator"/>
<addaction name="mActionDeleteComponents"/>
<addaction name="separator"/>
<addaction name="mActionSnapSelected"/>
</widget>
<addaction name="menu_Model"/>
<addaction name="mMenuEdit"/>
@@ -627,6 +629,18 @@
<string>Snap Selected Components to Grid</string>
</property>
</action>
<action name="mActionSelectAll">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSelectAll.svg</normaloff>:/images/themes/default/mActionSelectAll.svg</iconset>
</property>
<property name="text">
<string>Select All</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

0 comments on commit 7bba9de

Please sign in to comment.
You can’t perform that action at this time.