Skip to content

Commit

Permalink
Add equality operator for QgsProcessingFeatureSourceDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent 3601138 commit 3cbcd75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/core/processing/qgsprocessingparameters.sip
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class QgsProcessingFeatureSourceDefinition
True if only selected features in the source should be used by algorithms.
%End

bool operator==( const QgsProcessingFeatureSourceDefinition &other );

bool operator!=( const QgsProcessingFeatureSourceDefinition &other );
%Docstring
:rtype: bool
%End

operator QVariant() const;
%Docstring
Expand Down
9 changes: 9 additions & 0 deletions src/core/processing/qgsprocessingparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ class CORE_EXPORT QgsProcessingFeatureSourceDefinition
*/
bool selectedFeaturesOnly;

bool operator==( const QgsProcessingFeatureSourceDefinition &other )
{
return source == other.source && selectedFeaturesOnly == other.selectedFeaturesOnly;
}

bool operator!=( const QgsProcessingFeatureSourceDefinition &other )
{
return !( *this == other );
}

//! Allows direct construction of QVariants.
operator QVariant() const
Expand Down
4 changes: 4 additions & 0 deletions tests/src/core/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,10 @@ void TestQgsProcessing::features()
ids = getIds( source->getFeatures() );
QVERIFY( !encountered );

// equality operator
QVERIFY( QgsProcessingFeatureSourceDefinition( layer->id(), true ) == QgsProcessingFeatureSourceDefinition( layer->id(), true ) );
QVERIFY( QgsProcessingFeatureSourceDefinition( layer->id(), true ) != QgsProcessingFeatureSourceDefinition( "b", true ) );
QVERIFY( QgsProcessingFeatureSourceDefinition( layer->id(), true ) != QgsProcessingFeatureSourceDefinition( layer->id(), false ) );
}

void TestQgsProcessing::uniqueValues()
Expand Down

0 comments on commit 3cbcd75

Please sign in to comment.