Skip to content

Commit

Permalink
sipify QgsRelation
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 19, 2017
1 parent 652d6b4 commit 56aa36e
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 48 deletions.
1 change: 0 additions & 1 deletion python/auto_sip.blacklist
Expand Up @@ -95,7 +95,6 @@ core/qgsprovidermetadata.sip
core/qgsproviderregistry.sip
core/qgspythonrunner.sip
core/qgsrange.sip
core/qgsrelation.sip
core/qgsrelationmanager.sip
core/qgsrenderchecker.sip
core/qgsrendercontext.sip
Expand Down
291 changes: 247 additions & 44 deletions python/core/qgsrelation.sip
@@ -1,85 +1,288 @@
/***************************************************************************
qgsrelation.sip
--------------------------------------
Date : 29.4.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsrelation.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsRelation
{

%TypeHeaderCode
#include <qgsrelation.h>
#include "qgsrelation.h"
%End
public:


QgsRelation();
static QgsRelation createFromXml( const QDomNode& node );
%Docstring
Default constructor. Creates an invalid relation.
%End

static QgsRelation createFromXml( const QDomNode &node );
%Docstring
Creates a relation from an XML structure. Used for reading .qgs projects.

\param node The dom node containing the relation information

void writeXml( QDomNode& node, QDomDocument& doc ) const;
:return: A relation
:rtype: QgsRelation
%End

void writeXml( QDomNode &node, QDomDocument &doc ) const;
%Docstring
Writes a relation to an XML structure. Used for saving .qgs projects

\param node The parent node in which the relation will be created
\param doc The document in which the relation will be saved
%End

void setId( const QString &id );
%Docstring
Set an id for this relation
%End

void setId( const QString& id );
void setName( const QString &name );
%Docstring
Set a name for this relation
%End

void setName( const QString& name );
void setReferencingLayer( const QString &id );
%Docstring
Set the referencing (child) layer id. This layer will be searched in the registry.
%End

void setReferencingLayer( const QString& id );
void setReferencedLayer( const QString &id );
%Docstring
Set the referenced (parent) layer id. This layer will be searched in the registry.
%End

void setReferencedLayer( const QString& id );
void addFieldPair( const QString& referencingField, const QString& referencedField );
// void addFieldPair( const FieldPair& fieldPair );
void addFieldPair( const QString &referencingField, const QString &referencedField );
%Docstring
Add a field pairs which is part of this relation
The first element of each pair are the field names of the foreign key.
The second element of each pair are the field names of the matching primary key.

QgsFeatureIterator getRelatedFeatures( const QgsFeature& feature ) const;
\param referencingField The field name on the referencing (child) layer (FK)
\param referencedField The field name on the referenced (parent) layer (PK)
%End


QgsFeatureIterator getRelatedFeatures( const QgsFeature &feature ) const;
%Docstring
Creates an iterator which returns all the features on the referencing (child) layer
which have a foreign key pointing to the provided feature.

\param feature A feature from the referenced (parent) layer

:return: An iterator with all the referenced features
\see getRelatedFeaturesRequest()
\see getRelatedFeaturesFilter()
:rtype: QgsFeatureIterator
%End

QgsFeatureRequest getRelatedFeaturesRequest( const QgsFeature &feature ) const;
%Docstring
Creates a request to return all the features on the referencing (child) layer
which have a foreign key pointing to the provided feature.

\param feature A feature from the referenced (parent) layer

:return: A request for all the referencing features
\see getRelatedFeatures()
\see getRelatedFeaturesFilter()
:rtype: QgsFeatureRequest
%End

QString getRelatedFeaturesFilter( const QgsFeature &feature ) const;
%Docstring
Returns a filter expression which returns all the features on the referencing (child) layer
which have a foreign key pointing to the provided feature.
\param feature A feature from the referenced (parent) layer
:return: expression filter string for all the referencing features
.. versionadded:: 2.16
\see getRelatedFeatures()
\see getRelatedFeaturesRequest()
:rtype: str
%End

QgsFeatureRequest getReferencedFeatureRequest( const QgsAttributes &attributes ) const;
%Docstring
Creates a request to return the feature on the referenced (parent) layer
which is referenced by the provided feature.

\param attributes An attribute vector containing the foreign key

:return: A request the referenced feature
.. note::

not available in Python bindings
:rtype: QgsFeatureRequest
%End

QgsFeatureRequest getReferencedFeatureRequest( const QgsFeature &feature ) const;
%Docstring
Creates a request to return the feature on the referenced (parent) layer
which is referenced by the provided feature.

\param feature A feature from the referencing (child) layer

:return: A request the referenced feature
:rtype: QgsFeatureRequest
%End

QgsFeature getReferencedFeature( const QgsFeature &feature ) const;
%Docstring
Creates a request to return the feature on the referenced (parent) layer
which is referenced by the provided feature.

\param feature A feature from the referencing (child) layer

:return: A request the referenced feature
:rtype: QgsFeature
%End

QgsFeatureRequest getRelatedFeaturesRequest( const QgsFeature& feature ) const;
QString getRelatedFeaturesFilter( const QgsFeature& feature ) const;
QgsFeatureRequest getReferencedFeatureRequest( const QgsAttributes& attributes ) const;
QgsFeatureRequest getReferencedFeatureRequest( const QgsFeature& feature ) const;
QgsFeature getReferencedFeature( const QgsFeature& feature ) const;
QString name() const;
%Docstring
Returns a human readable name for this relation. Mostly used as title for the children.

\see id()

:return: A name
:rtype: str
%End

QString id() const;
%Docstring
A (project-wide) unique id for this relation

:return: The id
:rtype: str
%End

void generateId();
%Docstring
Generate a (project-wide) unique id for this relation
.. versionadded:: 3.0
%End

QString referencingLayerId() const;
%Docstring
Access the referencing (child) layer's id
This is the layer which has the field(s) which point to another layer

:return: The id of the referencing layer
:rtype: str
%End

QgsVectorLayer* referencingLayer() const;
QgsVectorLayer *referencingLayer() const;
%Docstring
Access the referencing (child) layer
This is the layer which has the field(s) which point to another layer

:return: The referencing layer
:rtype: QgsVectorLayer
%End

QString referencedLayerId() const;
%Docstring
Access the referenced (parent) layer's id

QgsVectorLayer* referencedLayer() const;
:return: The id of the referenced layer
:rtype: str
%End

QgsVectorLayer *referencedLayer() const;
%Docstring
Access the referenced (parent) layer

:return: referenced layer
:rtype: QgsVectorLayer
%End

/**
* Returns the field pairs which form this relation
* The first element of each pair are the field names fo the foreign key.
* The second element of each pair are the field names of the matching primary key.
*
* @return The fields forming the relation
*/
QMap< QString, QString > fieldPairs() const;
%Docstring
Returns the field pairs which form this relation
The first element of each pair are the field names of the foreign key.
The second element of each pair are the field names of the matching primary key.

:return: The fields forming the relation
:rtype: QMap< str, QString >
%End
%MethodCode
const QList< QgsRelation::FieldPair >& pairs = sipCpp->fieldPairs();
const QList< QgsRelation::FieldPair > &pairs = sipCpp->fieldPairs();
sipRes = new QMap< QString, QString >();
Q_FOREACH( const QgsRelation::FieldPair& pair, pairs )
Q_FOREACH ( const QgsRelation::FieldPair &pair, pairs )
{
sipRes->insert( pair.first, pair.second );
sipRes->insert( pair.first, pair.second );
}
%End

QgsAttributeList referencedFields() const;
%Docstring
Returns a list of attributes used to form the referenced fields
(most likely primary key) on the referenced (parent) layer.

:return: A list of attributes
:rtype: QgsAttributeList
%End

QgsAttributeList referencingFields() const;
%Docstring
Returns a list of attributes used to form the referencing fields
(foreign key) on the referencing (child) layer.

:return: A list of attributes
:rtype: QgsAttributeList
%End

bool isValid() const;
bool hasEqualDefinition( const QgsRelation& other ) const;
%Docstring
Returns the validity of this relation. Don't use the information if it's not valid.

:return: true if the relation is valid
:rtype: bool
%End

bool hasEqualDefinition( const QgsRelation &other ) const;
%Docstring
Compares the two QgsRelation, ignoring the name and the ID.

\param other The other relation
:return: true if they are similar
.. versionadded:: 3.0
:rtype: bool
%End

QString resolveReferencedField( const QString &referencingField ) const;
%Docstring
Get the referenced field counterpart given a referencing field.

.. versionadded:: 3.0
:rtype: str
%End

QString resolveReferencingField( const QString &referencedField ) const;
%Docstring
Get the referencing field counterpart given a referenced field.

.. versionadded:: 3.0
:rtype: str
%End

QString resolveReferencedField( const QString& referencingField ) const;
QString resolveReferencingField( const QString& referencedField ) const;
};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsrelation.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

0 comments on commit 56aa36e

Please sign in to comment.