Skip to content
Permalink
Browse files

Avoid temporary no-selection state when selecting a new item

in layouts using mouse interactions
  • Loading branch information
nyalldawson committed Oct 10, 2017
1 parent ab4e6c1 commit 29dfcc0d7d552fcc73936f1b7d5bd266ca23ee34
Showing with 11 additions and 8 deletions.
  1. +11 −8 src/gui/layout/qgslayoutviewtoolselect.cpp
@@ -62,11 +62,12 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
QgsLayoutItem *selectedItem = nullptr;
QgsLayoutItem *previousSelectedItem = nullptr;

QList<QgsLayoutItem *> selectedItems = layout()->selectedLayoutItems();

if ( event->modifiers() & Qt::ControlModifier )
{
//CTRL modifier, so we are trying to select the next item below the current one
//first, find currently selected item
QList<QgsLayoutItem *> selectedItems = layout()->selectedLayoutItems();
if ( !selectedItems.isEmpty() )
{
previousSelectedItem = selectedItems.at( 0 );
@@ -100,12 +101,6 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
return;
}

if ( ( !selectedItem->isSelected() ) && //keep selection if an already selected item pressed
!( event->modifiers() & Qt::ShiftModifier ) ) //keep selection if shift key pressed
{
layout()->deselectAll();
}

if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
{
//SHIFT-clicking a selected item deselects it
@@ -120,7 +115,15 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
}
else
{
selectedItem->setSelected( true );
if ( ( !selectedItem->isSelected() ) && //keep selection if an already selected item pressed
!( event->modifiers() & Qt::ShiftModifier ) ) //keep selection if shift key pressed
{
layout()->setSelectedItem( selectedItem ); // clears existing selection
}
else
{
selectedItem->setSelected( true );
}
event->ignore();
emit itemFocused( selectedItem );
}

0 comments on commit 29dfcc0

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