Commit df428756 authored by Laurent Montel's avatar Laurent Montel 😁

Clean up code

parent bbed6bc6
Pipeline #28838 passed with stage
in 21 minutes and 54 seconds
......@@ -12,9 +12,6 @@
AkonotesIndexer::AkonotesIndexer(const QString &path)
: AbstractIndexer()
, m_db(nullptr)
, m_doc(nullptr)
, m_termGen(nullptr)
{
try {
m_db = new Xapian::WritableDatabase(path.toUtf8().constData(), Xapian::DB_CREATE_OR_OPEN);
......
......@@ -15,7 +15,6 @@
CalendarIndexer::CalendarIndexer(const QString &path)
: AbstractIndexer()
, m_db(nullptr)
{
try {
m_db = new Akonadi::Search::XapianDatabase(path, true);
......
......@@ -41,8 +41,7 @@ CollectionIndexer::~CollectionIndexer()
static QByteArray getPath(const Akonadi::Collection &collection)
{
QStringList pathParts;
pathParts << collection.displayName();
QStringList pathParts = {collection.displayName()};
Akonadi::Collection col = collection;
while (col.parentCollection().isValid() && (col.parentCollection() != Akonadi::Collection::root())) {
col = col.parentCollection();
......
......@@ -22,9 +22,6 @@ CollectionIndexingJob::CollectionIndexingJob(Index &index, const Akonadi::Collec
, m_collection(col)
, m_pending(pending)
, m_index(index)
, m_reindexingLock(false)
, m_fullSync(true)
, m_progressTotal(0)
{
}
......
......@@ -49,10 +49,10 @@ private:
QList<Akonadi::Item::Id> m_needsIndexing;
Index &m_index;
QElapsedTimer m_time;
bool m_reindexingLock;
bool m_fullSync;
int m_progressCounter;
int m_progressTotal;
bool m_reindexingLock = false;
bool m_fullSync = true;
int m_progressCounter = 0;
int m_progressTotal = 0;
};
#endif
......@@ -16,7 +16,6 @@
ContactIndexer::ContactIndexer(const QString &path)
: AbstractIndexer()
, m_db(nullptr)
{
try {
m_db = new Akonadi::Search::XapianDatabase(path, true);
......
......@@ -16,9 +16,6 @@
EmailIndexer::EmailIndexer(const QString &path, const QString &contactDbPath)
: AbstractIndexer()
, m_doc(nullptr)
, m_termGen(nullptr)
, m_contactDb(nullptr)
{
try {
m_db = new Xapian::WritableDatabase(path.toUtf8().constData(), Xapian::DB_CREATE_OR_OPEN);
......
......@@ -22,7 +22,6 @@
using namespace Akonadi::Search::PIM;
Index::Index(QObject *parent)
: QObject(parent)
, m_collectionIndexer(nullptr)
{
m_indexedItems = new IndexedItems(this);
m_commitTimer.setInterval(1000);
......
......@@ -33,7 +33,6 @@ Scheduler::Scheduler(Index &index, const KSharedConfigPtr &config, const QShared
: QObject(parent)
, m_config(config)
, m_index(index)
, m_currentJob(nullptr)
, m_jobFactory(jobFactory)
, m_busyTimeout(5000)
{
......
......@@ -10,7 +10,7 @@
#include "collectionquery.h"
#include "resultiterator_p.h"
#include "akonadi_search_pim_debug.h"
#include <QList>
#include <QFile>
......@@ -82,7 +82,7 @@ ResultIterator CollectionQuery::exec()
try {
db = Xapian::Database(QFile::encodeName(d->databaseDir).constData());
} catch (const Xapian::DatabaseError &e) {
qWarning() << "Failed to open Xapian database:" << d->databaseDir
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Failed to open Xapian database:" << d->databaseDir
<< "; error:" << QString::fromStdString(e.get_error_string());
return ResultIterator();
}
......
......@@ -97,16 +97,16 @@ ResultIterator ContactQuery::exec()
try {
db = Xapian::Database(QFile::encodeName(dir).constData());
} catch (const Xapian::DatabaseOpeningError &) {
qWarning() << "Xapian Database does not exist at " << dir;
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database does not exist at " << dir;
return ResultIterator();
} catch (const Xapian::DatabaseCorruptError &) {
qWarning() << "Xapian Database corrupted";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database corrupted";
return ResultIterator();
} catch (const Xapian::DatabaseError &e) {
qWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
return ResultIterator();
} catch (...) {
qWarning() << "Random exception, but we do not want to crash";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Random exception, but we do not want to crash";
return ResultIterator();
}
......@@ -194,7 +194,7 @@ ResultIterator ContactQuery::exec()
iter.d->init(matches);
return iter;
} catch (const Xapian::Error &e) {
qWarning() << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
qCWarning(AKONADI_SEARCH_PIM_LOG) << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
return ResultIterator();
}
}
......@@ -11,6 +11,7 @@
#include "emailquery.h"
#include "resultiterator_p.h"
#include "../search/email/agepostingsource.h"
#include "akonadi_search_pim_debug.h"
#include <QStandardPaths>
#include <QRegularExpression>
......@@ -39,18 +40,15 @@ public:
QString subjectMatchString;
QString bodyMatchString;
EmailQuery::OpType opType;
int limit;
bool splitSearchMatchString;
EmailQuery::OpType opType = EmailQuery::OpAnd;
int limit = 0;
bool splitSearchMatchString = true;
};
EmailQuery::Private::Private()
: important('0')
, read('0')
, attachment('0')
, opType(OpAnd)
, limit(0)
, splitSearchMatchString(true)
{
}
......@@ -182,16 +180,16 @@ ResultIterator EmailQuery::exec()
try {
db = Xapian::Database(QFile::encodeName(dir).constData());
} catch (const Xapian::DatabaseOpeningError &) {
qWarning() << "Xapian Database does not exist at " << dir;
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database does not exist at " << dir;
return ResultIterator();
} catch (const Xapian::DatabaseCorruptError &) {
qWarning() << "Xapian Database corrupted";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database corrupted";
return ResultIterator();
} catch (const Xapian::DatabaseError &e) {
qWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_description());
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Failed to open Xapian database:" << QString::fromStdString(e.get_description());
return ResultIterator();
} catch (...) {
qWarning() << "Random exception, but we do not want to crash";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Random exception, but we do not want to crash";
return ResultIterator();
}
......@@ -350,7 +348,7 @@ ResultIterator EmailQuery::exec()
iter.d->init(mset);
return iter;
} catch (const Xapian::Error &e) {
qWarning() << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
qCWarning(AKONADI_SEARCH_PIM_LOG) << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
return ResultIterator();
}
}
......@@ -25,18 +25,18 @@ public:
{
}
QString dbPath(const QString &dbName) const;
QString emailIndexingPath() const;
QString collectionIndexingPath() const;
QString calendarIndexingPath() const;
QString akonotesIndexingPath() const;
QString emailContactsIndexingPath() const;
QString contactIndexingPath() const;
Q_REQUIRED_RESULT QString dbPath(const QString &dbName) const;
Q_REQUIRED_RESULT QString emailIndexingPath() const;
Q_REQUIRED_RESULT QString collectionIndexingPath() const;
Q_REQUIRED_RESULT QString calendarIndexingPath() const;
Q_REQUIRED_RESULT QString akonotesIndexingPath() const;
Q_REQUIRED_RESULT QString emailContactsIndexingPath() const;
Q_REQUIRED_RESULT QString contactIndexingPath() const;
mutable QHash<QString, QString> m_cachePath;
QString m_overridePrefixPath;
qlonglong indexedItems(const qlonglong id);
qlonglong indexedItemsInDatabase(const std::string &term, const QString &dbPath) const;
Q_REQUIRED_RESULT qlonglong indexedItems(const qlonglong id);
Q_REQUIRED_RESULT qlonglong indexedItemsInDatabase(const std::string &term, const QString &dbPath) const;
void findIndexedInDatabase(QSet<Akonadi::Item::Id> &indexed, Akonadi::Collection::Id collectionId, const QString &dbPath);
void findIndexed(QSet<Akonadi::Item::Id> &indexed, Akonadi::Collection::Id collectionId);
};
......
......@@ -10,6 +10,7 @@
#include "notequery.h"
#include "resultiterator_p.h"
#include "akonadi_search_pim_debug.h"
#include <QList>
#include <QStandardPaths>
......@@ -22,13 +23,12 @@ class Q_DECL_HIDDEN NoteQuery::Private
{
public:
Private()
: limit(0)
{
}
QString title;
QString note;
int limit;
int limit = 0;
};
NoteQuery::NoteQuery()
......@@ -70,16 +70,16 @@ ResultIterator NoteQuery::exec()
try {
db = Xapian::Database(QFile::encodeName(dir).constData());
} catch (const Xapian::DatabaseOpeningError &) {
qWarning() << "Xapian Database does not exist at " << dir;
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database does not exist at " << dir;
return ResultIterator();
} catch (const Xapian::DatabaseCorruptError &) {
qWarning() << "Xapian Database corrupted";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Xapian Database corrupted";
return ResultIterator();
} catch (const Xapian::DatabaseError &e) {
qWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
return ResultIterator();
} catch (...) {
qWarning() << "Random exception, but we do not want to crash";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Random exception, but we do not want to crash";
return ResultIterator();
}
......@@ -120,7 +120,7 @@ ResultIterator NoteQuery::exec()
iter.d->init(matches);
return iter;
} catch (const Xapian::Error &e) {
qWarning() << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
qCWarning(AKONADI_SEARCH_PIM_LOG) << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description());
return ResultIterator();
}
}
......@@ -8,6 +8,7 @@
#include "query.h"
#include "contactquery.h"
#include "akonadi_search_pim_debug.h"
#include <QVariant>
#include <QDebug>
......@@ -32,14 +33,14 @@ Query *Query::fromJSON(const QByteArray &json)
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(json, &error);
if (doc.isNull()) {
qWarning() << "Could not parse json query" << error.errorString();
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Could not parse json query" << error.errorString();
return nullptr;
}
QVariantMap result = doc.toVariant().toMap();
const QString type = result[QStringLiteral("type")].toString().toLower();
if (type != QLatin1String("contact")) {
qWarning() << "Can only handle contact queries";
qCWarning(AKONADI_SEARCH_PIM_LOG) << "Can only handle contact queries";
return nullptr;
}
......
......@@ -35,7 +35,6 @@ Q_DECLARE_METATYPE(KContacts::Addressee *)
PIMContactsRunner::PIMContactsRunner(QObject *parent, const QVariantList &args)
: Plasma::AbstractRunner(parent, args)
, mQueryAutocompleter(true)
{
setObjectName(QStringLiteral("PIMContactsRunner"));
setSpeed(Plasma::AbstractRunner::SlowSpeed);
......
......@@ -30,7 +30,7 @@ private:
void queryAutocompleter(Plasma::RunnerContext &context, const QString &queryString);
private:
bool mQueryAutocompleter;
bool mQueryAutocompleter = true;
};
#endif // PIMCONTACTSRUNNER_H
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