Bug report #1856
Improving Show/Hide all layers
|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|
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