Skip to content
Permalink
Browse files

Add missing QgsInterval != operator

  • Loading branch information
nyalldawson committed Jan 6, 2021
1 parent c25a9e8 commit 3d23cb62af749b2f80a28e0c094ea6a32cb75f5b
Showing with 19 additions and 14 deletions.
  1. +2 −0 python/core/auto_generated/qgsinterval.sip.in
  2. +0 −13 src/core/qgsinterval.cpp
  3. +17 −1 src/core/qgsinterval.h
@@ -288,6 +288,8 @@ QgsInterval instance or interval was set with a mix of units.

bool operator==( QgsInterval other ) const;

bool operator!=( QgsInterval other ) const;

static QgsInterval fromString( const QString &string );
%Docstring
Converts a string to an interval
@@ -14,7 +14,6 @@
***************************************************************************/

#include "qgsinterval.h"
#include "qgis.h"
#include <QString>
#include <QStringList>
#include <QMap>
@@ -207,18 +206,6 @@ void QgsInterval::setSeconds( double seconds )
mOriginalUnit = QgsUnitTypes::TemporalSeconds;
}

bool QgsInterval::operator==( QgsInterval other ) const
{
if ( !mValid && !other.mValid )
return true;
else if ( mValid && other.mValid && ( mOriginalUnit != QgsUnitTypes::TemporalUnknownUnit || other.mOriginalUnit != QgsUnitTypes::TemporalUnknownUnit ) )
return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
else if ( mValid && other.mValid )
return qgsDoubleNear( mSeconds, other.mSeconds );
else
return false;
}

QgsInterval QgsInterval::fromString( const QString &string )
{
double seconds = 0;
@@ -27,6 +27,7 @@
#include "qgis_sip.h"
#include "qgis_core.h"
#include "qgsunittypes.h"
#include "qgis.h"

class QString;

@@ -293,7 +294,22 @@ class CORE_EXPORT QgsInterval
*/
QgsUnitTypes::TemporalUnit originalUnit() const { return mOriginalUnit; }

bool operator==( QgsInterval other ) const;
bool operator==( QgsInterval other ) const
{
if ( !mValid && !other.mValid )
return true;
else if ( mValid && other.mValid && ( mOriginalUnit != QgsUnitTypes::TemporalUnknownUnit || other.mOriginalUnit != QgsUnitTypes::TemporalUnknownUnit ) )
return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
else if ( mValid && other.mValid )
return qgsDoubleNear( mSeconds, other.mSeconds );
else
return false;
}

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

/**
* Converts a string to an interval

0 comments on commit 3d23cb6

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