1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-14 16:57:55 +00:00

Merge pull request #11010 from Chocobo1/qvector

Replace QList by QVector
This commit is contained in:
Mike Tzou 2019-08-06 10:16:28 +08:00 committed by GitHub
commit 2b617b0e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 118 additions and 109 deletions

View File

@ -80,6 +80,7 @@ MagnetUri::MagnetUri(const QString &source)
for (const std::string &tracker : m_addTorrentParams.trackers) for (const std::string &tracker : m_addTorrentParams.trackers)
m_trackers.append(lt::announce_entry {tracker}); m_trackers.append(lt::announce_entry {tracker});
m_urlSeeds.reserve(m_addTorrentParams.url_seeds.size());
for (const std::string &urlSeed : m_addTorrentParams.url_seeds) for (const std::string &urlSeed : m_addTorrentParams.url_seeds)
m_urlSeeds.append(QUrl(QString::fromStdString(urlSeed))); m_urlSeeds.append(QUrl(QString::fromStdString(urlSeed)));
} }
@ -104,7 +105,7 @@ QVector<TrackerEntry> MagnetUri::trackers() const
return m_trackers; return m_trackers;
} }
QList<QUrl> MagnetUri::urlSeeds() const QVector<QUrl> MagnetUri::urlSeeds() const
{ {
return m_urlSeeds; return m_urlSeeds;
} }

View File

@ -31,7 +31,6 @@
#include <libtorrent/add_torrent_params.hpp> #include <libtorrent/add_torrent_params.hpp>
#include <QList>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -51,7 +50,7 @@ namespace BitTorrent
InfoHash hash() const; InfoHash hash() const;
QString name() const; QString name() const;
QVector<TrackerEntry> trackers() const; QVector<TrackerEntry> trackers() const;
QList<QUrl> urlSeeds() const; QVector<QUrl> urlSeeds() const;
QString url() const; QString url() const;
lt::add_torrent_params addTorrentParams() const; lt::add_torrent_params addTorrentParams() const;
@ -62,7 +61,7 @@ namespace BitTorrent
InfoHash m_hash; InfoHash m_hash;
QString m_name; QString m_name;
QVector<TrackerEntry> m_trackers; QVector<TrackerEntry> m_trackers;
QList<QUrl> m_urlSeeds; QVector<QUrl> m_urlSeeds;
lt::add_torrent_params m_addTorrentParams; lt::add_torrent_params m_addTorrentParams;
}; };
} }

View File

@ -33,7 +33,6 @@
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "base/net/geoipmanager.h" #include "base/net/geoipmanager.h"
#include "base/unicodestrings.h" #include "base/unicodestrings.h"
#include "base/utils/string.h"
#include "peeraddress.h" #include "peeraddress.h"
using namespace BitTorrent; using namespace BitTorrent;
@ -261,20 +260,18 @@ qreal PeerInfo::relevance() const
void PeerInfo::determineFlags() void PeerInfo::determineFlags()
{ {
QStringList flagsDescriptionList;
if (isInteresting()) { if (isInteresting()) {
// d = Your client wants to download, but peer doesn't want to send (interested and choked) // d = Your client wants to download, but peer doesn't want to send (interested and choked)
if (isRemoteChocked()) { if (isRemoteChocked()) {
m_flags += "d "; m_flags += "d ";
flagsDescriptionList += "d = " m_flagsDescription += ("d = "
+ tr("Interested(local) and Choked(peer)"); + tr("Interested(local) and Choked(peer)") + '\n');
} }
else { else {
// D = Currently downloading (interested and not choked) // D = Currently downloading (interested and not choked)
m_flags += "D "; m_flags += "D ";
flagsDescriptionList += "D = " m_flagsDescription += ("D = "
+ tr("interested(local) and unchoked(peer)"); + tr("interested(local) and unchoked(peer)") + '\n');
} }
} }
@ -282,95 +279,87 @@ void PeerInfo::determineFlags()
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked) // u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
if (isChocked()) { if (isChocked()) {
m_flags += "u "; m_flags += "u ";
flagsDescriptionList += "u = " m_flagsDescription += ("u = "
+ tr("interested(peer) and choked(local)"); + tr("interested(peer) and choked(local)") + '\n');
} }
else { else {
// U = Currently uploading (interested and not choked) // U = Currently uploading (interested and not choked)
m_flags += "U "; m_flags += "U ";
flagsDescriptionList += "U = " m_flagsDescription += ("U = "
+ tr("interested(peer) and unchoked(local)"); + tr("interested(peer) and unchoked(local)") + '\n');
} }
} }
// O = Optimistic unchoke // O = Optimistic unchoke
if (optimisticUnchoke()) { if (optimisticUnchoke()) {
m_flags += "O "; m_flags += "O ";
flagsDescriptionList += "O = " m_flagsDescription += ("O = " + tr("optimistic unchoke") + '\n');
+ tr("optimistic unchoke");
} }
// S = Peer is snubbed // S = Peer is snubbed
if (isSnubbed()) { if (isSnubbed()) {
m_flags += "S "; m_flags += "S ";
flagsDescriptionList += "S = " m_flagsDescription += ("S = " + tr("peer snubbed") + '\n');
+ tr("peer snubbed");
} }
// I = Peer is an incoming connection // I = Peer is an incoming connection
if (!isLocalConnection()) { if (!isLocalConnection()) {
m_flags += "I "; m_flags += "I ";
flagsDescriptionList += "I = " m_flagsDescription += ("I = " + tr("incoming connection") + '\n');
+ tr("incoming connection");
} }
// K = Peer is unchoking your client, but your client is not interested // K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting()) { if (!isRemoteChocked() && !isInteresting()) {
m_flags += "K "; m_flags += "K ";
flagsDescriptionList += "K = " m_flagsDescription += ("K = "
+ tr("not interested(local) and unchoked(peer)"); + tr("not interested(local) and unchoked(peer)") + '\n');
} }
// ? = Your client unchoked the peer but the peer is not interested // ? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested()) { if (!isChocked() && !isRemoteInterested()) {
m_flags += "? "; m_flags += "? ";
flagsDescriptionList += "? = " m_flagsDescription += ("? = "
+ tr("not interested(peer) and unchoked(local)"); + tr("not interested(peer) and unchoked(local)") + '\n');
} }
// X = Peer was included in peerlists obtained through Peer Exchange (PEX) // X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX()) { if (fromPeX()) {
m_flags += "X "; m_flags += "X ";
flagsDescriptionList += "X = " m_flagsDescription += ("X = " + tr("peer from PEX") + '\n');
+ tr("peer from PEX");
} }
// H = Peer was obtained through DHT // H = Peer was obtained through DHT
if (fromDHT()) { if (fromDHT()) {
m_flags += "H "; m_flags += "H ";
flagsDescriptionList += "H = " m_flagsDescription += ("H = " + tr("peer from DHT") + '\n');
+ tr("peer from DHT");
} }
// E = Peer is using Protocol Encryption (all traffic) // E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted()) { if (isRC4Encrypted()) {
m_flags += "E "; m_flags += "E ";
flagsDescriptionList += "E = " m_flagsDescription += ("E = " + tr("encrypted traffic") + '\n');
+ tr("encrypted traffic");
} }
// e = Peer is using Protocol Encryption (handshake) // e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted()) { if (isPlaintextEncrypted()) {
m_flags += "e "; m_flags += "e ";
flagsDescriptionList += "e = " m_flagsDescription += ("e = " + tr("encrypted handshake") + '\n');
+ tr("encrypted handshake");
} }
// P = Peer is using uTorrent uTP // P = Peer is using uTorrent uTP
if (useUTPSocket()) { if (useUTPSocket()) {
m_flags += "P "; m_flags += "P ";
flagsDescriptionList += "P = " m_flagsDescription += ("P = " + QString::fromUtf8(C_UTP) + '\n');
+ QString::fromUtf8(C_UTP);
} }
// L = Peer is local // L = Peer is local
if (fromLSD()) { if (fromLSD()) {
m_flags += 'L'; m_flags += "L ";
flagsDescriptionList += "L = " m_flagsDescription += ("L = " + tr("peer from LSD") + '\n');
+ tr("peer from LSD");
} }
m_flags = m_flags.trimmed(); m_flags = m_flags.trimmed();
m_flagsDescription = flagsDescriptionList.join('\n'); m_flagsDescription = m_flagsDescription.trimmed();
} }
QString PeerInfo::flags() const QString PeerInfo::flags() const

View File

@ -32,7 +32,6 @@
#include <libtorrent/peer_info.hpp> #include <libtorrent/peer_info.hpp>
#include <QCoreApplication> #include <QCoreApplication>
#include <QHostAddress>
class QBitArray; class QBitArray;
@ -46,6 +45,7 @@ namespace BitTorrent
Q_DECLARE_TR_FUNCTIONS(PeerInfo) Q_DECLARE_TR_FUNCTIONS(PeerInfo)
public: public:
PeerInfo() = default;
PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo); PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo);
bool fromDHT() const; bool fromDHT() const;
@ -98,8 +98,8 @@ namespace BitTorrent
void calcRelevance(const TorrentHandle *torrent); void calcRelevance(const TorrentHandle *torrent);
void determineFlags(); void determineFlags();
lt::peer_info m_nativeInfo; lt::peer_info m_nativeInfo = {};
qreal m_relevance; qreal m_relevance = 0;
QString m_flags; QString m_flags;
QString m_flagsDescription; QString m_flagsDescription;
}; };

View File

@ -3409,14 +3409,14 @@ void Session::handleTorrentTrackersChanged(TorrentHandle *const torrent)
emit trackersChanged(torrent); emit trackersChanged(torrent);
} }
void Session::handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds) void Session::handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QVector<QUrl> &newUrlSeeds)
{ {
torrent->saveResumeData(); torrent->saveResumeData();
for (const QUrl &newUrlSeed : newUrlSeeds) for (const QUrl &newUrlSeed : newUrlSeeds)
LogMsg(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name())); LogMsg(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name()));
} }
void Session::handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList<QUrl> &urlSeeds) void Session::handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QVector<QUrl> &urlSeeds)
{ {
torrent->saveResumeData(); torrent->saveResumeData();
for (const QUrl &urlSeed : urlSeeds) for (const QUrl &urlSeed : urlSeeds)

View File

@ -36,10 +36,10 @@
#include <QFile> #include <QFile>
#include <QHash> #include <QHash>
#include <QList>
#include <QNetworkConfigurationManager> #include <QNetworkConfigurationManager>
#include <QPointer> #include <QPointer>
#include <QSet> #include <QSet>
#include <QVector>
#include "base/settingvalue.h" #include "base/settingvalue.h"
#include "base/types.h" #include "base/types.h"
@ -439,8 +439,8 @@ namespace BitTorrent
void handleTorrentTrackersAdded(TorrentHandle *const torrent, const QVector<TrackerEntry> &newTrackers); void handleTorrentTrackersAdded(TorrentHandle *const torrent, const QVector<TrackerEntry> &newTrackers);
void handleTorrentTrackersRemoved(TorrentHandle *const torrent, const QVector<TrackerEntry> &deletedTrackers); void handleTorrentTrackersRemoved(TorrentHandle *const torrent, const QVector<TrackerEntry> &deletedTrackers);
void handleTorrentTrackersChanged(TorrentHandle *const torrent); void handleTorrentTrackersChanged(TorrentHandle *const torrent);
void handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds); void handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QVector<QUrl> &newUrlSeeds);
void handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList<QUrl> &urlSeeds); void handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QVector<QUrl> &urlSeeds);
void handleTorrentResumeDataReady(TorrentHandle *const torrent, const lt::entry &data); void handleTorrentResumeDataReady(TorrentHandle *const torrent, const lt::entry &data);
void handleTorrentResumeDataFailed(TorrentHandle *const torrent); void handleTorrentResumeDataFailed(TorrentHandle *const torrent);
void handleTorrentTrackerReply(TorrentHandle *const torrent, const QString &trackerUrl); void handleTorrentTrackerReply(TorrentHandle *const torrent, const QString &trackerUrl);

View File

@ -475,20 +475,23 @@ void TorrentHandle::replaceTrackers(const QVector<TrackerEntry> &trackers)
} }
} }
QList<QUrl> TorrentHandle::urlSeeds() const QVector<QUrl> TorrentHandle::urlSeeds() const
{ {
QList<QUrl> urlSeeds;
const std::set<std::string> seeds = m_nativeHandle.url_seeds(); const std::set<std::string> seeds = m_nativeHandle.url_seeds();
QVector<QUrl> urlSeeds;
urlSeeds.reserve(seeds.size());
for (const std::string &urlSeed : seeds) for (const std::string &urlSeed : seeds)
urlSeeds.append(QUrl(urlSeed.c_str())); urlSeeds.append(QUrl(urlSeed.c_str()));
return urlSeeds; return urlSeeds;
} }
void TorrentHandle::addUrlSeeds(const QList<QUrl> &urlSeeds) void TorrentHandle::addUrlSeeds(const QVector<QUrl> &urlSeeds)
{ {
QList<QUrl> addedUrlSeeds; QVector<QUrl> addedUrlSeeds;
addedUrlSeeds.reserve(urlSeeds.size());
for (const QUrl &urlSeed : urlSeeds) { for (const QUrl &urlSeed : urlSeeds) {
if (addUrlSeed(urlSeed)) if (addUrlSeed(urlSeed))
addedUrlSeeds << urlSeed; addedUrlSeeds << urlSeed;
@ -498,9 +501,10 @@ void TorrentHandle::addUrlSeeds(const QList<QUrl> &urlSeeds)
m_session->handleTorrentUrlSeedsAdded(this, addedUrlSeeds); m_session->handleTorrentUrlSeedsAdded(this, addedUrlSeeds);
} }
void TorrentHandle::removeUrlSeeds(const QList<QUrl> &urlSeeds) void TorrentHandle::removeUrlSeeds(const QVector<QUrl> &urlSeeds)
{ {
QList<QUrl> removedUrlSeeds; QVector<QUrl> removedUrlSeeds;
removedUrlSeeds.reserve(urlSeeds.size());
for (const QUrl &urlSeed : urlSeeds) { for (const QUrl &urlSeed : urlSeeds) {
if (removeUrlSeed(urlSeed)) if (removeUrlSeed(urlSeed))
removedUrlSeeds << urlSeed; removedUrlSeeds << urlSeed;
@ -512,7 +516,7 @@ void TorrentHandle::removeUrlSeeds(const QList<QUrl> &urlSeeds)
bool TorrentHandle::addUrlSeed(const QUrl &urlSeed) bool TorrentHandle::addUrlSeed(const QUrl &urlSeed)
{ {
QList<QUrl> seeds = urlSeeds(); const QVector<QUrl> seeds = urlSeeds();
if (seeds.contains(urlSeed)) return false; if (seeds.contains(urlSeed)) return false;
m_nativeHandle.add_url_seed(urlSeed.toString().toStdString()); m_nativeHandle.add_url_seed(urlSeed.toString().toStdString());
@ -521,7 +525,7 @@ bool TorrentHandle::addUrlSeed(const QUrl &urlSeed)
bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed) bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed)
{ {
QList<QUrl> seeds = urlSeeds(); const QVector<QUrl> seeds = urlSeeds();
if (!seeds.contains(urlSeed)) return false; if (!seeds.contains(urlSeed)) return false;
m_nativeHandle.remove_url_seed(urlSeed.toString().toStdString()); m_nativeHandle.remove_url_seed(urlSeed.toString().toStdString());
@ -1170,16 +1174,15 @@ bool TorrentHandle::superSeeding() const
#endif #endif
} }
QList<PeerInfo> TorrentHandle::peers() const QVector<PeerInfo> TorrentHandle::peers() const
{ {
QList<PeerInfo> peers;
std::vector<lt::peer_info> nativePeers; std::vector<lt::peer_info> nativePeers;
m_nativeHandle.get_peer_info(nativePeers); m_nativeHandle.get_peer_info(nativePeers);
QVector<PeerInfo> peers;
peers.reserve(nativePeers.size());
for (const lt::peer_info &peer : nativePeers) for (const lt::peer_info &peer : nativePeers)
peers << PeerInfo(this, peer); peers << PeerInfo(this, peer);
return peers; return peers;
} }

View File

@ -37,7 +37,6 @@
#include <libtorrent/torrent_status.hpp> #include <libtorrent/torrent_status.hpp>
#include <QHash> #include <QHash>
#include <QList>
#include <QObject> #include <QObject>
#include <QQueue> #include <QQueue>
#include <QSet> #include <QSet>
@ -263,7 +262,7 @@ namespace BitTorrent
int queuePosition() const; int queuePosition() const;
QVector<TrackerEntry> trackers() const; QVector<TrackerEntry> trackers() const;
QHash<QString, TrackerInfo> trackerInfos() const; QHash<QString, TrackerInfo> trackerInfos() const;
QList<QUrl> urlSeeds() const; QVector<QUrl> urlSeeds() const;
QString error() const; QString error() const;
qlonglong totalDownload() const; qlonglong totalDownload() const;
qlonglong totalUpload() const; qlonglong totalUpload() const;
@ -288,7 +287,7 @@ namespace BitTorrent
int downloadLimit() const; int downloadLimit() const;
int uploadLimit() const; int uploadLimit() const;
bool superSeeding() const; bool superSeeding() const;
QList<PeerInfo> peers() const; QVector<PeerInfo> peers() const;
QBitArray pieces() const; QBitArray pieces() const;
QBitArray downloadingPieces() const; QBitArray downloadingPieces() const;
QVector<int> pieceAvailability() const; QVector<int> pieceAvailability() const;
@ -326,8 +325,8 @@ namespace BitTorrent
void flushCache(); void flushCache();
void addTrackers(const QVector<TrackerEntry> &trackers); void addTrackers(const QVector<TrackerEntry> &trackers);
void replaceTrackers(const QVector<TrackerEntry> &trackers); void replaceTrackers(const QVector<TrackerEntry> &trackers);
void addUrlSeeds(const QList<QUrl> &urlSeeds); void addUrlSeeds(const QVector<QUrl> &urlSeeds);
void removeUrlSeeds(const QList<QUrl> &urlSeeds); void removeUrlSeeds(const QVector<QUrl> &urlSeeds);
bool connectPeer(const PeerAddress &peerAddress); bool connectPeer(const PeerAddress &peerAddress);
QString toMagnetUri() const; QString toMagnetUri() const;

View File

@ -278,14 +278,19 @@ QVector<TrackerEntry> TorrentInfo::trackers() const
return ret; return ret;
} }
QList<QUrl> TorrentInfo::urlSeeds() const QVector<QUrl> TorrentInfo::urlSeeds() const
{ {
if (!isValid()) return {}; if (!isValid()) return {};
QList<QUrl> urlSeeds; const std::vector<lt::web_seed_entry> &nativeWebSeeds = m_nativeInfo->web_seeds();
for (const lt::web_seed_entry &webSeed : m_nativeInfo->web_seeds())
QVector<QUrl> urlSeeds;
urlSeeds.reserve(nativeWebSeeds.size());
for (const lt::web_seed_entry &webSeed : nativeWebSeeds) {
if (webSeed.type == lt::web_seed_entry::url_seed) if (webSeed.type == lt::web_seed_entry::url_seed)
urlSeeds.append(QUrl(webSeed.url.c_str())); urlSeeds.append(QUrl(webSeed.url.c_str()));
}
return urlSeeds; return urlSeeds;
} }

View File

@ -33,7 +33,6 @@
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <QCoreApplication> #include <QCoreApplication>
#include <QList>
#include <QVector> #include <QVector>
#include "base/indexrange.h" #include "base/indexrange.h"
@ -89,7 +88,7 @@ namespace BitTorrent
qlonglong fileSize(int index) const; qlonglong fileSize(int index) const;
qlonglong fileOffset(int index) const; qlonglong fileOffset(int index) const;
QVector<TrackerEntry> trackers() const; QVector<TrackerEntry> trackers() const;
QList<QUrl> urlSeeds() const; QVector<QUrl> urlSeeds() const;
QByteArray metadata() const; QByteArray metadata() const;
QStringList filesForPiece(int pieceIndex) const; QStringList filesForPiece(int pieceIndex) const;
QVector<int> fileIndicesForPiece(int pieceIndex) const; QVector<int> fileIndicesForPiece(int pieceIndex) const;

View File

@ -32,8 +32,8 @@
#include <QDir> #include <QDir>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QHash> #include <QHash>
#include <QList>
#include <QTimer> #include <QTimer>
#include <QVector>
class QStringList; class QStringList;
@ -67,7 +67,7 @@ private:
QHash<QString, int> m_partialTorrents; QHash<QString, int> m_partialTorrents;
QTimer m_partialTorrentTimer; QTimer m_partialTorrentTimer;
QList<QDir> m_watchedFolders; QVector<QDir> m_watchedFolders;
QTimer m_watchTimer; QTimer m_watchTimer;
}; };

View File

@ -528,17 +528,21 @@ void Preferences::setWebUiAuthSubnetWhitelistEnabled(const bool enabled)
setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled); setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled);
} }
QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const QVector<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
{ {
QList<Utils::Net::Subnet> subnets; const QStringList subnets = value("Preferences/WebUI/AuthSubnetWhitelist").toStringList();
for (const QString &rawSubnet : asConst(value("Preferences/WebUI/AuthSubnetWhitelist").toStringList())) {
QVector<Utils::Net::Subnet> ret;
ret.reserve(subnets.size());
for (const QString &rawSubnet : subnets) {
bool ok = false; bool ok = false;
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok); const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok);
if (ok) if (ok)
subnets.append(subnet); ret.append(subnet);
} }
return subnets; return ret;
} }
void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets) void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets)

View File

@ -188,7 +188,7 @@ public:
void setWebUiLocalAuthEnabled(bool enabled); void setWebUiLocalAuthEnabled(bool enabled);
bool isWebUiAuthSubnetWhitelistEnabled() const; bool isWebUiAuthSubnetWhitelistEnabled() const;
void setWebUiAuthSubnetWhitelistEnabled(bool enabled); void setWebUiAuthSubnetWhitelistEnabled(bool enabled);
QList<Utils::Net::Subnet> getWebUiAuthSubnetWhitelist() const; QVector<Utils::Net::Subnet> getWebUiAuthSubnetWhitelist() const;
void setWebUiAuthSubnetWhitelist(QStringList subnets); void setWebUiAuthSubnetWhitelist(QStringList subnets);
QString getWebUiUsername() const; QString getWebUiUsername() const;
void setWebUiUsername(const QString &username); void setWebUiUsername(const QString &username);

View File

@ -127,13 +127,16 @@ void SearchHandler::processFinished(const int exitcode)
void SearchHandler::readSearchOutput() void SearchHandler::readSearchOutput()
{ {
QByteArray output = m_searchProcess->readAllStandardOutput(); QByteArray output = m_searchProcess->readAllStandardOutput();
output.replace("\r", ""); output.replace('\r', "");
QList<QByteArray> lines = output.split('\n'); QList<QByteArray> lines = output.split('\n');
if (!m_searchResultLineTruncated.isEmpty()) if (!m_searchResultLineTruncated.isEmpty())
lines.prepend(m_searchResultLineTruncated + lines.takeFirst()); lines.prepend(m_searchResultLineTruncated + lines.takeFirst());
m_searchResultLineTruncated = lines.takeLast().trimmed(); m_searchResultLineTruncated = lines.takeLast().trimmed();
QList<SearchResult> searchResultList; QVector<SearchResult> searchResultList;
searchResultList.reserve(lines.size());
for (const QByteArray &line : asConst(lines)) { for (const QByteArray &line : asConst(lines)) {
SearchResult searchResult; SearchResult searchResult;
if (parseSearchResult(QString::fromUtf8(line), searchResult)) if (parseSearchResult(QString::fromUtf8(line), searchResult))
@ -141,7 +144,8 @@ void SearchHandler::readSearchOutput()
} }
if (!searchResultList.isEmpty()) { if (!searchResultList.isEmpty()) {
m_results.append(searchResultList); for (const SearchResult &result : searchResultList)
m_results.append(result);
emit newSearchResults(searchResultList); emit newSearchResults(searchResultList);
} }
} }

View File

@ -33,6 +33,7 @@
#include <QList> #include <QList>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QVector>
class QProcess; class QProcess;
class QTimer; class QTimer;
@ -71,7 +72,7 @@ public:
signals: signals:
void searchFinished(bool cancelled = false); void searchFinished(bool cancelled = false);
void searchFailed(); void searchFailed();
void newSearchResults(const QList<SearchResult> &results); void newSearchResults(const QVector<SearchResult> &results);
private: private:
void readSearchOutput(); void readSearchOutput();

View File

@ -64,7 +64,7 @@ namespace Utils
|| (addr == QHostAddress(QLatin1String("::ffff:127.0.0.1"))); || (addr == QHostAddress(QLatin1String("::ffff:127.0.0.1")));
} }
bool isIPInRange(const QHostAddress &addr, const QList<Subnet> &subnets) bool isIPInRange(const QHostAddress &addr, const QVector<Subnet> &subnets)
{ {
QHostAddress protocolEquivalentAddress; QHostAddress protocolEquivalentAddress;
bool addrConversionOk = false; bool addrConversionOk = false;

View File

@ -32,6 +32,7 @@
#include <QHostAddress> #include <QHostAddress>
#include <QList> #include <QList>
#include <QPair> #include <QPair>
#include <QVector>
class QSslCertificate; class QSslCertificate;
class QSslKey; class QSslKey;
@ -47,7 +48,7 @@ namespace Utils
Subnet parseSubnet(const QString &subnetStr, bool *ok = nullptr); Subnet parseSubnet(const QString &subnetStr, bool *ok = nullptr);
bool canParseSubnet(const QString &subnetStr); bool canParseSubnet(const QString &subnetStr);
bool isLoopbackAddress(const QHostAddress &addr); bool isLoopbackAddress(const QHostAddress &addr);
bool isIPInRange(const QHostAddress &addr, const QList<Subnet> &subnets); bool isIPInRange(const QHostAddress &addr, const QVector<Subnet> &subnets);
QString subnetToString(const Subnet &subnet); QString subnetToString(const Subnet &subnet);
const int MAX_SSL_FILE_SIZE = 1024 * 1024; const int MAX_SSL_FILE_SIZE = 1024 * 1024;

View File

@ -239,7 +239,7 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
const QAction *addPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer...")); const QAction *addPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer..."));
connect(addPeerAct, &QAction::triggered, this, [this, torrent]() connect(addPeerAct, &QAction::triggered, this, [this, torrent]()
{ {
const QList<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this); const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this);
int peerCount = 0; int peerCount = 0;
for (const BitTorrent::PeerAddress &addr : peersList) { for (const BitTorrent::PeerAddress &addr : peersList) {
if (torrent->connectPeer(addr)) { if (torrent->connectPeer(addr)) {
@ -336,7 +336,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
{ {
if (!torrent) return; if (!torrent) return;
const QList<BitTorrent::PeerInfo> peers = torrent->peers(); const QVector<BitTorrent::PeerInfo> peers = torrent->peers();
QSet<QString> oldPeersSet = m_peerItems.keys().toSet(); QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
for (const BitTorrent::PeerInfo &peer : peers) { for (const BitTorrent::PeerInfo &peer : peers) {

View File

@ -48,7 +48,7 @@ PeersAdditionDialog::~PeersAdditionDialog()
delete m_ui; delete m_ui;
} }
QList<BitTorrent::PeerAddress> PeersAdditionDialog::askForPeers(QWidget *parent) QVector<BitTorrent::PeerAddress> PeersAdditionDialog::askForPeers(QWidget *parent)
{ {
PeersAdditionDialog dlg(parent); PeersAdditionDialog dlg(parent);
dlg.exec(); dlg.exec();

View File

@ -30,7 +30,7 @@
#define PEERADDITION_H #define PEERADDITION_H
#include <QDialog> #include <QDialog>
#include <QList> #include <QVector>
#include "base/bittorrent/peerinfo.h" #include "base/bittorrent/peerinfo.h"
@ -47,14 +47,14 @@ public:
PeersAdditionDialog(QWidget *parent); PeersAdditionDialog(QWidget *parent);
~PeersAdditionDialog(); ~PeersAdditionDialog();
static QList<BitTorrent::PeerAddress> askForPeers(QWidget *parent); static QVector<BitTorrent::PeerAddress> askForPeers(QWidget *parent);
protected slots: protected slots:
void validateInput(); void validateInput();
private: private:
Ui::PeersAdditionDialog *m_ui; Ui::PeersAdditionDialog *m_ui;
QList<BitTorrent::PeerAddress> m_peersList; QVector<BitTorrent::PeerAddress> m_peersList;
}; };
#endif // PEERADDITION_H #endif // PEERADDITION_H

View File

@ -495,7 +495,7 @@ void PropertiesWidget::loadUrlSeeds()
{ {
m_ui->listWebSeeds->clear(); m_ui->listWebSeeds->clear();
qDebug("Loading URL seeds"); qDebug("Loading URL seeds");
const QList<QUrl> hcSeeds = m_torrent->urlSeeds(); const QVector<QUrl> hcSeeds = m_torrent->urlSeeds();
// Add url seeds // Add url seeds
for (const QUrl &hcSeed : hcSeeds) { for (const QUrl &hcSeed : hcSeeds) {
qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString())); qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
@ -715,7 +715,7 @@ void PropertiesWidget::askWebSeed()
return; return;
} }
if (m_torrent) if (m_torrent)
m_torrent->addUrlSeeds(QList<QUrl>() << urlSeed); m_torrent->addUrlSeeds({urlSeed});
// Refresh the seeds list // Refresh the seeds list
loadUrlSeeds(); loadUrlSeeds();
} }
@ -725,7 +725,9 @@ void PropertiesWidget::deleteSelectedUrlSeeds()
const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems(); const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
if (selectedItems.isEmpty()) return; if (selectedItems.isEmpty()) return;
QList<QUrl> urlSeeds; QVector<QUrl> urlSeeds;
urlSeeds.reserve(selectedItems.size());
for (const QListWidgetItem *item : selectedItems) for (const QListWidgetItem *item : selectedItems)
urlSeeds << item->text(); urlSeeds << item->text();
@ -766,8 +768,8 @@ void PropertiesWidget::editWebSeed()
return; return;
} }
m_torrent->removeUrlSeeds(QList<QUrl>() << oldSeed); m_torrent->removeUrlSeeds({oldSeed});
m_torrent->addUrlSeeds(QList<QUrl>() << newSeed); m_torrent->addUrlSeeds({newSeed});
loadUrlSeeds(); loadUrlSeeds();
} }

View File

@ -238,9 +238,10 @@ void PluginSelectDialog::setRowColor(const int row, const QString &color)
} }
} }
QList<QTreeWidgetItem*> PluginSelectDialog::findItemsWithUrl(const QString &url) QVector<QTreeWidgetItem*> PluginSelectDialog::findItemsWithUrl(const QString &url)
{ {
QList<QTreeWidgetItem*> res; QVector<QTreeWidgetItem*> res;
res.reserve(m_ui->pluginsTree->topLevelItemCount());
for (int i = 0; i < m_ui->pluginsTree->topLevelItemCount(); ++i) { for (int i = 0; i < m_ui->pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i); QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i);

View File

@ -57,7 +57,7 @@ public:
explicit PluginSelectDialog(SearchPluginManager *pluginManager, QWidget *parent = nullptr); explicit PluginSelectDialog(SearchPluginManager *pluginManager, QWidget *parent = nullptr);
~PluginSelectDialog() override; ~PluginSelectDialog() override;
QList<QTreeWidgetItem*> findItemsWithUrl(const QString &url); QVector<QTreeWidgetItem*> findItemsWithUrl(const QString &url);
QTreeWidgetItem *findItemWithID(const QString &id); QTreeWidgetItem *findItemWithID(const QString &id);
protected: protected:

View File

@ -506,7 +506,7 @@ void SearchJobWidget::searchFailed()
setStatus(Status::Error); setStatus(Status::Error);
} }
void SearchJobWidget::appendSearchResults(const QList<SearchResult> &results) void SearchJobWidget::appendSearchResults(const QVector<SearchResult> &results)
{ {
for (const SearchResult &result : results) { for (const SearchResult &result : results) {
// Add item to search result list // Add item to search result list

View File

@ -100,7 +100,7 @@ private:
void onItemDoubleClicked(const QModelIndex &index); void onItemDoubleClicked(const QModelIndex &index);
void searchFinished(bool cancelled); void searchFinished(bool cancelled);
void searchFailed(); void searchFailed();
void appendSearchResults(const QList<SearchResult> &results); void appendSearchResults(const QVector<SearchResult> &results);
void updateResultsCount(); void updateResultsCount();
void setStatus(Status value); void setStatus(Status value);
void downloadTorrent(const QModelIndex &rowIndex); void downloadTorrent(const QModelIndex &rowIndex);

View File

@ -198,7 +198,7 @@ namespace
TorrentContentModel::TorrentContentModel(QObject *parent) TorrentContentModel::TorrentContentModel(QObject *parent)
: QAbstractItemModel(parent) : QAbstractItemModel(parent)
, m_rootItem(new TorrentContentModelFolder(QList<QVariant>({ tr("Name"), tr("Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") }))) , m_rootItem(new TorrentContentModelFolder(QVector<QVariant>({ tr("Name"), tr("Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
{ {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
m_fileIconProvider = new WinShellFileIconProvider(); m_fileIconProvider = new WinShellFileIconProvider();

View File

@ -43,7 +43,7 @@ TorrentContentModelFolder::TorrentContentModelFolder(const QString &name, Torren
m_name.chop(4); m_name.chop(4);
} }
TorrentContentModelFolder::TorrentContentModelFolder(const QList<QVariant> &data) TorrentContentModelFolder::TorrentContentModelFolder(const QVector<QVariant> &data)
: TorrentContentModelItem(nullptr) : TorrentContentModelItem(nullptr)
{ {
Q_ASSERT(data.size() == NB_COL); Q_ASSERT(data.size() == NB_COL);
@ -67,7 +67,7 @@ void TorrentContentModelFolder::deleteAllChildren()
m_childItems.clear(); m_childItems.clear();
} }
const QList<TorrentContentModelItem *> &TorrentContentModelFolder::children() const const QVector<TorrentContentModelItem *> &TorrentContentModelFolder::children() const
{ {
return m_childItems; return m_childItems;
} }

View File

@ -43,7 +43,7 @@ public:
TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent); TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent);
// Invisible root item constructor // Invisible root item constructor
explicit TorrentContentModelFolder(const QList<QVariant> &data); explicit TorrentContentModelFolder(const QVector<QVariant> &data);
~TorrentContentModelFolder() override; ~TorrentContentModelFolder() override;
@ -57,14 +57,14 @@ public:
void setPriority(BitTorrent::DownloadPriority newPriority, bool updateParent = true) override; void setPriority(BitTorrent::DownloadPriority newPriority, bool updateParent = true) override;
void deleteAllChildren(); void deleteAllChildren();
const QList<TorrentContentModelItem*> &children() const; const QVector<TorrentContentModelItem*> &children() const;
void appendChild(TorrentContentModelItem *item); void appendChild(TorrentContentModelItem *item);
TorrentContentModelItem *child(int row) const; TorrentContentModelItem *child(int row) const;
TorrentContentModelFolder *childFolderWithName(const QString &name) const; TorrentContentModelFolder *childFolderWithName(const QString &name) const;
int childCount() const; int childCount() const;
private: private:
QList<TorrentContentModelItem*> m_childItems; QVector<TorrentContentModelItem*> m_childItems;
}; };
#endif // TORRENTCONTENTMODELFOLDER_H #endif // TORRENTCONTENTMODELFOLDER_H

View File

@ -29,7 +29,7 @@
#ifndef TORRENTCONTENTMODELITEM_H #ifndef TORRENTCONTENTMODELITEM_H
#define TORRENTCONTENTMODELITEM_H #define TORRENTCONTENTMODELITEM_H
#include <QList> #include <QVector>
#include "base/bittorrent/downloadpriority.h" #include "base/bittorrent/downloadpriority.h"
@ -83,7 +83,7 @@ public:
protected: protected:
TorrentContentModelFolder *m_parentItem; TorrentContentModelFolder *m_parentItem;
// Root item members // Root item members
QList<QVariant> m_itemData; QVector<QVariant> m_itemData;
// Non-root item members // Non-root item members
QString m_name; QString m_name;
qulonglong m_size; qulonglong m_size;

View File

@ -490,7 +490,8 @@ void SyncController::torrentPeersAction()
QVariantMap data; QVariantMap data;
QVariantHash peers; QVariantHash peers;
const QList<BitTorrent::PeerInfo> peersList = torrent->peers();
const QVector<BitTorrent::PeerInfo> peersList = torrent->peers();
#ifndef DISABLE_COUNTRIES_RESOLUTION #ifndef DISABLE_COUNTRIES_RESOLUTION
bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries(); bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries();

View File

@ -145,7 +145,7 @@ private:
bool m_isLocalAuthEnabled; bool m_isLocalAuthEnabled;
bool m_isAuthSubnetWhitelistEnabled; bool m_isAuthSubnetWhitelistEnabled;
QList<Utils::Net::Subnet> m_authSubnetWhitelist; QVector<Utils::Net::Subnet> m_authSubnetWhitelist;
int m_sessionTimeout; int m_sessionTimeout;
// security related // security related