Skip to content

Commit

Permalink
insert new layer before selected layer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Dec 29, 2011
1 parent 8ddf119 commit 5a08812
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -808,19 +808,34 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
blockSignals( false );

QgsLegendGroup *lg = dynamic_cast<QgsLegendGroup *>( currentItem() );
QSettings settings;
if ( !lg && currentItem() )
{
lg = dynamic_cast<QgsLegendGroup *>( currentItem()->parent() );
}

int index;
if ( lg )
{
index = lg->indexOfChild( currentItem() );
}
else
{
index = indexOfTopLevelItem( currentItem() );
}

if ( index < 0 )
{
index = 0;
}

QSettings settings;
if ( lg && settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() )
{
lg->insertChild( 0, llayer );
lg->insertChild( index, llayer );
}
else
{
insertTopLevelItem( 0, llayer );
insertTopLevelItem( index, llayer );
setCurrentItem( llayer );
}

Expand Down

0 comments on commit 5a08812

Please sign in to comment.