mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-08 06:00:59 -07:00
Convert all foreach() to range-based for()
This commit is contained in:
parent
d668a4fe6d
commit
6b1d26d555
64 changed files with 326 additions and 292 deletions
|
@ -41,6 +41,7 @@
|
|||
#include <QString>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/rss/rss_article.h"
|
||||
|
@ -186,7 +187,7 @@ void RSSWidget::displayItemsListMenu(const QPoint &)
|
|||
{
|
||||
bool hasTorrent = false;
|
||||
bool hasLink = false;
|
||||
foreach (const QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
||||
for (const QListWidgetItem *item : copyAsConst(m_articleListWidget->selectedItems())) {
|
||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||
Q_ASSERT(article);
|
||||
|
||||
|
@ -286,7 +287,7 @@ void RSSWidget::on_newFeedButton_clicked()
|
|||
|
||||
void RSSWidget::deleteSelectedItems()
|
||||
{
|
||||
QList<QTreeWidgetItem *> selectedItems = m_feedListWidget->selectedItems();
|
||||
const QList<QTreeWidgetItem *> selectedItems = m_feedListWidget->selectedItems();
|
||||
if (selectedItems.isEmpty())
|
||||
return;
|
||||
if ((selectedItems.size() == 1) && (selectedItems.first() == m_feedListWidget->stickyUnreadItem()))
|
||||
|
@ -298,7 +299,7 @@ void RSSWidget::deleteSelectedItems()
|
|||
if (answer == QMessageBox::No)
|
||||
return;
|
||||
|
||||
foreach (QTreeWidgetItem *item, selectedItems)
|
||||
for (QTreeWidgetItem *item : selectedItems)
|
||||
if (item != m_feedListWidget->stickyUnreadItem())
|
||||
RSS::Session::instance()->removeItem(m_feedListWidget->itemPath(item));
|
||||
}
|
||||
|
@ -306,9 +307,9 @@ void RSSWidget::deleteSelectedItems()
|
|||
void RSSWidget::loadFoldersOpenState()
|
||||
{
|
||||
const QStringList openedFolders = Preferences::instance()->getRssOpenFolders();
|
||||
foreach (const QString &varPath, openedFolders) {
|
||||
for (const QString &varPath : openedFolders) {
|
||||
QTreeWidgetItem *parent = nullptr;
|
||||
foreach (const QString &name, varPath.split('\\')) {
|
||||
for (const QString &name : copyAsConst(varPath.split('\\'))) {
|
||||
int nbChildren = (parent ? parent->childCount() : m_feedListWidget->topLevelItemCount());
|
||||
for (int i = 0; i < nbChildren; ++i) {
|
||||
QTreeWidgetItem *child = (parent ? parent->child(i) : m_feedListWidget->topLevelItem(i));
|
||||
|
@ -325,7 +326,7 @@ void RSSWidget::loadFoldersOpenState()
|
|||
void RSSWidget::saveFoldersOpenState()
|
||||
{
|
||||
QStringList openedFolders;
|
||||
foreach (QTreeWidgetItem *item, m_feedListWidget->getAllOpenedFolders())
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_feedListWidget->getAllOpenedFolders()))
|
||||
openedFolders << m_feedListWidget->itemPath(item);
|
||||
Preferences::instance()->setRssOpenFolders(openedFolders);
|
||||
}
|
||||
|
@ -337,7 +338,7 @@ void RSSWidget::refreshAllFeeds()
|
|||
|
||||
void RSSWidget::downloadSelectedTorrents()
|
||||
{
|
||||
foreach (QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
||||
for (QListWidgetItem *item : copyAsConst(m_articleListWidget->selectedItems())) {
|
||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||
Q_ASSERT(article);
|
||||
|
||||
|
@ -356,7 +357,7 @@ void RSSWidget::downloadSelectedTorrents()
|
|||
// open the url of the selected RSS articles in the Web browser
|
||||
void RSSWidget::openSelectedArticlesUrls()
|
||||
{
|
||||
foreach (QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
||||
for (QListWidgetItem *item : copyAsConst(m_articleListWidget->selectedItems())) {
|
||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||
Q_ASSERT(article);
|
||||
|
||||
|
@ -397,7 +398,7 @@ void RSSWidget::renameSelectedRSSItem()
|
|||
|
||||
void RSSWidget::refreshSelectedItems()
|
||||
{
|
||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_feedListWidget->selectedItems())) {
|
||||
if (item == m_feedListWidget->stickyUnreadItem()) {
|
||||
refreshAllFeeds();
|
||||
return;
|
||||
|
@ -410,7 +411,7 @@ void RSSWidget::refreshSelectedItems()
|
|||
void RSSWidget::copySelectedFeedsURL()
|
||||
{
|
||||
QStringList URLs;
|
||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_feedListWidget->selectedItems())) {
|
||||
if (auto feed = qobject_cast<RSS::Feed *>(m_feedListWidget->getRSSItem(item)))
|
||||
URLs << feed->url();
|
||||
}
|
||||
|
@ -425,7 +426,7 @@ void RSSWidget::handleCurrentFeedItemChanged(QTreeWidgetItem *currentItem)
|
|||
|
||||
void RSSWidget::on_markReadButton_clicked()
|
||||
{
|
||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_feedListWidget->selectedItems())) {
|
||||
m_feedListWidget->getRSSItem(item)->markAsRead();
|
||||
if (item == m_feedListWidget->stickyUnreadItem())
|
||||
break; // all items was read
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue