[QGIS Commit] r13840 - in branches/threading-branch/src: app/legend gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Jun 29 05:45:10 EDT 2010


Author: wonder
Date: 2010-06-29 09:45:10 +0000 (Tue, 29 Jun 2010)
New Revision: 13840

Modified:
   branches/threading-branch/src/app/legend/qgslegend.cpp
   branches/threading-branch/src/gui/qgsmapcanvas.cpp
Log:
Fixed handling of layer visibility in legend


Modified: branches/threading-branch/src/app/legend/qgslegend.cpp
===================================================================
--- branches/threading-branch/src/app/legend/qgslegend.cpp	2010-06-29 09:41:56 UTC (rev 13839)
+++ branches/threading-branch/src/app/legend/qgslegend.cpp	2010-06-29 09:45:10 UTC (rev 13840)
@@ -420,11 +420,6 @@
 
 void QgsLegend::handleRightClickEvent( QTreeWidgetItem* item, const QPoint& position )
 {
-  if ( !mMapCanvas || mMapCanvas->isDrawing() )
-  {
-    return;
-  }
-
   QMenu theMenu;
 
   QgsLegendItem* li = dynamic_cast<QgsLegendItem *>( item );
@@ -495,25 +490,13 @@
 
 void QgsLegend::addLayer( QgsMapLayer * layer )
 {
-  if ( !mMapCanvas || mMapCanvas->isDrawing() )
-  {
-    return;
-  }
-
   QgsLegendLayer* llayer = new QgsLegendLayer( layer );
 
   //set the correct check states
+  Qt::CheckState checkState = llayer->isVisible() ? Qt::Checked : Qt::Unchecked;
   blockSignals( true );
-  if ( llayer->isVisible() )
-  {
-    llayer->setCheckState( 0, Qt::Checked );
-    llayer->setData( 0, Qt::UserRole, Qt::Checked );
-  }
-  else
-  {
-    llayer->setCheckState( 0, Qt::Unchecked );
-    llayer->setData( 0, Qt::UserRole, Qt::Unchecked );
-  }
+  llayer->setCheckState( 0, checkState );
+  llayer->setData( 0, Qt::UserRole, checkState );
   blockSignals( false );
 
   QgsLegendGroup *lg = dynamic_cast<QgsLegendGroup *>( currentItem() );
@@ -601,11 +584,6 @@
 
 void QgsLegend::legendGroupRemove()
 {
-  if ( !mMapCanvas || mMapCanvas->isDrawing() )
-  {
-    return;
-  }
-
   QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup *>( currentItem() );
   if ( lg )
   {
@@ -615,11 +593,6 @@
 
 void QgsLegend::removeGroup( QgsLegendGroup * lg )
 {
-  if ( !mMapCanvas || mMapCanvas->isDrawing() )
-  {
-    return;
-  }
-
   //delete the legend layers first
   QTreeWidgetItem * child = lg->child( 0 );
   while ( child )

Modified: branches/threading-branch/src/gui/qgsmapcanvas.cpp
===================================================================
--- branches/threading-branch/src/gui/qgsmapcanvas.cpp	2010-06-29 09:41:56 UTC (rev 13839)
+++ branches/threading-branch/src/gui/qgsmapcanvas.cpp	2010-06-29 09:45:10 UTC (rev 13840)
@@ -227,9 +227,6 @@
 
 void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
 {
-  // make sure we're not rendering
-  cancelRendering();
-
   // create layer set
   QStringList layerSet, layerSetOverview;
 
@@ -260,6 +257,9 @@
   // update only if needed
   if ( layerSetChanged )
   {
+    // make sure we're not rendering
+    cancelRendering();
+
     for ( i = 0; i < layerCount(); i++ )
     {
       // Add check if vector layer when disconnecting from selectionChanged slot
@@ -313,7 +313,7 @@
     refresh();
   }
 
-} // addLayer
+} // setLayerSet
 
 void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview )
 {



More information about the QGIS-commit mailing list