Commit 5cc58208 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some code to for(...:...)

parent ea5527b1
......@@ -302,8 +302,8 @@ void ContentTest::testEncodedContent()
"body\n";
msg->setContent(data);
QByteArray content = msg->encodedContent(true /* use CRLF */);
QStringList lines = QString::fromLatin1(content).split(QStringLiteral("\r\n"));
foreach (const QString &line, lines) {
const QStringList lines = QString::fromLatin1(content).split(QStringLiteral("\r\n"));
for (const QString &line : lines) {
QEXPECT_FAIL("", "KMime does not fold lines longer than 998 characters", Continue);
QVERIFY(line.length() < 998 && !line.isEmpty() && line != QLatin1String("body"));
// The test should be (after the expected failure disappears):
......
......@@ -208,7 +208,7 @@ QByteArray Content::assembleHeaders()
{
Q_D(Content);
QByteArray newHead;
foreach (const Headers::Base *h, d->headers) {
for (const Headers::Base *h : qAsConst(d->headers)) {
if (!h->isEmpty()) {
newHead += h->as7BitString() + '\n';
}
......@@ -621,7 +621,7 @@ Headers::Base *Content::headerByType(const char *type) const
{
Q_ASSERT(type && *type);
foreach (Headers::Base *h, d_ptr->headers) {
for (Headers::Base *h : qAsConst(d_ptr->headers)) {
if (h->is(type)) {
return h; // Found.
}
......@@ -636,7 +636,7 @@ QVector<Headers::Base*> Content::headersByType(const char *type) const
QVector<Headers::Base*> result;
foreach (Headers::Base *h, d_ptr->headers) {
for (Headers::Base *h : qAsConst(d_ptr->headers)) {
if (h->is(type)) {
result << h;
}
......
......@@ -98,7 +98,7 @@ QString KMime::ContentIndex::toString() const
{
QStringList l;
l.reserve(d->index.count());
foreach (unsigned int i, d->index) {
for (unsigned int i : qAsConst(d->index)) {
l.append(QString::number(i));
}
return l.join(QLatin1Char('.'));
......
......@@ -436,7 +436,7 @@ bool MailboxList::parse(const char *&scursor, const char *const send,
d->mailboxList.reserve(maybeAddressList.count());
// extract the mailboxes and complain if there are groups:
foreach (const auto &it, maybeAddressList) {
for (const auto &it : qAsConst(maybeAddressList)) {
if (!(it).displayName.isEmpty()) {
KMIME_WARN << "mailbox groups in header disallowing them! Name: \""
<< (it).displayName << "\""
......@@ -500,8 +500,9 @@ QByteArray AddressList::as7BitString(bool withHeaderType) const
if (withHeaderType) {
rv = typeIntro();
}
foreach (const Types::Address &addr, d->addressList) {
foreach (const Types::Mailbox &mbox, addr.mailboxList) {
for (const Types::Address &addr : qAsConst(d->addressList)) {
const auto mailBoxList = addr.mailboxList;
for (const Types::Mailbox &mbox : mailBoxList) {
rv += mbox.as7BitString(d->encCS);
rv += ", ";
}
......@@ -576,8 +577,9 @@ QStringList AddressList::displayNames() const
{
Q_D(const AddressList);
QStringList rv;
foreach (const Types::Address &addr, d->addressList) {
foreach (const Types::Mailbox &mbox, addr.mailboxList) {
for (const Types::Address &addr : qAsConst(d->addressList)) {
const auto mailboxList = addr.mailboxList;
for (const Types::Mailbox &mbox : mailboxList) {
if (mbox.hasName())
rv.append(mbox.name());
else
......@@ -952,7 +954,7 @@ QByteArray Ident::as7BitString(bool withHeaderType) const
if (withHeaderType) {
rv = typeIntro();
}
foreach (const Types::AddrSpec &addr, d->msgIdList) {
for (const Types::AddrSpec &addr : qAsConst(d->msgIdList)) {
if (!addr.isEmpty()) {
const QString asString = addr.asString();
rv += '<';
......
......@@ -225,7 +225,7 @@ QVector<KMime::Types::Mailbox> Mailbox::listFrom7BitString(const QByteArray& s)
}
res.reserve(maybeAddressList.size());
foreach (const auto &it, maybeAddressList) {
for (const auto &it : qAsConst(maybeAddressList)) {
res += (it).mailboxList;
}
return res;
......@@ -238,7 +238,7 @@ QString Mailbox::listToUnicodeString(const QVector<Mailbox>& mailboxes)
QStringList rv;
rv.reserve(mailboxes.count());
foreach (const Types::Mailbox &mbox, mailboxes) {
for (const Types::Mailbox &mbox : mailboxes) {
rv.append(mbox.prettyAddress());
}
return rv.join(QLatin1String(", "));
......
......@@ -55,7 +55,7 @@ bool u_seOutlookEncoding = false;
QByteArray cachedCharset(const QByteArray &name)
{
foreach (const QByteArray &charset, c_harsetCache) {
for (const QByteArray &charset : qAsConst(c_harsetCache)) {
if (qstricmp(name.data(), charset.data()) == 0) {
return charset;
}
......
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