QgsVectorLayerJoinBuffer inherits from QgsFeatureSink

This commit is contained in:
Blottiere Paul 2017-08-25 07:56:48 +01:00
parent f27764d2ba
commit 1fb88a778c
3 changed files with 10 additions and 44 deletions

View File

@ -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.
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );
\param feature The feature added in the target layer.
:return: false if an error happened, true otherwise
.. versionadded:: 3.0
:rtype: bool
%End
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,6 +142,7 @@ 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
@ -164,7 +150,7 @@ Quick way to test if there is any join at all
: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

View File

@ -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;

View File

@ -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