@@ -20,181 +20,40 @@ class QgsRelation
20
20
%End
21
21
public:
22
22
23
- /**
24
- * Default constructor. Creates an invalid relation.
25
- */
26
23
QgsRelation();
27
-
28
- /**
29
- * Creates a relation from an XML structure. Used for reading .qgs projects.
30
- *
31
- * @param node The dom node containing the relation information
32
- *
33
- * @return A relation
34
- */
35
24
static QgsRelation createFromXml( const QDomNode& node );
36
25
37
- /**
38
- * Writes a relation to an XML structure. Used for saving .qgs projects
39
- *
40
- * @param node The parent node in which the relation will be created
41
- * @param doc The document in which the relation will be saved
42
- */
43
26
void writeXml( QDomNode& node, QDomDocument& doc ) const;
44
27
45
28
void setId( const QString& id );
46
29
47
30
void setName( const QString& name );
48
31
49
- /**
50
- * Set the referencing (child) layer id. This layer will be searched in the registry.
51
- *
52
- * @param id
53
- */
54
32
void setReferencingLayer( const QString& id );
55
33
56
- /**
57
- * Set the referenced (parent) layer id. This layer will be searched in the registry.
58
- *
59
- * @param id
60
- */
61
34
void setReferencedLayer( const QString& id );
62
-
63
- /**
64
- * Add a field pairs which is part of this relation
65
- * The first element of each pair are the field names of the foreign key.
66
- * The second element of each pair are the field names of the matching primary key.
67
- *
68
- * @param referencingField The field name on the referencing (child) layer (FK)
69
- * @param referencedField The field name on the referenced (parent) layer (PK)
70
- */
71
35
void addFieldPair( const QString& referencingField, const QString& referencedField );
72
-
73
- /**
74
- * Add a field pairs which is part of this relation
75
- * The first element of each pair are the field names of the foreign key.
76
- * The second element of each pair are the field names of the matching primary key.
77
- *
78
- * @param fieldPair A pair of two strings
79
- * @note not available in python bindings
80
- */
81
36
// void addFieldPair( const FieldPair& fieldPair );
82
37
83
- /**
84
- * Creates an iterator which returns all the features on the referencing (child) layer
85
- * which have a foreign key pointing to the provided feature.
86
- *
87
- * @param feature A feature from the referenced (parent) layer
88
- *
89
- * @return An iterator with all the referenced features
90
- * @see getRelatedFeaturesRequest()
91
- * @see getRelatedFeaturesFilter()
92
- */
93
38
QgsFeatureIterator getRelatedFeatures( const QgsFeature& feature ) const;
94
39
95
- /**
96
- * Creates a request to return all the features on the referencing (child) layer
97
- * which have a foreign key pointing to the provided feature.
98
- *
99
- * @param feature A feature from the referenced (parent) layer
100
- *
101
- * @return A request for all the referencing features
102
- * @see getRelatedFeatures()
103
- * @see getRelatedFeaturesFilter()
104
- */
105
40
QgsFeatureRequest getRelatedFeaturesRequest( const QgsFeature& feature ) const;
106
-
107
- /** Returns a filter expression which returns all the features on the referencing (child) layer
108
- * which have a foreign key pointing to the provided feature.
109
- * @param feature A feature from the referenced (parent) layer
110
- * @return expression filter string for all the referencing features
111
- * @note added in QGIS 2.16
112
- * @see getRelatedFeatures()
113
- * @see getRelatedFeaturesRequest()
114
- */
115
41
QString getRelatedFeaturesFilter( const QgsFeature& feature ) const;
116
-
117
- /**
118
- * Creates a request to return the feature on the referenced (parent) layer
119
- * which is referenced by the provided feature.
120
- *
121
- * @param attributes An attribute vector containing the foreign key
122
- *
123
- * @return A request the referenced feature
124
- * @note not available in python bindings
125
- */
126
42
QgsFeatureRequest getReferencedFeatureRequest( const QgsAttributes& attributes ) const;
127
-
128
- /**
129
- * Creates a request to return the feature on the referenced (parent) layer
130
- * which is referenced by the provided feature.
131
- *
132
- * @param feature A feature from the referencing (child) layer
133
- *
134
- * @return A request the referenced feature
135
- */
136
43
QgsFeatureRequest getReferencedFeatureRequest( const QgsFeature& feature ) const;
137
-
138
- /**
139
- * Creates a request to return the feature on the referenced (parent) layer
140
- * which is referenced by the provided feature.
141
- *
142
- * @param feature A feature from the referencing (child) layer
143
- *
144
- * @return A request the referenced feature
145
- */
146
44
QgsFeature getReferencedFeature( const QgsFeature& feature ) const;
147
-
148
- /**
149
- * Returns a human readable name for this relation. Mostly used as title for the children.
150
- *
151
- * @see id()
152
- *
153
- * @return A name
154
- */
155
45
QString name() const;
156
46
157
- /**
158
- * A (project-wide) unique id for this relation
159
- *
160
- * @return The id
161
- */
162
47
QString id() const;
163
48
164
- /**
165
- * Generate a (project-wide) unique id for this relation
166
- * @note added in QGIS 3.0
167
- */
168
49
void generateId();
169
50
170
- /**
171
- * Access the referencing (child) layer's id
172
- * This is the layer which has the field(s) which point to another layer
173
- *
174
- * @return The id of the referencing layer
175
- */
176
51
QString referencingLayerId() const;
177
52
178
- /**
179
- * Access the referencing (child) layer
180
- * This is the layer which has the field(s) which point to another layer
181
- *
182
- * @return The referencing layer
183
- */
184
53
QgsVectorLayer* referencingLayer() const;
185
54
186
- /**
187
- * Access the referenced (parent) layer's id
188
- *
189
- * @return The id of the referenced layer
190
- */
191
55
QString referencedLayerId() const;
192
56
193
- /**
194
- * Access the referenced (parent) layer
195
- *
196
- * @return referenced layer
197
- */
198
57
QgsVectorLayer* referencedLayer() const;
199
58
200
59
/**
@@ -214,36 +73,13 @@ class QgsRelation
214
73
}
215
74
%End
216
75
217
- /**
218
- * Returns a list of attributes used to form the referenced fields
219
- * (most likely primary key) on the referenced (parent) layer.
220
- *
221
- * @return A list of attributes
222
- */
223
76
QgsAttributeList referencedFields() const;
224
77
225
- /**
226
- * Returns a list of attributes used to form the referencing fields
227
- * (foreign key) on the referencing (child) layer.
228
- *
229
- * @return A list of attributes
230
- */
231
78
QgsAttributeList referencingFields() const;
232
79
233
- /**
234
- * Returns the validity of this relation. Don't use the information if it's not valid.
235
- *
236
- * @return true if the relation is valid
237
- */
238
80
bool isValid() const;
239
-
240
- /**
241
- * Compares the two QgsRelation, ignoring the name and the ID.
242
- *
243
- * @param other The other relation
244
- * @return true if they are similar
245
- * @note added in QGIS 3.0
246
- */
247
81
bool hasEqualDefinition( const QgsRelation& other ) const;
248
82
83
+ QString resolveReferencedField( const QString& referencingField ) const;
84
+ QString resolveReferencingField( const QString& referencedField ) const;
249
85
};
0 commit comments