1568_fix2.patch

Made against revision 11533, delete a layer when one of its file group is selected - Gabriele Monfardini, 2009-08-31 02:16 PM

Download (1.24 KB)

View differences:

src/app/legend/qgslegend.cpp (copia locale)
735 735
      QgsMapLayerRegistry::instance()->removeMapLayer( llf->layer()->getLayerID() );
736 736
    }
737 737
  }
738
  
739
  //if the current item is a legend layer file group
740
  QgsLegendLayerFileGroup* llfg = dynamic_cast<QgsLegendLayerFileGroup*>( currentItem() );
741
  if ( llfg )
742
  {
743
    QgsDebugMsg( "QgsLegendLayerFileGroup" );
744
    ll = dynamic_cast<QgsLegendLayer*>( llfg->parent() );
745
    if (ll)
746
    {
747
      std::list<QgsMapLayer*> maplayers = ll->mapLayers();
748
      int layerCount = maplayers.size();
749

  
750
      for ( std::list<QgsMapLayer*>::iterator it = maplayers.begin(); it != maplayers.end(); ++it )
751
      {
752
	//remove the layer
753
	if ( *it )
754
	{
755
	  removeLayer( *it, true );
756
	}
757
      }
758

  
759
      if ( layerCount == 0 )
760
      {
761
	// delete the item only when it didn't have any child legend layer files
762
	// (otherwise it is deleted in QgsLegend::removeLayer when deleting last legend layer file)
763
	mStateOfCheckBoxes.erase( ll );
764
	removeItem( ll );
765
	delete ll;
766
      }
767

  
768
      adjustIconSize();
769
      return;
770
    }
771
  }
738 772
  return;
739 773
}
740 774