Skip to content
Permalink
Browse files

Merge pull request #38677 from 3nids/rel-strength-qenum

make QgsRelation::RelationStrength a Q_ENUM and simplify code
  • Loading branch information
3nids committed Sep 10, 2020
2 parents 85e444e + 8471d5a commit 969f9f98a9c3e02717e4b0c9f4da5642a92e443d
@@ -0,0 +1,2 @@
# The following has been generated automatically from src/core/qgsrelation.h
QgsRelation.RelationStrength.baseClass = QgsRelation
@@ -26,7 +26,6 @@ class QgsRelation
{
Association,
Composition

};


@@ -94,14 +94,7 @@ QgsRelation QgsRelation::createFromXml( const QDomNode &node, QgsReadWriteContex
relation.d->mReferencedLayer = qobject_cast<QgsVectorLayer *>( referencedLayer );
relation.d->mRelationId = id;
relation.d->mRelationName = name;
if ( strength == QLatin1String( "Composition" ) )
{
relation.d->mRelationStrength = RelationStrength::Composition;
}
else
{
relation.d->mRelationStrength = RelationStrength::Association;
}
relation.d->mRelationStrength = qgsEnumKeyToValue<QgsRelation::RelationStrength>( strength, RelationStrength::Association );

QDomNodeList references = elem.elementsByTagName( QStringLiteral( "fieldRef" ) );
for ( int i = 0; i < references.size(); ++i )
@@ -126,14 +119,7 @@ void QgsRelation::writeXml( QDomNode &node, QDomDocument &doc ) const
elem.setAttribute( QStringLiteral( "name" ), d->mRelationName );
elem.setAttribute( QStringLiteral( "referencingLayer" ), d->mReferencingLayerId );
elem.setAttribute( QStringLiteral( "referencedLayer" ), d->mReferencedLayerId );
if ( d->mRelationStrength == RelationStrength::Composition )
{
elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Composition" ) );
}
else
{
elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Association" ) );
}
elem.setAttribute( QStringLiteral( "strength" ), qgsEnumValueToKey<RelationStrength>( d->mRelationStrength ) );

for ( const FieldPair &pair : qgis::as_const( d->mFieldPairs ) )
{
@@ -58,8 +58,8 @@ class CORE_EXPORT QgsRelation
{
Association, //!< Loose relation, related elements are not part of the parent and a parent copy will not copy any children.
Composition //!< Fix relation, related elements are part of the parent and a parent copy will copy any children or delete of parent will delete children

};
Q_ENUM( RelationStrength )

#ifndef SIP_RUN

0 comments on commit 969f9f9

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