Commit 54e63a49 authored by Laurent Montel's avatar Laurent Montel 😁

Port Q_FOREACH to for(... : )

parent 9827f225
......@@ -886,7 +886,7 @@ void AttachmentControllerBase::showAttachVcard()
dlg->view()->view()->setSelectionMode(QAbstractItemView::MultiSelection);
if (dlg->exec()) {
const Akonadi::EmailAddressSelection::List selectedEmail = dlg->selectedAddresses();
Q_FOREACH (const Akonadi::EmailAddressSelection &selected, selectedEmail) {
for (const Akonadi::EmailAddressSelection &selected : selectedEmail) {
MessageComposer::AttachmentVcardFromAddressBookJob *ajob = new MessageComposer::AttachmentVcardFromAddressBookJob(selected.item(), this);
connect(ajob, SIGNAL(result(KJob*)), this, SLOT(attachVcardFromAddressBook(KJob*)));
ajob->start();
......
......@@ -32,7 +32,7 @@ bool Utils::resizeImage(MessageCore::AttachmentPart::Ptr part)
if (!pattern.isEmpty()) {
//TODO use regexp ?
const QStringList lstPattern = pattern.split(QLatin1Char(';'));
Q_FOREACH (const QString &patternStr, lstPattern) {
for (const QString &patternStr : lstPattern) {
switch (MessageComposer::MessageComposerSettings::self()->filterSourceType()) {
case MessageComposer::MessageComposerSettings::EnumFilterSourceType::NoFilter:
break;
......@@ -55,7 +55,7 @@ bool Utils::resizeImage(MessageCore::AttachmentPart::Ptr part)
if (!formatsType.isEmpty()) {
const QStringList lstFormat = formatsType.split(QLatin1Char(';'));
bool willResizeImage = false;
Q_FOREACH (const QString &type, lstFormat) {
for (const QString &type : lstFormat) {
if (QString::fromLatin1(part->mimeType()) == type) {
willResizeImage = true;
break;
......@@ -133,7 +133,7 @@ bool Utils::filterRecipients(const QStringList &recipients)
if (resizeEmailsPattern.isEmpty()) {
return false;
}
Q_FOREACH (const QString &emails, recipients) {
for (const QString &emails : recipients) {
if (!emails.contains(resizeEmailsPattern)) {
return false;
}
......@@ -143,7 +143,7 @@ bool Utils::filterRecipients(const QStringList &recipients)
if (resizeEmailsPattern.isEmpty()) {
return false;
}
Q_FOREACH (const QString &emails, recipients) {
for (const QString &emails : recipients) {
if (emails.contains(resizeEmailsPattern)) {
return true;
}
......@@ -153,7 +153,7 @@ bool Utils::filterRecipients(const QStringList &recipients)
if (doNotResizeEmailsPattern.isEmpty()) {
return false;
}
Q_FOREACH (const QString &emails, recipients) {
for (const QString &emails : recipients) {
if (!emails.contains(doNotResizeEmailsPattern)) {
return false;
}
......@@ -163,7 +163,7 @@ bool Utils::filterRecipients(const QStringList &recipients)
if (doNotResizeEmailsPattern.isEmpty()) {
return false;
}
Q_FOREACH (const QString &emails, recipients) {
for (const QString &emails : recipients) {
if (emails.contains(doNotResizeEmailsPattern)) {
return true;
}
......
......@@ -169,9 +169,8 @@ void ImageScalingWidget::slotComboboxChanged(int index)
void ImageScalingWidget::initComboBox(KComboBox *combo)
{
QList<int> size;
size << 240 << 320 << 512 << 640 << 800 << 1024 << 1600 << 2048;
Q_FOREACH (int val, size) {
const QList<int> size = { 240, 320, 512, 640, 800, 1024, 1600, 2048 };
for (int val : size) {
combo->addItem(QString::number(val), val);
}
combo->addItem(i18n("Custom"), -1);
......
......@@ -89,11 +89,11 @@ bool MessageCore::Util::getLinkInformation(const KMime::Message::Ptr &msg, QList
return false;
}
Q_FOREACH (const QString &idStr, messages) {
for (const QString &idStr : messages) {
id << idStr.toLongLong();
}
Q_FOREACH (const QString &typeStr, types) {
for (const QString &typeStr : types) {
if (typeStr == QLatin1String("reply")) {
status << Akonadi::MessageStatus::statusReplied();
} else if (typeStr == QLatin1String("forward")) {
......
......@@ -567,7 +567,7 @@ QString MessageItem::accessibleText(const Theme *theme, int columnIndex)
const QList<Theme::Row *> rows = theme->column(columnIndex)->messageRows();
rowsTexts.reserve(rows.count());
Q_FOREACH (Theme::Row *row, rows) {
for (Theme::Row *row : rows) {
QStringList leftStrings;
QStringList rightStrings;
const QList<Theme::ContentItem *> leftItems = row->leftItems();
......
......@@ -45,7 +45,7 @@ void QuickSearchWarning::setSearchText(const QString &text)
if (!MessageList::MessageListSettings::quickSearchWarningDoNotShowAgain()) {
const QStringList lstText = text.split(QLatin1Char(' '), QString::SkipEmptyParts);
bool foundLessThanThreeCharacters = false;
Q_FOREACH (const QString &text, lstText) {
for (const QString &text : lstText) {
if (text.trimmed().size() < 3) {
foundLessThanThreeCharacters = true;
break;
......
......@@ -393,13 +393,13 @@ void ConfigureAggregationsDialog::Private::cloneAggregationButtonClicked()
void ConfigureAggregationsDialog::Private::deleteAggregationButtonClicked()
{
QList<QListWidgetItem *> list = mAggregationList->selectedItems();
const QList<QListWidgetItem *> list = mAggregationList->selectedItems();
if (list.isEmpty()) {
return;
}
mEditor->editAggregation(Q_NULLPTR); // forget it
Q_FOREACH (QListWidgetItem *it, list) {
for (QListWidgetItem *it : list) {
AggregationListWidgetItem *item = dynamic_cast< AggregationListWidgetItem * >(it);
if (!item) {
return;
......@@ -447,7 +447,7 @@ void ConfigureAggregationsDialog::Private::importAggregationButtonClicked()
void ConfigureAggregationsDialog::Private::exportAggregationButtonClicked()
{
QList<QListWidgetItem *> list = mAggregationList->selectedItems();
const QList<QListWidgetItem *> list = mAggregationList->selectedItems();
if (list.isEmpty()) {
return;
}
......@@ -459,7 +459,7 @@ void ConfigureAggregationsDialog::Private::exportAggregationButtonClicked()
grp.writeEntry("Count", list.count());
int idx = 0;
Q_FOREACH (QListWidgetItem *item, list) {
for (QListWidgetItem *item : list) {
AggregationListWidgetItem *themeItem = static_cast< AggregationListWidgetItem * >(item);
grp.writeEntry(QStringLiteral("Set%1").arg(idx), themeItem->aggregation()->saveToString());
++idx;
......
......@@ -397,14 +397,14 @@ void ConfigureThemesDialog::Private::cloneThemeButtonClicked()
void ConfigureThemesDialog::Private::deleteThemeButtonClicked()
{
QList<QListWidgetItem *> list = mThemeList->selectedItems();
const QList<QListWidgetItem *> list = mThemeList->selectedItems();
if (list.isEmpty()) {
return;
}
if (KMessageBox::Yes == KMessageBox::questionYesNo(q, list.count() > 1 ? i18n("Do you want to delete selected themes?")
: i18n("Do you want to delete \"%1\"?", list.first()->text()), i18nc("@title:window", "Delete Theme"))) {
mEditor->editTheme(Q_NULLPTR); // forget it
Q_FOREACH (QListWidgetItem *it, list) {
for (QListWidgetItem *it : list) {
ThemeListWidgetItem *item = dynamic_cast< ThemeListWidgetItem * >(it);
if (!item) {
return;
......@@ -457,7 +457,7 @@ void ConfigureThemesDialog::Private::importThemeButtonClicked()
void ConfigureThemesDialog::Private::exportThemeButtonClicked()
{
QList<QListWidgetItem *> list = mThemeList->selectedItems();
const QList<QListWidgetItem *> list = mThemeList->selectedItems();
if (list.isEmpty()) {
return;
}
......@@ -469,7 +469,7 @@ void ConfigureThemesDialog::Private::exportThemeButtonClicked()
grp.writeEntry("Count", list.count());
int idx = 0;
Q_FOREACH (QListWidgetItem *item, list) {
for (QListWidgetItem *item : list) {
ThemeListWidgetItem *themeItem = static_cast< ThemeListWidgetItem * >(item);
grp.writeEntry(QStringLiteral("Set%1").arg(idx), themeItem->theme()->saveToString());
++idx;
......
......@@ -472,7 +472,7 @@ void Widget::viewStartDragRequest()
return; // no folder here
}
QList<Core::MessageItem *> selection = view()->selectionAsMessageItemList();
const QList<Core::MessageItem *> selection = view()->selectionAsMessageItemList();
if (selection.isEmpty()) {
return;
}
......@@ -490,7 +490,7 @@ void Widget::viewStartDragRequest()
QList<QUrl> urls;
urls.reserve(selection.count());
Q_FOREACH (Core::MessageItem *mi, selection) {
for (Core::MessageItem *mi : selection) {
const Item i = d->itemForRow(mi->currentModelIndexRow());
QUrl url = i.url(Item::Item::Item::UrlWithMimeType);
url.addQueryItem(QStringLiteral("parent"), QString::number(mi->parentCollectionId()));
......
......@@ -145,7 +145,7 @@ bool ContactDisplayMessageMemento::allowToRemoteContent() const
bool ContactDisplayMessageMemento::searchPhoto(const KContacts::AddresseeList &list)
{
bool foundPhoto = false;
Q_FOREACH (const KContacts::Addressee &addressee, list) {
for (const KContacts::Addressee &addressee : list) {
if (!addressee.photo().isEmpty()) {
mPhoto = addressee.photo();
foundPhoto = true;
......@@ -168,7 +168,7 @@ QPixmap ContactDisplayMessageMemento::gravatarPixmap() const
void ContactDisplayMessageMemento::processAddress(const KContacts::Addressee &addressee)
{
const QStringList customs = addressee.customs();
Q_FOREACH (const QString &custom, customs) {
for (const QString &custom : customs) {
if (custom.contains(QStringLiteral("MailPreferedFormatting"))) {
const QString value = addressee.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("MailPreferedFormatting"));
if (value == QLatin1String("TEXT")) {
......
......@@ -132,7 +132,7 @@ void HeaderStyleMenuManagerPrivate::initialize(KActionCollection *ac)
group = new QActionGroup(q);
const QVector<MessageViewer::HeaderStylePlugin *> lstPlugin = MessageViewer::HeaderStylePluginManager::self()->pluginsList();
Q_FOREACH (MessageViewer::HeaderStylePlugin *plugin, lstPlugin) {
for (MessageViewer::HeaderStylePlugin *plugin : lstPlugin) {
if (plugin->isEnabled()) {
MessageViewer::HeaderStyleInterface *interface = plugin->createView(headerMenu, group, ac, q);
lstInterface.insert(plugin->name(), interface);
......
......@@ -109,7 +109,7 @@ void ScamDetectionWebEngine::handleScanPage(const QVariant &result)
QRegularExpression ip4regExp(QStringLiteral("\\b[0-9]{1,3}\\.[0-9]{1,3}(?:\\.[0-9]{0,3})?(?:\\.[0-9]{0,3})?"));
const QVariantMap mapResult = resultList.at(0).toMap();
const QList<QVariant> lst = mapResult.value(QStringLiteral("anchors")).toList();
Q_FOREACH (const QVariant &var, lst) {
for (const QVariant &var : lst) {
QMap<QString, QVariant> mapVariant = var.toMap();
//qDebug()<<" mapVariant"<<mapVariant;
......
......@@ -36,16 +36,16 @@ void TemplatesSyntaxHighlighterRules::init()
const QStringList keywords = QStringList() << Util::keywords();
Q_FOREACH (const QString &s, keywords) {
for (const QString &s : keywords) {
const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption);
mRules.append(KPIMTextEdit::Rule(regex, keywordFormat));
}
QTextCharFormat keywordWithArgsFormat;
keywordWithArgsFormat.setForeground(palette.link());
const QStringList keywordsWithArgs = QStringList() << Util::keywordsWithArgsForCompleter();
const QStringList keywordsWithArgs = Util::keywordsWithArgsForCompleter();
Q_FOREACH (const QString &s, keywordsWithArgs) {
for (const QString &s : keywordsWithArgs) {
const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption);
mRules.append(KPIMTextEdit::Rule(regex, keywordWithArgsFormat));
}
......
......@@ -56,7 +56,7 @@ void CreateDatabaseFileJobPrivate::createFileFromFullUpdate(const QVector<Additi
//2 add number of items
QList<Addition> itemToStore;
Q_FOREACH (const Addition &add, additionList) {
for (const Addition &add : additionList) {
switch (add.compressionType) {
case UpdateDataBaseInfo::RawCompression: {
//qCWarning(WEBENGINEVIEWER_LOG) << " add.size" << add.prefixSize;
......
......@@ -218,7 +218,7 @@ RiceDeltaEncoding CreatePhishingUrlDataBaseJobPrivate::parseRiceDeltaEncoding(co
QVector<Addition> CreatePhishingUrlDataBaseJobPrivate::parseAdditions(const QVariantList &lst)
{
QVector<Addition> additionList;
Q_FOREACH (const QVariant &v, lst) {
for (const QVariant &v : lst) {
if (v.canConvert<QVariantMap>()) {
QMapIterator<QString, QVariant> mapIt(v.toMap());
Addition tmp;
......@@ -277,7 +277,7 @@ UpdateDataBaseInfo::CompressionType CreatePhishingUrlDataBaseJobPrivate::parseCo
QVector<Removal> CreatePhishingUrlDataBaseJobPrivate::parseRemovals(const QVariantList &lst)
{
QVector<Removal> removalList;
Q_FOREACH (const QVariant &v, lst) {
for (const QVariant &v : lst) {
if (v.canConvert<QVariantMap>()) {
Removal tmp;
QMapIterator<QString, QVariant> mapIt(v.toMap());
......@@ -299,7 +299,7 @@ QVector<Removal> CreatePhishingUrlDataBaseJobPrivate::parseRemovals(const QVaria
if (rawIndicesIt.key() == QStringLiteral("indices")) {
const QVariantList lst = rawIndicesIt.value().toList();
QList<quint32> indexList;
Q_FOREACH (const QVariant &var, lst) {
for (const QVariant &var : lst) {
indexList.append(var.toUInt());
}
tmp.indexes = indexList;
......
......@@ -153,8 +153,8 @@ void SearchFullHashJob::parse(const QByteArray &replyStr)
bool SearchFullHashJobPrivate::foundExactHash(const QList<QByteArray> &listLongHash)
{
QList<QByteArray> lstLongHash = mHashs.keys();
Q_FOREACH (const QByteArray &ba, lstLongHash) {
const QList<QByteArray> lstLongHash = mHashs.keys();
for (const QByteArray &ba : lstLongHash) {
if (listLongHash.contains(ba)) {
return true;
}
......
......@@ -141,8 +141,8 @@ QHash<QByteArray, QByteArray> UrlHashing::hashList() const
const QStringList hosts = WebEngineViewer::UrlHashing::generateHostsToCheck(url.host());
const QStringList paths = WebEngineViewer::UrlHashing::generatePathsToCheck(url.path(), url.query());
Q_FOREACH (const QString &host, hosts) {
Q_FOREACH (const QString &path, paths) {
for (const QString &host : hosts) {
for (const QString &path : paths) {
const QString str = host + path;
QByteArray ba = QCryptographicHash::hash(str.toLatin1(), QCryptographicHash::Sha256);
QByteArray baShort = ba;
......
......@@ -66,7 +66,7 @@ void TestWebEngineAccessKey::handleSearchAccessKey(const QVariant &var)
const QVariantList lst = var.toList();
QVector<WebEngineViewer::WebEngineAccessKeyAnchor> anchorList;
anchorList.reserve(lst.count());
Q_FOREACH (const QVariant &anchor, lst) {
for (const QVariant &anchor : lst) {
anchorList << WebEngineViewer::WebEngineAccessKeyAnchor(anchor);
}
Q_EMIT accessKeySearchFinished(anchorList);
......
......@@ -265,7 +265,7 @@ void WebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
const QVariantList lst = res.toList();
QVector<WebEngineViewer::WebEngineAccessKeyAnchor> anchorList;
anchorList.reserve(lst.count());
Q_FOREACH (const QVariant &var, lst) {
for (const QVariant &var : lst) {
//qDebug()<<" var"<<var;
anchorList << WebEngineViewer::WebEngineAccessKeyAnchor(var);
}
......
......@@ -41,11 +41,11 @@ void WebEngineManageScript::addScript(QWebEngineProfile *profile, const QString
{
if (profile) {
QWebEngineScript script;
QList<QWebEngineScript> collectionScripts = profile->scripts()->findScripts(scriptName);
const QList<QWebEngineScript> collectionScripts = profile->scripts()->findScripts(scriptName);
if (!collectionScripts.isEmpty()) {
script = collectionScripts.first();
}
Q_FOREACH (const QWebEngineScript &s, collectionScripts) {
for (const QWebEngineScript &s : collectionScripts) {
profile->scripts()->remove(s);
}
......
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