Skip to content

Commit

Permalink
fix #4600: also remove invisible layers from layer order list
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 3, 2011
1 parent bde0427 commit e2dac54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/legend/qgslayerorder.cpp
Expand Up @@ -44,6 +44,9 @@ QgsLayerOrder::QgsLayerOrder( QgsLegend *legend, QWidget * parent, const char *n
connect( mLegend, SIGNAL( zOrderChanged() ),
this, SLOT( refreshLayerList() ) );

connect( mLegend, SIGNAL( invisibleLayerRemoved() ),
this, SLOT( refreshLayerList() ) );

connect( mLegend->canvas(), SIGNAL( layersChanged() ),
this, SLOT( refreshLayerList() ) );

Expand Down
10 changes: 9 additions & 1 deletion src/app/legend/qgslegend.cpp
Expand Up @@ -244,6 +244,8 @@ void QgsLegend::removeLayer( QString layerId )
{
QgsDebugMsg( "Entering." );

bool invLayerRemoved = false;

for ( QTreeWidgetItem* theItem = firstItem(); theItem; theItem = nextItem( theItem ) )
{
QgsLegendItem *li = dynamic_cast<QgsLegendItem *>( theItem );
Expand All @@ -254,15 +256,21 @@ void QgsLegend::removeLayer( QString layerId )

if ( ll && ll->layer() && ll->layer()->id() == layerId )
{
if( !ll->isVisible() )
{
invLayerRemoved = true;
}
removeItem( ll );
delete ll;
break;
}
}
}

updateMapCanvasLayerSet();
adjustIconSize();

if( invLayerRemoved )
emit invisibleLayerRemoved();
}

void QgsLegend::mousePressEvent( QMouseEvent * e )
Expand Down
1 change: 1 addition & 0 deletions src/app/legend/qgslegend.h
Expand Up @@ -515,6 +515,7 @@ class QgsLegend : public QTreeWidget
void itemMoved( QModelIndex oldIndex, QModelIndex newIndex );

void zOrderChanged();
void invisibleLayerRemoved();

void updateDrawingOrderChecked( bool );
void updateDrawingOrderUnchecked( bool );
Expand Down

0 comments on commit e2dac54

Please sign in to comment.