Skip to content
Permalink
Browse files

Merge pull request #42469 from m-kuhn/qvariant_operators

[qt6] Add comparison operators for QVariant
  • Loading branch information
m-kuhn committed Mar 25, 2021
2 parents 7feb362 + 2059622 commit 31513ba412cdcd8529220d8977acdf470b3dfa28
Showing with 33 additions and 2 deletions.
  1. +5 −1 python/core/auto_generated/qgis.sip.in
  2. +28 −1 src/core/qgis.h
@@ -250,7 +250,6 @@ always treated as equal and 0 is not treated as equal with NULL
:return: ``True`` if values are equal
%End


bool qgsVariantGreaterThan( const QVariant &lhs, const QVariant &rhs );
%Docstring
Compares two QVariant values and returns whether the first is greater than the second.
@@ -261,6 +260,11 @@ QVariant data types (such as strings, numeric values, dates and times)
%End


bool operator> ( const QVariant &v1, const QVariant &v2 );

bool operator< ( const QVariant &v1, const QVariant &v2 );




QString qgsVsiPrefix( const QString &path );
@@ -544,7 +544,6 @@ CORE_EXPORT bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs );
*/
CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );


/**
* Compares two QVariant values and returns whether the first is greater than the second.
* Useful for sorting lists of variants, correctly handling sorting of the various
@@ -553,6 +552,34 @@ CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );
*/
CORE_EXPORT bool qgsVariantGreaterThan( const QVariant &lhs, const QVariant &rhs );

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)

/**
* Compares two QVariant values and returns whether the first is greater than the second.
* Useful for sorting lists of variants, correctly handling sorting of the various
* QVariant data types (such as strings, numeric values, dates and times)
* \see qgsVariantLessThan()
*/
inline bool operator> ( const QVariant &v1, const QVariant &v2 )
{
return qgsVariantGreaterThan( v1, v2 );
}

/**
* Compares two QVariant values and returns whether the first is less than the second.
* Useful for sorting lists of variants, correctly handling sorting of the various
* QVariant data types (such as strings, numeric values, dates and times)
*
* Invalid < NULL < Values
*
* \see qgsVariantGreaterThan()
*/
inline bool operator< ( const QVariant &v1, const QVariant &v2 )
{
return qgsVariantLessThan( v1, v2 );
}
#endif


#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)

0 comments on commit 31513ba

Please sign in to comment.