Skip to content
Permalink
Browse files
Fix check/unchek of groups in TOC (ticket #5013)
  • Loading branch information
mhugent committed Apr 2, 2012
1 parent 9154e4e commit 9e15906f063a4947324b68c94ff65e1e9c4e05c1
Showing with 17 additions and 3 deletions.
  1. +16 −2 src/app/legend/qgslegend.cpp
  2. +1 −1 src/app/legend/qgslegend.h
@@ -521,11 +521,22 @@ void QgsLegend::updateGroupCheckStates( QTreeWidgetItem *item )

void QgsLegend::mouseReleaseEvent( QMouseEvent * e )
{
QStringList layersPriorToEvent = layerIDs();
QTreeWidget::mouseReleaseEvent( e );
mMousePressedFlag = false;

if ( mItemsBeingMoved.isEmpty() )
{
//Trigger refresh because of check states on layers.
//If it comes from a check action on a group, it is not covered in handleItemChanges(),
//so we do it here
QgsLegendGroup *lg = dynamic_cast<QgsLegendGroup *>( currentItem() );
if ( lg && ( layersPriorToEvent != layerIDs() ) )
{
mMapCanvas->refresh();
}
return;
}

setCursor( QCursor( Qt::ArrowCursor ) );
hideLine();
@@ -1907,8 +1918,11 @@ QStringList QgsLegend::layerIDs()
QgsLegendLayer* ll = qobject_cast<QgsLegendLayer *>( li );
if ( ll )
{
QgsMapLayer *lyr = ll->layer();
layers.push_front( lyr->id() );
if ( ll->checkState( 0 ) == Qt::Checked )
{
QgsMapLayer *lyr = ll->layer();
layers.push_front( lyr->id() );
}
}
}

@@ -169,7 +169,7 @@ class QgsLegend : public QTreeWidget
/**Removes an item from the legend. This is e.g. necessary before shifting it to another place*/
void removeItem( QTreeWidgetItem* item );

/**Returns the ids of the layers contained in this legend. The order is bottom->top*/
/**Returns the ids of the visible layers contained in this legend. The order is bottom->top*/
QStringList layerIDs();

/**Updates layer set of map canvas*/

0 comments on commit 9e15906

Please sign in to comment.