Skip to content

Commit

Permalink
Added QgsRelation::Type
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed Jan 18, 2021
1 parent 57f033f commit 449e275
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/core/auto_additions/qgsrelation.py
@@ -1,2 +1,3 @@
# The following has been generated automatically from src/core/qgsrelation.h
QgsRelation.RelationType.baseClass = QgsRelation
QgsRelation.RelationStrength.baseClass = QgsRelation
13 changes: 13 additions & 0 deletions python/core/auto_generated/qgsrelation.sip.in
Expand Up @@ -22,6 +22,12 @@ class QgsRelation

public:

enum RelationType
{
Normal,
Generated,
};

enum RelationStrength
{
Association,
Expand Down Expand Up @@ -333,6 +339,13 @@ Returns the parent polymorphic relation id. If the relation is a normal relation
%Docstring
Returns the parent polymorphic relation. If the relation is a normal relation, an invalid polymorphic relation is returned.

.. versionadded:: 3.18
%End

RelationType type() const;
%Docstring
Returns the type of the relation

.. versionadded:: 3.18
%End

Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsrelation.cpp
Expand Up @@ -435,3 +435,11 @@ QgsPolymorphicRelation QgsRelation::polymorphicRelation() const

return mContext.project()->relationManager()->polymorphicRelation( d->mPolymorphicRelationId );
}

QgsRelation::RelationType QgsRelation::type() const
{
if ( d->mPolymorphicRelationId.isNull() )
return QgsRelation::Normal;
else
return QgsRelation::Generated;
}
16 changes: 16 additions & 0 deletions src/core/qgsrelation.h
Expand Up @@ -53,6 +53,16 @@ class CORE_EXPORT QgsRelation

public:

/**
* Enum holding the relations type
*/
enum RelationType
{
Normal, //! A normal relation
Generated, //! A generated relation is a child of a polymorphic relation
};
Q_ENUM( RelationType )

/**
* enum for the relation strength
* Association, Composition
Expand Down Expand Up @@ -402,6 +412,12 @@ class CORE_EXPORT QgsRelation
*/
QgsPolymorphicRelation polymorphicRelation() const;

/**
* Returns the type of the relation
* \since QGIS 3.18
*/
RelationType type() const;

private:

mutable QExplicitlySharedDataPointer<QgsRelationPrivate> d;
Expand Down

0 comments on commit 449e275

Please sign in to comment.