Skip to content
Permalink
Browse files

QgsVectorLayerJoinBuffer inherits from QgsFeatureSink

  • Loading branch information
pblottiere committed Aug 25, 2017
1 parent f27764d commit 1fb88a778c5a72450fa14eb7cd0d576e9cf91dce
@@ -14,7 +14,7 @@
typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;


class QgsVectorLayerJoinBuffer : QObject
class QgsVectorLayerJoinBuffer : QObject, QgsFeatureSink
{
%Docstring
Manages joined fields for a vector layer*
@@ -132,23 +132,8 @@ Quick way to test if there is any join at all
:rtype: QgsVectorLayerJoinBuffer
%End

bool addFeature( const QgsFeature &feature ) const;
%Docstring
Adds a feature in joined layers. The feature given in parameter is the
one 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 feature The feature added in the target layer.

:return: false if an error happened, true otherwise

.. versionadded:: 3.0
:rtype: bool
%End
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );

bool addFeatures( const QgsFeatureList &features ) const;
%Docstring
Adds a list of features in joined layers. Features given in parameter
are those added in target layer. If a corresponding joined feature yet
@@ -157,14 +142,15 @@ Quick way to test if there is any join at all
created nor added.

\param features The list of features added in the target layer
\param flags Unused parameter

:return: false if an error happened, true otherwise

.. versionadded:: 3.0
:rtype: bool
%End

bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() ) const;
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
%Docstring
Changes attribute value in joined layers. The feature id given in
parameter is the one added in target layer. If the corresponding joined
@@ -135,7 +135,6 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo

QgsFeatureRequest request;
request.setFlags( QgsFeatureRequest::NoGeometry );

// maybe user requested just a subset of layer's attributes
// so we do not have to cache everything
bool hasSubset = joinInfo.joinFieldNamesSubset();
@@ -518,12 +517,7 @@ void QgsVectorLayerJoinBuffer::connectJoinedLayer( QgsVectorLayer *vl )
connect( vl, &QgsVectorLayer::willBeDeleted, this, &QgsVectorLayerJoinBuffer::joinedLayerWillBeDeleted, Qt::UniqueConnection );
}

bool QgsVectorLayerJoinBuffer::addFeature( const QgsFeature &feature ) const
{
return addFeatures( QgsFeatureList() << feature );
}

bool QgsVectorLayerJoinBuffer::addFeatures( const QgsFeatureList &features ) const
bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags )
{
if ( !containsJoins() )
return false;
@@ -598,7 +592,7 @@ bool QgsVectorLayerJoinBuffer::addFeatures( const QgsFeatureList &features ) con
return true;
}

bool QgsVectorLayerJoinBuffer::changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue ) const
bool QgsVectorLayerJoinBuffer::changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue )
{
if ( mLayer->fields().fieldOrigin( field ) != QgsFields::OriginJoin )
return false;
@@ -31,7 +31,7 @@ typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;

/** \ingroup core
* Manages joined fields for a vector layer*/
class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject, public QgsFeatureSink
{
Q_OBJECT
public:
@@ -109,21 +109,6 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
//! \since QGIS 2.6
QgsVectorLayerJoinBuffer *clone() const SIP_FACTORY;

/**
* Adds a feature in joined layers. The feature given in parameter is the
* one 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 feature The feature added in the target layer.
*
* \returns false if an error happened, true otherwise
*
* \since QGIS 3.0
*/
bool addFeature( const QgsFeature &feature ) const;

/**
* Adds a list of features in joined layers. Features given in parameter
* are those added in target layer. If a corresponding joined feature yet
@@ -132,12 +117,13 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
* created nor added.
*
* \param features The list of features added in the target layer
* \param flags Unused parameter
*
* \returns false if an error happened, true otherwise
*
* \since QGIS 3.0
*/
bool addFeatures( const QgsFeatureList &features ) const;
bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 ) override;

/**
* Changes attribute value in joined layers. The feature id given in
@@ -154,7 +140,7 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
*
* \since QGIS 3.0
*/
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() ) const;
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );

/**
* Deletes a feature from joined layers. The feature id given in

0 comments on commit 1fb88a7

Please sign in to comment.
You can’t perform that action at this time.