make QgsRelation::RelationStrength a Q_ENUM and simplify code

This commit is contained in:
Denis Rouzaud 2020-09-10 14:26:42 +02:00
parent 27422fd717
commit e87ba45edc
4 changed files with 4 additions and 10 deletions

View File

@ -0,0 +1,2 @@
# The following has been generated automatically from src/core/qgsrelation.h
QgsRelation.RelationStrength.baseClass = QgsRelation

View File

@ -26,7 +26,6 @@ class QgsRelation
{ {
Association, Association,
Composition Composition
}; };

View File

@ -126,14 +126,7 @@ void QgsRelation::writeXml( QDomNode &node, QDomDocument &doc ) const
elem.setAttribute( QStringLiteral( "name" ), d->mRelationName ); elem.setAttribute( QStringLiteral( "name" ), d->mRelationName );
elem.setAttribute( QStringLiteral( "referencingLayer" ), d->mReferencingLayerId ); elem.setAttribute( QStringLiteral( "referencingLayer" ), d->mReferencingLayerId );
elem.setAttribute( QStringLiteral( "referencedLayer" ), d->mReferencedLayerId ); elem.setAttribute( QStringLiteral( "referencedLayer" ), d->mReferencedLayerId );
if ( d->mRelationStrength == RelationStrength::Composition ) elem.setAttribute( QStringLiteral( "strength" ), qgsEnumValueToKey<RelationStrength>( d->mRelationStrength ) );
{
elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Composition" ) );
}
else
{
elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Association" ) );
}
for ( const FieldPair &pair : qgis::as_const( d->mFieldPairs ) ) for ( const FieldPair &pair : qgis::as_const( d->mFieldPairs ) )
{ {

View File

@ -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. 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 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 #ifndef SIP_RUN