Skip to content

Commit

Permalink
make QgsRelation::RelationStrength a Q_ENUM and simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 10, 2020
1 parent 27422fd commit e87ba45
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 2 additions & 0 deletions python/core/auto_additions/qgsrelation.py
@@ -0,0 +1,2 @@
# The following has been generated automatically from src/core/qgsrelation.h
QgsRelation.RelationStrength.baseClass = QgsRelation
1 change: 0 additions & 1 deletion python/core/auto_generated/qgsrelation.sip.in
Expand Up @@ -26,7 +26,6 @@ class QgsRelation
{
Association,
Composition

};


Expand Down
9 changes: 1 addition & 8 deletions src/core/qgsrelation.cpp
Expand Up @@ -126,14 +126,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 ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsrelation.h
Expand Up @@ -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

Expand Down

0 comments on commit e87ba45

Please sign in to comment.