Skip to content

Commit 56aa36e

Browse files
committed
sipify QgsRelation
1 parent 652d6b4 commit 56aa36e

File tree

3 files changed

+267
-48
lines changed

3 files changed

+267
-48
lines changed

python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ core/qgsprovidermetadata.sip
9595
core/qgsproviderregistry.sip
9696
core/qgspythonrunner.sip
9797
core/qgsrange.sip
98-
core/qgsrelation.sip
9998
core/qgsrelationmanager.sip
10099
core/qgsrenderchecker.sip
101100
core/qgsrendercontext.sip

python/core/qgsrelation.sip

Lines changed: 247 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,288 @@
1-
/***************************************************************************
2-
qgsrelation.sip
3-
--------------------------------------
4-
Date : 29.4.2013
5-
Copyright : (C) 2013 Matthias Kuhn
6-
Email : matthias at opengis dot ch
7-
***************************************************************************
8-
* *
9-
* This program is free software; you can redistribute it and/or modify *
10-
* it under the terms of the GNU General Public License as published by *
11-
* the Free Software Foundation; either version 2 of the License, or *
12-
* (at your option) any later version. *
13-
* *
14-
***************************************************************************/
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsrelation.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
1513

1614
class QgsRelation
1715
{
16+
1817
%TypeHeaderCode
19-
#include <qgsrelation.h>
18+
#include "qgsrelation.h"
2019
%End
2120
public:
2221

22+
2323
QgsRelation();
24-
static QgsRelation createFromXml( const QDomNode& node );
24+
%Docstring
25+
Default constructor. Creates an invalid relation.
26+
%End
27+
28+
static QgsRelation createFromXml( const QDomNode &node );
29+
%Docstring
30+
Creates a relation from an XML structure. Used for reading .qgs projects.
31+
32+
\param node The dom node containing the relation information
2533

26-
void writeXml( QDomNode& node, QDomDocument& doc ) const;
34+
:return: A relation
35+
:rtype: QgsRelation
36+
%End
37+
38+
void writeXml( QDomNode &node, QDomDocument &doc ) const;
39+
%Docstring
40+
Writes a relation to an XML structure. Used for saving .qgs projects
41+
42+
\param node The parent node in which the relation will be created
43+
\param doc The document in which the relation will be saved
44+
%End
45+
46+
void setId( const QString &id );
47+
%Docstring
48+
Set an id for this relation
49+
%End
2750

28-
void setId( const QString& id );
51+
void setName( const QString &name );
52+
%Docstring
53+
Set a name for this relation
54+
%End
2955

30-
void setName( const QString& name );
56+
void setReferencingLayer( const QString &id );
57+
%Docstring
58+
Set the referencing (child) layer id. This layer will be searched in the registry.
59+
%End
3160

32-
void setReferencingLayer( const QString& id );
61+
void setReferencedLayer( const QString &id );
62+
%Docstring
63+
Set the referenced (parent) layer id. This layer will be searched in the registry.
64+
%End
3365

34-
void setReferencedLayer( const QString& id );
35-
void addFieldPair( const QString& referencingField, const QString& referencedField );
36-
// void addFieldPair( const FieldPair& fieldPair );
66+
void addFieldPair( const QString &referencingField, const QString &referencedField );
67+
%Docstring
68+
Add a field pairs which is part of this relation
69+
The first element of each pair are the field names of the foreign key.
70+
The second element of each pair are the field names of the matching primary key.
3771

38-
QgsFeatureIterator getRelatedFeatures( const QgsFeature& feature ) const;
72+
\param referencingField The field name on the referencing (child) layer (FK)
73+
\param referencedField The field name on the referenced (parent) layer (PK)
74+
%End
75+
76+
77+
QgsFeatureIterator getRelatedFeatures( const QgsFeature &feature ) const;
78+
%Docstring
79+
Creates an iterator which returns all the features on the referencing (child) layer
80+
which have a foreign key pointing to the provided feature.
81+
82+
\param feature A feature from the referenced (parent) layer
83+
84+
:return: An iterator with all the referenced features
85+
\see getRelatedFeaturesRequest()
86+
\see getRelatedFeaturesFilter()
87+
:rtype: QgsFeatureIterator
88+
%End
89+
90+
QgsFeatureRequest getRelatedFeaturesRequest( const QgsFeature &feature ) const;
91+
%Docstring
92+
Creates a request to return all the features on the referencing (child) layer
93+
which have a foreign key pointing to the provided feature.
94+
95+
\param feature A feature from the referenced (parent) layer
96+
97+
:return: A request for all the referencing features
98+
\see getRelatedFeatures()
99+
\see getRelatedFeaturesFilter()
100+
:rtype: QgsFeatureRequest
101+
%End
102+
103+
QString getRelatedFeaturesFilter( const QgsFeature &feature ) const;
104+
%Docstring
105+
Returns a filter expression which returns all the features on the referencing (child) layer
106+
which have a foreign key pointing to the provided feature.
107+
\param feature A feature from the referenced (parent) layer
108+
:return: expression filter string for all the referencing features
109+
.. versionadded:: 2.16
110+
\see getRelatedFeatures()
111+
\see getRelatedFeaturesRequest()
112+
:rtype: str
113+
%End
114+
115+
QgsFeatureRequest getReferencedFeatureRequest( const QgsAttributes &attributes ) const;
116+
%Docstring
117+
Creates a request to return the feature on the referenced (parent) layer
118+
which is referenced by the provided feature.
119+
120+
\param attributes An attribute vector containing the foreign key
121+
122+
:return: A request the referenced feature
123+
.. note::
124+
125+
not available in Python bindings
126+
:rtype: QgsFeatureRequest
127+
%End
128+
129+
QgsFeatureRequest getReferencedFeatureRequest( const QgsFeature &feature ) const;
130+
%Docstring
131+
Creates a request to return the feature on the referenced (parent) layer
132+
which is referenced by the provided feature.
133+
134+
\param feature A feature from the referencing (child) layer
135+
136+
:return: A request the referenced feature
137+
:rtype: QgsFeatureRequest
138+
%End
139+
140+
QgsFeature getReferencedFeature( const QgsFeature &feature ) const;
141+
%Docstring
142+
Creates a request to return the feature on the referenced (parent) layer
143+
which is referenced by the provided feature.
144+
145+
\param feature A feature from the referencing (child) layer
146+
147+
:return: A request the referenced feature
148+
:rtype: QgsFeature
149+
%End
39150

40-
QgsFeatureRequest getRelatedFeaturesRequest( const QgsFeature& feature ) const;
41-
QString getRelatedFeaturesFilter( const QgsFeature& feature ) const;
42-
QgsFeatureRequest getReferencedFeatureRequest( const QgsAttributes& attributes ) const;
43-
QgsFeatureRequest getReferencedFeatureRequest( const QgsFeature& feature ) const;
44-
QgsFeature getReferencedFeature( const QgsFeature& feature ) const;
45151
QString name() const;
152+
%Docstring
153+
Returns a human readable name for this relation. Mostly used as title for the children.
154+
155+
\see id()
156+
157+
:return: A name
158+
:rtype: str
159+
%End
46160

47161
QString id() const;
162+
%Docstring
163+
A (project-wide) unique id for this relation
164+
165+
:return: The id
166+
:rtype: str
167+
%End
48168

49169
void generateId();
170+
%Docstring
171+
Generate a (project-wide) unique id for this relation
172+
.. versionadded:: 3.0
173+
%End
50174

51175
QString referencingLayerId() const;
176+
%Docstring
177+
Access the referencing (child) layer's id
178+
This is the layer which has the field(s) which point to another layer
179+
180+
:return: The id of the referencing layer
181+
:rtype: str
182+
%End
52183

53-
QgsVectorLayer* referencingLayer() const;
184+
QgsVectorLayer *referencingLayer() const;
185+
%Docstring
186+
Access the referencing (child) layer
187+
This is the layer which has the field(s) which point to another layer
188+
189+
:return: The referencing layer
190+
:rtype: QgsVectorLayer
191+
%End
54192

55193
QString referencedLayerId() const;
194+
%Docstring
195+
Access the referenced (parent) layer's id
56196

57-
QgsVectorLayer* referencedLayer() const;
197+
:return: The id of the referenced layer
198+
:rtype: str
199+
%End
200+
201+
QgsVectorLayer *referencedLayer() const;
202+
%Docstring
203+
Access the referenced (parent) layer
204+
205+
:return: referenced layer
206+
:rtype: QgsVectorLayer
207+
%End
58208

59-
/**
60-
* Returns the field pairs which form this relation
61-
* The first element of each pair are the field names fo the foreign key.
62-
* The second element of each pair are the field names of the matching primary key.
63-
*
64-
* @return The fields forming the relation
65-
*/
66209
QMap< QString, QString > fieldPairs() const;
210+
%Docstring
211+
Returns the field pairs which form this relation
212+
The first element of each pair are the field names of the foreign key.
213+
The second element of each pair are the field names of the matching primary key.
214+
215+
:return: The fields forming the relation
216+
:rtype: QMap< str, QString >
217+
%End
67218
%MethodCode
68-
const QList< QgsRelation::FieldPair >& pairs = sipCpp->fieldPairs();
219+
const QList< QgsRelation::FieldPair > &pairs = sipCpp->fieldPairs();
69220
sipRes = new QMap< QString, QString >();
70-
Q_FOREACH( const QgsRelation::FieldPair& pair, pairs )
221+
Q_FOREACH ( const QgsRelation::FieldPair &pair, pairs )
71222
{
72-
sipRes->insert( pair.first, pair.second );
223+
sipRes->insert( pair.first, pair.second );
73224
}
74225
%End
75226

76227
QgsAttributeList referencedFields() const;
228+
%Docstring
229+
Returns a list of attributes used to form the referenced fields
230+
(most likely primary key) on the referenced (parent) layer.
231+
232+
:return: A list of attributes
233+
:rtype: QgsAttributeList
234+
%End
77235

78236
QgsAttributeList referencingFields() const;
237+
%Docstring
238+
Returns a list of attributes used to form the referencing fields
239+
(foreign key) on the referencing (child) layer.
240+
241+
:return: A list of attributes
242+
:rtype: QgsAttributeList
243+
%End
79244

80245
bool isValid() const;
81-
bool hasEqualDefinition( const QgsRelation& other ) const;
246+
%Docstring
247+
Returns the validity of this relation. Don't use the information if it's not valid.
248+
249+
:return: true if the relation is valid
250+
:rtype: bool
251+
%End
252+
253+
bool hasEqualDefinition( const QgsRelation &other ) const;
254+
%Docstring
255+
Compares the two QgsRelation, ignoring the name and the ID.
256+
257+
\param other The other relation
258+
:return: true if they are similar
259+
.. versionadded:: 3.0
260+
:rtype: bool
261+
%End
262+
263+
QString resolveReferencedField( const QString &referencingField ) const;
264+
%Docstring
265+
Get the referenced field counterpart given a referencing field.
266+
267+
.. versionadded:: 3.0
268+
:rtype: str
269+
%End
270+
271+
QString resolveReferencingField( const QString &referencedField ) const;
272+
%Docstring
273+
Get the referencing field counterpart given a referenced field.
274+
275+
.. versionadded:: 3.0
276+
:rtype: str
277+
%End
82278

83-
QString resolveReferencedField( const QString& referencingField ) const;
84-
QString resolveReferencingField( const QString& referencedField ) const;
85279
};
280+
281+
282+
/************************************************************************
283+
* This file has been generated automatically from *
284+
* *
285+
* src/core/qgsrelation.h *
286+
* *
287+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
288+
************************************************************************/

0 commit comments

Comments
 (0)