File indexing completed on 2024-11-17 04:44:42
0001 /* 0002 SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org> 0003 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <KCalendarCore/Event> 0011 0012 #include <Akonadi/ResourceBase> 0013 0014 #include <QHash> 0015 0016 namespace KContacts 0017 { 0018 class Addressee; 0019 } 0020 0021 class QDate; 0022 0023 class BirthdaysResource : public Akonadi::ResourceBase, public Akonadi::AgentBase::Observer 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 explicit BirthdaysResource(const QString &id); 0029 ~BirthdaysResource() override; 0030 0031 protected: 0032 using ResourceBase::retrieveItems; // Suppress -Woverload-virtual 0033 0034 protected: 0035 void retrieveCollections() override; 0036 void retrieveItems(const Akonadi::Collection &collection) override; 0037 bool retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts) override; 0038 bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) override; 0039 0040 private: 0041 void addPendingEvent(const KCalendarCore::Event::Ptr &event, const QString &remoteId); 0042 void checkForUnknownCategories(const QString &categoryToCheck, KCalendarCore::Event::Ptr &event); 0043 0044 [[nodiscard]] KCalendarCore::Event::Ptr createBirthday(const KContacts::Addressee &contact, Akonadi::Item::Id itemId); 0045 [[nodiscard]] KCalendarCore::Event::Ptr createAnniversary(const KContacts::Addressee &contact, Akonadi::Item::Id itemId); 0046 [[nodiscard]] KCalendarCore::Event::Ptr createEvent(QDate date); 0047 0048 private Q_SLOTS: 0049 void doFullSearch(); 0050 void listContacts(const Akonadi::Collection::List &cols); 0051 void createEvents(const Akonadi::Item::List &items); 0052 0053 void contactChanged(const Akonadi::Item &item); 0054 void contactRemoved(const Akonadi::Item &item); 0055 0056 void contactRetrieved(KJob *job); 0057 void contactsRetrieved(KJob *job); 0058 0059 private: 0060 void slotReloadConfig(); 0061 QHash<QString, Akonadi::Item> mPendingItems; 0062 QHash<QString, Akonadi::Item> mDeletedItems; 0063 };