mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Check if join information is for auxiliary layer when filtering
This commit is contained in:
parent
cbd7973035
commit
9fd80f9b40
@ -130,6 +130,18 @@ Quick way to test if there is any join at all
|
||||
:rtype: QgsFeature
|
||||
%End
|
||||
|
||||
bool isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const;
|
||||
%Docstring
|
||||
Returns true if the join information is about auxiliary layer, false otherwise
|
||||
|
||||
\param info The join information
|
||||
|
||||
:return: true if the join information is about auxiliary layer, false otherwise
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsVectorLayerJoinBuffer *clone() const /Factory/;
|
||||
%Docstring
|
||||
Create a copy of the join buffer
|
||||
|
@ -79,6 +79,7 @@
|
||||
#include "qgstaskmanager.h"
|
||||
#include "qgsziputils.h"
|
||||
#include "qgsbrowsermodel.h"
|
||||
#include "qgsvectorlayerjoinbuffer.h"
|
||||
|
||||
#ifdef HAVE_3D
|
||||
#include "qgsabstract3drenderer.h"
|
||||
@ -8635,7 +8636,14 @@ void QgisApp::layerSubsetString()
|
||||
if ( !vlayer )
|
||||
return;
|
||||
|
||||
if ( !vlayer->vectorJoins().isEmpty() )
|
||||
bool joins = !vlayer->vectorJoins().isEmpty();
|
||||
if ( vlayer->vectorJoins().size() == 1 )
|
||||
{
|
||||
QgsVectorLayerJoinInfo info = vlayer->vectorJoins()[0];
|
||||
joins = !vlayer->joinBuffer()->isAuxiliaryJoin( info );
|
||||
}
|
||||
|
||||
if ( joins )
|
||||
{
|
||||
if ( QMessageBox::question( nullptr, tr( "Filter on joined fields" ),
|
||||
tr( "You are about to set a subset filter on a layer that has joined fields. "
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qgslogger.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsauxiliarystorage.h"
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
@ -265,6 +266,9 @@ void QgsVectorLayerJoinBuffer::writeXml( QDomNode &layer_node, QDomDocument &doc
|
||||
QList< QgsVectorLayerJoinInfo >::const_iterator joinIt = mVectorJoins.constBegin();
|
||||
for ( ; joinIt != mVectorJoins.constEnd(); ++joinIt )
|
||||
{
|
||||
if ( isAuxiliaryJoin( *joinIt ) )
|
||||
continue;
|
||||
|
||||
QDomElement joinElem = document.createElement( QStringLiteral( "join" ) );
|
||||
|
||||
joinElem.setAttribute( QStringLiteral( "targetFieldName" ), joinIt->targetFieldName() );
|
||||
@ -656,3 +660,13 @@ bool QgsVectorLayerJoinBuffer::deleteFeatures( const QgsFeatureIds &fids ) const
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsVectorLayerJoinBuffer::isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const
|
||||
{
|
||||
const QgsAuxiliaryLayer *al = mLayer->auxiliaryLayer();
|
||||
|
||||
if ( al && al->id() == info.joinLayerId() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -121,6 +121,17 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject, public QgsFeatureSi
|
||||
*/
|
||||
QgsFeature targetedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
|
||||
|
||||
/**
|
||||
* Returns true if the join information is about auxiliary layer, false otherwise
|
||||
*
|
||||
* \param info The join information
|
||||
*
|
||||
* \returns true if the join information is about auxiliary layer, false otherwise
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
bool isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const;
|
||||
|
||||
/**
|
||||
* Create a copy of the join buffer
|
||||
* \since QGIS 2.6
|
||||
|
Loading…
x
Reference in New Issue
Block a user