File indexing completed on 2025-07-13 04:47:26
0001 /* 0002 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef KITINERARY_INTERNAL_STRICT_LESS_H 0007 #define KITINERARY_INTERNAL_STRICT_LESSL_H 0008 0009 #include "parameter_type.h" 0010 0011 #include <QDateTime> 0012 #include <QVariant> 0013 0014 namespace KItinerary { 0015 namespace detail { 0016 0017 /** Less-than counterpart to strict_equal.h 0018 * This is far less complete though, as we only need this to make equality comparison 0019 * work in Qt6, which requires a less-than comparison to be present. 0020 */ 0021 0022 template <typename T> 0023 inline bool strict_less(typename parameter_type<T>::type lhs, typename parameter_type<T>::type rhs) 0024 { 0025 return lhs < rhs; 0026 } 0027 0028 template <> inline 0029 bool strict_less<QDateTime>(const QDateTime &lhs, const QDateTime &rhs) 0030 { 0031 if (lhs == rhs) { 0032 return lhs.timeSpec() < rhs.timeSpec(); 0033 } 0034 return lhs < rhs; 0035 } 0036 0037 // compare QVariant contents (no longer the default with Qt6) 0038 template <> inline 0039 bool strict_less<QVariant>(const QVariant &lhs, const QVariant &rhs) 0040 { 0041 return !lhs.isNull() && !rhs.isNull() && QVariant::compare(lhs, rhs) == QPartialOrdering::Less; 0042 } 0043 0044 template<> inline 0045 bool strict_less<QList<QVariant>>([[maybe_unused]] const QList<QVariant> &lhs, [[maybe_unused]] const QList<QVariant> &rhs) 0046 { 0047 return false; 0048 } 0049 0050 } 0051 } 0052 0053 #endif 0054