Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a92a0d1
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -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
Expand Down

0 comments on commit a92a0d1

Please sign in to comment.