Commit 53e34da7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to for(...:...)

parent 22ba9df9
......@@ -142,7 +142,7 @@ QMimeData *AttachmentModel::mimeData(const QModelIndexList &indexes) const
{
qCDebug(MESSAGECOMPOSER_LOG);
QList<QUrl> urls;
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
if (index.column() != 0) {
// Avoid processing the same attachment more than once, since the entire
// row is selected.
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -90,7 +90,7 @@ void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement
message->removeHeader<KMime::Headers::Bcc>();
} else {
const auto mailboxes = KMime::Types::Mailbox::listFromUnicodeString(ident.bcc());
foreach (const KMime::Types::Mailbox &mailbox, mailboxes) {
for (const KMime::Types::Mailbox &mailbox : mailboxes) {
message->bcc()->addAddress(mailbox);
}
}
......@@ -99,7 +99,7 @@ void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement
message->removeHeader<KMime::Headers::Cc>();
} else {
const auto mailboxes = KMime::Types::Mailbox::listFromUnicodeString(ident.cc());
foreach (const KMime::Types::Mailbox &mailbox, mailboxes) {
for (const KMime::Types::Mailbox &mailbox : mailboxes) {
message->cc()->addAddress(mailbox);
}
}
......
......@@ -186,7 +186,7 @@ bool Utils::hasImage(const QByteArray &mimetype)
bool Utils::containsImage(const MessageCore::AttachmentPart::List &parts)
{
foreach (const MessageCore::AttachmentPart::Ptr &part, parts) {
for (const MessageCore::AttachmentPart::Ptr &part : parts) {
if (hasImage(part->mimeType())) {
return true;
}
......
......@@ -21,6 +21,7 @@
*/
#include "aliasesexpandjob.h"
#include "helper/helper_p.h"
#include "distributionlistexpandjob.h"
#include <Akonadi/Contact/ContactSearchJob>
......@@ -48,7 +49,7 @@ void AliasesExpandJob::start()
{
// At first we try to expand the recipient to a distribution list
// or nick name and save the results in a map for later lookup
foreach (const QString &recipient, mRecipients) {
for (const QString &recipient : qAsConst(mRecipients)) {
// speedup: assume aliases and list names don't contain '@'
if (recipient.isEmpty() || recipient.contains(QLatin1Char('@'))) {
......@@ -123,7 +124,7 @@ void AliasesExpandJob::slotNicknameExpansionDone(KJob *job)
const KContacts::Addressee::List contacts = searchJob->contacts();
const QString recipient = searchJob->property("recipient").toString();
foreach (const KContacts::Addressee &contact, contacts) {
for (const KContacts::Addressee &contact : contacts) {
if (contact.nickName().toLower() == recipient.toLower()) {
mNicknameExpansionResults.insert(recipient, contact.fullEmail());
break;
......@@ -138,7 +139,7 @@ void AliasesExpandJob::slotNicknameExpansionDone(KJob *job)
void AliasesExpandJob::finishExpansion()
{
foreach (const QString &recipient, mRecipients) {
for (const QString &recipient : qAsConst(mRecipients)) {
if (recipient.isEmpty()) {
continue;
}
......
......@@ -20,7 +20,7 @@
*/
#include "distributionlistdialog.h"
#include "helper/helper_p.h"
#include <AkonadiWidgets/collectiondialog.h>
#include <Akonadi/Contact/ContactGroupSearchJob>
#include <Akonadi/Contact/ContactSearchJob>
......@@ -208,7 +208,7 @@ void DistributionListDialog::slotDelayedSetRecipients(KJob *job)
item->setCheckState(0, Qt::Checked);
} else {
bool isFirst = true;
foreach (const Akonadi::Item &akItem, akItems) {
for (const Akonadi::Item &akItem : qAsConst(akItems)) {
if (akItem.hasPayload<KContacts::Addressee>()) {
const KContacts::Addressee contact = akItem.payload<KContacts::Addressee>();
......
......@@ -146,9 +146,9 @@ void RecipientsEditor::setRecipientString(const QVector< KMime::Types::Mailbox >
Recipient::List RecipientsEditor::recipients() const
{
QList<MultiplyingLineData::Ptr> dataList = allData();
const QList<MultiplyingLineData::Ptr> dataList = allData();
Recipient::List recList;
foreach (const MultiplyingLineData::Ptr &datum, dataList) {
for (const MultiplyingLineData::Ptr &datum : dataList) {
Recipient::Ptr rec = qSharedPointerDynamicCast<Recipient>(datum);
if (!rec) {
continue;
......
......@@ -166,7 +166,7 @@ void RecipientsPicker::pick(Recipient::Type type)
}
bool tooManyAddress = false;
foreach (const Akonadi::EmailAddressSelection &selection, selections) {
for (const Akonadi::EmailAddressSelection &selection : selections) {
Recipient recipient;
recipient.setType(type);
recipient.setEmail(selection.quotedEmail());
......
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