mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-30 12:18:05 -06:00
Combine qAsConst() with copyAsConst() to asConst()
This commit is contained in:
committed by
sledgehammer999
parent
e2ee928017
commit
bd4d2fa424
@@ -202,7 +202,7 @@ void AppController::preferencesAction()
|
||||
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
|
||||
data["bypass_auth_subnet_whitelist_enabled"] = pref->isWebUiAuthSubnetWhitelistEnabled();
|
||||
QStringList authSubnetWhitelistStringList;
|
||||
for (const Utils::Net::Subnet &subnet : copyAsConst(pref->getWebUiAuthSubnetWhitelist()))
|
||||
for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist()))
|
||||
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
|
||||
data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n");
|
||||
// Security
|
||||
|
||||
@@ -72,7 +72,7 @@ void LogController::mainAction()
|
||||
Logger *const logger = Logger::instance();
|
||||
QVariantList msgList;
|
||||
|
||||
for (const Log::Msg &msg : copyAsConst(logger->getMessages(lastKnownId))) {
|
||||
for (const Log::Msg &msg : asConst(logger->getMessages(lastKnownId))) {
|
||||
if (!((msg.type == Log::NORMAL && isNormal)
|
||||
|| (msg.type == Log::INFO && isInfo)
|
||||
|| (msg.type == Log::WARNING && isWarning)
|
||||
@@ -111,7 +111,7 @@ void LogController::peersAction()
|
||||
Logger *const logger = Logger::instance();
|
||||
QVariantList peerList;
|
||||
|
||||
for (const Log::Peer &peer : copyAsConst(logger->getPeers(lastKnownId))) {
|
||||
for (const Log::Peer &peer : asConst(logger->getPeers(lastKnownId))) {
|
||||
QVariantMap map;
|
||||
map[KEY_LOG_ID] = peer.id;
|
||||
map[KEY_LOG_TIMESTAMP] = peer.timestamp;
|
||||
|
||||
@@ -202,7 +202,7 @@ void SearchController::categoriesAction()
|
||||
const QString name = params()["pluginName"].trimmed();
|
||||
|
||||
categories << SearchPluginManager::categoryFullName("all");
|
||||
for (const QString &category : copyAsConst(SearchPluginManager::instance()->getPluginCategories(name)))
|
||||
for (const QString &category : asConst(SearchPluginManager::instance()->getPluginCategories(name)))
|
||||
categories << SearchPluginManager::categoryFullName(category);
|
||||
|
||||
const QJsonArray result = QJsonArray::fromStringList(categories);
|
||||
@@ -263,7 +263,7 @@ void SearchController::checkForUpdatesFinished(const QHash<QString, PluginVersio
|
||||
LogMsg(tr("Updating %1 plugins").arg(updateInfo.size()), Log::INFO);
|
||||
|
||||
SearchPluginManager *const pluginManager = SearchPluginManager::instance();
|
||||
for (const QString &pluginName : copyAsConst(updateInfo.keys())) {
|
||||
for (const QString &pluginName : asConst(updateInfo.keys())) {
|
||||
LogMsg(tr("Updating plugin %1").arg(pluginName), Log::INFO);
|
||||
pluginManager->updatePlugin(pluginName);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace
|
||||
|
||||
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
||||
quint32 peers = 0;
|
||||
for (BitTorrent::TorrentHandle *const torrent : copyAsConst(BitTorrent::Session::instance()->torrents()))
|
||||
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||
peers += torrent->peersCount();
|
||||
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0";
|
||||
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0";
|
||||
@@ -410,7 +410,7 @@ void SyncController::maindataAction()
|
||||
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
|
||||
for (BitTorrent::TorrentHandle *const torrent : copyAsConst(session->torrents())) {
|
||||
for (BitTorrent::TorrentHandle *const torrent : asConst(session->torrents())) {
|
||||
QVariantMap map = serialize(*torrent);
|
||||
map.remove(KEY_TORRENT_HASH);
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace
|
||||
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::TorrentHandle *torrent)> &func)
|
||||
{
|
||||
if ((hashes.size() == 1) && (hashes[0] == QLatin1String("all"))) {
|
||||
for (BitTorrent::TorrentHandle *torrent : copyAsConst(BitTorrent::Session::instance()->torrents()))
|
||||
for (BitTorrent::TorrentHandle *torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||
func(torrent);
|
||||
}
|
||||
else {
|
||||
@@ -167,7 +167,7 @@ void TorrentsController::infoAction()
|
||||
|
||||
QVariantList torrentList;
|
||||
TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
|
||||
for (BitTorrent::TorrentHandle *const torrent : copyAsConst(BitTorrent::Session::instance()->torrents())) {
|
||||
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) {
|
||||
if (torrentFilter.match(torrent))
|
||||
torrentList.append(serialize(*torrent));
|
||||
}
|
||||
@@ -307,7 +307,7 @@ void TorrentsController::trackersAction()
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
QHash<QString, BitTorrent::TrackerInfo> trackersData = torrent->trackerInfos();
|
||||
for (const BitTorrent::TrackerEntry &tracker : copyAsConst(torrent->trackers())) {
|
||||
for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) {
|
||||
QVariantMap trackerDict;
|
||||
trackerDict[KEY_TRACKER_URL] = tracker.url();
|
||||
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
|
||||
@@ -346,7 +346,7 @@ void TorrentsController::webseedsAction()
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
for (const QUrl &webseed : copyAsConst(torrent->urlSeeds())) {
|
||||
for (const QUrl &webseed : asConst(torrent->urlSeeds())) {
|
||||
QVariantMap webSeedDict;
|
||||
webSeedDict[KEY_WEBSEED_URL] = webseed.toString();
|
||||
webSeedList.append(webSeedDict);
|
||||
@@ -498,7 +498,7 @@ void TorrentsController::addAction()
|
||||
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
|
||||
|
||||
bool partialSuccess = false;
|
||||
for (QString url : copyAsConst(urls.split('\n'))) {
|
||||
for (QString url : asConst(urls.split('\n'))) {
|
||||
url = url.trimmed();
|
||||
if (!url.isEmpty()) {
|
||||
Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8()));
|
||||
@@ -531,7 +531,7 @@ void TorrentsController::addTrackersAction()
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
if (torrent) {
|
||||
QList<BitTorrent::TrackerEntry> trackers;
|
||||
for (QString url : copyAsConst(params()["urls"].split('\n'))) {
|
||||
for (QString url : asConst(params()["urls"].split('\n'))) {
|
||||
url = url.trimmed();
|
||||
if (!url.isEmpty())
|
||||
trackers << url;
|
||||
|
||||
@@ -525,7 +525,7 @@ Http::Response WebApplication::processRequest(const Http::Request &request, cons
|
||||
if (m_request.method == Http::METHOD_GET) {
|
||||
// Parse GET parameters
|
||||
using namespace Utils::ByteArray;
|
||||
for (const QByteArray ¶m : copyAsConst(splitToViews(m_request.query, "&"))) {
|
||||
for (const QByteArray ¶m : asConst(splitToViews(m_request.query, "&"))) {
|
||||
const int sepPos = param.indexOf('=');
|
||||
if (sepPos <= 0) continue; // ignores params without name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user