Skip to content
Permalink
Browse files

Equality operator for QgsTextShadowSettings

  • Loading branch information
nyalldawson committed Jul 14, 2020
1 parent 52d7d18 commit 9bad5578cf7dbc6b835d1c40f43d7155dcf1a6dd
@@ -47,6 +47,9 @@ Copy constructor.

~QgsTextShadowSettings();

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

bool enabled() const;
%Docstring
Returns whether the shadow is enabled.
@@ -43,6 +43,33 @@ QgsTextShadowSettings::~QgsTextShadowSettings() //NOLINT

}

bool QgsTextShadowSettings::operator==( const QgsTextShadowSettings &other ) const
{
if ( d->enabled != other.enabled()
|| d->shadowUnder != other.shadowPlacement()
|| d->offsetAngle != other.offsetAngle()
|| d->offsetDist != other.offsetDistance()
|| d->offsetUnits != other.offsetUnit()
|| d->offsetMapUnitScale != other.offsetMapUnitScale()
|| d->offsetGlobal != other.offsetGlobal()
|| d->radius != other.blurRadius()
|| d->radiusUnits != other.blurRadiusUnit()
|| d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
|| d->radiusAlphaOnly != other.blurAlphaOnly()
|| d->scale != other.scale()
|| d->color != other.color()
|| d->opacity != other.opacity()
|| d->blendMode != other.blendMode() )
return false;

return true;
}

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

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

~QgsTextShadowSettings();

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

/**
* Returns whether the shadow is enabled.
* \see setEnabled()
@@ -550,6 +550,70 @@ def createShadowSettings(self):
s.setBlendMode(QPainter.CompositionMode_DestinationAtop)
return s

def testShadowEquality(self):
s = self.createShadowSettings()
s2 = self.createShadowSettings()
self.assertEqual(s, s2)

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

s.setShadowPlacement(QgsTextShadowSettings.ShadowText)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setOffsetAngle(145)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setOffsetDistance(175)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setOffsetUnit(QgsUnitTypes.RenderPixels)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setOffsetMapUnitScale(QgsMapUnitScale(15, 16))
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setOffsetGlobal(False)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setBlurRadius(21)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setBlurRadiusUnit(QgsUnitTypes.RenderPoints)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setBlurRadiusMapUnitScale(QgsMapUnitScale(115, 116))
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setBlurAlphaOnly(False)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setColor(QColor(255, 255, 0))
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

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

s.setScale(23)
self.assertNotEqual(s, s2)
s = self.createShadowSettings()

s.setBlendMode(QPainter.CompositionMode_Darken)
self.assertNotEqual(s, s2)

def checkShadowSettings(self, s):
""" test QgsTextShadowSettings """
self.assertTrue(s.enabled())

0 comments on commit 9bad557

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