From 8eabaf5eb278cdc6e23dca7c20b3d6fb4581d331 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 27 Jun 2019 23:36:54 +0800 Subject: [PATCH] Replace QList by QVector --- src/gui/transferlistwidget.cpp | 22 +++++++++++----------- src/gui/transferlistwidget.h | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 290f70ce5..4f3fe511d 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -78,7 +78,7 @@ namespace { using ToggleFn = std::function; - QStringList extractHashes(const QList &torrents) + QStringList extractHashes(const QVector &torrents) { QStringList hashes; for (BitTorrent::TorrentHandle *const torrent : torrents) @@ -400,9 +400,9 @@ void TransferListWidget::torrentDoubleClicked() } } -QList TransferListWidget::getSelectedTorrents() const +QVector TransferListWidget::getSelectedTorrents() const { - QList torrents; + QVector torrents; for (const QModelIndex &index : asConst(selectionModel()->selectedRows())) torrents << m_listModel->torrentHandle(mapToSource(index)); @@ -411,7 +411,7 @@ QList TransferListWidget::getSelectedTorrents() con void TransferListWidget::setSelectedTorrentsLocation() { - const QList torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); if (torrents.isEmpty()) return; const QString oldLocation = torrents[0]->savePath(); @@ -494,7 +494,7 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) { if (m_mainWindow->currentTabWidget() != this) return; - const QList torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); if (torrents.empty()) return; if (Preferences::instance()->confirmTorrentDeletion() @@ -508,7 +508,7 @@ void TransferListWidget::deleteVisibleTorrents() { if (m_sortFilterModel->rowCount() <= 0) return; - QList torrents; + QVector torrents; for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); @@ -622,7 +622,7 @@ void TransferListWidget::previewSelectedTorrents() void TransferListWidget::setDlLimitSelectedTorrents() { - QList torrentsList; + QVector torrentsList; for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) { if (torrent->isSeed()) continue; @@ -652,7 +652,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() void TransferListWidget::setUpLimitSelectedTorrents() { - QList torrentsList = getSelectedTorrents(); + QVector torrentsList = getSelectedTorrents(); if (torrentsList.empty()) return; int oldLimit = torrentsList.first()->uploadLimit(); @@ -677,7 +677,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() void TransferListWidget::setMaxRatioSelectedTorrents() { - const QList torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); if (torrents.isEmpty()) return; qreal currentMaxRatio = BitTorrent::Session::instance()->globalMaxRatio(); @@ -814,8 +814,8 @@ void TransferListWidget::askAddTagsForSelection() void TransferListWidget::editTorrentTrackers() { - const QList torrents = getSelectedTorrents(); - QList commonTrackers; + const QVector torrents = getSelectedTorrents(); + QVector commonTrackers; if (!torrents.empty()) { commonTrackers = torrents[0]->trackers(); diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 862c6ca19..41d3421e5 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -31,6 +31,7 @@ #include #include +#include namespace BitTorrent { @@ -99,7 +100,7 @@ protected: QModelIndex mapToSource(const QModelIndex &index) const; QModelIndex mapFromSource(const QModelIndex &index) const; bool loadSettings(); - QList getSelectedTorrents() const; + QVector getSelectedTorrents() const; protected slots: void torrentDoubleClicked();