Added QgsRelation::Type

This commit is contained in:
Ivan Ivanov 2021-01-15 10:22:05 +02:00
parent 57f033f675
commit 449e2757d9
4 changed files with 38 additions and 0 deletions

View File

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

View File

@ -22,6 +22,12 @@ class QgsRelation
public:
enum RelationType
{
Normal,
Generated,
};
enum RelationStrength
{
Association,
@ -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

View File

@ -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;
}

View File

@ -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
@ -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;