Commit 0724ad04 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code (using auto/using/etc)

parent 4b5220d1
Pipeline #39372 passed with stage
in 19 minutes and 26 seconds
......@@ -256,7 +256,7 @@ void AkonadiIndexingAgent::collectionChanged(const Akonadi::Collection &collecti
if (changes.contains("ENTITYDISPLAY")) {
//If the name changed we have to reindex all subcollections
CollectionUpdateJob *job = new CollectionUpdateJob(m_index, collection, this);
auto *job = new CollectionUpdateJob(m_index, collection, this);
job->start();
} else {
m_index.index(collection);
......@@ -283,7 +283,7 @@ void AkonadiIndexingAgent::collectionMoved(const Akonadi::Collection &collection
}
m_index.remove(collection);
CollectionUpdateJob *job = new CollectionUpdateJob(m_index, collection, this);
auto *job = new CollectionUpdateJob(m_index, collection, this);
job->start();
}
......
......@@ -95,7 +95,7 @@ private Q_SLOTS:
Akonadi::Search::Query query(term);
query.setType(QStringLiteral("Email"));
Akonadi::Search::EmailSearchStore *emailSearchStore = new Akonadi::Search::EmailSearchStore(this);
auto *emailSearchStore = new Akonadi::Search::EmailSearchStore(this);
emailSearchStore->setDbPath(emailDir);
int res = emailSearchStore->exec(query);
qDebug() << res;
......
......@@ -78,7 +78,7 @@ void CollectionIndexer::index(const Akonadi::Collection &collection)
doc.add_boolean_term(term.constData());
QByteArray ns;
if (const Akonadi::CollectionIdentificationAttribute *folderAttribute = collection.attribute<Akonadi::CollectionIdentificationAttribute>()) {
if (const auto *folderAttribute = collection.attribute<Akonadi::CollectionIdentificationAttribute>()) {
if (!folderAttribute->collectionNamespace().isEmpty()) {
ns = folderAttribute->collectionNamespace();
}
......
......@@ -36,7 +36,7 @@ void CollectionIndexingJob::start()
m_time.start();
//Fetch collection for statistics
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(m_collection, Akonadi::CollectionFetchJob::Base);
auto *job = new Akonadi::CollectionFetchJob(m_collection, Akonadi::CollectionFetchJob::Base);
job->fetchScope().setIncludeStatistics(true);
job->fetchScope().setListFilter(Akonadi::CollectionFetchScope::NoFilter);
job->fetchScope().fetchAttribute<Akonadi::IndexPolicyAttribute>();
......@@ -90,7 +90,7 @@ void CollectionIndexingJob::indexItems(const QList<Akonadi::Item::Id> &itemIds)
items << Akonadi::Item(id);
}
Akonadi::ItemFetchJob *fetchJob = new Akonadi::ItemFetchJob(items);
auto *fetchJob = new Akonadi::ItemFetchJob(items);
fetchJob->fetchScope().fetchFullPayload(true);
fetchJob->fetchScope().setCacheOnly(true);
fetchJob->fetchScope().setIgnoreRetrievalErrors(true);
......@@ -166,7 +166,7 @@ void CollectionIndexingJob::findUnindexed()
m_index.findIndexed(m_indexedItems, m_collection.id());
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Found " << m_indexedItems.size() << " indexed items. Took (ms): " << m_time.elapsed() - start << " collection id :" << m_collection.id();
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(m_collection, this);
auto *job = new Akonadi::ItemFetchJob(m_collection, this);
job->fetchScope().fetchFullPayload(false);
job->fetchScope().setCacheOnly(true);
job->fetchScope().setIgnoreRetrievalErrors(true);
......
......@@ -26,7 +26,7 @@ void CollectionUpdateJob::start()
}
//Fetch children to update the path accordingly
Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(mCol, Akonadi::CollectionFetchJob::Recursive, this);
auto *fetchJob = new Akonadi::CollectionFetchJob(mCol, Akonadi::CollectionFetchJob::Recursive, this);
fetchJob->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
fetchJob->fetchScope().ancestorFetchScope().fetchAttribute<Akonadi::EntityDisplayAttribute>();
fetchJob->fetchScope().setListFilter(Akonadi::CollectionFetchScope::NoFilter);
......
......@@ -24,7 +24,7 @@ JobFactory::~JobFactory()
CollectionIndexingJob *JobFactory::createCollectionIndexingJob(Index &index, const Akonadi::Collection &col, const QList<Akonadi::Item::Id> &pending, bool fullSync, QObject *parent)
{
CollectionIndexingJob *job = new CollectionIndexingJob(index, col, pending, parent);
auto *job = new CollectionIndexingJob(index, col, pending, parent);
job->setFullSync(fullSync);
return job;
}
......@@ -167,7 +167,7 @@ void Scheduler::scheduleCompleteSync()
void Scheduler::slotRootCollectionsFetched(KJob *kjob)
{
Akonadi::CollectionFetchJob *cjob = static_cast<Akonadi::CollectionFetchJob *>(kjob);
auto *cjob = static_cast<Akonadi::CollectionFetchJob *>(kjob);
const Akonadi::Collection::List lstCols = cjob->collections();
for (const Akonadi::Collection &c : lstCols) {
//For skipping search collections
......@@ -193,7 +193,7 @@ void Scheduler::slotRootCollectionsFetched(KJob *kjob)
void Scheduler::slotCollectionsToIndexFetched(KJob *kjob)
{
Akonadi::CollectionFetchJob *cjob = static_cast<Akonadi::CollectionFetchJob *>(kjob);
auto *cjob = static_cast<Akonadi::CollectionFetchJob *>(kjob);
const Akonadi::Collection::List lstCols = cjob->collections();
for (const Akonadi::Collection &c : lstCols) {
//For skipping search collections
......@@ -261,7 +261,7 @@ void Scheduler::slotIndexingFinished(KJob *job)
if (job->error()) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << "Indexing failed: " << job->errorString();
} else {
const Akonadi::Collection::Id collectionId = job->property("collection").value<Akonadi::Collection::Id>();
const auto collectionId = job->property("collection").value<Akonadi::Collection::Id>();
m_dirtyCollections.remove(collectionId);
Q_EMIT status(Akonadi::AgentBase::Idle, i18n("Collection \"%1\" indexed", collectionId));
Q_EMIT collectionIndexingFinished(collectionId);
......
......@@ -77,7 +77,7 @@ void App::main()
void App::slotRootCollectionsFetched(KJob *kjob)
{
Akonadi::CollectionFetchJob *job = qobject_cast<Akonadi::CollectionFetchJob *>(kjob);
auto *job = qobject_cast<Akonadi::CollectionFetchJob *>(kjob);
m_collections = job->collections();
QMutableVectorIterator<Akonadi::Collection> it(m_collections);
......
......@@ -107,7 +107,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("subject2");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("body2");
msg->addContent(b, true);
......@@ -131,7 +131,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("subject3");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("body3");
msg->addContent(b, true);
......@@ -155,7 +155,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("subject4");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("body4");
msg->addContent(b, true);
......@@ -166,7 +166,7 @@ private Q_SLOTS:
msg->bcc()->addAddress("bcc@test.com", QStringLiteral("Jane Doe"));
msg->date()->setDateTime(QDateTime(QDate(2014, 11, 11), QTime(13, 0, 0)));
msg->replyTo()->from7BitString("test@kde.org");
KMime::Headers::Generic *header = new KMime::Headers::Generic("Resent-From");
auto *header = new KMime::Headers::Generic("Resent-From");
header->fromUnicodeString(QStringLiteral("resent@kde.org"), "utf-8");
msg->setHeader(header);
header = new KMime::Headers::Generic("List-Id");
......@@ -188,7 +188,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("all tags");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("tags");
msg->addContent(b, true);
......@@ -227,7 +227,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("Change in qt/qtx11extras[stable]: remove QtWidgets dependency");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("body5");
msg->addContent(b, true);
......@@ -340,7 +340,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("note");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("body note");
msg->addContent(b, true);
......@@ -359,7 +359,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("note2");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("note");
msg->addContent(b, true);
......@@ -378,7 +378,7 @@ private Q_SLOTS:
msg->subject()->from7BitString("note3");
//Multipart message
KMime::Content *b = new KMime::Content;
auto *b = new KMime::Content;
b->contentType()->setMimeType("text/plain");
b->setBody("note3");
msg->addContent(b, true);
......@@ -419,13 +419,13 @@ private Q_SLOTS:
}
calendarIndexer.commit();
Akonadi::Search::EmailSearchStore *emailSearchStore = new Akonadi::Search::EmailSearchStore();
auto *emailSearchStore = new Akonadi::Search::EmailSearchStore();
emailSearchStore->setDbPath(emailDir);
Akonadi::Search::ContactSearchStore *contactSearchStore = new Akonadi::Search::ContactSearchStore();
auto *contactSearchStore = new Akonadi::Search::ContactSearchStore();
contactSearchStore->setDbPath(contactsDir);
Akonadi::Search::NoteSearchStore *noteSearchStore = new Akonadi::Search::NoteSearchStore();
auto *noteSearchStore = new Akonadi::Search::NoteSearchStore();
noteSearchStore->setDbPath(noteDir);
Akonadi::Search::CalendarSearchStore *calendarSearchStore = new Akonadi::Search::CalendarSearchStore();
auto *calendarSearchStore = new Akonadi::Search::CalendarSearchStore();
calendarSearchStore->setDbPath(calendarDir);
Akonadi::Search::SearchStore::overrideSearchStores(QList<Akonadi::Search::SearchStore *>() << emailSearchStore << contactSearchStore << noteSearchStore << calendarSearchStore);
......
......@@ -34,7 +34,7 @@ public:
*/
static void overrideSearchStores(const QList<SearchStore *> &overrideSearchStores);
typedef QList< QSharedPointer<SearchStore> > List;
using List = QList<QSharedPointer<SearchStore> >;
/**
* Gives a list of available search stores. These stores must be managed and
......
......@@ -34,9 +34,9 @@ AkonadiSearchDebugDialog::AkonadiSearchDebugDialog(QWidget *parent)
//Don't translate it's just a dialog to debug
setWindowTitle(QStringLiteral("Debug Akonadi Search"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
QPushButton *user1Button = new QPushButton;
auto *user1Button = new QPushButton;
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
//Don't translate it.
user1Button->setText(QStringLiteral("Save As..."));
......
......@@ -20,9 +20,9 @@ using namespace Akonadi::Search;
AkonadiSearchDebugWidget::AkonadiSearchDebugWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QHBoxLayout *hbox = new QHBoxLayout;
auto *hbox = new QHBoxLayout;
mainLayout->addLayout(hbox);
QLabel *lab = new QLabel(QStringLiteral("Item identifier:"), this);
hbox->addWidget(lab);
......@@ -87,7 +87,7 @@ void AkonadiSearchDebugWidget::slotSearch()
if (searchId.isEmpty()) {
return;
}
Akonadi::Search::AkonadiSearchDebugSearchJob *job = new Akonadi::Search::AkonadiSearchDebugSearchJob(this);
auto *job = new Akonadi::Search::AkonadiSearchDebugSearchJob(this);
job->setAkonadiId(searchId);
job->setSearchPath(mSearchPathComboBox->searchPath());
connect(job, &Akonadi::Search::AkonadiSearchDebugSearchJob::result, this, &AkonadiSearchDebugWidget::slotResult);
......
......@@ -29,11 +29,11 @@ void AkonadiSearchDebugDialogTest::initTestCase()
void AkonadiSearchDebugDialogTest::shouldHaveDefaultValue()
{
Akonadi::Search::AkonadiSearchDebugDialog dlg;
Akonadi::Search::AkonadiSearchDebugWidget *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
auto *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
QPlainTextEdit *editorWidget = debugWidget->findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
auto *editorWidget = debugWidget->findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
QVERIFY(editorWidget);
KLineEdit *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
auto *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(lineEdit);
QVERIFY(lineEdit->text().isEmpty());
}
......@@ -41,9 +41,9 @@ void AkonadiSearchDebugDialogTest::shouldHaveDefaultValue()
void AkonadiSearchDebugDialogTest::shouldFillLineEditWhenWeWantToSearchItem()
{
Akonadi::Search::AkonadiSearchDebugDialog dlg;
Akonadi::Search::AkonadiSearchDebugWidget *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
auto *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
KLineEdit *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
auto *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(lineEdit);
const int value = 42;
const QString akonadiItem = QString::number(value);
......
......@@ -24,26 +24,26 @@ AkonadiSearchDebugWidgetTest::~AkonadiSearchDebugWidgetTest()
void AkonadiSearchDebugWidgetTest::shouldHaveDefaultValue()
{
Akonadi::Search::AkonadiSearchDebugWidget widget;
QPushButton *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
auto *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
QVERIFY(button);
QVERIFY(!button->isEnabled());
KLineEdit *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
auto *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(lineEdit);
QVERIFY(lineEdit->text().isEmpty());
QVERIFY(lineEdit->trapReturnKey());
QVERIFY(lineEdit->isClearButtonEnabled());
QPlainTextEdit *editorWidget = widget.findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
auto *editorWidget = widget.findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
QVERIFY(editorWidget->isReadOnly());
QVERIFY(editorWidget);
QVERIFY(editorWidget->toPlainText().isEmpty());
Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *searchCombo = widget.findChild<Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *>(QStringLiteral("searchpathcombo"));
auto *searchCombo = widget.findChild<Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *>(QStringLiteral("searchpathcombo"));
QVERIFY(searchCombo);
}
void AkonadiSearchDebugWidgetTest::shouldFillLineEditWhenWeWantToSearchItem()
{
Akonadi::Search::AkonadiSearchDebugWidget widget;
KLineEdit *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
auto *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
const int value = 42;
const QString akonadiItem = QString::number(value);
widget.setAkonadiId(value);
......@@ -55,10 +55,10 @@ void AkonadiSearchDebugWidgetTest::shouldEnabledPushButtonWhenLineEditIsNotEmpty
Akonadi::Search::AkonadiSearchDebugWidget widget;
const int value = 42;
widget.setAkonadiId(value);
QPushButton *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
auto *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
QVERIFY(button->isEnabled());
KLineEdit *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
auto *lineEdit = widget.findChild<KLineEdit *>(QStringLiteral("lineedit"));
lineEdit->setText(QString());
QVERIFY(!button->isEnabled());
......@@ -72,7 +72,7 @@ void AkonadiSearchDebugWidgetTest::shouldChangeSearchType()
Akonadi::Search::AkonadiSearchDebugWidget widget;
Akonadi::Search::AkonadiSearchDebugSearchPathComboBox::SearchType type = Akonadi::Search::AkonadiSearchDebugSearchPathComboBox::Emails;
widget.setSearchType(type);
Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *searchCombo = widget.findChild<Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *>(QStringLiteral("searchpathcombo"));
auto *searchCombo = widget.findChild<Akonadi::Search::AkonadiSearchDebugSearchPathComboBox *>(QStringLiteral("searchpathcombo"));
const QString path = searchCombo->pathFromEnum(type);
QCOMPARE(searchCombo->searchPath(), path);
}
......
......@@ -20,7 +20,7 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.process(app);
Akonadi::Search::AkonadiSearchDebugDialog *dlg = new Akonadi::Search::AkonadiSearchDebugDialog();
auto *dlg = new Akonadi::Search::AkonadiSearchDebugDialog();
dlg->resize(800, 600);
dlg->show();
app.exec();
......
......@@ -44,7 +44,7 @@ Query *Query::fromJSON(const QByteArray &json)
return nullptr;
}
ContactQuery *cq = new ContactQuery();
auto *cq = new ContactQuery();
cq->matchName(result[QStringLiteral("name")].toString());
cq->matchNickname(result[QStringLiteral("nick")].toString());
cq->matchEmail(result[QStringLiteral("email")].toString());
......
......@@ -70,7 +70,7 @@ void App::main()
return;
}
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(m_akonadiIds);
auto *job = new Akonadi::ItemFetchJob(m_akonadiIds);
job->fetchScope().fetchFullPayload(true);
connect(job, &Akonadi::ItemFetchJob::itemsReceived,
......
......@@ -93,7 +93,7 @@ void PIMContactsRunner::queryContacts(Plasma::RunnerContext &context, const QStr
// a separate Session for each, otherwise things might explode
QScopedPointer<Akonadi::Session, QScopedPointerDeleteLater> session(
new Akonadi::Session("PIIMContactRunner-" + QByteArray::number((qlonglong)QThread::currentThread())));
Akonadi::ItemFetchJob *fetch = new Akonadi::ItemFetchJob(results, session.data());
auto *fetch = new Akonadi::ItemFetchJob(results, session.data());
Akonadi::ItemFetchScope &scope = fetch->fetchScope();
scope.fetchFullPayload(true);
scope.setFetchRemoteIdentification(false);
......
......@@ -20,7 +20,7 @@ K_PLUGIN_FACTORY(PIMContactsRunnerConfigFactory,
PIMContactsRunnerConfig::PIMContactsRunnerConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
auto *vbox = new QVBoxLayout(this);
mQueryCompletionCheckBox = new QCheckBox(i18n("Search in contacts indexed from sent and received emails too"), this);
connect(mQueryCompletionCheckBox, &QCheckBox::stateChanged,
......
......@@ -116,7 +116,7 @@ int XapianSearchStore::exec(const Query &query)
return 0;
}
while (1) {
while (true) {
try {
QMutexLocker lock(&m_mutex);
try {
......
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