File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -521,11 +521,22 @@ void QgsLegend::updateGroupCheckStates( QTreeWidgetItem *item )
521521
522522void QgsLegend::mouseReleaseEvent ( QMouseEvent * e )
523523{
524+ QStringList layersPriorToEvent = layerIDs ();
524525 QTreeWidget::mouseReleaseEvent ( e );
525526 mMousePressedFlag = false ;
526527
527528 if ( mItemsBeingMoved .isEmpty () )
529+ {
530+ // Trigger refresh because of check states on layers.
531+ // If it comes from a check action on a group, it is not covered in handleItemChanges(),
532+ // so we do it here
533+ QgsLegendGroup *lg = dynamic_cast <QgsLegendGroup *>( currentItem () );
534+ if ( lg && ( layersPriorToEvent != layerIDs () ) )
535+ {
536+ mMapCanvas ->refresh ();
537+ }
528538 return ;
539+ }
529540
530541 setCursor ( QCursor ( Qt::ArrowCursor ) );
531542 hideLine ();
@@ -1907,8 +1918,11 @@ QStringList QgsLegend::layerIDs()
19071918 QgsLegendLayer* ll = qobject_cast<QgsLegendLayer *>( li );
19081919 if ( ll )
19091920 {
1910- QgsMapLayer *lyr = ll->layer ();
1911- layers.push_front ( lyr->id () );
1921+ if ( ll->checkState ( 0 ) == Qt::Checked )
1922+ {
1923+ QgsMapLayer *lyr = ll->layer ();
1924+ layers.push_front ( lyr->id () );
1925+ }
19121926 }
19131927 }
19141928
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ class QgsLegend : public QTreeWidget
169169 /* *Removes an item from the legend. This is e.g. necessary before shifting it to another place*/
170170 void removeItem ( QTreeWidgetItem* item );
171171
172- /* *Returns the ids of the layers contained in this legend. The order is bottom->top*/
172+ /* *Returns the ids of the visible layers contained in this legend. The order is bottom->top*/
173173 QStringList layerIDs ();
174174
175175 /* *Updates layer set of map canvas*/
You can’t perform that action at this time.
0 commit comments