Commit 3364444c authored by Laurent Montel's avatar Laurent Montel 😁

Use new Akonadi::Search::PIM::IndexedItems

parent 6587747f
......@@ -300,6 +300,7 @@ target_link_libraries(kmailprivate
KF5::Completion
KF5::Ldap
KF5::AkonadiSearchDebug
KF5::AkonadiSearchPIM
KF5::WebEngineViewer
)
target_include_directories(kmailprivate PUBLIC $<TARGET_PROPERTY:KF5::MessageList,INTERFACE_INCLUDE_DIRECTORIES>)
......
......@@ -19,6 +19,7 @@
#include "checkindexingjob.h"
#include "kmail_debug.h"
#include <AkonadiSearch/PIM/indexeditems.h>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
......@@ -29,8 +30,9 @@
#include <QDBusInterface>
#include <QDebug>
CheckIndexingJob::CheckIndexingJob(QObject *parent)
: QObject(parent)
CheckIndexingJob::CheckIndexingJob(Akonadi::Search::PIM::IndexedItems *indexedItems, QObject *parent)
: QObject(parent),
mIndexedItems(indexedItems)
{
}
......@@ -75,23 +77,9 @@ void CheckIndexingJob::slotCollectionPropertiesFinished(KJob *job)
}
mCollection = fetch->collections().first();
PimCommon::CollectionIndexStatusJob *indexerJob = new PimCommon::CollectionIndexStatusJob(Akonadi::Collection::List() << mCollection, this);
connect(indexerJob, &PimCommon::CollectionIndexStatusJob::finished, this, &CheckIndexingJob::indexerStatsFetchFinished);
indexerJob->start();
}
void CheckIndexingJob::indexerStatsFetchFinished(KJob* job)
{
if (job->error()) {
qCWarning(KMAIL_LOG) << "CheckIndexingJob::indexerStatsFetchFinished error :" << job->errorString();
askForNextCheck(-1);
return;
}
QMap<qint64, qint64> stats = qobject_cast<PimCommon::CollectionIndexStatusJob*>(job)->resultStats();
//qDebug()<<" stats "<< stats;
qCDebug(KMAIL_LOG) << " mCollection.statistics().count() "<< mCollection.statistics().count() << "stats.value(mCollection.id())" << stats.value(mCollection.id());
if (mCollection.statistics().count() != stats.value(mCollection.id())) {
const qlonglong result = mIndexedItems->indexedItems(mCollection.id());
qCDebug(KMAIL_LOG) << " mCollection.statistics().count() "<< mCollection.statistics().count() << "stats.value(mCollection.id())" << result;
if (mCollection.statistics().count() != result) {
QDBusInterface interfaceBalooIndexer(PimCommon::indexerServiceName(), QStringLiteral("/"), QStringLiteral("org.freedesktop.Akonadi.Indexer"));
if (interfaceBalooIndexer.isValid()) {
qCDebug(KMAIL_LOG) << "Reindex collection :"<< mCollection.id() << "name :"<< mCollection.name();
......
......@@ -22,12 +22,22 @@
#include <QObject>
#include <AkonadiCore/Collection>
namespace Akonadi
{
namespace Search
{
namespace PIM
{
class IndexedItems;
}
}
}
class KJob;
class CheckIndexingJob : public QObject
{
Q_OBJECT
public:
explicit CheckIndexingJob(QObject *parent = Q_NULLPTR);
explicit CheckIndexingJob(Akonadi::Search::PIM::IndexedItems *indexedItems, QObject *parent = Q_NULLPTR);
~CheckIndexingJob();
void setCollection(const Akonadi::Collection &col);
......@@ -39,10 +49,10 @@ Q_SIGNALS:
private Q_SLOTS:
void slotCollectionPropertiesFinished(KJob *job);
void indexerStatsFetchFinished(KJob *job);
private:
void askForNextCheck(quint64 id);
Akonadi::Collection mCollection;
Akonadi::Search::PIM::IndexedItems *mIndexedItems;
};
#endif // CHECKINDEXINGJOB_H
......@@ -27,11 +27,13 @@
#include <KConfigGroup>
#include <MailCommon/MailUtil>
#include <PimCommon/PimUtil>
#include <AkonadiSearch/PIM/indexeditems.h>
#include <QTimer>
#include <AkonadiCore/entityhiddenattribute.h>
CheckIndexingManager::CheckIndexingManager(QObject *parent)
: QObject(parent),
mIndexedItems(new Akonadi::Search::PIM::IndexedItems(this)),
mIndex(0),
mIsReady(true)
{
......@@ -74,7 +76,7 @@ void CheckIndexingManager::start(QAbstractItemModel *collectionModel)
void CheckIndexingManager::createJob()
{
CheckIndexingJob *job = new CheckIndexingJob(this);
CheckIndexingJob *job = new CheckIndexingJob(mIndexedItems, this);
job->setCollection(mListCollection.at(mIndex));
connect(job, &CheckIndexingJob::finished, this, &CheckIndexingManager::indexingFinished);
job->start();
......
......@@ -23,6 +23,16 @@
#include <QObject>
#include <AkonadiCore/Collection>
#include <QAbstractItemModel>
namespace Akonadi
{
namespace Search
{
namespace PIM
{
class IndexedItems;
}
}
}
class QTimer;
class CheckIndexingManager : public QObject
{
......@@ -41,6 +51,7 @@ private:
void initializeCollectionList(QAbstractItemModel *model, const QModelIndex &parentIndex = QModelIndex());
void createJob();
Akonadi::Search::PIM::IndexedItems *mIndexedItems;
Akonadi::Collection::List mListCollection;
QTimer *mTimer;
QList<qint64> mCollectionsIndexed;
......
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