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

Minor optimization. Port to for(...:...)

parent bb9894af
......@@ -68,7 +68,7 @@ AccountConfigOrderDialog::AccountConfigOrderDialog(QWidget *parent)
d(new MailCommon::AccountConfigOrderDialogPrivate)
{
setWindowTitle(i18n("Edit Accounts Order"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
......@@ -84,7 +84,7 @@ AccountConfigOrderDialog::AccountConfigOrderDialog(QWidget *parent)
vbox->setMargin(0);
page->setLayout(vbox);
d->mEnableAccountOrder = new QCheckBox(i18n("Use custom order"));
d->mEnableAccountOrder = new QCheckBox(i18n("Use custom order"), this);
connect(d->mEnableAccountOrder, &QCheckBox::clicked, this, &AccountConfigOrderDialog::slotEnableAccountOrder);
vbox->addWidget(d->mEnableAccountOrder);
......@@ -189,7 +189,8 @@ void AccountConfigOrderDialog::init()
QStringList instanceList;
QMap<QString, InstanceStruct> mapInstance;
foreach (const Akonadi::AgentInstance &instance, Akonadi::AgentManager::self()->instances()) {
const Akonadi::AgentInstance::List lstInstances = Akonadi::AgentManager::self()->instances();
for (const Akonadi::AgentInstance &instance : lstInstances) {
const QStringList capabilities(instance.type().capabilities());
if (instance.type().mimeTypes().contains(KMime::Message::mimeType())) {
if (capabilities.contains(QStringLiteral("Resource")) &&
......
......@@ -67,7 +67,7 @@ FolderSelectionDialog::FolderSelectionDialog(QWidget *parent, SelectionFolderOpt
setObjectName(QStringLiteral("folder dialog"));
d->mNotAllowToCreateNewFolder = (options & FolderSelectionDialog::NotAllowToCreateNewFolder);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
d->mOkButton = buttonBox->button(QDialogButtonBox::Ok);
......
......@@ -128,8 +128,10 @@ bool FolderTreeWidgetProxyModel::enabledCheck() const
void FolderTreeWidgetProxyModel::setHideVirtualFolder(bool exclude)
{
d->hideVirtualFolder = exclude;
invalidate();
if (d->hideVirtualFolder != exclude) {
d->hideVirtualFolder = exclude;
invalidate();
}
}
bool FolderTreeWidgetProxyModel::hideVirtualFolder() const
......@@ -139,8 +141,10 @@ bool FolderTreeWidgetProxyModel::hideVirtualFolder() const
void FolderTreeWidgetProxyModel::setHideSpecificFolder(bool hide)
{
d->hideSpecificFolder = hide;
invalidate();
if (d->hideSpecificFolder != hide) {
d->hideSpecificFolder = hide;
invalidate();
}
}
bool FolderTreeWidgetProxyModel::hideSpecificFolder() const
......@@ -150,8 +154,10 @@ bool FolderTreeWidgetProxyModel::hideSpecificFolder() const
void FolderTreeWidgetProxyModel::setHideOutboxFolder(bool hide)
{
d->hideOutboxFolder = hide;
invalidate();
if (d->hideOutboxFolder != hide) {
d->hideOutboxFolder = hide;
invalidate();
}
}
bool FolderTreeWidgetProxyModel::hideOutboxFolder() const
......
......@@ -20,6 +20,7 @@
*/
#include "backupjob.h"
#include "helper_p.h"
#include <Libkdepim/BroadcastStatus>
#include "mailcommon_debug.h"
......@@ -120,7 +121,8 @@ bool BackupJob::queueFolders(const Akonadi::Collection &root)
return false;
}
foreach (const Akonadi::Collection &collection, job->collections()) {
const Akonadi::Collection::List lstCols = job->collections();
for (const Akonadi::Collection &collection : lstCols) {
if (!queueFolders(collection)) {
return false;
}
......@@ -132,7 +134,7 @@ bool BackupJob::queueFolders(const Akonadi::Collection &root)
bool BackupJob::hasChildren(const Akonadi::Collection &collection) const
{
foreach (const Akonadi::Collection &curCol, mAllFolders) {
for (const Akonadi::Collection &curCol : qAsConst(mAllFolders)) {
if (collection == curCol.parentCollection()) {
return true;
}
......@@ -304,7 +306,7 @@ bool BackupJob::writeDirHelper(const QString &directoryPath)
QString BackupJob::collectionName(const Akonadi::Collection &collection) const
{
foreach (const Akonadi::Collection &curCol, mAllFolders) {
for (const Akonadi::Collection &curCol : qAsConst(mAllFolders)) {
if (curCol == collection) {
return curCol.name();
}
......
......@@ -127,7 +127,8 @@ void ExpireJob::itemFetchResult(KJob *job)
return;
}
foreach (const Akonadi::Item &item, qobject_cast<Akonadi::ItemFetchJob *>(job)->items()) {
const Akonadi::Item::List items = qobject_cast<Akonadi::ItemFetchJob *>(job)->items();
for (const Akonadi::Item &item : items) {
if (!item.hasPayload<KMime::Message::Ptr>()) {
continue;
}
......
......@@ -31,8 +31,7 @@
#include <kio/global.h> //krazy:exclude=camelcase as there is no such
namespace MailCommon
{
using namespace MailCommon;
//----------------------------------------------------------------------------
FolderJob::FolderJob() :
......@@ -78,5 +77,3 @@ void FolderJob::setCancellable(bool b)
mCancellable = b;
}
}
......@@ -18,6 +18,7 @@
#include "addtagdialog.h"
#include "tag/tagwidget.h"
#include "mailcommon_debug.h"
#include "helper_p.h"
#include <KLocalizedString>
#include <KLineEdit>
......@@ -91,7 +92,7 @@ void AddTagDialog::slotSave()
{
const QString name(d->mTagWidget->tagNameLineEdit()->text());
Q_FOREACH (const MailCommon::Tag::Ptr &tag, d->mTags) {
for (const MailCommon::Tag::Ptr &tag : qAsConst(d->mTags)) {
if (tag->name() == name) {
KMessageBox::error(this, i18n("Tag %1 already exists", name));
d->mTagWidget->tagNameLineEdit()->setFocus();
......
......@@ -135,12 +135,12 @@ RedirectDialog::RedirectDialog(SendMode mode, QWidget *parent)
: QDialog(parent), d(new Private(this, mode))
{
setWindowTitle(i18n("Redirect Message"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
QVBoxLayout *topLayout = new QVBoxLayout;
setLayout(topLayout);
d->mUser1Button = new QPushButton;
d->mUser1Button = new QPushButton(this);
buttonBox->addButton(d->mUser1Button, QDialogButtonBox::ActionRole);
d->mUser2Button = new QPushButton;
d->mUser2Button = new QPushButton(this);
buttonBox->addButton(d->mUser2Button, QDialogButtonBox::ActionRole);
connect(buttonBox, &QDialogButtonBox::rejected, this, &RedirectDialog::reject);
if (mode == SendNow) {
......
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