Commit 52710ca8 authored by Laurent Montel's avatar Laurent Montel 😁

Modernize code

parent a86629be
Pipeline #39280 passed with stage
in 11 minutes and 4 seconds
......@@ -21,9 +21,9 @@ ConfigModule::ConfigModule(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
setButtons(NoAdditionalButton);
QVBoxLayout *l = new QVBoxLayout(this);
auto *l = new QVBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
TransportManagementWidget *tmw = new TransportManagementWidget(this);
auto *tmw = new TransportManagementWidget(this);
l->addWidget(tmw);
}
......
......@@ -57,7 +57,7 @@ void FakeServer::dataAvailable()
{
QMutexLocker locker(&m_mutex);
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
auto *socket = qobject_cast<QTcpSocket *>(sender());
Q_ASSERT(socket != nullptr);
int scenarioNumber = m_clientSockets.indexOf(socket);
......
......@@ -22,7 +22,7 @@ SmtpConfigDialog::SmtpConfigDialog(Transport *transport, QWidget *parent)
{
Q_ASSERT(transport);
mTransport = transport;
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
mConfigWidget = new SMTPConfigWidget(transport, this);
mConfigWidget->setObjectName(QStringLiteral("smtpconfigwidget"));
mainLayout->addWidget(mConfigWidget);
......
......@@ -15,11 +15,11 @@
AddTransportDialogNG_gui::AddTransportDialogNG_gui(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
auto *layout = new QHBoxLayout(this);
QPushButton *button = new QPushButton(QStringLiteral("Add transport"));
layout->addWidget(button);
connect(button, &QPushButton::clicked, this, [this] {
MailTransport::AddTransportDialogNG *dlg = new MailTransport::AddTransportDialogNG(this);
auto *dlg = new MailTransport::AddTransportDialogNG(this);
dlg->exec();
delete dlg;
});
......@@ -30,7 +30,7 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
app.setApplicationName(QStringLiteral("addtransportnewng"));
QStandardPaths::setTestModeEnabled(true);
AddTransportDialogNG_gui *t = new AddTransportDialogNG_gui();
auto *t = new AddTransportDialogNG_gui();
t->show();
app.exec();
delete t;
......
......@@ -24,7 +24,7 @@ using namespace MailTransport;
TransportMgr::TransportMgr()
: mCurrentJob(nullptr)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
auto *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, 0, 0, 0);
vbox->addWidget(new TransportManagementWidget(this));
......@@ -117,7 +117,7 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
app.setApplicationName(QStringLiteral("transportmgr"));
TransportMgr *t = new TransportMgr();
auto *t = new TransportMgr();
t->show();
app.exec();
delete t;
......
......@@ -87,7 +87,7 @@ AddTransportDialogNG::AddTransportDialogNG(QWidget *parent)
{
// Setup UI.
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QWidget *widget = new QWidget(this);
d->ui.setupUi(widget);
mainLayout->addWidget(widget);
......@@ -105,7 +105,7 @@ AddTransportDialogNG::AddTransportDialogNG(QWidget *parent)
// Populate type list.
const auto transportTypes = TransportManager::self()->types();
for (const TransportType &type : transportTypes) {
QTreeWidgetItem *treeItem = new QTreeWidgetItem(d->ui.typeListView);
auto *treeItem = new QTreeWidgetItem(d->ui.typeListView);
treeItem->setText(0, type.name());
treeItem->setText(1, type.description());
treeItem->setToolTip(1, type.description());
......
......@@ -68,7 +68,7 @@ void TransportListView::commitData(QWidget *editor)
return;
}
QTreeWidgetItem *item = selectedItems().first();
QLineEdit *edit = dynamic_cast<QLineEdit *>(editor); // krazy:exclude=qclasses
auto *edit = dynamic_cast<QLineEdit *>(editor); // krazy:exclude=qclasses
Q_ASSERT(edit); // original code had if
const int id = item->data(0, Qt::UserRole).toInt();
......@@ -94,7 +94,7 @@ void TransportListView::fillTransportList()
clear();
const auto lstTransports = TransportManager::self()->transports();
for (Transport *t : lstTransports) {
QTreeWidgetItem *item = new QTreeWidgetItem(this);
auto *item = new QTreeWidgetItem(this);
item->setData(0, Qt::UserRole, t->id());
QString name = t->name();
if (TransportManager::self()->defaultTransportId() == t->id()) {
......
......@@ -73,7 +73,7 @@ void AttributeTest::testSerialization()
cc << QStringLiteral("cc2@me.org");
QStringList bcc(QStringLiteral("bcc1@me.org"));
bcc << QStringLiteral("bcc2@me.org");
AddressAttribute *a = new AddressAttribute(from, to, cc, bcc);
auto *a = new AddressAttribute(from, to, cc, bcc);
QByteArray data = a->serialized();
delete a;
a = new AddressAttribute;
......@@ -92,7 +92,7 @@ void AttributeTest::testSerialization()
qDebug() << "ms" << date.toString(QStringLiteral("z"));
int ms = date.toString(QStringLiteral("z")).toInt();
date = date.addMSecs(-ms);
DispatchModeAttribute *a = new DispatchModeAttribute(mode);
auto *a = new DispatchModeAttribute(mode);
a->setSendAfter(date);
QByteArray data = a->serialized();
delete a;
......@@ -105,7 +105,7 @@ void AttributeTest::testSerialization()
{
QString msg(QStringLiteral("The #!@$ing thing failed!"));
ErrorAttribute *a = new ErrorAttribute(msg);
auto *a = new ErrorAttribute(msg);
QByteArray data = a->serialized();
delete a;
a = new ErrorAttribute;
......@@ -115,7 +115,7 @@ void AttributeTest::testSerialization()
}
{
SentActionAttribute *a = new SentActionAttribute();
auto *a = new SentActionAttribute();
const qlonglong id = 123456789012345ll;
a->addAction(SentActionAttribute::Action::MarkAsReplied, QVariant(id));
......@@ -225,7 +225,7 @@ void AttributeTest::testSerialization()
{
int id = 3219;
TransportAttribute *a = new TransportAttribute(id);
auto *a = new TransportAttribute(id);
QByteArray data = a->serialized();
delete a;
a = new TransportAttribute;
......
......@@ -52,7 +52,7 @@ void MessageQueueJobTest::initTestCase()
mda.setIsOnline(false);
// check that outbox is empty
SpecialMailCollectionsRequestJob *rjob = new SpecialMailCollectionsRequestJob(this);
auto *rjob = new SpecialMailCollectionsRequestJob(this);
rjob->requestDefaultCollection(SpecialMailCollections::Outbox);
QSignalSpy spy(rjob, &KJob::result);
QVERIFY(spy.wait(10000));
......@@ -66,7 +66,7 @@ void MessageQueueJobTest::testValidMessages()
QVERIFY2(tid >= 0, "I need a default transport, but there is none.");
// send a valid message using the default transport
MessageQueueJob *qjob = new MessageQueueJob;
auto *qjob = new MessageQueueJob;
qjob->transportAttribute().setTransportId(tid);
Message::Ptr msg = Message::Ptr(new Message);
msg->setContent("\nThis is message #1 from the MessageQueueJobTest unit test.\n");
......@@ -87,30 +87,30 @@ void MessageQueueJobTest::testValidMessages()
Item item = fjob->items().constFirst();
QVERIFY(!item.remoteId().isEmpty()); // stored by the resource
QVERIFY(item.hasPayload<Message::Ptr>());
AddressAttribute *addrA = item.attribute<AddressAttribute>();
auto *addrA = item.attribute<AddressAttribute>();
QVERIFY(addrA);
QVERIFY(addrA->from().isEmpty());
QCOMPARE(addrA->to().count(), 1);
QCOMPARE(addrA->to(), SPAM_ADDRESS);
QCOMPARE(addrA->cc().count(), 0);
QCOMPARE(addrA->bcc().count(), 0);
DispatchModeAttribute *dA = item.attribute<DispatchModeAttribute>();
auto *dA = item.attribute<DispatchModeAttribute>();
QVERIFY(dA);
QCOMPARE(dA->dispatchMode(), DispatchModeAttribute::Automatic); // default mode
SentBehaviourAttribute *sA = item.attribute<SentBehaviourAttribute>();
auto *sA = item.attribute<SentBehaviourAttribute>();
QVERIFY(sA);
// default sent collection
QCOMPARE(sA->sentBehaviour(), SentBehaviourAttribute::MoveToDefaultSentCollection);
TransportAttribute *tA = item.attribute<TransportAttribute>();
auto *tA = item.attribute<TransportAttribute>();
QVERIFY(tA);
QCOMPARE(tA->transportId(), tid);
ErrorAttribute *eA = item.attribute<ErrorAttribute>();
auto *eA = item.attribute<ErrorAttribute>();
QVERIFY(!eA); // no error
QCOMPARE(item.flags().count(), 1);
QVERIFY(item.flags().contains(Akonadi::MessageFlags::Queued));
// delete message, for further tests
ItemDeleteJob *djob = new ItemDeleteJob(item);
auto *djob = new ItemDeleteJob(item);
AKVERIFYEXEC(djob);
verifyOutboxContents(0);
......@@ -126,7 +126,7 @@ void MessageQueueJobTest::testInvalidMessages()
Message::Ptr msg;
// without message
MessageQueueJob *job = new MessageQueueJob;
auto *job = new MessageQueueJob;
job->transportAttribute().setTransportId(TransportManager::self()->defaultTransportId());
job->addressAttribute().setTo(SPAM_ADDRESS);
QVERIFY(!job->exec());
......@@ -166,7 +166,7 @@ void MessageQueueJobTest::verifyOutboxContents(qlonglong count)
Collection outbox
= SpecialMailCollections::self()->defaultCollection(SpecialMailCollections::Outbox);
QVERIFY(outbox.isValid());
CollectionStatisticsJob *job = new CollectionStatisticsJob(outbox);
auto *job = new CollectionStatisticsJob(outbox);
AKVERIFYEXEC(job);
QCOMPARE(job->statistics().count(), count);
}
......
......@@ -54,7 +54,7 @@ void DispatcherInterface::dispatchManually()
return;
}
FilterActionJob *mjob = new FilterActionJob(outbox, new SendQueuedAction, sInstance);
auto *mjob = new FilterActionJob(outbox, new SendQueuedAction, sInstance);
QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
}
......@@ -67,7 +67,7 @@ void DispatcherInterface::retryDispatching()
return;
}
FilterActionJob *mjob = new FilterActionJob(outbox, new ClearErrorAction, sInstance);
auto *mjob = new FilterActionJob(outbox, new ClearErrorAction, sInstance);
QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
}
......@@ -80,7 +80,7 @@ void DispatcherInterface::dispatchManualTransport(int transportId)
return;
}
FilterActionJob *mjob
auto *mjob
= new FilterActionJob(outbox, new DispatchManualTransportAction(transportId), sInstance);
QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
}
......
......@@ -33,7 +33,7 @@ DispatchModeAttribute::~DispatchModeAttribute()
DispatchModeAttribute *DispatchModeAttribute::clone() const
{
DispatchModeAttribute *const cloned = new DispatchModeAttribute(d->mMode);
auto *const cloned = new DispatchModeAttribute(d->mMode);
cloned->setSendAfter(d->mDueDate);
return cloned;
}
......
......@@ -46,7 +46,7 @@ void FilterActionJob::Private::fetchResult(KJob *job)
return;
}
ItemFetchJob *fjob = dynamic_cast<ItemFetchJob *>(job);
auto *fjob = dynamic_cast<ItemFetchJob *>(job);
Q_ASSERT(fjob);
Q_ASSERT(items.isEmpty());
items = fjob->items();
......@@ -109,7 +109,7 @@ void FilterActionJob::doStart()
{
if (d->collection.isValid()) {
qCDebug(MAILTRANSPORTAKONADI_LOG) << "Fetching collection" << d->collection.id();
ItemFetchJob *fjob = new ItemFetchJob(d->collection, this);
auto *fjob = new ItemFetchJob(d->collection, this);
Q_ASSERT(d->functor);
d->fetchScope = d->functor->fetchScope();
fjob->setFetchScope(d->fetchScope);
......
......@@ -111,7 +111,7 @@ void MessageQueueJob::Private::outboxRequestResult(KJob *job)
return;
}
SpecialMailCollectionsRequestJob *requestJob
auto *requestJob
= qobject_cast<SpecialMailCollectionsRequestJob *>(job);
if (!requestJob) {
return;
......@@ -136,7 +136,7 @@ void MessageQueueJob::Private::outboxRequestResult(KJob *job)
// Store the item in the outbox.
const Collection collection = requestJob->collection();
Q_ASSERT(collection.isValid());
ItemCreateJob *cjob = new ItemCreateJob(item, collection); // job autostarts
auto *cjob = new ItemCreateJob(item, collection); // job autostarts
q->addSubjob(cjob);
}
......@@ -188,7 +188,7 @@ void MessageQueueJob::setMessage(const Message::Ptr &message)
void MessageQueueJob::start()
{
SpecialMailCollectionsRequestJob *rjob = new SpecialMailCollectionsRequestJob(this);
auto *rjob = new SpecialMailCollectionsRequestJob(this);
rjob->requestDefaultCollection(SpecialMailCollections::Outbox);
connect(rjob, &SpecialMailCollectionsRequestJob::result, this, [this](KJob *job) {
d->outboxRequestResult(job);
......
......@@ -84,7 +84,7 @@ MailTransport::TransportJob *AkonadiMailTransportPlugin::createTransportJob(Mail
void AkonadiMailTransportPlugin::initializeTransport(MailTransport::Transport *t, const QString &identifier)
{
AgentInstanceCreateJob *cjob = new AgentInstanceCreateJob(identifier);
auto *cjob = new AgentInstanceCreateJob(identifier);
if (!cjob->exec()) {
qCWarning(MAILTRANSPORT_AKONADI_LOG) << "Failed to create agent instance of type" << identifier;
return;
......
......@@ -30,7 +30,7 @@ void ResourceSendJob::doStart()
{
Message::Ptr msg = Message::Ptr(new Message);
msg->setContent(data());
MessageQueueJob *job = new MessageQueueJob;
auto *job = new MessageQueueJob;
job->setMessage(msg);
job->transportAttribute().setTransportId(transport()->id());
// Default dispatch mode (send now).
......
......@@ -104,7 +104,7 @@ SentActionAttribute::Action::List SentActionAttribute::actions() const
SentActionAttribute *SentActionAttribute::clone() const
{
SentActionAttribute *attribute = new SentActionAttribute;
auto *attribute = new SentActionAttribute;
attribute->d->mActions = d->mActions;
return attribute;
......
......@@ -22,7 +22,7 @@ Runner::Runner()
{
Control::start();
SpecialMailCollectionsRequestJob *rjob = new SpecialMailCollectionsRequestJob(this);
auto *rjob = new SpecialMailCollectionsRequestJob(this);
rjob->requestDefaultCollection(SpecialMailCollections::Outbox);
connect(rjob, &SpecialMailCollectionsRequestJob::result, this, &Runner::checkFolders);
rjob->start();
......
......@@ -35,7 +35,7 @@ MessageQueuer::MessageQueuer()
if (!Akonadi::Control::start()) {
qFatal("Could not start Akonadi server.");
}
QVBoxLayout *vbox = new QVBoxLayout(this);
auto *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, 0, 0, 0);
mComboBox = new TransportComboBox(this);
......@@ -89,7 +89,7 @@ void MessageQueuer::sendOnDateClicked()
{
QPointer<QDialog> dialog = new QDialog(this);
auto layout = new QVBoxLayout(dialog);
QDateTimeEdit *dt = new QDateTimeEdit(dialog);
auto *dt = new QDateTimeEdit(dialog);
dt->setDateTime(QDateTime::currentDateTime());
dt->setDisplayFormat(QStringLiteral("hh:mm:ss"));
layout->addWidget(dt);
......@@ -116,7 +116,7 @@ MessageQueueJob *MessageQueuer::createQueueJob()
msg->setContent(QByteArray("\n") + mMailEdit->document()->toPlainText().toLatin1());
qDebug() << "msg:" << msg->encodedContent(true);
MessageQueueJob *job = new MessageQueueJob();
auto *job = new MessageQueueJob();
job->setMessage(msg);
job->transportAttribute().setTransportId(mComboBox->currentTransportId());
// default dispatch mode
......@@ -144,7 +144,7 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
app.setApplicationName(QStringLiteral("messagequeuer"));
MessageQueuer *t = new MessageQueuer();
auto *t = new MessageQueuer();
t->show();
app.exec();
delete t;
......
......@@ -22,7 +22,7 @@ Runner::Runner()
{
Control::start();
SpecialMailCollectionsRequestJob *rjob = new SpecialMailCollectionsRequestJob(this);
auto *rjob = new SpecialMailCollectionsRequestJob(this);
rjob->requestDefaultCollection(SpecialMailCollections::Outbox);
connect(rjob, &SpecialMailCollectionsRequestJob::result, this, &Runner::checkFolders);
rjob->start();
......
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