mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Use InfoHash type in queueing operations
This avoids redundant type conversions.
This commit is contained in:
parent
a9e6ef183b
commit
e0a23ba93d
4 changed files with 59 additions and 43 deletions
|
|
@ -40,6 +40,7 @@
|
|||
#include <QUrl>
|
||||
|
||||
#include "base/bittorrent/downloadpriority.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/peeraddress.h"
|
||||
#include "base/bittorrent/peerinfo.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
|
|
@ -197,6 +198,15 @@ namespace
|
|||
|
||||
return {dht, pex, lsd};
|
||||
}
|
||||
|
||||
QVector<BitTorrent::InfoHash> toInfoHashes(const QStringList &hashes)
|
||||
{
|
||||
QVector<BitTorrent::InfoHash> infoHashes;
|
||||
infoHashes.reserve(hashes.size());
|
||||
for (const QString &hash : hashes)
|
||||
infoHashes << hash;
|
||||
return infoHashes;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns all the torrents in JSON format.
|
||||
|
|
@ -901,7 +911,7 @@ void TorrentsController::increasePrioAction()
|
|||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
BitTorrent::Session::instance()->increaseTorrentsQueuePos(hashes);
|
||||
BitTorrent::Session::instance()->increaseTorrentsQueuePos(toInfoHashes(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::decreasePrioAction()
|
||||
|
|
@ -912,7 +922,7 @@ void TorrentsController::decreasePrioAction()
|
|||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
BitTorrent::Session::instance()->decreaseTorrentsQueuePos(hashes);
|
||||
BitTorrent::Session::instance()->decreaseTorrentsQueuePos(toInfoHashes(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::topPrioAction()
|
||||
|
|
@ -923,7 +933,7 @@ void TorrentsController::topPrioAction()
|
|||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
BitTorrent::Session::instance()->topTorrentsQueuePos(hashes);
|
||||
BitTorrent::Session::instance()->topTorrentsQueuePos(toInfoHashes(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::bottomPrioAction()
|
||||
|
|
@ -934,7 +944,7 @@ void TorrentsController::bottomPrioAction()
|
|||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
BitTorrent::Session::instance()->bottomTorrentsQueuePos(hashes);
|
||||
BitTorrent::Session::instance()->bottomTorrentsQueuePos(toInfoHashes(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::setLocationAction()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue