1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2025-02-02 10:36:45 +01:00

Change return type of qHash with Qt 6 to size_t

This commit is contained in:
Jonas Kvinge 2020-11-17 01:22:38 +01:00
parent 4dcae4ce21
commit 042da74955
8 changed files with 33 additions and 1 deletions

View File

@ -1500,7 +1500,11 @@ bool Song::operator!=(const Song &other) const {
return source() != other.source() || url() != other.url() || beginning_nanosec() != other.beginning_nanosec(); return source() != other.source() || url() != other.url() || beginning_nanosec() != other.beginning_nanosec();
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
size_t qHash(const Song &song) {
#else
uint qHash(const Song &song) { uint qHash(const Song &song) {
#endif
// Should compare the same fields as operator== // Should compare the same fields as operator==
return qHash(song.url().toString()) ^ qHash(song.beginning_nanosec()); return qHash(song.url().toString()) ^ qHash(song.beginning_nanosec());
} }

View File

@ -378,7 +378,11 @@ Q_DECLARE_METATYPE(Song)
typedef QList<Song> SongList; typedef QList<Song> SongList;
Q_DECLARE_METATYPE(QList<Song>) Q_DECLARE_METATYPE(QList<Song>)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
size_t qHash(const Song &song);
#else
uint qHash(const Song &song); uint qHash(const Song &song);
#endif
// Hash function using field checked in IsSimilar function // Hash function using field checked in IsSimilar function
uint HashSimilar(const Song &song); uint HashSimilar(const Song &song);

View File

@ -109,7 +109,11 @@ class MacOsDeviceLister : public DeviceLister {
static QSet<MTPDevice> sMTPDeviceList; static QSet<MTPDevice> sMTPDeviceList;
}; };
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
size_t qHash(const MacOsDeviceLister::MTPDevice& device);
#else
uint qHash(const MacOsDeviceLister::MTPDevice& device); uint qHash(const MacOsDeviceLister::MTPDevice& device);
#endif
inline bool operator==(const MacOsDeviceLister::MTPDevice& a, const MacOsDeviceLister::MTPDevice& b) { inline bool operator==(const MacOsDeviceLister::MTPDevice& a, const MacOsDeviceLister::MTPDevice& b) {
return (a.vendor_id == b.vendor_id) && (a.product_id == b.product_id); return (a.vendor_id == b.vendor_id) && (a.product_id == b.product_id);
} }

View File

@ -100,7 +100,11 @@ class ScopedIOObject {
QSet<MacOsDeviceLister::MTPDevice> MacOsDeviceLister::sMTPDeviceList; QSet<MacOsDeviceLister::MTPDevice> MacOsDeviceLister::sMTPDeviceList;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
size_t qHash(const MacOsDeviceLister::MTPDevice& d) {
#else
uint qHash(const MacOsDeviceLister::MTPDevice& d) { uint qHash(const MacOsDeviceLister::MTPDevice& d) {
#endif
return qHash(d.vendor_id) ^ qHash(d.product_id); return qHash(d.vendor_id) ^ qHash(d.product_id);
} }

View File

@ -96,7 +96,11 @@ class InternetSearchModel : public QStandardItemModel {
}; };
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
inline size_t qHash(const InternetSearchModel::ContainerKey &key) {
#else
inline uint qHash(const InternetSearchModel::ContainerKey &key) { inline uint qHash(const InternetSearchModel::ContainerKey &key) {
#endif
return qHash(key.group_[0]) ^ qHash(key.group_[1]) ^ qHash(key.group_[2]); return qHash(key.group_[0]) ^ qHash(key.group_[1]) ^ qHash(key.group_[2]);
} }

View File

@ -218,7 +218,11 @@ class MusicBrainzClient : public QObject {
}; };
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
inline size_t qHash(const MusicBrainzClient::Result& result) {
#else
inline uint qHash(const MusicBrainzClient::Result& result) { inline uint qHash(const MusicBrainzClient::Result& result) {
#endif
return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^ qHash(result.title_) ^ result.track_ ^ result.year_; return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^ qHash(result.title_) ^ result.track_ ^ result.year_;
} }

View File

@ -84,7 +84,11 @@ bool PlaylistFilter::filterAcceptsRow(int row, const QModelIndex &parent) const
QString filter = filterRegExp().pattern(); QString filter = filterRegExp().pattern();
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
size_t hash = qHash(filter);
#else
uint hash = qHash(filter); uint hash = qHash(filter);
#endif
if (hash != query_hash_) { if (hash != query_hash_) {
// Parse the query // Parse the query
FilterParser p(filter, column_names_, numerical_columns_); FilterParser p(filter, column_names_, numerical_columns_);

View File

@ -47,10 +47,14 @@ class PlaylistFilter : public QSortFilterProxyModel {
// public so Playlist::NextVirtualIndex and friends can get at it // public so Playlist::NextVirtualIndex and friends can get at it
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
private: private:
// Mutable because they're modified from filterAcceptsRow() const // Mutable because they're modified from filterAcceptsRow() const
mutable QScopedPointer<FilterTree> filter_tree_; mutable QScopedPointer<FilterTree> filter_tree_;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
mutable size_t query_hash_;
#else
mutable uint query_hash_; mutable uint query_hash_;
#endif
QMap<QString, int> column_names_; QMap<QString, int> column_names_;
QSet<int> numerical_columns_; QSet<int> numerical_columns_;