[layertree] Preserve the order of layers when adding several layers at once

This commit is contained in:
Martin Dobias 2014-06-04 00:31:48 +07:00
parent 974a3eb3a8
commit be7c4d0822

View File

@ -47,10 +47,11 @@ void QgsLayerTreeRegistryBridge::layersAdded( QList<QgsMapLayer*> layers )
if ( !mEnabled )
return;
int i = 0;
foreach ( QgsMapLayer* layer, layers )
{
// add new layer to the top
QgsLayerTreeLayer* nodeLayer = mInsertionPointGroup->insertLayer( mInsertionPointIndex, layer );
QgsLayerTreeLayer* nodeLayer = mInsertionPointGroup->insertLayer( mInsertionPointIndex + i++, layer );
// check whether the layer is marked as embedded
QString projectFile = QgsProject::instance()->layerIsEmbedded( nodeLayer->layerId() );