Commit 19e7d802 authored by Laurent Montel's avatar Laurent Montel 😁

Use Akonadi::Search::PIM::IndexedItems to avoid to use dbus call

parent 1063c124
......@@ -83,7 +83,7 @@ find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5SendLater ${KDEPIM_APPS_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5AkonadiSearch "5.2.40" CONFIG REQUIRED)
find_package(KF5AkonadiSearch "5.2.41" CONFIG REQUIRED)
set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi")
option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE)
......
......@@ -27,17 +27,19 @@
#include <AkonadiCore/entityhiddenattribute.h>
#include <AkonadiCore/cachepolicy.h>
#include <PimCommon/CollectionIndexStatusJob>
#include <PimCommon/PimUtil>
#include <QDBusInterface>
#include <KLocalizedString>
#include <AkonadiSearch/PIM/indexeditems.h>
using namespace MessageList::Core;
SearchCollectionIndexingWarning::SearchCollectionIndexingWarning(QWidget *parent)
: KMessageWidget(parent)
: KMessageWidget(parent),
mIndexedItems(new Akonadi::Search::PIM::IndexedItems(this))
{
setVisible(false);
setWordWrap(true);
......@@ -123,20 +125,7 @@ void SearchCollectionIndexingWarning::queryCollectionFetchFinished(KJob *job)
void SearchCollectionIndexingWarning::queryIndexerStatus()
{
PimCommon::CollectionIndexStatusJob *indexerJob = new PimCommon::CollectionIndexStatusJob(mCollections, this);
connect(indexerJob, &PimCommon::CollectionIndexStatusJob::finished, this, &SearchCollectionIndexingWarning::indexerStatsFetchFinished);
indexerJob->start();
}
void SearchCollectionIndexingWarning::indexerStatsFetchFinished(KJob* job)
{
if (job->error()) {
qCWarning(MESSAGELIST_LOG) << job->errorString();
return;
}
bool allFullyIndexed = true;
QMap<qint64, qint64> stats = qobject_cast<PimCommon::CollectionIndexStatusJob*>(job)->resultStats();
Q_FOREACH (const Akonadi::Collection &col, mCollections) {
if (col.hasAttribute<Akonadi::EntityHiddenAttribute>()) {
continue;
......@@ -144,9 +133,10 @@ void SearchCollectionIndexingWarning::indexerStatsFetchFinished(KJob* job)
if (PimCommon::Util::isImapResource(col.resource()) && !col.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
continue;
}
const qlonglong result = mIndexedItems->indexedItems(col.id());
qCDebug(MESSAGELIST_LOG) << "Collection:" << col.displayName() << "(" << col.id() << "), count:" << col.statistics().count() << ", index:" << stats.value(col.id());
if (col.statistics().count() != stats.value(col.id())) {
qCDebug(MESSAGELIST_LOG) << "Collection:" << col.displayName() << "(" << col.id() << "), count:" << col.statistics().count() << ", index:" << result;
if (col.statistics().count() != result) {
allFullyIndexed = false;
break;
}
......
......@@ -25,6 +25,16 @@
#include "messagelist_export.h"
class KJob;
namespace Akonadi
{
namespace Search
{
namespace PIM
{
class IndexedItems;
}
}
}
namespace Akonadi {
class CollectionFetchJob;
}
......@@ -44,7 +54,6 @@ public:
private Q_SLOTS:
void queryRootCollectionFetchFinished(KJob *job);
void queryCollectionFetchFinished(KJob *job);
void indexerStatsFetchFinished(KJob *job);
private:
Akonadi::CollectionFetchJob *fetchCollections(const Akonadi::Collection::List &cols, bool recursive);
......@@ -52,6 +61,7 @@ private:
Akonadi::Collection mCollection;
Akonadi::Collection::List mCollections;
Akonadi::Search::PIM::IndexedItems *mIndexedItems;
};
}
}
......
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