mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Add operator< for InfoHash class
This commit is contained in:
parent
cba8d83b21
commit
5ba6a5fca1
3 changed files with 8 additions and 2 deletions
|
@ -84,6 +84,11 @@ bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right)
|
||||||
return !(left == right);
|
return !(left == right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BitTorrent::operator<(const InfoHash &left, const InfoHash &right)
|
||||||
|
{
|
||||||
|
return static_cast<lt::sha1_hash>(left) < static_cast<lt::sha1_hash>(right);
|
||||||
|
}
|
||||||
|
|
||||||
uint BitTorrent::qHash(const InfoHash &key, const uint seed)
|
uint BitTorrent::qHash(const InfoHash &key, const uint seed)
|
||||||
{
|
{
|
||||||
return ::qHash((std::hash<lt::sha1_hash> {})(key), seed);
|
return ::qHash((std::hash<lt::sha1_hash> {})(key), seed);
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace BitTorrent
|
||||||
|
|
||||||
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);
|
||||||
|
bool operator<(const InfoHash &left, const InfoHash &right);
|
||||||
uint qHash(const InfoHash &key, uint seed);
|
uint qHash(const InfoHash &key, uint seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI
|
||||||
const auto hashLessThan = [this, &left, &right]() -> bool
|
const auto hashLessThan = [this, &left, &right]() -> bool
|
||||||
{
|
{
|
||||||
const TransferListModel *model = qobject_cast<TransferListModel *>(sourceModel());
|
const TransferListModel *model = qobject_cast<TransferListModel *>(sourceModel());
|
||||||
const QString hashL = model->torrentHandle(left)->hash();
|
const BitTorrent::InfoHash hashL = model->torrentHandle(left)->hash();
|
||||||
const QString hashR = model->torrentHandle(right)->hash();
|
const BitTorrent::InfoHash hashR = model->torrentHandle(right)->hash();
|
||||||
return hashL < hashR;
|
return hashL < hashR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue