Commit 0e229b15 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code (using auto)

parent fcdd975c
Pipeline #39327 passed with stage
in 10 minutes and 7 seconds
......@@ -30,13 +30,13 @@ void MailDir20PercentAsRead::runTest()
clj2->exec();
const Collection::List list2 = clj2->collections();
for (const Collection &collection : list2) {
ItemFetchJob *ifj = new ItemFetchJob(collection, this);
auto *ifj = new ItemFetchJob(collection, this);
ifj->exec();
Item::List itemlist = ifj->items();
for (int i = ifj->items().count() - 1; i >= 0; i -= 5) {
Item item = itemlist[i];
item.setFlag("\\SEEN");
ItemModifyJob *isj = new ItemModifyJob(item, this);
auto *isj = new ItemModifyJob(item, this);
isj->exec();
}
}
......
......@@ -33,7 +33,7 @@ void MailDirFetchAllHeaders::runTest()
clj->exec();
const Collection::List list = clj->collections();
for (const Collection &collection : list) {
ItemFetchJob *ifj = new ItemFetchJob(collection, this);
auto *ifj = new ItemFetchJob(collection, this);
ifj->fetchScope().fetchPayloadPart(MessagePart::Envelope);
ifj->exec();
QString a;
......
......@@ -33,7 +33,7 @@ void MailDirFetchUnreadHeaders::runTest()
clj3->exec();
const Collection::List list3 = clj3->collections();
for (const Collection &collection : list3) {
ItemFetchJob *ifj = new ItemFetchJob(collection, this);
auto *ifj = new ItemFetchJob(collection, this);
ifj->fetchScope().fetchPayloadPart(MessagePart::Envelope);
ifj->exec();
QString a;
......
......@@ -29,13 +29,13 @@ void MailDirRemoveReadMessages::runTest()
clj4->exec();
const Collection::List list4 = clj4->collections();
for (const Collection &collection : list4) {
ItemFetchJob *ifj = new ItemFetchJob(collection, this);
auto *ifj = new ItemFetchJob(collection, this);
ifj->exec();
const auto items = ifj->items();
for (const Item &item : items) {
// delete read messages
if (item.hasFlag("\\SEEN")) {
ItemDeleteJob *idj = new ItemDeleteJob(item, this);
auto *idj = new ItemDeleteJob(item, this);
idj->exec();
}
}
......
......@@ -26,8 +26,8 @@ int main(int argc, char *argv[])
const QString maildir = parser.value(QStringLiteral("maildir"));
const QString vcarddir = parser.value(QStringLiteral("vcarddir"));
TestMailDir *mailDirTest = new TestMailDir(maildir);
TestVCard *vcardTest = new TestVCard(vcarddir);
auto *mailDirTest = new TestMailDir(maildir);
auto *vcardTest = new TestVCard(vcarddir);
mailDirTest->runTests();
vcardTest->runTests();
......
......@@ -31,7 +31,7 @@ void MakeTest::createAgent(const QString &name)
{
const AgentType type = AgentManager::self()->type(name);
AgentInstanceCreateJob *job = new AgentInstanceCreateJob(type);
auto *job = new AgentInstanceCreateJob(type);
job->exec();
currentInstance = job->instance();
......@@ -98,7 +98,7 @@ void MakeTest::removeCollections()
clj5->exec();
const Collection::List list5 = clj5->collections();
for (const Collection &collection : list5) {
CollectionDeleteJob *cdj = new CollectionDeleteJob(collection, this);
auto *cdj = new CollectionDeleteJob(collection, this);
cdj->exec();
}
outputStats(QStringLiteral("removeallcollections"));
......
......@@ -39,7 +39,7 @@ void MailSerializerTest::testEnvelopeDeserialize_data()
QTest::newRow("v1 - no references")
<< 1
<< QByteArray(
"(\"Wed, 1 Feb 2006 13:37:19 UT\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL <{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>)")
R"(("Wed, 1 Feb 2006 13:37:19 UT" "IMPORTANT: Akonadi Test" (("Tobias Koenig" NIL "tokoe" "kde.org")) (("Tobias Koenig" NIL "tokoe" "kde.org")) NIL (("Ingo Kloecker" NIL "kloecker" "kde.org")) NIL NIL NIL <{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>))")
<< QDateTime(QDate(2006, 2, 1), QTime(13, 37, 19), Qt::UTC)
<< QStringLiteral("IMPORTANT: Akonadi Test")
<< QStringLiteral("Tobias Koenig <tokoe@kde.org>")
......@@ -53,7 +53,7 @@ void MailSerializerTest::testEnvelopeDeserialize_data()
QTest::newRow("v1 - with references")
<< 1
<< QByteArray(
"(\"Wed, 1 Feb 2006 13:37:19 UT\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL <{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org> \"<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>\")")
R"(("Wed, 1 Feb 2006 13:37:19 UT" "IMPORTANT: Akonadi Test" (("Tobias Koenig" NIL "tokoe" "kde.org")) (("Tobias Koenig" NIL "tokoe" "kde.org")) NIL (("Ingo Kloecker" NIL "kloecker" "kde.org")) NIL NIL NIL <{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org> "<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>"))")
<< QDateTime(QDate(2006, 2, 1), QTime(13, 37, 19), Qt::UTC)
<< QStringLiteral("IMPORTANT: Akonadi Test")
<< QStringLiteral("Tobias Koenig <tokoe@kde.org>")
......@@ -116,7 +116,7 @@ void MailSerializerTest::testEnvelopeDeserialize()
Item i;
i.setMimeType(QStringLiteral("message/rfc822"));
SerializerPluginMail *serializer = new SerializerPluginMail();
auto *serializer = new SerializerPluginMail();
// envelope
QBuffer buffer;
......@@ -205,7 +205,7 @@ void MailSerializerTest::testEnvelopeSerialize()
Item i;
i.setMimeType(QStringLiteral("message/rfc822"));
Message *msg = new Message();
auto *msg = new Message();
msg->date()->setDateTime(date);
msg->subject()->fromUnicodeString(subject, "UTF-8");
msg->from()->fromUnicodeString(from, "UTF-8");
......@@ -219,7 +219,7 @@ void MailSerializerTest::testEnvelopeSerialize()
msg->references()->fromUnicodeString(references, "UTF-8");
i.setPayload(KMime::Message::Ptr(msg));
SerializerPluginMail *serializer = new SerializerPluginMail();
auto *serializer = new SerializerPluginMail();
// envelope
QByteArray env;
......@@ -240,11 +240,11 @@ void MailSerializerTest::testParts()
{
Item item;
item.setMimeType(QStringLiteral("message/rfc822"));
KMime::Message *m = new Message;
auto *m = new Message;
KMime::Message::Ptr msg(m);
item.setPayload(msg);
SerializerPluginMail *serializer = new SerializerPluginMail();
auto *serializer = new SerializerPluginMail();
QVERIFY(serializer->parts(item).isEmpty());
msg->setHead("foo");
......@@ -268,7 +268,7 @@ void MailSerializerTest::testHeaderFetch()
Item i;
i.setMimeType(QStringLiteral("message/rfc822"));
SerializerPluginMail *serializer = new SerializerPluginMail();
auto *serializer = new SerializerPluginMail();
QByteArray headerData("From: David Johnson <david@usermode.org>\n"
"To: kde-commits@kde.org\n"
......@@ -307,7 +307,7 @@ void MailSerializerTest::testMultiDeserialize()
Item i;
i.setMimeType(QStringLiteral("message/rfc822"));
SerializerPluginMail *serializer = new SerializerPluginMail();
auto *serializer = new SerializerPluginMail();
QByteArray messageData("From: David Johnson <david@usermode.org>\n"
"To: kde-commits@kde.org\n"
......
......@@ -88,7 +88,7 @@ bool SerializerPluginMail::deserialize(Item &item, const QByteArray &label, QIOD
KMime::Message::Ptr msg;
if (!item.hasPayload()) {
Message *m = new Message();
auto *m = new Message();
msg = KMime::Message::Ptr(m);
item.setPayload(msg);
} else {
......
......@@ -88,7 +88,7 @@ void EmptyTrashCommand::execute()
void EmptyTrashCommand::expunge(const Akonadi::Collection &col)
{
if (col.isValid()) {
Akonadi::ItemDeleteJob *jobDelete = new Akonadi::ItemDeleteJob(col, this);
auto *jobDelete = new Akonadi::ItemDeleteJob(col, this);
connect(jobDelete, &Akonadi::ItemDeleteJob::result,
this, [this, jobDelete]() {
if (jobDelete->error()) {
......
......@@ -70,7 +70,7 @@ void MarkAsCommand::slotCollectionFetchDone(KJob *job)
return;
}
Akonadi::CollectionFetchJob *fjob = static_cast<Akonadi::CollectionFetchJob *>(job);
auto *fjob = static_cast<Akonadi::CollectionFetchJob *>(job);
d->mFolders += fjob->collections();
d->mFolderListJobCount = d->mFolders.size();
......@@ -90,7 +90,7 @@ void MarkAsCommand::slotFetchDone(KJob *job)
return;
}
Akonadi::ItemFetchJob *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
d->mMessages.clear();
const auto items = fjob->items();
for (const Akonadi::Item &item : items) {
......@@ -113,7 +113,7 @@ void MarkAsCommand::slotFetchDone(KJob *job)
markMessages();
}
if (d->mFolderListJobCount > 0) {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(d->mFolders[d->mFolderListJobCount - 1], parent());
auto *job = new Akonadi::ItemFetchJob(d->mFolders[d->mFolderListJobCount - 1], parent());
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
connect(job, &Akonadi::ItemFetchJob::result, this, &MarkAsCommand::slotFetchDone);
}
......@@ -125,14 +125,14 @@ void MarkAsCommand::execute()
if (KMessageBox::questionYesNo(qobject_cast<QWidget *>(parent()),
i18n("Are you sure you want to mark all messages in this folder and all its subfolders?"),
i18n("Mark All Recursively")) == KMessageBox::Yes) {
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(d->mFolders.constFirst());
auto *job = new Akonadi::CollectionFetchJob(d->mFolders.constFirst());
connect(job, &Akonadi::CollectionFetchJob::result, this, &MarkAsCommand::slotCollectionFetchDone);
} else {
emitResult(Canceled);
}
} else if (!d->mFolders.isEmpty()) {
//yes, we go backwards, shouldn't matter
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(d->mFolders[d->mFolderListJobCount - 1], parent());
auto *job = new Akonadi::ItemFetchJob(d->mFolders[d->mFolderListJobCount - 1], parent());
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
connect(job, &Akonadi::ItemFetchJob::result, this, &MarkAsCommand::slotFetchDone);
} else if (!d->mMessages.isEmpty()) {
......@@ -177,7 +177,7 @@ void MarkAsCommand::markMessages()
if (itemsToModify.isEmpty()) {
slotModifyItemDone(nullptr); // pretend we did something
} else {
Akonadi::ItemModifyJob *modifyJob = new Akonadi::ItemModifyJob(itemsToModify, this);
auto *modifyJob = new Akonadi::ItemModifyJob(itemsToModify, this);
modifyJob->setIgnorePayload(true);
modifyJob->disableRevisionCheck();
connect(modifyJob, &Akonadi::ItemModifyJob::result, this, &MarkAsCommand::slotModifyItemDone);
......
......@@ -43,10 +43,10 @@ void MoveCommand::execute()
return;
}
if (d->mDestFolder.isValid()) {
Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob(d->mMessages, d->mDestFolder, this);
auto *job = new Akonadi::ItemMoveJob(d->mMessages, d->mDestFolder, this);
connect(job, &Akonadi::ItemMoveJob::result, this, &MoveCommand::slotMoveResult);
} else {
Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob(d->mMessages, this);
auto *job = new Akonadi::ItemDeleteJob(d->mMessages, this);
connect(job, &Akonadi::ItemDeleteJob::result, this, &MoveCommand::slotMoveResult);
}
}
......
......@@ -44,13 +44,13 @@ void MoveToTrashCommand::slotFetchDone(KJob *job)
return;
}
Akonadi::ItemFetchJob *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
mMessages = fjob->items();
moveMessages();
if (mFolderListJobCount > 0) {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(mFolders[mFolderListJobCount - 1], parent());
auto *job = new Akonadi::ItemFetchJob(mFolders[mFolderListJobCount - 1], parent());
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
connect(job, &Akonadi::ItemFetchJob::result, this, &MoveToTrashCommand::slotFetchDone);
}
......@@ -59,7 +59,7 @@ void MoveToTrashCommand::slotFetchDone(KJob *job)
void MoveToTrashCommand::execute()
{
if (!mFolders.isEmpty()) {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(mFolders[mFolderListJobCount - 1], parent());
auto *job = new Akonadi::ItemFetchJob(mFolders[mFolderListJobCount - 1], parent());
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
connect(job, &Akonadi::ItemFetchJob::result, this, &MoveToTrashCommand::slotFetchDone);
} else if (!mMessages.isEmpty()) {
......
......@@ -28,7 +28,7 @@ NewMailNotifierAttribute::~NewMailNotifierAttribute() = default;
NewMailNotifierAttribute *NewMailNotifierAttribute::clone() const
{
NewMailNotifierAttribute *attr = new NewMailNotifierAttribute();
auto *attr = new NewMailNotifierAttribute();
attr->setIgnoreNewMail(ignoreNewMail());
return attr;
}
......
......@@ -27,7 +27,7 @@ Pop3ResourceAttribute::~Pop3ResourceAttribute() = default;
Pop3ResourceAttribute *Pop3ResourceAttribute::clone() const
{
Pop3ResourceAttribute *attr = new Pop3ResourceAttribute();
auto *attr = new Pop3ResourceAttribute();
attr->setPop3AccountName(pop3AccountName());
return attr;
}
......
......@@ -29,7 +29,7 @@ public:
Akonadi::Collection collection = mFolders.value(mJobCount - 1);
qCDebug(AKONADIMIME_LOG) << "Processing collection" << collection.name() << "(" << collection.id() << ")";
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection, mParent);
auto *job = new Akonadi::ItemFetchJob(collection, mParent);
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
job->fetchScope().fetchFullPayload();
job->fetchScope().setIgnoreRetrievalErrors(true);
......@@ -58,7 +58,7 @@ public:
Q_EMIT mParent->description(mParent, i18n("Searching for duplicates..."));
Akonadi::ItemFetchJob *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *fjob = static_cast<Akonadi::ItemFetchJob *>(job);
Akonadi::Item::List items = fjob->items();
//find duplicate mails with the same messageid
......@@ -116,7 +116,7 @@ public:
return;
} else {
Q_EMIT mParent->description(mParent, i18n("Removing duplicates..."));
Akonadi::ItemDeleteJob *delCmd = new Akonadi::ItemDeleteJob(mDuplicateItems, mParent);
auto *delCmd = new Akonadi::ItemDeleteJob(mDuplicateItems, mParent);
mParent->connect(delCmd, &ItemDeleteJob::result, mParent, [this](KJob *job) {
slotDeleteDone(job);
});
......
......@@ -155,7 +155,7 @@ void SpecialMailCollections::verifyI18nDefaultCollection(Type type)
if (collection.hasAttribute<Akonadi::EntityDisplayAttribute>()) {
if (collection.attribute<Akonadi::EntityDisplayAttribute>()->displayName() != defaultI18n) {
collection.attribute<Akonadi::EntityDisplayAttribute>()->setDisplayName(defaultI18n);
Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob(collection, this);
auto *job = new Akonadi::CollectionModifyJob(collection, this);
connect(job, &Akonadi::CollectionModifyJob::result, this, &SpecialMailCollections::slotCollectionModified);
}
}
......
......@@ -516,7 +516,7 @@ public:
return;
}
MarkAsCommand *command = new MarkAsCommand(targetStatus, items, invert, mParent);
auto *command = new MarkAsCommand(targetStatus, items, invert, mParent);
command->execute();
}
......@@ -569,7 +569,7 @@ public:
return;
}
MarkAsCommand *command = new MarkAsCommand(targetStatus, collections, invert, recursive, mParent);
auto *command = new MarkAsCommand(targetStatus, collections, invert, recursive, mParent);
command->execute();
}
......@@ -601,7 +601,7 @@ public:
return;
}
MoveToTrashCommand *command = new MoveToTrashCommand(mCollectionSelectionModel->model(), items, mParent);
auto *command = new MoveToTrashCommand(mCollectionSelectionModel->model(), items, mParent);
command->execute();
}
......@@ -620,7 +620,7 @@ public:
return;
}
MoveToTrashCommand *command = new MoveToTrashCommand(mCollectionSelectionModel->model(), collections, mParent);
auto *command = new MoveToTrashCommand(mCollectionSelectionModel->model(), collections, mParent);
command->execute();
}
......@@ -635,7 +635,7 @@ public:
return;
}
RemoveDuplicatesJob *job = new RemoveDuplicatesJob(collections, mParent);
auto *job = new RemoveDuplicatesJob(collections, mParent);
connect(job, &RemoveDuplicatesJob::finished, mParent, [this](KJob *job) {
slotJobFinished(job);
});
......@@ -654,7 +654,7 @@ public:
return;
}
EmptyTrashCommand *command = new EmptyTrashCommand(const_cast<QAbstractItemModel *>(mCollectionSelectionModel->model()), mParent);
auto *command = new EmptyTrashCommand(const_cast<QAbstractItemModel *>(mCollectionSelectionModel->model()), mParent);
command->execute();
}
......@@ -673,7 +673,7 @@ public:
return;
}
EmptyTrashCommand *command = new EmptyTrashCommand(collections.first(), mParent);
auto *command = new EmptyTrashCommand(collections.first(), mParent);
command->execute();
}
......
......@@ -23,7 +23,7 @@ void showJobError(KJob *job)
assert(job);
// we can be called from the KJob::kill, where we are no longer a KIO::Job
// so better safe than sorry
KIO::Job *kiojob = qobject_cast<KIO::Job *>(job);
auto *kiojob = qobject_cast<KIO::Job *>(job);
if (kiojob && kiojob->uiDelegate()) {
kiojob->uiDelegate()->showErrorMessage();
} else {
......
......@@ -22,7 +22,7 @@ Requester::Requester()
{
Control::start();
SpecialMailCollectionsRequestJob *rjob = new SpecialMailCollectionsRequestJob(this);
auto *rjob = new SpecialMailCollectionsRequestJob(this);
rjob->requestDefaultCollection(SpecialMailCollections::Outbox);
connect(rjob, &SpecialMailCollectionsRequestJob::result, this, &Requester::requestResult);
rjob->start();
......
......@@ -34,7 +34,7 @@ HeadFetcher::HeadFetcher(bool multipart)
clj->exec();
const Collection::List list = clj->collections();
for (const Collection &collection : list) {
ItemFetchJob *ifj = new ItemFetchJob(collection, this);
auto *ifj = new ItemFetchJob(collection, this);
if (multipart) {
ifj->fetchScope().fetchPayloadPart(MessagePart::Envelope);
} else {
......
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