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