Skip to content
Permalink
Browse files
fix for bug #85 (remove layer does not work for legend layer files)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5440 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 11, 2006
1 parent f5820dc commit e49b162f7a4cd59a42d8dbc71fd8c61d1cc5d17c
Showing with 39 additions and 30 deletions.
  1. +0 −3 src/gui/qgsmaptoolcapture.cpp
  2. +39 −27 src/legend/qgslegend.cpp
@@ -102,7 +102,6 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
QMessageBox::Ok);
return;
}

QgsPoint idPoint = toMapCoords(e->pos());

// emit signal - QgisApp can catch it and save point position to clipboard
@@ -150,8 +149,6 @@ QMessageBox::Ok);
}
else if (mTool == CaptureLine || mTool == CapturePolygon)
{
// LINE & POLYGON CAPTURING

//check we only use the line tool for line/multiline layers
if(mTool == CaptureLine && vlayer->vectorType() != QGis::Line)
{
@@ -592,39 +592,51 @@ void QgsLegend::legendGroupRemove()

void QgsLegend::legendLayerRemove()
{
//remove all layers of the current legendLayer
//if the current item is a legend layer: remove all layers of the current legendLayer
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
if(!ll)
{
return;
}

std::list<QgsMapLayer*> maplayers = ll->mapLayers();
mStateOfCheckBoxes.erase(ll);

//todo: also remove the entries for the QgsLegendLayerFiles from the map
std::list<QgsLegendLayerFile*> llfiles = ll->legendLayerFiles();
for(std::list<QgsLegendLayerFile*>::iterator it = llfiles.begin(); it != llfiles.end(); ++it)
{
mStateOfCheckBoxes.erase(*it);
}

for(std::list<QgsMapLayer*>::iterator it = maplayers.begin(); it!=maplayers.end(); ++it)
if(ll)
{
//remove the layer
if(*it)
std::list<QgsMapLayer*> maplayers = ll->mapLayers();
mStateOfCheckBoxes.erase(ll);

//also remove the entries for the QgsLegendLayerFiles from the map
std::list<QgsLegendLayerFile*> llfiles = ll->legendLayerFiles();
for(std::list<QgsLegendLayerFile*>::iterator it = llfiles.begin(); it != llfiles.end(); ++it)
{
mStateOfCheckBoxes.erase(*it);
}

for(std::list<QgsMapLayer*>::iterator it = maplayers.begin(); it!=maplayers.end(); ++it)
{
QgsMapLayerRegistry::instance()->removeMapLayer((*it)->getLayerID());
//remove the layer
if(*it)
{
QgsMapLayerRegistry::instance()->removeMapLayer((*it)->getLayerID());
}
}

if(maplayers.size()>0)
{
mMapCanvas->refresh();
}
removeItem(ll);
delete ll;
adjustIconSize();
return;
}

if(maplayers.size()>0)
{
mMapCanvas->refresh();
}
removeItem(ll);
delete ll;
adjustIconSize();
//if the current item is a legend layer file
QgsLegendLayerFile* llf = dynamic_cast<QgsLegendLayerFile*>(currentItem());
if(llf)
{
if(llf->layer())
{
//the map layer registry emits a signal an this will remove the legend layer
//from the legend and from memory by calling QgsLegend::removeLayer(QString layer key)
QgsMapLayerRegistry::instance()->removeMapLayer(llf->layer()->getLayerID());
}
}
return;
}

void QgsLegend::legendLayerAddToOverview()

0 comments on commit e49b162

Please sign in to comment.