Browse Source

Replace QList by QVector

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
e90a2c00a5
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 3
      src/base/bittorrent/magneturi.cpp
  2. 5
      src/base/bittorrent/magneturi.h
  3. 5
      src/base/bittorrent/peerinfo.h
  4. 4
      src/base/bittorrent/session.cpp
  5. 6
      src/base/bittorrent/session.h
  6. 27
      src/base/bittorrent/torrenthandle.cpp
  7. 9
      src/base/bittorrent/torrenthandle.h
  8. 11
      src/base/bittorrent/torrentinfo.cpp
  9. 3
      src/base/bittorrent/torrentinfo.h
  10. 4
      src/base/filesystemwatcher.h
  11. 14
      src/base/preferences.cpp
  12. 2
      src/base/preferences.h
  13. 10
      src/base/search/searchhandler.cpp
  14. 3
      src/base/search/searchhandler.h
  15. 2
      src/base/utils/net.cpp
  16. 3
      src/base/utils/net.h
  17. 4
      src/gui/properties/peerlistwidget.cpp
  18. 2
      src/gui/properties/peersadditiondialog.cpp
  19. 6
      src/gui/properties/peersadditiondialog.h
  20. 12
      src/gui/properties/propertieswidget.cpp
  21. 5
      src/gui/search/pluginselectdialog.cpp
  22. 2
      src/gui/search/pluginselectdialog.h
  23. 2
      src/gui/search/searchjobwidget.cpp
  24. 2
      src/gui/search/searchjobwidget.h
  25. 2
      src/gui/torrentcontentmodel.cpp
  26. 4
      src/gui/torrentcontentmodelfolder.cpp
  27. 6
      src/gui/torrentcontentmodelfolder.h
  28. 4
      src/gui/torrentcontentmodelitem.h
  29. 3
      src/webui/api/synccontroller.cpp
  30. 2
      src/webui/webapplication.h

3
src/base/bittorrent/magneturi.cpp

@ -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;
} }

5
src/base/bittorrent/magneturi.h

@ -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;
}; };
} }

5
src/base/bittorrent/peerinfo.h

@ -46,6 +46,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 +99,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;
}; };

4
src/base/bittorrent/session.cpp

@ -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)

6
src/base/bittorrent/session.h

@ -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);

27
src/base/bittorrent/torrenthandle.cpp

@ -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;
} }

9
src/base/bittorrent/torrenthandle.h

@ -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;

11
src/base/bittorrent/torrentinfo.cpp

@ -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;
} }

3
src/base/bittorrent/torrentinfo.h

@ -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;

4
src/base/filesystemwatcher.h

@ -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;
}; };

14
src/base/preferences.cpp

@ -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)

2
src/base/preferences.h

@ -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);

10
src/base/search/searchhandler.cpp

@ -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);
} }
} }

3
src/base/search/searchhandler.h

@ -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();

2
src/base/utils/net.cpp

@ -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;

3
src/base/utils/net.h

@ -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;

4
src/gui/properties/peerlistwidget.cpp

@ -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) {

2
src/gui/properties/peersadditiondialog.cpp

@ -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();

6
src/gui/properties/peersadditiondialog.h

@ -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

12
src/gui/properties/propertieswidget.cpp

@ -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();
} }

5
src/gui/search/pluginselectdialog.cpp

@ -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);

2
src/gui/search/pluginselectdialog.h

@ -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:

2
src/gui/search/searchjobwidget.cpp

@ -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

2
src/gui/search/searchjobwidget.h

@ -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);

2
src/gui/torrentcontentmodel.cpp

@ -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();

4
src/gui/torrentcontentmodelfolder.cpp

@ -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;
} }

6
src/gui/torrentcontentmodelfolder.h

@ -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

4
src/gui/torrentcontentmodelitem.h

@ -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;

3
src/webui/api/synccontroller.cpp

@ -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();

2
src/webui/webapplication.h

@ -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

Loading…
Cancel
Save