Commit 6d6b2f79 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach code

parent b837da43
......@@ -913,7 +913,8 @@ void MessageFactoryTest::test_multipartAlternative_data()
QTest::addColumn<QString>("expected");
QDir dir(QStringLiteral(MAIL_DATA_DIR));
foreach (const QString &file, dir.entryList(QStringList(QLatin1String("plain_message.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks)) {
const QStringList lst = dir.entryList(QStringList(QLatin1String("plain_message.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
for (const QString &file : lst) {
QTest::newRow(file.toLatin1().constData()) << QString(dir.path() + QLatin1Char('/') + file) << 0 << ""
<<"> This *is* the *message* text *from* Sudhendu Kumar<dontspamme@yoohoo.com>\n"
"> \n"
......
......@@ -375,7 +375,7 @@ void RichTextComposerNg::insertSignature(const KIdentityManagement::Signature &s
// We added the text of the signature above, now it is time to add the images as well.
if (signature.isInlinedHtml()) {
foreach (const KIdentityManagement::Signature::EmbeddedImagePtr &image, signature.embeddedImages()) {
for (const KIdentityManagement::Signature::EmbeddedImagePtr &image : signature.embeddedImages()) {
composerControler()->composerImages()->loadImage(image->image, image->name, image->name);
}
}
......
......@@ -166,7 +166,7 @@ QString RecipientsEditor::recipientString(Recipient::Type type) const
QStringList RecipientsEditor::recipientStringList(Recipient::Type type) const
{
QStringList selectedRecipients;
foreach (const Recipient::Ptr &r, recipients()) {
for (const Recipient::Ptr &r : recipients()) {
if (r->type() == type) {
selectedRecipients << r->email();
}
......
......@@ -138,7 +138,7 @@ void GrantleeHeaderFormatterTest::testBlock_data()
QDir dir(QStringLiteral(HEADER_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.tmpl")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
if (!QFile::exists(dir.path() + QLatin1Char('/') + file + QStringLiteral(".html"))) {
continue;
}
......
......@@ -154,7 +154,7 @@ void GrantleeHeaderStyleTest::testRenderHeader_data()
QDir dir(QStringLiteral(HEADER_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
if (!QFile::exists(dir.path() + QLatin1Char('/') + file + QStringLiteral(".html"))) {
continue;
}
......
......@@ -51,7 +51,7 @@ void RenderTest::testRenderSmart_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
if (!QFile::exists(dir.path() + QLatin1Char('/') + file + QStringLiteral(".html"))) {
continue;
}
......@@ -79,7 +79,7 @@ void RenderTest::testRenderSmartAsync_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
if (!QFile::exists(dir.path() + QLatin1Char('/') + file
+ QStringLiteral(".inProgress.html"))) {
continue;
......@@ -111,7 +111,7 @@ void RenderTest::testRenderSmartDetails_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
QString fname = dir.path() + QStringLiteral("/details/") + file + QStringLiteral(".html");
if (!QFile::exists(fname)) {
continue;
......@@ -138,7 +138,7 @@ void RenderTest::testRenderInlined_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
QString fname = dir.path() + QStringLiteral("/inlined/") + file + QStringLiteral(".html");
if (!QFile::exists(fname)) {
fname = dir.path() + QStringLiteral("/") + file + QStringLiteral(".html");
......@@ -169,7 +169,7 @@ void RenderTest::testRenderIconic_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
QString fname = dir.path() + QStringLiteral("/iconic/") + file + QStringLiteral(".html");
if (!QFile::exists(fname)) {
fname = dir.path() + QStringLiteral("/") + file + QStringLiteral(".html");
......@@ -200,7 +200,7 @@ void RenderTest::testRenderHidden_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
QString fname = dir.path() + QStringLiteral("/hidden/") + file + QStringLiteral(".html");
if (!QFile::exists(fname)) {
fname = dir.path() + QStringLiteral("/") + file + QStringLiteral(".html");
......@@ -231,7 +231,7 @@ void RenderTest::testRenderHeaderOnly_data()
QDir dir(QStringLiteral(MAIL_DATA_DIR));
const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks);
foreach (const QString &file, l) {
for (const QString &file : l) {
QString fname = dir.path() + QStringLiteral("/headeronly/") + file
+ QStringLiteral(".html");
if (!QFile::exists(fname)) {
......
......@@ -340,7 +340,7 @@ Interface::ObjectTreeSource *DefaultRendererPrivate::source() const
void DefaultRendererPrivate::renderSubParts(const MessagePart::Ptr &msgPart, HtmlWriter *htmlWriter)
{
foreach (const auto &m, msgPart->subParts()) {
for (const auto &m : msgPart->subParts()) {
renderFactory(m, htmlWriter);
}
}
......@@ -792,7 +792,7 @@ void DefaultRendererPrivate::render(const AlternativeMessagePart::Ptr &mp, HtmlW
auto mode = mp->preferredMode();
if (mode == MimeTreeParser::Util::MultipartPlain && mp->text().trimmed().isEmpty()) {
foreach (const auto m, mp->availableModes()) {
for (const auto m : mp->availableModes()) {
if (m != MimeTreeParser::Util::MultipartPlain) {
mode = m;
break;
......@@ -1144,13 +1144,11 @@ void DefaultRenderer::setCreateMessageHeader(std::function<QString(KMime::Messag
QString renderTreeHelper(const MimeTreeParser::MessagePart::Ptr &messagePart, QString indent)
{
const QString line
QString ret
= QStringLiteral("%1 * %3\n").arg(indent,
QString::fromUtf8(messagePart->metaObject()->className()));
QString ret = line;
indent += QLatin1Char(' ');
foreach (const auto &subPart, messagePart->subParts()) {
for (const auto &subPart : messagePart->subParts()) {
ret += renderTreeHelper(subPart, indent);
}
return ret;
......
......@@ -130,7 +130,7 @@ void MessagePartRendererManager::initializeRenderer()
Grantlee::registerMetaType<const QGpgME::Protocol *>();
Grantlee::registerMetaType<std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key> >();
m_engine = new GrantleeTheme::Engine;
foreach (const auto &p, QCoreApplication::libraryPaths()) {
for (const auto &p : QCoreApplication::libraryPaths()) {
m_engine->addPluginPath(p + QStringLiteral("/messageviewer"));
}
m_engine->addDefaultLibrary(QStringLiteral("messageviewer_grantlee_extension"));
......
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