File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
python/core/auto_generated Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,13 @@ Sets the parent polymorphic relation id.
326
326
%Docstring
327
327
Returns the parent polymorphic relation id. If the relation is a normal relation, a null string is returned.
328
328
329
+ .. versionadded:: 3.18
330
+ %End
331
+
332
+ QgsPolymorphicRelation polymorphicRelation() const;
333
+ %Docstring
334
+ Returns the parent polymorphic relation. If the relation is a normal relation, an invalid polymorphic relation is returned.
335
+
329
336
.. versionadded:: 3.18
330
337
%End
331
338
Original file line number Diff line number Diff line change @@ -206,11 +206,10 @@ QString QgsRelation::getRelatedFeaturesFilter( const QgsFeature &feature ) const
206
206
207
207
if ( ! d->mPolymorphicRelationId .isEmpty () )
208
208
{
209
- QgsPolymorphicRelation polymorphicRelation = mContext .project ()->relationManager ()->polymorphicRelation ( d->mPolymorphicRelationId );
210
-
211
- if ( polymorphicRelation.isValid () )
209
+ QgsPolymorphicRelation polyRel = polymorphicRelation ();
210
+ if ( polyRel.isValid () )
212
211
{
213
- conditions << QgsExpression::createFieldEqualityExpression ( polymorphicRelation .referencedLayerField (), polymorphicRelation .layerRepresentation ( referencedLayer () ) );
212
+ conditions << QgsExpression::createFieldEqualityExpression ( polyRel .referencedLayerField (), polyRel .layerRepresentation ( referencedLayer () ) );
214
213
}
215
214
else
216
215
{
@@ -429,3 +428,10 @@ QString QgsRelation::polymorphicRelationId() const
429
428
return d->mPolymorphicRelationId ;
430
429
}
431
430
431
+ QgsPolymorphicRelation QgsRelation::polymorphicRelation () const
432
+ {
433
+ if ( ! mContext .project () || ! mContext .project ()->relationManager () )
434
+ return QgsPolymorphicRelation ();
435
+
436
+ return mContext .project ()->relationManager ()->polymorphicRelation ( d->mPolymorphicRelationId );
437
+ }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class QgsFeatureRequest;
33
33
class QgsAttributes ;
34
34
class QgsVectorLayer ;
35
35
class QgsRelationPrivate ;
36
- class QgsExpressionContext ;
36
+ class QgsPolymorphicRelation ;
37
37
38
38
/* *
39
39
* \ingroup core
@@ -49,6 +49,7 @@ class CORE_EXPORT QgsRelation
49
49
Q_PROPERTY ( QString name READ name WRITE setName )
50
50
Q_PROPERTY ( bool isValid READ isValid )
51
51
Q_PROPERTY ( QString polymorphicRelationId READ polymorphicRelationId WRITE setPolymorphicRelationId )
52
+ Q_PROPERTY ( QgsPolymorphicRelation polymorphicRelation READ polymorphicRelation )
52
53
53
54
public:
54
55
@@ -395,6 +396,12 @@ class CORE_EXPORT QgsRelation
395
396
*/
396
397
QString polymorphicRelationId () const ;
397
398
399
+ /* *
400
+ * Returns the parent polymorphic relation. If the relation is a normal relation, an invalid polymorphic relation is returned.
401
+ * \since QGIS 3.18
402
+ */
403
+ QgsPolymorphicRelation polymorphicRelation () const ;
404
+
398
405
private:
399
406
400
407
mutable QExplicitlySharedDataPointer<QgsRelationPrivate> d;
You can’t perform that action at this time.
0 commit comments