[QGIS-trac] [Quantum GIS] #1856: Improving Show/Hide all layers

Quantum GIS qgis at qgis.org
Mon Aug 3 23:21:36 EDT 2009


#1856: Improving Show/Hide all layers
-------------------------------------------------------+--------------------
   Reporter:  gcarrillo                                |              Owner:  nobody       
       Type:  bug                                      |             Status:  new          
   Priority:  minor: annoyance                         |          Milestone:  Version 1.2.0
  Component:  Map Legend                               |            Version:  HEAD         
   Keywords:  show hide all layers legend canvas slow  |   Platform_version:               
   Platform:  All                                      |           Must_fix:  No           
Status_info:  0                                        |  
-------------------------------------------------------+--------------------
 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

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1856>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list