Commit c5278fe4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port foreach

parent 24dffb04
Pipeline #48170 failed with stage
in 10 minutes and 20 seconds
......@@ -51,6 +51,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"libkimap5\")
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054F00)
add_definitions(-DQT_NO_EMIT)
add_definitions(-DQT_NO_FOREACH)
configure_package_config_file(
......
......@@ -88,7 +88,8 @@ private Q_SLOTS:
QCOMPARE(getMetadataJob->allMetaData(mailbox).size(), expectedAnnotations.size());
const QMap <QByteArray, QByteArray> &allMetaData = getMetadataJob->allMetaData();
QCOMPARE(allMetaData.size(), expectedAnnotations.size());
foreach (const QByteArray &entry, expectedAnnotations.keys()) {
const auto keys = expectedAnnotations.keys();
for (const QByteArray &entry : keys ) {
QCOMPARE(getMetadataJob->metaData(mailbox, entry), expectedAnnotations.value(entry));
QCOMPARE(getMetadataJob->metaData(entry), expectedAnnotations.value(entry));
QCOMPARE(allMetaData.value(entry), expectedAnnotations.value(entry));
......@@ -274,7 +275,8 @@ private Q_SLOTS:
qDebug() << getMetadataJob->allMetaData();
const QMap <QByteArray, QByteArray> &allMetaData = getMetadataJob->allMetaData();
QCOMPARE(allMetaData.size(), expectedAnnotations.size());
foreach (const QByteArray &e, expectedAnnotations.keys()) {
const auto keys = expectedAnnotations.keys();
for (const QByteArray &e : keys) {
QCOMPARE(getMetadataJob->metaData(e), expectedAnnotations.value(e));
QCOMPARE(allMetaData.value(e), expectedAnnotations.value(e));
}
......
......@@ -43,7 +43,8 @@ void testId()
KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989);
auto *job = new KIMAP::IdJob(&session);
foreach (const QByteArray &key, values.keys()) {
const auto keys = values.keys();
for (const QByteArray &key : keys) {
job->setField(key, values.value(key));
}
bool result = job->exec();
......
......@@ -173,7 +173,7 @@ bool FakeServer::isAllScenarioDone() const
{
QMutexLocker locker(&m_mutex);
foreach (const QList<QByteArray> &scenario, m_scenarios) {
for (const QList<QByteArray> &scenario : qAsConst(m_scenarios)) {
if (!scenario.isEmpty()) {
return false;
}
......
......@@ -93,7 +93,8 @@ private Q_SLOTS:
auto *setMetadataJob = new KIMAP::SetMetaDataJob(&session);
setMetadataJob->setServerCapability(KIMAP::MetaDataJobBase::Metadata);
setMetadataJob->setMailBox(mailbox);
foreach (const QByteArray &entry, annotations.keys()) {
const auto keys = annotations.keys();
for (const QByteArray &entry : keys) {
setMetadataJob->addMetaData(entry, annotations[entry]);
}
......@@ -138,7 +139,8 @@ private Q_SLOTS:
auto *setMetadataJob = new KIMAP::SetMetaDataJob(&session);
setMetadataJob->setServerCapability(KIMAP::MetaDataJobBase::Annotatemore);
setMetadataJob->setMailBox(mailbox);
foreach (const QByteArray &entry, annotations.keys()) {
const auto keys = annotations.keys();
for (const QByteArray &entry : keys) {
if (legacyMode) {
setMetadataJob->setEntry(entry);
setMetadataJob->addMetaData("value.shared", annotations[entry]);
......
......@@ -62,7 +62,8 @@ void GetMetaDataJob::doStart()
if (d->entries.size() > 1) {
parameters += '(';
}
Q_FOREACH (const QByteArray &entry, sort(d->entries)) {
const auto sortedEntries = sort(d->entries);
for (const QByteArray &entry : sortedEntries) {
parameters += '\"' + entry + "\" ";
}
if (d->entries.size() > 1) {
......@@ -73,7 +74,8 @@ void GetMetaDataJob::doStart()
if (d->attributes.size() > 1) {
parameters += '(';
}
Q_FOREACH (const QByteArray &attribute, sort(d->attributes)) {
const auto sortedAttributes = sort(d->attributes);
for (const QByteArray &attribute : sortedAttributes) {
parameters += '\"' + attribute + "\" ";
}
if (d->attributes.size() > 1) {
......@@ -101,7 +103,8 @@ void GetMetaDataJob::doStart()
if (d->entries.size() >= 1) {
parameters += '(';
Q_FOREACH (const QByteArray &entry, sort(d->entries)) {
const auto sortedEntries = sort(d->entries);
for (const QByteArray &entry : sortedEntries) {
parameters += entry + " ";
}
parameters[parameters.length() - 1 ] = ')';
......@@ -236,9 +239,11 @@ QMap<QByteArray, QByteArray> GetMetaDataJob::allMetaDataForMailbox(const QString
Q_D(const GetMetaDataJob);
const QMap<QByteArray, QMap<QByteArray, QByteArray> > &entries = d->metadata[mailbox];
QMap<QByteArray, QByteArray> map;
foreach (const QByteArray &entry, entries.keys()) {
const auto entriesKeys = entries.keys();
for (const QByteArray &entry : entriesKeys) {
const QMap<QByteArray, QByteArray> &values = entries[entry];
foreach (const QByteArray &attribute, values.keys()) {
const auto valuesKeys = values.keys();
for (const QByteArray &attribute : valuesKeys) {
map.insert(d->addPrefix(entry, attribute), values[attribute]);
}
}
......
......@@ -447,17 +447,20 @@ int main(int argc, char **argv)
qDebug() << "Contains empty namespace:" << namespaces->containsEmptyNamespace();
qDebug() << "Personal:";
foreach (MailBoxDescriptor ns, namespaces->personalNamespaces()) {
const auto personalNamespaces = namespaces->personalNamespaces();
for (MailBoxDescriptor ns : personalNamespaces) {
qDebug() << ns.separator << ns.name;
}
qDebug() << "User: ";
foreach (MailBoxDescriptor ns, namespaces->userNamespaces()) {
const auto userNamespaces = namespaces->userNamespaces();
for (MailBoxDescriptor ns : userNamespaces) {
qDebug() << ns.separator << ns.name;
}
qDebug() << "Shared: ";
foreach (MailBoxDescriptor ns, namespaces->sharedNamespaces()) {
const auto sharedNamespaces = namespaces->sharedNamespaces();
for (MailBoxDescriptor ns : sharedNamespaces) {
qDebug() << ns.separator << ns.name;
}
qDebug();
......@@ -502,7 +505,8 @@ int main(int argc, char **argv)
fetch->exec();
Q_ASSERT_X(fetch->error() == 0, "FetchJob", fetch->errorString().toLocal8Bit().constData());
Q_ASSERT(session.state() == Session::Selected);
foreach (qint64 id, messages.keys()) {
const auto messagesKey = messages.keys();
for (qint64 id : messagesKey) {
qDebug() << "* Message" << id << "(" << sizes[id] << "bytes )";
qDebug() << " From :" << messages[id]->from()->asUnicodeString();
qDebug() << " To :" << messages[id]->to()->asUnicodeString();
......@@ -529,7 +533,8 @@ int main(int argc, char **argv)
fetch->exec();
Q_ASSERT_X(fetch->error() == 0, "FetchJob", fetch->errorString().toLocal8Bit().constData());
Q_ASSERT(session.state() == Session::Selected);
foreach (qint64 id, flags.keys()) {
const auto flagsKey = flags.keys();
for (qint64 id : flagsKey) {
qDebug() << "* Message" << id << "flags:" << flags[id];
}
qDebug();
......@@ -570,10 +575,12 @@ int main(int argc, char **argv)
fetch->exec();
Q_ASSERT_X(fetch->error() == 0, "FetchJob", fetch->errorString().toLocal8Bit().constData());
Q_ASSERT(session.state() == Session::Selected);
foreach (qint64 id, allParts.keys()) {
const auto allkeys = allParts.keys();
for (qint64 id : allkeys) {
qDebug() << "* Message" << id << "parts headers";
MessageParts parts = allParts[id];
foreach (const QByteArray &partId, parts.keys()) {
const auto parsKeys = parts.keys();
for (const QByteArray &partId : parsKeys) {
qDebug() << " ** Part" << partId;
qDebug() << " Name :" << parts[partId]->contentType()->name();
qDebug() << " Mimetype :" << parts[partId]->contentType()->mimeType();
......@@ -597,9 +604,11 @@ int main(int argc, char **argv)
fetch->exec();
Q_ASSERT_X(fetch->error() == 0, "FetchJob", fetch->errorString().toLocal8Bit().constData());
Q_ASSERT(session.state() == Session::Selected);
foreach (int id, allParts.keys()) {
const auto allpartskeys = allParts.keys();
for (int id : allpartskeys) {
MessageParts parts = allParts[id];
foreach (const QByteArray &partId, parts.keys()) {
const auto partsKeys = parts.keys();
for (const QByteArray &partId : partsKeys) {
qDebug() << "* Message" << id << "part" << partId << "content:";
qDebug() << parts[partId]->body();
}
......
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