File indexing completed on 2024-11-17 04:42:38
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0005 */ 0006 0007 #pragma once 0008 0009 #include "eventviews_export.h" 0010 0011 #include <Akonadi/CollectionCalendar> 0012 #include <Akonadi/Item> 0013 #include <KCalendarCore/Incidence> 0014 0015 #include <QColor> 0016 #include <QList> 0017 0018 namespace EventViews 0019 { 0020 class AgendaView; 0021 0022 class EVENTVIEWS_EXPORT ViewCalendar 0023 { 0024 public: 0025 using Ptr = QSharedPointer<ViewCalendar>; 0026 0027 virtual ~ViewCalendar(); 0028 virtual bool isValid(const KCalendarCore::Incidence::Ptr &incidence) const = 0; 0029 virtual bool isValid(const QString &incidenceIdentifier) const = 0; 0030 virtual QString displayName(const KCalendarCore::Incidence::Ptr &incidence) const = 0; 0031 0032 virtual QColor resourceColor(const KCalendarCore::Incidence::Ptr &incidence) const = 0; 0033 virtual QString iconForIncidence(const KCalendarCore::Incidence::Ptr &incidence) const = 0; 0034 0035 virtual KCalendarCore::Calendar::Ptr getCalendar() const = 0; 0036 }; 0037 0038 class AkonadiViewCalendar : public ViewCalendar 0039 { 0040 public: 0041 using Ptr = QSharedPointer<AkonadiViewCalendar>; 0042 0043 ~AkonadiViewCalendar() override; 0044 bool isValid(const KCalendarCore::Incidence::Ptr &incidence) const override; 0045 bool isValid(const QString &incidenceIdentifier) const override; 0046 QString displayName(const KCalendarCore::Incidence::Ptr &incidence) const override; 0047 0048 QColor resourceColor(const KCalendarCore::Incidence::Ptr &incidence) const override; 0049 QString iconForIncidence(const KCalendarCore::Incidence::Ptr &incidence) const override; 0050 0051 Akonadi::Item item(const KCalendarCore::Incidence::Ptr &incidence) const; 0052 0053 KCalendarCore::Calendar::Ptr getCalendar() const override; 0054 0055 Akonadi::CollectionCalendar::Ptr mCalendar; 0056 AgendaView *mAgendaView = nullptr; 0057 }; 0058 0059 class MultiViewCalendar : public ViewCalendar 0060 { 0061 public: 0062 using Ptr = QSharedPointer<MultiViewCalendar>; 0063 0064 ~MultiViewCalendar() override; 0065 ViewCalendar::Ptr findCalendar(const KCalendarCore::Incidence::Ptr &incidence) const; 0066 ViewCalendar::Ptr findCalendar(const QString &incidenceIdentifier) const; 0067 [[nodiscard]] bool isValid(const KCalendarCore::Incidence::Ptr &incidence) const override; 0068 [[nodiscard]] bool isValid(const QString &incidenceIdentifier) const override; 0069 [[nodiscard]] QString displayName(const KCalendarCore::Incidence::Ptr &incidence) const override; 0070 0071 [[nodiscard]] QColor resourceColor(const KCalendarCore::Incidence::Ptr &incidence) const override; 0072 [[nodiscard]] QString iconForIncidence(const KCalendarCore::Incidence::Ptr &incidence) const override; 0073 0074 [[nodiscard]] Akonadi::Item item(const KCalendarCore::Incidence::Ptr &incidence) const; 0075 0076 void addCalendar(const ViewCalendar::Ptr &calendar); 0077 void removeCalendar(const ViewCalendar::Ptr &calendar); 0078 [[nodiscard]] int calendarCount() const; 0079 0080 [[nodiscard]] Akonadi::CollectionCalendar::Ptr calendarForCollection(const Akonadi::Collection &col) const; 0081 [[nodiscard]] Akonadi::CollectionCalendar::Ptr calendarForCollection(Akonadi::Collection::Id id) const; 0082 0083 [[nodiscard]] KCalendarCore::Calendar::Ptr getCalendar() const override; 0084 [[nodiscard]] KCalendarCore::Incidence::List incidences() const; 0085 0086 AgendaView *mAgendaView = nullptr; 0087 QList<ViewCalendar::Ptr> mSubCalendars; 0088 }; 0089 }