2017-05-22 09:01:45 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsvectorlayerjoinbuffer.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;
|
|
|
|
|
|
|
|
|
2017-08-25 07:56:48 +01:00
|
|
|
class QgsVectorLayerJoinBuffer : QObject, QgsFeatureSink
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Manages joined fields for a vector layer*
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
%TypeHeaderCode
|
2017-05-22 09:01:45 +02:00
|
|
|
#include "qgsvectorlayerjoinbuffer.h"
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
public:
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsVectorLayerJoinBuffer( QgsVectorLayer *layer = 0 );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Joins another vector layer to this layer
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param joinInfo: join object containing join layer id, target and source field
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
:return: (since 2.6) whether the join was successfully added *
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
bool removeJoin( const QString &joinLayerId );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Removes a vector layer join
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
:return: true if join was found and successfully removed *
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void updateFields( QgsFields &fields );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Updates field map with joined attributes
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param fields: map to append joined attributes
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void createJoinCaches();
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
|
|
|
Calls cacheJoinLayer() for all vector joins
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void writeXml( QDomNode &layer_node, QDomDocument &document ) const;
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
|
|
|
Saves mVectorJoins to xml under the layer node
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void readXml( const QDomNode &layer_node );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Reads joins from project file.
|
|
|
|
Does not resolve layer IDs to layers - call resolveReferences() afterwards
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void resolveReferences( QgsProject *project );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Resolves layer IDs of joined layers using given project's available layers
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2017-01-30 15:33:18 +08:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
bool containsJoins() const;
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
|
|
|
Quick way to test if there is any join at all
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
const QgsVectorJoinList &vectorJoins() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
const QgsVectorLayerJoinInfo *joinForFieldIndex( int index, const QgsFields &fields, int &sourceFieldIndex /Out/ ) const;
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Finds the vector join for a layer field index.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param index: this layers attribute index
|
|
|
|
:param fields: fields of the vector layer (including joined fields)
|
|
|
|
:param sourceFieldIndex: Output: field's index in source layer *
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
int joinedFieldsOffset( const QgsVectorLayerJoinInfo *info, const QgsFields &fields );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Find out what is the first index of the join within fields. Returns -1 if join is not present
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
%End
|
2014-09-13 13:36:45 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QVector<int> joinSubsetIndices( QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Return a vector of indices for use in join based on field names from the layer
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
%End
|
2014-09-13 13:36:45 +07:00
|
|
|
|
2017-06-30 06:46:22 +01:00
|
|
|
QList<const QgsVectorLayerJoinInfo *> joinsWhereFieldIsId( const QgsField &field ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns joins where the field of a target layer is considered as an id.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param field: the field of a target layer
|
|
|
|
|
|
|
|
:return: a list of vector joins
|
|
|
|
|
2017-06-30 06:46:22 +01:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-07-02 16:58:54 +02:00
|
|
|
QgsFeature joinedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
|
2017-06-30 06:46:22 +01:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns the joined feature corresponding to the feature.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param info: the vector join information
|
|
|
|
:param feature: the feature of the target layer
|
|
|
|
|
2017-06-30 06:46:22 +01:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-07-18 10:35:55 +01:00
|
|
|
QgsFeature targetedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns the targeted feature corresponding to the joined feature.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param info: the vector join information
|
|
|
|
:param feature: the feature of the joined layer
|
|
|
|
|
2017-07-18 10:35:55 +01:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-10-02 08:24:39 +01:00
|
|
|
bool isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns true if the join information is about auxiliary layer, false otherwise
|
|
|
|
|
|
|
|
:param info: The join information
|
2017-10-02 08:24:39 +01:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:return: true if the join information is about auxiliary layer, false otherwise
|
2017-10-02 08:24:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsVectorLayerJoinBuffer *clone() const /Factory/;
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Create a copy of the join buffer
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
%End
|
2014-09-09 19:47:41 +07:00
|
|
|
|
2017-08-25 07:56:48 +01:00
|
|
|
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );
|
2017-08-25 01:21:56 +01:00
|
|
|
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Adds a list of features in joined layers. Features given in parameter
|
|
|
|
are those added in target layer. If a corresponding joined feature yet
|
|
|
|
exists in a joined layer, then this feature is just updated. Note that
|
|
|
|
if a corresponding joined feature has only empty fields, then it's not
|
|
|
|
created nor added.
|
|
|
|
|
|
|
|
:param features: The list of features added in the target layer
|
|
|
|
:param flags: Unused parameter
|
2017-08-25 01:21:56 +01:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:return: false if an error happened, true otherwise
|
2017-08-25 01:21:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-08-25 07:56:48 +01:00
|
|
|
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
|
2017-08-25 01:21:56 +01:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Changes attribute value in joined layers. The feature id given in
|
|
|
|
parameter is the one added in target layer. If the corresponding joined
|
|
|
|
feature does not exist in a joined layer, then it's automatically
|
|
|
|
created if its fields are not empty.
|
|
|
|
|
|
|
|
:param fid: The feature id
|
|
|
|
:param field: The field to update
|
|
|
|
:param newValue: The new value of the attribute
|
|
|
|
:param oldValue: The old value of the attribute
|
2017-08-25 01:21:56 +01:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:return: false if an error happened, true otherwise
|
2017-08-25 01:21:56 +01:00
|
|
|
|
|
|
|
|
2018-01-23 13:07:35 +00:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap() );
|
|
|
|
%Docstring
|
|
|
|
Changes attributes' values in joined layers. The feature id given in
|
|
|
|
parameter is the one added in target layer. If the corresponding joined
|
|
|
|
feature does not exist in a joined layer, then it's automatically
|
|
|
|
created if its fields are not empty.
|
|
|
|
|
|
|
|
:param fid: The feature id
|
|
|
|
:param newValues: The new values for attributes
|
|
|
|
:param oldValues: The old values for attributes
|
|
|
|
|
|
|
|
:return: false if an error happened, true otherwise
|
|
|
|
|
|
|
|
|
2017-08-25 01:21:56 +01:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
bool deleteFeature( QgsFeatureId fid ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Deletes a feature from joined layers. The feature id given in
|
|
|
|
parameter is the one coming from the target layer.
|
2017-08-25 01:21:56 +01:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param fid: The feature id from the target layer to delete
|
|
|
|
|
|
|
|
:return: false if an error happened, true otherwise
|
2017-08-25 01:21:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
bool deleteFeatures( const QgsFeatureIds &fids ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Deletes a list of features from joined layers. Feature ids given
|
|
|
|
in aprameter are those coming from the target layer.
|
|
|
|
|
|
|
|
:param fids: Feature ids from the target layer to delete
|
2017-08-25 01:21:56 +01:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:return: false if an error happened, true otherwise
|
2017-08-25 01:21:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2014-09-09 19:47:41 +07:00
|
|
|
signals:
|
2017-10-05 11:51:04 +10:00
|
|
|
|
2014-09-09 19:47:41 +07:00
|
|
|
void joinedFieldsChanged();
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Emitted whenever the list of joined fields changes (e.g. added join or joined layer's fields change)
|
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
%End
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
2017-05-22 09:01:45 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsvectorlayerjoinbuffer.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|