Commit 26803c41 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent ae75dfe1
Pipeline #100205 passed with stage
in 23 minutes and 55 seconds
......@@ -96,7 +96,7 @@ qreal ArchiveMailKernel::closeToQuotaThreshold()
QStringList ArchiveMailKernel::customTemplates()
{
Q_ASSERT(false);
return QStringList();
return {};
}
bool ArchiveMailKernel::excludeImportantMailFromExpiry()
......
......@@ -84,7 +84,7 @@ qreal DummyKernel::closeToQuotaThreshold()
QStringList DummyKernel::customTemplates()
{
Q_ASSERT(false);
return QStringList();
return {};
}
bool DummyKernel::excludeImportantMailFromExpiry()
......
......@@ -14,6 +14,4 @@ MailMergeConfigureWidget::MailMergeConfigureWidget(QWidget *parent)
mWidget->setupUi(this);
}
MailMergeConfigureWidget::~MailMergeConfigureWidget()
{
}
MailMergeConfigureWidget::~MailMergeConfigureWidget() = default;
......@@ -11,9 +11,7 @@ MailMergeManager::MailMergeManager(QObject *parent)
{
}
MailMergeManager::~MailMergeManager()
{
}
MailMergeManager::~MailMergeManager() = default;
QString MailMergeManager::printDebugInfo() const
{
......
......@@ -56,7 +56,7 @@ void SendLaterManager::load(bool forcereload)
const int numberOfItems = itemList.count();
for (int i = 0; i < numberOfItems; ++i) {
KConfigGroup group = mConfig->group(itemList.at(i));
auto *info = SendLaterUtil::readSendLaterInfo(group);
auto info = SendLaterUtil::readSendLaterInfo(group);
if (info->isValid()) {
mListSendLaterInfo.append(info);
} else {
......
......@@ -101,7 +101,7 @@ qreal MailKernel::closeToQuotaThreshold()
QStringList MailKernel::customTemplates()
{
Q_ASSERT(false);
return QStringList();
return {};
}
bool MailKernel::excludeImportantMailFromExpiry()
......
......@@ -8,8 +8,8 @@
#include <config-ktnef.h> // WORDS_BIGENDIAN
#include <assert.h>
#include <math.h>
#include <cassert>
#include <cmath>
#include <QBuffer>
#include <QDataStream>
......
......@@ -92,7 +92,7 @@ void KMCommandsTest::resetIdentities()
void KMCommandsTest::verifyEncryption(bool encrypt)
{
const KMainWindow *w = mKernel->mainWin();
auto *encryption = w->findChild<QLabel *>(QStringLiteral("encryptionindicator"));
auto encryption = w->findChild<QLabel *>(QStringLiteral("encryptionindicator"));
QVERIFY(encryption);
QCOMPARE(encryption->isVisible(), encrypt);
}
......@@ -100,7 +100,7 @@ void KMCommandsTest::verifyEncryption(bool encrypt)
void KMCommandsTest::verifySignature(bool sign)
{
const KMainWindow *w = mKernel->mainWin();
auto *signature = w->findChild<QLabel *>(QStringLiteral("signatureindicator"));
auto signature = w->findChild<QLabel *>(QStringLiteral("signatureindicator"));
QVERIFY(signature);
QCOMPARE(signature->isVisible(), sign);
}
......@@ -113,7 +113,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->defaultIdentity();
Akonadi::Item item(createItem(ident));
auto *cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
auto cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......@@ -123,7 +123,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("secundus@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
auto cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(false);
waitForMainWindowToClose();
......@@ -133,7 +133,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("drei@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
auto cmd(new KMMailtoReplyCommand(nullptr, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......@@ -148,7 +148,7 @@ void KMCommandsTest::testReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->defaultIdentity();
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......@@ -158,7 +158,7 @@ void KMCommandsTest::testReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("secundus@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(false);
waitForMainWindowToClose();
......@@ -168,7 +168,7 @@ void KMCommandsTest::testReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("drei@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......@@ -187,7 +187,7 @@ void KMCommandsTest::testReplyWithoutDefaultGPGSign()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->defaultIdentity();
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(false);
waitForMainWindowToClose();
......@@ -197,7 +197,7 @@ void KMCommandsTest::testReplyWithoutDefaultGPGSign()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("secundus@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(false);
waitForMainWindowToClose();
......@@ -207,7 +207,7 @@ void KMCommandsTest::testReplyWithoutDefaultGPGSign()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("drei@example.com"));
Akonadi::Item item(createItem(ident));
auto *cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
auto cmd(new KMReplyCommand(nullptr, item, MessageComposer::ReplyAll));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......
......@@ -152,7 +152,7 @@ void KMComposerWinTest::testSignature()
composer->show();
QVERIFY(QTest::qWaitForWindowExposed(composer));
QCoreApplication::processEvents(QEventLoop::AllEvents);
auto *signature = composer->findChild<QLabel *>(QStringLiteral("signatureindicator"));
auto signature = composer->findChild<QLabel *>(QStringLiteral("signatureindicator"));
QVERIFY(signature);
QCOMPARE(signature->isVisible(), sign);
composer->close();
......@@ -186,7 +186,7 @@ void KMComposerWinTest::testEncryption()
composer->show();
QVERIFY(QTest::qWaitForWindowExposed(composer));
QCoreApplication::processEvents(QEventLoop::AllEvents);
auto *encryption = composer->findChild<QLabel *>(QStringLiteral("encryptionindicator"));
auto encryption = composer->findChild<QLabel *>(QStringLiteral("encryptionindicator"));
QVERIFY(encryption);
QCOMPARE(encryption->isVisible(), encrypt);
composer->close();
......
......@@ -16,9 +16,7 @@ TagSelectDialogTest::TagSelectDialogTest(QObject *parent)
{
}
TagSelectDialogTest::~TagSelectDialogTest()
{
}
TagSelectDialogTest::~TagSelectDialogTest() = default;
void TagSelectDialogTest::initTestCase()
{
......@@ -28,10 +26,10 @@ void TagSelectDialogTest::initTestCase()
void TagSelectDialogTest::shouldHaveDefaultValue()
{
TagSelectDialog dlg(nullptr, 1, Akonadi::Item());
auto *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("listtag"));
auto listWidget = dlg.findChild<QListWidget *>(QStringLiteral("listtag"));
QVERIFY(listWidget);
auto *listWidgetSearchLine = dlg.findChild<KListWidgetSearchLine *>(QStringLiteral("searchline"));
auto listWidgetSearchLine = dlg.findChild<KListWidgetSearchLine *>(QStringLiteral("searchline"));
QVERIFY(listWidgetSearchLine);
QVERIFY(listWidgetSearchLine->isClearButtonEnabled());
}
......
......@@ -807,7 +807,7 @@ MessageComposer::Composer *KMComposerWin::createSimpleComposer()
mComposerBase->setFrom(from());
mComposerBase->setSubject(subject());
mComposerBase->setCharsets(charsets);
MessageComposer::Composer *composer = new MessageComposer::Composer();
auto composer = new MessageComposer::Composer();
mComposerBase->fillComposer(composer);
return composer;
}
......@@ -826,7 +826,7 @@ void KMComposerWin::slotUpdateView()
// This sucks awfully, but no, I cannot get an activated(int id) from
// actionContainer()
auto *act = ::qobject_cast<KToggleAction *>(sender());
auto act = ::qobject_cast<KToggleAction *>(sender());
if (!act) {
return;
}
......@@ -1469,7 +1469,7 @@ void KMComposerWin::setupActions()
void KMComposerWin::updateHamburgerMenu()
{
QMenu *menu = new QMenu(this);
auto menu = new QMenu(this);
menu->addAction(actionCollection()->action(QStringLiteral("new_composer")));
menu->addSeparator();
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::Undo))));
......@@ -2685,7 +2685,7 @@ void KMComposerWin::slotPrintPreview()
void KMComposerWin::printComposer(bool preview)
{
MessageComposer::Composer *composer = new MessageComposer::Composer();
auto composer = new MessageComposer::Composer();
mComposerBase->fillComposer(composer);
mMiscComposers.append(composer);
composer->setProperty("preview", preview);
......
......@@ -19,6 +19,4 @@ TooManyRecipientsWarning::TooManyRecipientsWarning(QWidget *parent)
MessageComposer::MessageComposerSettings::self()->maximumRecipients()));
}
TooManyRecipientsWarning::~TooManyRecipientsWarning()
{
}
TooManyRecipientsWarning::~TooManyRecipientsWarning() = default;
......@@ -12,9 +12,7 @@ CollectionSwitcherModel::CollectionSwitcherModel(QObject *parent)
{
}
CollectionSwitcherModel::~CollectionSwitcherModel()
{
}
CollectionSwitcherModel::~CollectionSwitcherModel() = default;
int CollectionSwitcherModel::rowCount(const QModelIndex &parent) const
{
......
......@@ -19,7 +19,7 @@ public:
};
struct CollectionInfo {
CollectionInfo(){};
CollectionInfo() = default;
CollectionInfo(const Akonadi::Collection &col, const QString &path)
: mNewCollection(col)
, mFullPath(path)
......
......@@ -22,9 +22,7 @@ CollectionSwitcherTreeView::CollectionSwitcherTreeView(QWidget *parent)
setRootIsDecorated(false);
}
CollectionSwitcherTreeView::~CollectionSwitcherTreeView()
{
}
CollectionSwitcherTreeView::~CollectionSwitcherTreeView() = default;
int CollectionSwitcherTreeView::sizeHintWidth() const
{
......
......@@ -968,7 +968,7 @@ void IdentityDialog::updateIdentity(KIdentityManagement::Identity &ident)
}
if (collection.isValid()) {
ident.setFcc(QString::number(collection.id()));
auto *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
auto attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
attribute->setIconName(QStringLiteral("mail-folder-sent"));
// It will also start a CollectionModifyJob
Akonadi::SpecialMailCollections::self()->registerCollection(Akonadi::SpecialMailCollections::SentMail, collection);
......@@ -982,7 +982,7 @@ void IdentityDialog::updateIdentity(KIdentityManagement::Identity &ident)
}
if (collection.isValid()) {
ident.setDrafts(QString::number(collection.id()));
auto *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
auto attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
attribute->setIconName(QStringLiteral("document-properties"));
// It will also start a CollectionModifyJob
Akonadi::SpecialMailCollections::self()->registerCollection(Akonadi::SpecialMailCollections::Drafts, collection);
......@@ -996,7 +996,7 @@ void IdentityDialog::updateIdentity(KIdentityManagement::Identity &ident)
}
if (collection.isValid()) {
ident.setTemplates(QString::number(collection.id()));
auto *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
auto attribute = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
attribute->setIconName(QStringLiteral("document-new"));
// It will also start a CollectionModifyJob
Akonadi::SpecialMailCollections::self()->registerCollection(Akonadi::SpecialMailCollections::Templates, collection);
......
......@@ -121,7 +121,7 @@ IdentityListView::IdentityListView(QWidget *parent)
void IdentityListView::editItem(QTreeWidgetItem *item, int column)
{
if (column == 0 && item) {
auto *lvItem = dynamic_cast<IdentityListViewItem *>(item);
auto lvItem = dynamic_cast<IdentityListViewItem *>(item);
if (lvItem) {
KIdentityManagement::Identity &ident = lvItem->identity();
if (ident.isDefault()) {
......@@ -154,7 +154,7 @@ void IdentityListView::slotCustomContextMenuRequested(const QPoint &pos)
{
QTreeWidgetItem *item = itemAt(pos);
if (item) {
auto *lvItem = dynamic_cast<IdentityListViewItem *>(item);
auto lvItem = dynamic_cast<IdentityListViewItem *>(item);
if (lvItem) {
Q_EMIT contextMenu(lvItem, viewport()->mapToGlobal(pos));
}
......@@ -166,7 +166,7 @@ void IdentityListView::slotCustomContextMenuRequested(const QPoint &pos)
#ifndef QT_NO_DRAGANDDROP
void IdentityListView::startDrag(Qt::DropActions /*supportedActions*/)
{
auto *item = dynamic_cast<IdentityListViewItem *>(currentItem());
auto item = dynamic_cast<IdentityListViewItem *>(currentItem());
if (!item) {
return;
}
......
......@@ -222,7 +222,7 @@ void IdentityPage::slotRemoveIdentity()
KGuiItem(i18n("&Remove"), QStringLiteral("edit-delete")))
== KMessageBox::Continue) {
for (QTreeWidgetItem *selecteditem : selectedItems) {
auto *identityItem = dynamic_cast<IdentityListViewItem *>(item);
auto identityItem = dynamic_cast<IdentityListViewItem *>(item);
identityName = identityItem->identity().identityName();
if (mIdentityManager->removeIdentity(identityName)) {
delete selecteditem;
......@@ -306,7 +306,7 @@ void IdentityPage::refreshList()
{
const int numberOfTopLevel(mIPage.mIdentityList->topLevelItemCount());
for (int i = 0; i < numberOfTopLevel; ++i) {
auto *item = dynamic_cast<IdentityListViewItem *>(mIPage.mIdentityList->topLevelItem(i));
auto item = dynamic_cast<IdentityListViewItem *>(mIPage.mIdentityList->topLevelItem(i));
if (item) {
item->redisplay();
}
......
......@@ -27,7 +27,7 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include <assert.h>
#include <cassert>
using namespace KMail;
......
......@@ -52,7 +52,7 @@ void RemoveDuplicateMailJob::start()
void RemoveDuplicateMailJob::slotRemoveDuplicatesDone(KJob *job)
{
auto *item = job->property("ProgressItem").value<KPIM::ProgressItem *>();
auto item = job->property("ProgressItem").value<KPIM::ProgressItem *>();
if (item) {
item->setComplete();
item->setStatus(i18n("Done"));
......@@ -66,7 +66,7 @@ void RemoveDuplicateMailJob::slotRemoveDuplicatesDone(KJob *job)
void RemoveDuplicateMailJob::slotRemoveDuplicatesCanceled(KPIM::ProgressItem *item)
{
auto *job = item->property("RemoveDuplicatesJob").value<Akonadi::Job *>();
auto job = item->property("RemoveDuplicatesJob").value<Akonadi::Job *>();
if (job) {
job->kill(KJob::Quietly);
}
......@@ -78,7 +78,7 @@ void RemoveDuplicateMailJob::slotRemoveDuplicatesCanceled(KPIM::ProgressItem *it
void RemoveDuplicateMailJob::slotRemoveDuplicatesUpdate(KJob *job, const QString &description)
{
auto *item = job->property("ProgressItem").value<KPIM::ProgressItem *>();
auto item = job->property("ProgressItem").value<KPIM::ProgressItem *>();
if (item) {
item->setStatus(description);
}
......
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