mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Replace QList by QVector
This commit is contained in:
@@ -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..."));
|
||||
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;
|
||||
for (const BitTorrent::PeerAddress &addr : peersList) {
|
||||
if (torrent->connectPeer(addr)) {
|
||||
@@ -336,7 +336,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
|
||||
{
|
||||
if (!torrent) return;
|
||||
|
||||
const QList<BitTorrent::PeerInfo> peers = torrent->peers();
|
||||
const QVector<BitTorrent::PeerInfo> peers = torrent->peers();
|
||||
QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
|
||||
|
||||
for (const BitTorrent::PeerInfo &peer : peers) {
|
||||
|
||||
@@ -48,7 +48,7 @@ PeersAdditionDialog::~PeersAdditionDialog()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QList<BitTorrent::PeerAddress> PeersAdditionDialog::askForPeers(QWidget *parent)
|
||||
QVector<BitTorrent::PeerAddress> PeersAdditionDialog::askForPeers(QWidget *parent)
|
||||
{
|
||||
PeersAdditionDialog dlg(parent);
|
||||
dlg.exec();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define PEERADDITION_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
#include "base/bittorrent/peerinfo.h"
|
||||
|
||||
@@ -47,14 +47,14 @@ public:
|
||||
PeersAdditionDialog(QWidget *parent);
|
||||
~PeersAdditionDialog();
|
||||
|
||||
static QList<BitTorrent::PeerAddress> askForPeers(QWidget *parent);
|
||||
static QVector<BitTorrent::PeerAddress> askForPeers(QWidget *parent);
|
||||
|
||||
protected slots:
|
||||
void validateInput();
|
||||
|
||||
private:
|
||||
Ui::PeersAdditionDialog *m_ui;
|
||||
QList<BitTorrent::PeerAddress> m_peersList;
|
||||
QVector<BitTorrent::PeerAddress> m_peersList;
|
||||
};
|
||||
|
||||
#endif // PEERADDITION_H
|
||||
|
||||
@@ -495,7 +495,7 @@ void PropertiesWidget::loadUrlSeeds()
|
||||
{
|
||||
m_ui->listWebSeeds->clear();
|
||||
qDebug("Loading URL seeds");
|
||||
const QList<QUrl> hcSeeds = m_torrent->urlSeeds();
|
||||
const QVector<QUrl> hcSeeds = m_torrent->urlSeeds();
|
||||
// Add url seeds
|
||||
for (const QUrl &hcSeed : hcSeeds) {
|
||||
qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
|
||||
@@ -715,7 +715,7 @@ void PropertiesWidget::askWebSeed()
|
||||
return;
|
||||
}
|
||||
if (m_torrent)
|
||||
m_torrent->addUrlSeeds(QList<QUrl>() << urlSeed);
|
||||
m_torrent->addUrlSeeds({urlSeed});
|
||||
// Refresh the seeds list
|
||||
loadUrlSeeds();
|
||||
}
|
||||
@@ -725,7 +725,9 @@ void PropertiesWidget::deleteSelectedUrlSeeds()
|
||||
const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
|
||||
if (selectedItems.isEmpty()) return;
|
||||
|
||||
QList<QUrl> urlSeeds;
|
||||
QVector<QUrl> urlSeeds;
|
||||
urlSeeds.reserve(selectedItems.size());
|
||||
|
||||
for (const QListWidgetItem *item : selectedItems)
|
||||
urlSeeds << item->text();
|
||||
|
||||
@@ -766,8 +768,8 @@ void PropertiesWidget::editWebSeed()
|
||||
return;
|
||||
}
|
||||
|
||||
m_torrent->removeUrlSeeds(QList<QUrl>() << oldSeed);
|
||||
m_torrent->addUrlSeeds(QList<QUrl>() << newSeed);
|
||||
m_torrent->removeUrlSeeds({oldSeed});
|
||||
m_torrent->addUrlSeeds({newSeed});
|
||||
loadUrlSeeds();
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i);
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
explicit PluginSelectDialog(SearchPluginManager *pluginManager, QWidget *parent = nullptr);
|
||||
~PluginSelectDialog() override;
|
||||
|
||||
QList<QTreeWidgetItem*> findItemsWithUrl(const QString &url);
|
||||
QVector<QTreeWidgetItem*> findItemsWithUrl(const QString &url);
|
||||
QTreeWidgetItem *findItemWithID(const QString &id);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -506,7 +506,7 @@ void SearchJobWidget::searchFailed()
|
||||
setStatus(Status::Error);
|
||||
}
|
||||
|
||||
void SearchJobWidget::appendSearchResults(const QList<SearchResult> &results)
|
||||
void SearchJobWidget::appendSearchResults(const QVector<SearchResult> &results)
|
||||
{
|
||||
for (const SearchResult &result : results) {
|
||||
// Add item to search result list
|
||||
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
void onItemDoubleClicked(const QModelIndex &index);
|
||||
void searchFinished(bool cancelled);
|
||||
void searchFailed();
|
||||
void appendSearchResults(const QList<SearchResult> &results);
|
||||
void appendSearchResults(const QVector<SearchResult> &results);
|
||||
void updateResultsCount();
|
||||
void setStatus(Status value);
|
||||
void downloadTorrent(const QModelIndex &rowIndex);
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace
|
||||
|
||||
TorrentContentModel::TorrentContentModel(QObject *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)
|
||||
m_fileIconProvider = new WinShellFileIconProvider();
|
||||
|
||||
@@ -43,7 +43,7 @@ TorrentContentModelFolder::TorrentContentModelFolder(const QString &name, Torren
|
||||
m_name.chop(4);
|
||||
}
|
||||
|
||||
TorrentContentModelFolder::TorrentContentModelFolder(const QList<QVariant> &data)
|
||||
TorrentContentModelFolder::TorrentContentModelFolder(const QVector<QVariant> &data)
|
||||
: TorrentContentModelItem(nullptr)
|
||||
{
|
||||
Q_ASSERT(data.size() == NB_COL);
|
||||
@@ -67,7 +67,7 @@ void TorrentContentModelFolder::deleteAllChildren()
|
||||
m_childItems.clear();
|
||||
}
|
||||
|
||||
const QList<TorrentContentModelItem *> &TorrentContentModelFolder::children() const
|
||||
const QVector<TorrentContentModelItem *> &TorrentContentModelFolder::children() const
|
||||
{
|
||||
return m_childItems;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent);
|
||||
|
||||
// Invisible root item constructor
|
||||
explicit TorrentContentModelFolder(const QList<QVariant> &data);
|
||||
explicit TorrentContentModelFolder(const QVector<QVariant> &data);
|
||||
|
||||
~TorrentContentModelFolder() override;
|
||||
|
||||
@@ -57,14 +57,14 @@ public:
|
||||
void setPriority(BitTorrent::DownloadPriority newPriority, bool updateParent = true) override;
|
||||
|
||||
void deleteAllChildren();
|
||||
const QList<TorrentContentModelItem*> &children() const;
|
||||
const QVector<TorrentContentModelItem*> &children() const;
|
||||
void appendChild(TorrentContentModelItem *item);
|
||||
TorrentContentModelItem *child(int row) const;
|
||||
TorrentContentModelFolder *childFolderWithName(const QString &name) const;
|
||||
int childCount() const;
|
||||
|
||||
private:
|
||||
QList<TorrentContentModelItem*> m_childItems;
|
||||
QVector<TorrentContentModelItem*> m_childItems;
|
||||
};
|
||||
|
||||
#endif // TORRENTCONTENTMODELFOLDER_H
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#ifndef TORRENTCONTENTMODELITEM_H
|
||||
#define TORRENTCONTENTMODELITEM_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
#include "base/bittorrent/downloadpriority.h"
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
protected:
|
||||
TorrentContentModelFolder *m_parentItem;
|
||||
// Root item members
|
||||
QList<QVariant> m_itemData;
|
||||
QVector<QVariant> m_itemData;
|
||||
// Non-root item members
|
||||
QString m_name;
|
||||
qulonglong m_size;
|
||||
|
||||
Reference in New Issue
Block a user