Skip to content
Permalink
Browse files

Add an equality operator for QgsTextMaskSettings

  • Loading branch information
nyalldawson committed Jul 14, 2020
1 parent 305fa33 commit 52d7d1886a1af8366e754613bdbe17eb8fd95e44
@@ -46,6 +46,9 @@ Copy constructor.

~QgsTextMaskSettings();

bool operator==( const QgsTextMaskSettings &other ) const;
bool operator!=( const QgsTextMaskSettings &other ) const;

bool enabled() const;
%Docstring
Returns whether the mask is enabled.
@@ -37,6 +37,30 @@ QgsTextMaskSettings &QgsTextMaskSettings::operator=( const QgsTextMaskSettings &
return *this;
}

bool QgsTextMaskSettings::operator==( const QgsTextMaskSettings &other ) const
{
if ( d->enabled != other.enabled()
|| d->type != other.type()
|| d->size != other.size()
|| d->sizeUnit != other.sizeUnit()
|| d->sizeMapUnitScale != other.sizeMapUnitScale()
|| d->joinStyle != other.joinStyle()
|| d->opacity != other.opacity()
|| d->maskedSymbolLayers != other.maskedSymbolLayers() )
return false;

if ( static_cast< bool >( d->paintEffect ) != static_cast< bool >( other.paintEffect() )
|| ( d->paintEffect && d->paintEffect->properties() != other.paintEffect()->properties() ) )
return false;

return true;
}

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

bool QgsTextMaskSettings::enabled() const
{
return d->enabled;
@@ -66,6 +66,9 @@ class CORE_EXPORT QgsTextMaskSettings

~QgsTextMaskSettings();

bool operator==( const QgsTextMaskSettings &other ) const;
bool operator!=( const QgsTextMaskSettings &other ) const;

/**
* Returns whether the mask is enabled.
*/
@@ -277,6 +277,39 @@ def createMaskSettings(self):
QgsSymbolLayerReference("layerid2", QgsSymbolLayerId("symbol2", 2))])
return s

def testMaskEquality(self):
s = self.createMaskSettings()
s2 = self.createMaskSettings()
self.assertEqual(s, s2)

s.setEnabled(False)
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setSize(15)
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setSizeUnit(QgsUnitTypes.RenderPixels)
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setSizeMapUnitScale(QgsMapUnitScale(11, 12))
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setOpacity(0.6)
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setJoinStyle(Qt.MiterJoin)
self.assertNotEqual(s, s2)
s = self.createMaskSettings()

s.setMaskedSymbolLayers([QgsSymbolLayerReference("layerid11", QgsSymbolLayerId("symbol", 1)),
QgsSymbolLayerReference("layerid21", QgsSymbolLayerId("symbol2", 2))])
self.assertNotEqual(s, s2)

def checkMaskSettings(self, s):
""" test QgsTextMaskSettings """
self.assertTrue(s.enabled())

0 comments on commit 52d7d18

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