Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a0ffb572 authored by Laurent Montel's avatar Laurent Montel 😁

Remove foreach

parent 61e50c2f
......@@ -82,7 +82,7 @@ void CreateTripWidget::tripSelected(const Akonadi::Item &item)
void addTrip(QVariantList *list, Item::Id newId)
{
bool found = false;
foreach (const QVariant &id, *list) {
for (const QVariant &id : qAsConst(*list)) {
if (id.toLongLong() == newId) {
found = true;
}
......
......@@ -80,7 +80,8 @@ static QModelIndexList selectedRows(const QItemSelection &selection, int column
{
QModelIndexList list;
foreach (const QModelIndex &idx, selection.indexes()) {
const auto listSelection = selection.indexes();
for (const QModelIndex &idx : listSelection) {
if (idx.column() == column) {
list << idx;
}
......
......@@ -49,7 +49,8 @@ void TodoCheckableProxyModel::selectionChanged(const QItemSelection &selected, c
void TodoCheckableProxyModel::setChecked(const QItemSelection &selection, bool checked)
{
foreach (const QModelIndex &index, selection.indexes()) {
const auto listSelection = selection.indexes();
for (const QModelIndex &index : listSelection) {
if (index.column() == 0) {
Item item = sourceModel()->data(index, Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (!item.hasPayload<KCalCore::Todo::Ptr>()) {
......
......@@ -65,7 +65,8 @@ void CollectionMonitoredWidget::selectionChanged(const QItemSelection &selected,
return;
}
foreach (const Akonadi::Collection &oldCol, m_oneCollectionChangeRecorder->collectionsMonitored()) {
const auto listCol = m_oneCollectionChangeRecorder->collectionsMonitored();
for (const Akonadi::Collection &oldCol : listCol) {
m_oneCollectionChangeRecorder->setCollectionMonitored(oldCol, false);
}
m_oneCollectionChangeRecorder->setCollectionMonitored(col, true);
......
......@@ -90,7 +90,8 @@ void EntityTreeWidget::mimeTypesChanged(const QString &mimetypeList)
{
const QStringList list = mimetypeList.isEmpty() ? QStringList() : mimetypeList.split(QStringLiteral(","));
foreach (const QString mimetype, m_monitor->mimeTypesMonitored()) {
const auto listMimetypes = m_monitor->mimeTypesMonitored();
for (const QString mimetype : listMimetypes) {
if (!list.contains(mimetype)) {
m_monitor->setMimeTypeMonitored(mimetype, false);
}
......
......@@ -112,7 +112,7 @@ void AdblockManager::loadSubscriptions()
mCustomList = new AdBlockCustomList(this);
mSubscriptions.append(mCustomList);
// Load all subscriptions
foreach (AdBlockSubscription *subscription, mSubscriptions) {
for (AdBlockSubscription *subscription : qAsConst(mSubscriptions)) {
subscription->loadSubscription(mDisabledRules);
connect(subscription, &AdBlockSubscription::subscriptionChanged, this, &AdblockManager::updateMatcher);
}
......@@ -129,7 +129,8 @@ void AdblockManager::save()
KConfig config(QStringLiteral("AdBlockadblockrc"));
KConfigGroup general = config.group(QStringLiteral("General"));
general.writeEntry(QStringLiteral("disabledRules"), mDisabledRules);
foreach (AdBlockSubscription *subscription, mSubscriptions) {
for (AdBlockSubscription *subscription : qAsConst(mSubscriptions)) {
subscription->saveSubscription();
}
}
......@@ -188,7 +189,7 @@ QList<AdBlockSubscription *> AdblockManager::subscriptions() const
void AdblockManager::updateAllSubscriptions()
{
foreach (AdBlockSubscription *subscription, mSubscriptions) {
for (AdBlockSubscription *subscription : qAsConst(mSubscriptions)) {
subscription->updateSubscription();
}
......
......@@ -294,26 +294,26 @@ bool AdBlockRule::matchDomain(const QString &domain) const
}
if (m_blockedDomains.isEmpty()) {
foreach (const QString &d, m_allowedDomains) {
for (const QString &d : qAsConst(m_allowedDomains)) {
if (isMatchingDomain(domain, d)) {
return true;
}
}
} else if (m_allowedDomains.isEmpty()) {
foreach (const QString &d, m_blockedDomains) {
for (const QString &d : qAsConst(m_blockedDomains)) {
if (isMatchingDomain(domain, d)) {
return false;
}
}
return true;
} else {
foreach (const QString &d, m_blockedDomains) {
for (const QString &d : qAsConst(m_blockedDomains)) {
if (isMatchingDomain(domain, d)) {
return false;
}
}
foreach (const QString &d, m_allowedDomains) {
for (const QString &d : qAsConst(m_allowedDomains)) {
if (isMatchingDomain(domain, d)) {
return true;
}
......
......@@ -367,7 +367,7 @@ void AdBlockCustomList::saveSubscription()
textStream << "Url: " << url().toString() << endl;
textStream << "[Adblock Plus 1.1.1]" << endl;
foreach (const AdBlockRule *rule, mRules) {
for (const AdBlockRule *rule : qAsConst(mRules)) {
textStream << rule->filter() << endl;
}
......@@ -386,7 +386,7 @@ bool AdBlockCustomList::canBeRemoved() const
bool AdBlockCustomList::containsFilter(const QString &filter) const
{
foreach (const AdBlockRule *rule, mRules) {
for (const AdBlockRule *rule : qAsConst(mRules)) {
if (rule->filter() == filter) {
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment