mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Merge pull request #13912 from Chocobo1/infohash
Use the correct type when referring to info hash
This commit is contained in:
@@ -35,11 +35,6 @@ using namespace BitTorrent;
|
||||
|
||||
const int InfoHashTypeId = qRegisterMetaType<InfoHash>();
|
||||
|
||||
InfoHash::InfoHash()
|
||||
: m_valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
InfoHash::InfoHash(const lt::sha1_hash &nativeHash)
|
||||
: m_valid(true)
|
||||
, m_nativeHash(nativeHash)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BitTorrent
|
||||
class InfoHash
|
||||
{
|
||||
public:
|
||||
InfoHash();
|
||||
InfoHash() = default;
|
||||
InfoHash(const lt::sha1_hash &nativeHash);
|
||||
InfoHash(const QString &hashString);
|
||||
InfoHash(const InfoHash &other) = default;
|
||||
@@ -54,7 +54,7 @@ namespace BitTorrent
|
||||
operator QString() const;
|
||||
|
||||
private:
|
||||
bool m_valid;
|
||||
bool m_valid = false;
|
||||
lt::sha1_hash m_nativeHash;
|
||||
QString m_hashString;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "bittorrent/torrenthandle.h"
|
||||
|
||||
const QString TorrentFilter::AnyCategory;
|
||||
const QStringSet TorrentFilter::AnyHash = (QStringSet() << QString());
|
||||
const InfoHashSet TorrentFilter::AnyHash {{}};
|
||||
const QString TorrentFilter::AnyTag;
|
||||
|
||||
const TorrentFilter TorrentFilter::DownloadingTorrent(TorrentFilter::Downloading);
|
||||
@@ -49,12 +49,7 @@ const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
|
||||
|
||||
using BitTorrent::TorrentHandle;
|
||||
|
||||
TorrentFilter::TorrentFilter()
|
||||
: m_type(All)
|
||||
{
|
||||
}
|
||||
|
||||
TorrentFilter::TorrentFilter(const Type type, const QStringSet &hashSet, const QString &category, const QString &tag)
|
||||
TorrentFilter::TorrentFilter(const Type type, const InfoHashSet &hashSet, const QString &category, const QString &tag)
|
||||
: m_type(type)
|
||||
, m_category(category)
|
||||
, m_tag(tag)
|
||||
@@ -62,7 +57,7 @@ TorrentFilter::TorrentFilter(const Type type, const QStringSet &hashSet, const Q
|
||||
{
|
||||
}
|
||||
|
||||
TorrentFilter::TorrentFilter(const QString &filter, const QStringSet &hashSet, const QString &category, const QString &tag)
|
||||
TorrentFilter::TorrentFilter(const QString &filter, const InfoHashSet &hashSet, const QString &category, const QString &tag)
|
||||
: m_type(All)
|
||||
, m_category(category)
|
||||
, m_tag(tag)
|
||||
@@ -112,7 +107,7 @@ bool TorrentFilter::setTypeByName(const QString &filter)
|
||||
return setType(type);
|
||||
}
|
||||
|
||||
bool TorrentFilter::setHashSet(const QStringSet &hashSet)
|
||||
bool TorrentFilter::setHashSet(const InfoHashSet &hashSet)
|
||||
{
|
||||
if (m_hashSet != hashSet)
|
||||
{
|
||||
|
||||
@@ -32,13 +32,15 @@
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
|
||||
typedef QSet<QString> QStringSet;
|
||||
#include "base/bittorrent/infohash.h"
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
class TorrentHandle;
|
||||
}
|
||||
|
||||
using InfoHashSet = QSet<BitTorrent::InfoHash>;
|
||||
|
||||
class TorrentFilter
|
||||
{
|
||||
public:
|
||||
@@ -60,7 +62,7 @@ public:
|
||||
|
||||
// These mean any permutation, including no category / tag.
|
||||
static const QString AnyCategory;
|
||||
static const QStringSet AnyHash;
|
||||
static const InfoHashSet AnyHash;
|
||||
static const QString AnyTag;
|
||||
|
||||
static const TorrentFilter DownloadingTorrent;
|
||||
@@ -75,15 +77,15 @@ public:
|
||||
static const TorrentFilter StalledDownloadingTorrent;
|
||||
static const TorrentFilter ErroredTorrent;
|
||||
|
||||
TorrentFilter();
|
||||
TorrentFilter() = default;
|
||||
// category & tags: pass empty string for uncategorized / untagged torrents.
|
||||
// Pass null string (QString()) to disable filtering (i.e. all torrents).
|
||||
TorrentFilter(Type type, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tag = AnyTag);
|
||||
TorrentFilter(const QString &filter, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tags = AnyTag);
|
||||
TorrentFilter(Type type, const InfoHashSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tag = AnyTag);
|
||||
TorrentFilter(const QString &filter, const InfoHashSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tags = AnyTag);
|
||||
|
||||
bool setType(Type type);
|
||||
bool setTypeByName(const QString &filter);
|
||||
bool setHashSet(const QStringSet &hashSet);
|
||||
bool setHashSet(const InfoHashSet &hashSet);
|
||||
bool setCategory(const QString &category);
|
||||
bool setTag(const QString &tag);
|
||||
|
||||
@@ -95,10 +97,10 @@ private:
|
||||
bool matchCategory(const BitTorrent::TorrentHandle *torrent) const;
|
||||
bool matchTag(const BitTorrent::TorrentHandle *torrent) const;
|
||||
|
||||
Type m_type;
|
||||
Type m_type {All};
|
||||
QString m_category;
|
||||
QString m_tag;
|
||||
QStringSet m_hashSet;
|
||||
InfoHashSet m_hashSet;
|
||||
};
|
||||
|
||||
#endif // TORRENTFILTER_H
|
||||
|
||||
Reference in New Issue
Block a user