Commit 332c0dc1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 9c262e64
Pipeline #60369 passed with stage
in 15 minutes and 29 seconds
......@@ -90,7 +90,7 @@ private Q_SLOTS:
QVERIFY(agent.isValid());
agent.setIsOnline(true);
Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
auto fetchJob = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
fetchJob->exec();
const Akonadi::Collection::List lstCols = fetchJob->collections();
for (const Akonadi::Collection &col : lstCols) {
......@@ -104,7 +104,7 @@ private Q_SLOTS:
void testFullSync()
{
TestIndex index;
CollectionIndexingJob *job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
auto job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
job->setFullSync(true);
AKVERIFYEXEC(job);
QCOMPARE(index.itemsIndexed.size(), 3);
......@@ -113,7 +113,7 @@ private Q_SLOTS:
void testNoFullSync()
{
TestIndex index;
CollectionIndexingJob *job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
auto job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
job->setFullSync(false);
AKVERIFYEXEC(job);
QCOMPARE(index.itemsIndexed.size(), 0);
......@@ -122,7 +122,7 @@ private Q_SLOTS:
void testNoFullSyncWithPending()
{
TestIndex index;
CollectionIndexingJob *job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>() << 1);
auto job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>() << 1);
job->setFullSync(false);
AKVERIFYEXEC(job);
QCOMPARE(index.itemsIndexed.size(), 1);
......@@ -132,7 +132,7 @@ private Q_SLOTS:
{
TestIndex index;
index.alreadyIndexed << 1 << 2 << 3;
CollectionIndexingJob *job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
auto job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
job->setFullSync(true);
AKVERIFYEXEC(job);
QCOMPARE(index.itemsIndexed.size(), 0);
......@@ -142,7 +142,7 @@ private Q_SLOTS:
{
TestIndex index;
index.alreadyIndexed << 15 << 16 << 17;
CollectionIndexingJob *job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
auto job = new CollectionIndexingJob(index, itemCollection, QList<Akonadi::Item::Id>());
job->setFullSync(true);
AKVERIFYEXEC(job);
QCOMPARE(index.itemsIndexed.size(), 3);
......
......@@ -78,7 +78,7 @@ void CollectionIndexer::index(const Akonadi::Collection &collection)
doc.add_boolean_term(term.constData());
QByteArray ns;
if (const auto *folderAttribute = collection.attribute<Akonadi::CollectionIdentificationAttribute>()) {
if (const auto folderAttribute = collection.attribute<Akonadi::CollectionIdentificationAttribute>()) {
if (!folderAttribute->collectionNamespace().isEmpty()) {
ns = folderAttribute->collectionNamespace();
}
......
......@@ -137,7 +137,7 @@ void Scheduler::scheduleCompleteSync()
{
qCDebug(AKONADI_INDEXER_AGENT_LOG);
{
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
job->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
job->fetchScope().setListFilter(Akonadi::CollectionFetchScope::Index);
job->fetchScope().fetchAttribute<Akonadi::IndexPolicyAttribute>();
......@@ -147,7 +147,7 @@ void Scheduler::scheduleCompleteSync()
// We want to index all collections, even if we don't index their content
{
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
job->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
job->fetchScope().setListFilter(Akonadi::CollectionFetchScope::NoFilter);
job->fetchScope().setListFilter(Akonadi::CollectionFetchScope::Index);
......
......@@ -65,7 +65,7 @@ void App::main()
connect(&m_commitTimer, &QTimer::timeout, this, &App::slotCommitTimerElapsed);
m_commitTimer.start();
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive);
connect(job, &Akonadi::CollectionFetchJob::finished, this, &App::slotRootCollectionsFetched);
job->start();
......@@ -97,7 +97,7 @@ void App::slotRootCollectionsFetched(KJob *kjob)
void App::indexNextCollection()
{
Akonadi::ItemFetchJob *fetchJob = new Akonadi::ItemFetchJob(m_collections.takeFirst(), this);
auto fetchJob = new Akonadi::ItemFetchJob(m_collections.takeFirst(), this);
fetchJob->fetchScope().fetchAllAttributes(true);
fetchJob->fetchScope().fetchFullPayload(true);
fetchJob->fetchScope().setFetchModificationTime(false);
......
......@@ -35,7 +35,7 @@ AkonadiSearchDebugDialog::AkonadiSearchDebugDialog(QWidget *parent)
setWindowTitle(QStringLiteral("Debug Akonadi Search"));
auto mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
auto user1Button = new QPushButton;
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
// Don't translate it.
......
......@@ -24,7 +24,7 @@ AkonadiSearchDebugWidget::AkonadiSearchDebugWidget(QWidget *parent)
auto hbox = new QHBoxLayout;
mainLayout->addLayout(hbox);
QLabel *lab = new QLabel(QStringLiteral("Item identifier:"), this);
auto lab = new QLabel(QStringLiteral("Item identifier:"), this);
hbox->addWidget(lab);
mLineEdit = new KLineEdit(this);
mLineEdit->setTrapReturnKey(true);
......
......@@ -29,11 +29,11 @@ void AkonadiSearchDebugDialogTest::initTestCase()
void AkonadiSearchDebugDialogTest::shouldHaveDefaultValue()
{
Akonadi::Search::AkonadiSearchDebugDialog dlg;
auto *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
auto debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
auto *editorWidget = debugWidget->findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
auto editorWidget = debugWidget->findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
QVERIFY(editorWidget);
auto *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;
auto *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
auto debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
auto *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;
auto *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
auto button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
QVERIFY(button);
QVERIFY(!button->isEnabled());
auto *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());
auto *editorWidget = widget.findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
auto editorWidget = widget.findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
QVERIFY(editorWidget->isReadOnly());
QVERIFY(editorWidget);
QVERIFY(editorWidget->toPlainText().isEmpty());
auto *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;
auto *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);
auto *button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
auto button = widget.findChild<QPushButton *>(QStringLiteral("searchbutton"));
QVERIFY(button->isEnabled());
auto *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);
auto *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);
}
......
......@@ -67,7 +67,7 @@ private:
Xapian::Database *m_db = nullptr;
Xapian::WritableDatabase m_wDb;
typedef QPair<Xapian::docid, Xapian::Document> DocIdPair;
using DocIdPair = QPair<Xapian::docid, Xapian::Document>;
QVector<DocIdPair> m_docsToAdd;
QVector<uint> m_docsToRemove;
......
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