mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 14:42:29 -06:00
Combine qAsConst() with copyAsConst() to asConst()
This commit is contained in:
@@ -62,7 +62,7 @@ void PeersAdditionDialog::validateInput()
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
for (const QString &peer : copyAsConst(m_ui->textEditPeers->toPlainText().trimmed().split('\n'))) {
|
||||
for (const QString &peer : asConst(m_ui->textEditPeers->toPlainText().trimmed().split('\n'))) {
|
||||
BitTorrent::PeerAddress addr = parsePeer(peer);
|
||||
if (!addr.ip.isNull()) {
|
||||
m_peersList.append(addr);
|
||||
|
||||
@@ -103,7 +103,7 @@ PropTabBar::PropTabBar(QWidget *parent)
|
||||
connect(m_btnGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked)
|
||||
, this, &PropTabBar::setCurrentIndex);
|
||||
// Disable buttons focus
|
||||
for (QAbstractButton *btn : copyAsConst(m_btnGroup->buttons()))
|
||||
for (QAbstractButton *btn : asConst(m_btnGroup->buttons()))
|
||||
btn->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||
|
||||
double legendHeight = 0;
|
||||
int legendWidth = 0;
|
||||
for (const auto &property : qAsConst(m_properties)) {
|
||||
for (const auto &property : asConst(m_properties)) {
|
||||
if (!property.enable)
|
||||
continue;
|
||||
|
||||
@@ -363,7 +363,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||
painter.fillRect(legendBackgroundRect, legendBackgroundColor);
|
||||
|
||||
i = 0;
|
||||
for (const auto &property : qAsConst(m_properties)) {
|
||||
for (const auto &property : asConst(m_properties)) {
|
||||
if (!property.enable)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ void TrackerListWidget::loadStickyItems(BitTorrent::TorrentHandle *const torrent
|
||||
// XXX: libtorrent should provide this info...
|
||||
// Count peers from DHT, PeX, LSD
|
||||
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
|
||||
for (const BitTorrent::PeerInfo &peer : copyAsConst(torrent->peers())) {
|
||||
for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers())) {
|
||||
if (peer.isConnecting()) continue;
|
||||
|
||||
if (peer.fromDHT()) {
|
||||
@@ -332,7 +332,7 @@ void TrackerListWidget::loadTrackers()
|
||||
// Load actual trackers information
|
||||
QHash<QString, BitTorrent::TrackerInfo> trackerData = torrent->trackerInfos();
|
||||
QStringList oldTrackerURLs = m_trackerItems.keys();
|
||||
for (const BitTorrent::TrackerEntry &entry : copyAsConst(torrent->trackers())) {
|
||||
for (const BitTorrent::TrackerEntry &entry : asConst(torrent->trackers())) {
|
||||
QString trackerURL = entry.url();
|
||||
QTreeWidgetItem *item = m_trackerItems.value(trackerURL, nullptr);
|
||||
if (!item) {
|
||||
@@ -384,7 +384,7 @@ void TrackerListWidget::loadTrackers()
|
||||
item->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
|
||||
}
|
||||
// Remove old trackers
|
||||
for (const QString &tracker : qAsConst(oldTrackerURLs))
|
||||
for (const QString &tracker : asConst(oldTrackerURLs))
|
||||
delete m_trackerItems.take(tracker);
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ void TrackerListWidget::askForTrackers()
|
||||
if (!torrent) return;
|
||||
|
||||
QList<BitTorrent::TrackerEntry> trackers;
|
||||
for (const QString &tracker : copyAsConst(TrackersAdditionDialog::askForTrackers(this, torrent)))
|
||||
for (const QString &tracker : asConst(TrackersAdditionDialog::askForTrackers(this, torrent)))
|
||||
trackers << tracker;
|
||||
|
||||
torrent->addTrackers(trackers);
|
||||
|
||||
@@ -60,7 +60,7 @@ TrackersAdditionDialog::~TrackersAdditionDialog()
|
||||
QStringList TrackersAdditionDialog::newTrackers() const
|
||||
{
|
||||
QStringList cleanTrackers;
|
||||
for (QString url : copyAsConst(m_ui->textEditTrackersList->toPlainText().split('\n'))) {
|
||||
for (QString url : asConst(m_ui->textEditTrackersList->toPlainText().split('\n'))) {
|
||||
url = url.trimmed();
|
||||
if (!url.isEmpty())
|
||||
cleanTrackers << url;
|
||||
|
||||
Reference in New Issue
Block a user