Add missing QgsInterval != operator

This commit is contained in:
Nyall Dawson 2021-01-06 07:55:57 +10:00
parent c25a9e8450
commit 3d23cb62af
3 changed files with 19 additions and 14 deletions

View File

@ -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

View File

@ -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;

View File

@ -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