Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix check/unchek of groups in TOC (ticket #5013)
  • Loading branch information
mhugent committed Apr 2, 2012
1 parent 9154e4e commit 9e15906
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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() );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegend.h
Expand Up @@ -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*/
Expand Down

0 comments on commit 9e15906

Please sign in to comment.