File indexing completed on 2024-05-12 05:11:15
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 * 0006 */ 0007 #pragma once 0008 0009 #include "index.h" 0010 #include <Akonadi/Collection> 0011 #include <Akonadi/Item> 0012 #include <KJob> 0013 #include <QElapsedTimer> 0014 0015 /** 0016 * Indexing Job that ensure a collections is fully indexed. 0017 * The following steps are required to bring the index up-to date: 0018 * 1. Index pending items 0019 * 2. Check if indexed item == local items (optimization) 0020 * 3. Make a full diff if necessary 0021 */ 0022 class CollectionIndexingJob : public KJob 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit CollectionIndexingJob(Index &index, const Akonadi::Collection &col, const QList<Akonadi::Item::Id> &pending, QObject *parent = nullptr); 0027 void setFullSync(bool); 0028 void start() override; 0029 0030 Q_SIGNALS: 0031 void status(int, const QString &); 0032 void percent(int); 0033 0034 private Q_SLOTS: 0035 void slotOnCollectionFetched(KJob *); 0036 void slotPendingItemsReceived(const Akonadi::Item::List &items); 0037 void slotPendingIndexed(KJob *); 0038 void slotUnindexedItemsReceived(const Akonadi::Item::List &items); 0039 void slotFoundUnindexed(KJob *); 0040 0041 private: 0042 void findUnindexed(); 0043 void indexItems(const QList<Akonadi::Item::Id> &itemIds); 0044 0045 Akonadi::Collection m_collection; 0046 QList<Akonadi::Item::Id> m_pending; 0047 QSet<Akonadi::Item::Id> m_indexedItems; 0048 QList<Akonadi::Item::Id> m_needsIndexing; 0049 Index &m_index; 0050 QElapsedTimer m_time; 0051 bool m_reindexingLock = false; 0052 bool m_fullSync = true; 0053 int m_progressCounter = 0; 0054 int m_progressTotal = 0; 0055 };