QGIS API Documentation  3.17.0-Master (a035f434f4)
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
The layer is referencing.
WeakRelationType
Enum to distinguish if the layer is referenced or referencing.
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:94
MatchType
Flag for match type in weak resolution.
RelationStrength
enum for the relation strength Association, Composition
Definition: qgsrelation.h:57
Resolves relative paths into absolute paths and vice versa.
Represents a vector layer which manages a vector based data sets.