Skip to content
Permalink
Browse files
Update to legend right-click
- Right-click now performs widget item change before contextual menu is handled (no more lost right-clicks)
- Right-clicks within multiple selection preserve selection, but still switch item
- Right-clicks outside of current selection clears selection and switches to new item before contextual menu
  • Loading branch information
dakcarto committed Dec 26, 2012
1 parent 369971a commit a92a0d1eb5ca0a09e5707049ec294108755baa13
Showing with 25 additions and 4 deletions.
  1. +25 −4 src/app/legend/qgslegend.cpp
@@ -387,12 +387,33 @@ void QgsLegend::mousePressEvent( QMouseEvent * e )
else if ( e->button() == Qt::RightButton )
{
QTreeWidgetItem* item = itemAt( e->pos() );
if ( !item || item == currentItem() )
if ( !item )
{
setCurrentItem( 0 );
}
else if ( item != currentItem() )
{
if ( selectedItems().contains( item ) )
{
setCurrentItem( item, currentColumn(), QItemSelectionModel::NoUpdate );
}
else
{
clearSelection();
setCurrentItem( item );
}
}
else
{
if ( !item )
setCurrentItem( 0 );
handleRightClickEvent( item, e->globalPos() );
// item is the current layer, but maybe previous selection was none
if ( !item->isSelected() )
{
item->setSelected( true );
}
}
handleRightClickEvent( item, e->globalPos() );
e->ignore();
return;
}
QTreeWidget::mousePressEvent( e );
} // contentsMousePressEvent

0 comments on commit a92a0d1

Please sign in to comment.