QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsweakrelation.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsweakrelation.h - QgsWeakRelation
3 
4  ---------------------
5  begin : 5.12.2019
6  copyright : (C) 2019 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSWEAKRELATION_H
17 #define QGSWEAKRELATION_H
18 
19 #define SIP_NO_FILE
20 
21 #include "qgis_core.h"
22 #include "qgsrelation.h"
23 #include "qgsvectorlayerref.h"
24 
38 class CORE_EXPORT QgsWeakRelation
39 {
40  public:
41 
47  {
49  Referenced
50  };
51 
52 
56  QgsWeakRelation( const QString &relationId,
57  const QString &relationName,
58  const QgsRelation::RelationStrength strength,
59  const QString &referencingLayerId,
60  const QString &referencingLayerName,
61  const QString &referencingLayerSource,
62  const QString &referencingLayerProviderKey,
63  const QString &referencedLayerId,
64  const QString &referencedLayerName,
65  const QString &referencedLayerSource,
66  const QString &referencedLayerProviderKey,
67  const QList<QgsRelation::FieldPair> &fieldPairs
68  );
69 
77  QgsRelation resolvedRelation( const QgsProject *project, QgsVectorLayerRef::MatchType matchType = QgsVectorLayerRef::MatchType::All ) const;
78 
82  QgsVectorLayerRef referencingLayer() const;
83 
87  QgsVectorLayerRef referencedLayer() const;
88 
92  QgsRelation::RelationStrength strength() const;
93 
97  QList<QgsRelation::FieldPair> fieldPairs() const;
98 
107  static QgsWeakRelation readXml( const QgsVectorLayer *layer, WeakRelationType type, const QDomNode &node, const QgsPathResolver resolver );
108 
119  static void writeXml( const QgsVectorLayer *layer, WeakRelationType type, const QgsRelation &relation, QDomNode &node, QDomDocument &doc );
120 
121  private:
122 
123  QgsVectorLayerRef mReferencingLayer;
124  QgsVectorLayerRef mReferencedLayer;
125  QString mRelationId;
126  QString mRelationName;
127  QgsRelation::RelationStrength mStrength = QgsRelation::RelationStrength::Association;
128  QList<QgsRelation::FieldPair> mFieldPairs;
129 
130  friend class TestQgsWeakRelation;
131 
132 };
133 
134 #endif // QGSWEAKRELATION_H
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsWeakRelation::WeakRelationType
WeakRelationType
Enum to distinguish if the layer is referenced or referencing.
Definition: qgsweakrelation.h:47
qgsrelation.h
_LayerRef< QgsVectorLayer >::MatchType
MatchType
Flag for match type in weak resolution.
Definition: qgsmaplayerref.h:41
qgsvectorlayerref.h
QgsWeakRelation::Referencing
@ Referencing
The layer is referencing.
Definition: qgsweakrelation.h:48
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsRelation
Definition: qgsrelation.h:42
QgsRelation::RelationStrength
RelationStrength
enum for the relation strength Association, Composition
Definition: qgsrelation.h:58
_LayerRef< QgsVectorLayer >
QgsWeakRelation
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
Definition: qgsweakrelation.h:39
QgsPathResolver
Resolves relative paths into absolute paths and vice versa.
Definition: qgspathresolver.h:32