Skip to content
Permalink
Browse files

Copy layer variables when duplicating layers

  • Loading branch information
m-kuhn committed Jan 20, 2016
1 parent ff8472d commit 28b541ab4bc9af035ac86f643710f1f8a20f290c
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/app/qgisapp.cpp
@@ -7691,6 +7691,24 @@ void QgisApp::duplicateLayers( const QList<QgsMapLayer *>& lyrList )
{
dupVLayer->setProviderEncoding( vlayer->dataProvider()->encoding() );
}

//add variables defined in layer properties
QStringList variableNames = vlayer->customProperty( "variableNames" ).toStringList();
QStringList variableValues = vlayer->customProperty( "variableValues" ).toStringList();

int varIndex = 0;
Q_FOREACH ( const QString& variableName, variableNames )
{
if ( varIndex >= variableValues.length() )
{
break;
}

QVariant varValue = variableValues.at( varIndex );
varIndex++;
QgsExpressionContextUtils::setLayerVariable( dupVLayer, variableName, varValue );
}

dupLayer = dupVLayer;
}
}

0 comments on commit 28b541a

Please sign in to comment.
You can’t perform that action at this time.