diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-07-26 17:05:11 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-28 11:48:02 +0000 |
commit | 7267bff5d9d5f6868799566685bea35d068d5f57 (patch) | |
tree | 0032c73b97f1929b8ea2391a4c0d5fbaf83e0dfa /src | |
parent | 7e582367560546c4187ad400beb1223a7140cd31 (diff) |
QGeoLocation: add qHash overload
Task-number: QTBUG-95163
Change-Id: I6b867a27095c26dbc803609b7d0da6d23cd46249
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 71bed5569c615a84fe91d3a55bb84fc8010c5d5a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/positioning/qgeolocation.cpp | 19 | ||||
-rw-r--r-- | src/positioning/qgeolocation.h | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/positioning/qgeolocation.cpp b/src/positioning/qgeolocation.cpp index 38de9d04..a7c86f1f 100644 --- a/src/positioning/qgeolocation.cpp +++ b/src/positioning/qgeolocation.cpp @@ -40,7 +40,7 @@ #include "qgeolocation.h" #include "qgeolocation_p.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE QGeoLocationPrivate::QGeoLocationPrivate() : QSharedData() @@ -263,3 +263,20 @@ bool QGeoLocation::equals(const QGeoLocation &lhs, const QGeoLocation &rhs) { return (*(lhs.d.constData()) == *(rhs.d.constData())); } + +/*! + \relates QGeoLocation + + Returns the hash value for the \a location, using \a seed for the + calculation. + + \note The hash does not take extended attributes into account. This means + that two geo location objects that differ only in the extended attributes + will provide similar hashes. +*/ +size_t qHash(const QGeoLocation &location, size_t seed) noexcept +{ + return qHashMulti(seed, location.coordinate(), location.boundingShape(), location.address()); +} + +QT_END_NAMESPACE diff --git a/src/positioning/qgeolocation.h b/src/positioning/qgeolocation.h index 0c86be26..3fe20986 100644 --- a/src/positioning/qgeolocation.h +++ b/src/positioning/qgeolocation.h @@ -90,6 +90,8 @@ private: QSharedDataPointer<QGeoLocationPrivate> d; }; +Q_POSITIONING_EXPORT size_t qHash(const QGeoLocation &location, size_t seed = 0) noexcept; + Q_DECLARE_SHARED(QGeoLocation) QT_END_NAMESPACE |