Skip to content
Permalink
Browse files

[qt6] Add comparison operators for QVariant

makes them usable as QMap keys
  • Loading branch information
m-kuhn committed Mar 25, 2021
1 parent 9b07d95 commit 42b79396b43ecfa276f3c2284c16f68c12272680
Showing with 29 additions and 2 deletions.
  1. +4 −1 python/core/auto_generated/qgis.sip.in
  2. +25 −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.
@@ -260,6 +259,10 @@ QVariant data types (such as strings, numeric values, dates and times)
.. seealso:: :py:func:`qgsVariantLessThan`
%End

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

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




@@ -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,31 @@ CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );
*/
CORE_EXPORT bool qgsVariantGreaterThan( 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
* 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 );
}


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

0 comments on commit 42b7939

Please sign in to comment.