Skip to content
Permalink
Browse files
On duplicate copy join and virtual fields
Fixes #14191
  • Loading branch information
m-kuhn committed Feb 5, 2016
1 parent 0e3faf7 commit 57b5eb954ef988489456fcd14b236bb784d150a2
Showing 1 changed file with 9 additions and 0 deletions.
@@ -7812,6 +7812,15 @@ void QgisApp::duplicateLayers( const QList<QgsMapLayer *>& lyrList )
QgsExpressionContextUtils::setLayerVariable( dupVLayer, variableName, varValue );
}

Q_FOREACH ( const QgsVectorJoinInfo& join, vlayer->vectorJoins() )
dupVLayer->addJoin( join );

for ( int fld = 0; fld < vlayer->fields().count(); fld++ )
{
if ( vlayer->fields().fieldOrigin( fld ) == QgsFields::OriginExpression )
dupVLayer->addExpressionField( vlayer->expressionField( fld ), vlayer->fields().at( fld ) );
}

dupLayer = dupVLayer;
}
}

5 comments on commit 57b5eb9

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 57b5eb9 Feb 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant, thanks for fixing the joins too.

@3nids
Copy link
Member

@3nids 3nids commented on 57b5eb9 Feb 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work for relations?
Duplicate with new id? Adapt fields accordingly?

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on 57b5eb9 Feb 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably the best we can get with relations.

@SebDieBln
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing the joins too

The joins were not broken at all, so now duplicated layers get every join twice. See PR #2816.

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on 57b5eb9 Feb 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that and thanks for the fix

Please sign in to comment.