Bug report #1856

Improving Show/Hide all layers

Added by gcarrillo - about 10 years ago. Updated about 10 years ago.

Status:Closed
Priority:Low
Assignee:Magnus Homann
Category:Map Legend
Affected QGIS version: Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:11916

Description

I think Show/Hide all layers are really slow methods (prove it with 4 or 5 heavy layers). The users can see every layer changing its state and consuming some time.

It is caused by multiple calls (one for each layer) to updateMapCanvasLayerSet method (QgsLegend class, selectAll slot). So one solution for this issue is: Set the state for the QTreeWidgetItems, set the state for the layers and finally call the updateMapCanvasLayerSet method.

I did this on a python app and get evident results (even faster than QGis :D), but my app is simple, I don't have layer groups or layer files. I don't understand how to manage them so, please try this in QgsLegend.

If you want I can make a screencast to show the difference.

Here is my Python code:

self.blockSignals( True )
status = Qt.Checked if select else Qt.Unchecked
for i in range( self.topLevelItemCount() ):
self.topLevelItem( i ).setCheckState( 0, status )
self.topLevelItem( i ).canvasLayer.setVisible( select )
self.blockSignals( False )
self.updateLayerSet() # Finally, update the layer set

Associated revisions

Revision d44fe793
Added by Magnus Homann about 10 years ago

Turn off rendering while looping through all layers hinding/showing. Fixes #1856

git-svn-id: http://svn.osgeo.org/qgis/trunk/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision 89818278
Added by Magnus Homann about 10 years ago

Turn off rendering while looping through all layers hinding/showing. Fixes #1856

git-svn-id: http://svn.osgeo.org/qgis/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Giovanni Manghi about 10 years ago

Hi!

homann is working on changes in the legend gui (see #1815), so he may be interested in this ticket and should be able to help.

#2 Updated by Magnus Homann about 10 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

Fixed in 89818278 (SVN r11264). Turned off rendering instead of blocking signals :-)
Thanks for the idea.

Also available in: Atom PDF