File indexing completed on 2025-01-05 04:49:49

0001 /*
0002  * SPDX-FileCopyrightText: 2016 Daniel Vrátil <dvratil@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  */
0007 
0008 #pragma once
0009 
0010 #include <CalendarEvents/CalendarEventsPlugin>
0011 #include <KCalendarCore/Calendar>
0012 
0013 namespace Akonadi
0014 {
0015 class ETMCalendar;
0016 }
0017 
0018 class PimDataSource;
0019 class PimEventsPlugin : public CalendarEvents::CalendarEventsPlugin, public KCalendarCore::Calendar::CalendarObserver
0020 {
0021     Q_OBJECT
0022     Q_INTERFACES(CalendarEvents::CalendarEventsPlugin)
0023     Q_PLUGIN_METADATA(IID "org.kde.CalendarEventsPlugin" FILE "pimeventsplugin.json")
0024 
0025 public:
0026     explicit PimEventsPlugin(QObject *parent = nullptr);
0027     explicit PimEventsPlugin(PimDataSource *factory, QObject *parent = nullptr);
0028     ~PimEventsPlugin() override;
0029 
0030     // CalendarEvents::CalendarEventsPlugin
0031     void loadEventsForDateRange(const QDate &startDate, const QDate &endDate) override;
0032 
0033     // KCalendarCore::Calendar::CalendarObserver
0034     void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) override;
0035     void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) override;
0036     // Handle removal before it really happens otherwise we would not be able
0037     // to lookup corresponding Akonadi ID in ETMCalendar
0038     void calendarIncidenceAboutToBeDeleted(const KCalendarCore::Incidence::Ptr &incidence) override;
0039 
0040 private:
0041     PimDataSource *const mDataSource;
0042     QDate mStart;
0043     QDate mEnd;
0044 };