1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Update function signature for Qt6 qHash()

Since the `qhash()` signature has changed in Qt6.
This commit is contained in:
Chocobo1 2022-03-12 20:59:29 +08:00
parent 8de966ea88
commit 926d51839f
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
17 changed files with 87 additions and 10 deletions

View File

@ -90,7 +90,11 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::Info
return infoHash.toTorrentID(); return infoHash.toTorrentID();
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::TorrentID &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const BitTorrent::TorrentID &key, const uint seed) uint BitTorrent::qHash(const BitTorrent::TorrentID &key, const uint seed)
#endif
{ {
return ::qHash(std::hash<TorrentID::UnderlyingType>()(key), seed); return ::qHash(std::hash<TorrentID::UnderlyingType>()(key), seed);
} }

View File

@ -32,6 +32,7 @@
#include <libtorrent/info_hash.hpp> #include <libtorrent/info_hash.hpp>
#endif #endif
#include <QtGlobal>
#include <QHash> #include <QHash>
#include <QMetaType> #include <QMetaType>
@ -81,7 +82,11 @@ namespace BitTorrent
WrappedType m_nativeHash; WrappedType m_nativeHash;
}; };
uint qHash(const TorrentID &key, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentID &key, std::size_t seed = 0);
#else
uint qHash(const TorrentID &key, uint seed = 0);
#endif
bool operator==(const InfoHash &left, const InfoHash &right); bool operator==(const InfoHash &left, const InfoHash &right);
bool operator!=(const InfoHash &left, const InfoHash &right); bool operator!=(const InfoHash &left, const InfoHash &right);

View File

@ -32,6 +32,7 @@
#include <libtorrent/units.hpp> #include <libtorrent/units.hpp>
#include <QtGlobal>
#include <QHash> #include <QHash>
// From https://doc.qt.io/qt-6/qhash.html#the-hashing-function: // From https://doc.qt.io/qt-6/qhash.html#the-hashing-function:
@ -42,7 +43,11 @@ namespace libtorrent
namespace aux namespace aux
{ {
template <typename T, typename Tag> template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const strong_typedef<T, Tag> &key, const std::size_t seed = 0)
#else
uint qHash(const strong_typedef<T, Tag> &key, const uint seed = 0)
#endif
{ {
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed); return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
} }

View File

@ -77,7 +77,11 @@ bool BitTorrent::operator==(const BitTorrent::PeerAddress &left, const BitTorren
return (left.ip == right.ip) && (left.port == right.port); return (left.ip == right.ip) && (left.port == right.port);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const std::size_t seed)
#else
uint BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const uint seed) uint BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const uint seed)
#endif
{ {
return (::qHash(addr.ip, seed) ^ ::qHash(addr.port)); return (::qHash(addr.ip, seed) ^ ::qHash(addr.port));
} }

View File

@ -28,6 +28,7 @@
#pragma once #pragma once
#include <QtGlobal>
#include <QHostAddress> #include <QHostAddress>
class QString; class QString;
@ -44,5 +45,9 @@ namespace BitTorrent
}; };
bool operator==(const PeerAddress &left, const PeerAddress &right); bool operator==(const PeerAddress &left, const PeerAddress &right);
uint qHash(const PeerAddress &addr, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerAddress &addr, std::size_t seed = 0);
#else
uint qHash(const PeerAddress &addr, uint seed = 0);
#endif
} }

View File

@ -35,7 +35,11 @@
namespace BitTorrent namespace BitTorrent
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentState key, const std::size_t seed)
#else
uint qHash(const TorrentState key, const uint seed) uint qHash(const TorrentState key, const uint seed)
#endif
{ {
return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed); return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed);
} }

View File

@ -29,6 +29,7 @@
#pragma once #pragma once
#include <QtGlobal>
#include <QtContainerFwd> #include <QtContainerFwd>
#include <QMetaType> #include <QMetaType>
#include <QString> #include <QString>
@ -97,7 +98,11 @@ namespace BitTorrent
Error Error
}; };
uint qHash(TorrentState key, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(TorrentState key, std::size_t seed = 0);
#else
uint qHash(TorrentState key, uint seed = 0);
#endif
class Torrent : public AbstractFileStorage class Torrent : public AbstractFileStorage
{ {

View File

@ -140,7 +140,11 @@ namespace BitTorrent
return !(left == right); return !(left == right);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, const std::size_t seed)
#else
uint qHash(const Peer &key, const uint seed) uint qHash(const Peer &key, const uint seed)
#endif
{ {
return qHash(key.uniqueID(), seed); return qHash(key.uniqueID(), seed);
} }

View File

@ -34,6 +34,7 @@
#include <libtorrent/entry.hpp> #include <libtorrent/entry.hpp>
#include <QtGlobal>
#include <QHash> #include <QHash>
#include <QObject> #include <QObject>
#include <QSet> #include <QSet>
@ -64,7 +65,11 @@ namespace BitTorrent
bool operator==(const Peer &left, const Peer &right); bool operator==(const Peer &left, const Peer &right);
bool operator!=(const Peer &left, const Peer &right); bool operator!=(const Peer &left, const Peer &right);
uint qHash(const Peer &key, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, std::size_t seed = 0);
#else
uint qHash(const Peer &key, uint seed = 0);
#endif
// *Basic* Bittorrent tracker implementation // *Basic* Bittorrent tracker implementation
// [BEP-3] The BitTorrent Protocol Specification // [BEP-3] The BitTorrent Protocol Specification

View File

@ -36,7 +36,11 @@ bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
&& QUrl(left.url) == QUrl(right.url)); && QUrl(left.url) == QUrl(right.url));
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const TrackerEntry &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const TrackerEntry &key, const uint seed) uint BitTorrent::qHash(const TrackerEntry &key, const uint seed)
#endif
{ {
return (::qHash(key.url, seed) ^ ::qHash(key.tier)); return (::qHash(key.url, seed) ^ ::qHash(key.tier));
} }

View File

@ -71,5 +71,9 @@ namespace BitTorrent
}; };
bool operator==(const TrackerEntry &left, const TrackerEntry &right); bool operator==(const TrackerEntry &left, const TrackerEntry &right);
uint qHash(const TrackerEntry &key, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TrackerEntry &key, std::size_t seed = 0);
#else
uint qHash(const TrackerEntry &key, uint seed = 0);
#endif
} }

View File

@ -30,6 +30,7 @@
#include <libtorrent/sha1_hash.hpp> #include <libtorrent/sha1_hash.hpp>
#include <QtGlobal>
#include <QByteArray> #include <QByteArray>
#include <QHash> #include <QHash>
#include <QSharedData> #include <QSharedData>
@ -131,7 +132,11 @@ bool operator<(const Digest32<N> &left, const Digest32<N> &right)
} }
template <int N> template <int N>
uint qHash(const Digest32<N> &key, const uint seed) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0)
#else
uint qHash(const Digest32<N> &key, const uint seed = 0)
#endif
{ {
return ::qHash(std::hash<typename Digest32<N>::UnderlyingType>()(key), seed); return ::qHash(std::hash<typename Digest32<N>::UnderlyingType>()(key), seed);
} }

View File

@ -364,7 +364,11 @@ Net::ServiceID Net::ServiceID::fromURL(const QUrl &url)
return {url.host(), url.port(80)}; return {url.host(), url.port(80)};
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t Net::qHash(const ServiceID &serviceID, const std::size_t seed)
#else
uint Net::qHash(const ServiceID &serviceID, const uint seed) uint Net::qHash(const ServiceID &serviceID, const uint seed)
#endif
{ {
return ::qHash(serviceID.hostName, seed) ^ ::qHash(serviceID.port); return ::qHash(serviceID.hostName, seed) ^ ::qHash(serviceID.port);
} }

View File

@ -29,6 +29,7 @@
#pragma once #pragma once
#include <QtGlobal>
#include <QHash> #include <QHash>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QObject> #include <QObject>
@ -52,7 +53,11 @@ namespace Net
static ServiceID fromURL(const QUrl &url); static ServiceID fromURL(const QUrl &url);
}; };
uint qHash(const ServiceID &serviceID, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const ServiceID &serviceID, std::size_t seed = 0);
#else
uint qHash(const ServiceID &serviceID, uint seed = 0);
#endif
bool operator==(const ServiceID &lhs, const ServiceID &rhs); bool operator==(const ServiceID &lhs, const ServiceID &rhs);
enum class DownloadStatus enum class DownloadStatus

View File

@ -332,7 +332,11 @@ QDataStream &operator>>(QDataStream &in, Path &path)
return in; return in;
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, const std::size_t seed)
#else
uint qHash(const Path &key, const uint seed) uint qHash(const Path &key, const uint seed)
#endif
{ {
return ::qHash(key.data(), seed); return ::qHash(key.data(), seed);
} }

View File

@ -29,6 +29,7 @@
#pragma once #pragma once
#include <QtGlobal>
#include <QMetaType> #include <QMetaType>
#include <QString> #include <QString>
@ -96,4 +97,8 @@ Path operator+(const Path &lhs, const std::string &rhs);
QDataStream &operator<<(QDataStream &out, const Path &path); QDataStream &operator<<(QDataStream &out, const Path &path);
QDataStream &operator>>(QDataStream &in, Path &path); QDataStream &operator>>(QDataStream &in, Path &path);
uint qHash(const Path &key, uint seed); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, std::size_t seed = 0);
#else
uint qHash(const Path &key, uint seed = 0);
#endif

View File

@ -30,6 +30,7 @@
#include <algorithm> #include <algorithm>
#include <QtGlobal>
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QHeaderView> #include <QHeaderView>
@ -70,7 +71,11 @@ bool operator==(const PeerEndpoint &left, const PeerEndpoint &right)
return (left.address == right.address) && (left.connectionType == right.connectionType); return (left.address == right.address) && (left.connectionType == right.connectionType);
} }
uint qHash(const PeerEndpoint &peerEndpoint, const uint seed) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerEndpoint &peerEndpoint, const std::size_t seed = 0)
#else
uint qHash(const PeerEndpoint &peerEndpoint, const uint seed = 0)
#endif
{ {
return (qHash(peerEndpoint.address, seed) ^ ::qHash(peerEndpoint.connectionType)); return (qHash(peerEndpoint.address, seed) ^ ::qHash(peerEndpoint.connectionType));
} }