File indexing completed on 2025-01-05 04:47:39

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  *
0006  */
0007 
0008 #pragma once
0009 
0010 #include "calendarsupport_export.h"
0011 
0012 #include "freebusyitemmodel.h"
0013 
0014 #include <KCalendarCore/Calendar>
0015 #include <KCalendarCore/Event>
0016 
0017 #include <memory>
0018 
0019 namespace CalendarSupport
0020 {
0021 class FreeBusyCalendarPrivate;
0022 
0023 /// A FreeBusyCalendar exposes a FreeBusyItemModel as a KCalendarCore::Calendar::Ptr.
0024 class CALENDARSUPPORT_EXPORT FreeBusyCalendar : public QObject
0025 {
0026     Q_OBJECT
0027 public:
0028     /// Constructor
0029     explicit FreeBusyCalendar(QObject *parent = nullptr);
0030 
0031     ~FreeBusyCalendar() override;
0032 
0033     /// Set the FreeBusyItemModel used by the FreeBusyCalendar.
0034     void setModel(FreeBusyItemModel *model);
0035 
0036     /// Get the FreeBusyItemModel used by the FreeBusyCalendar.
0037     FreeBusyItemModel *model() const;
0038 
0039     /// Get the calendar created from the FreeBusyItemModel.
0040     KCalendarCore::Calendar::Ptr calendar() const;
0041 
0042 private:
0043     CALENDARSUPPORT_NO_EXPORT void onRowsChanged(const QModelIndex &, const QModelIndex &);
0044     CALENDARSUPPORT_NO_EXPORT void onRowsInserted(const QModelIndex &, int, int);
0045     CALENDARSUPPORT_NO_EXPORT void onRowsRemoved(const QModelIndex &, int, int);
0046     CALENDARSUPPORT_NO_EXPORT void onLayoutChanged();
0047     CALENDARSUPPORT_NO_EXPORT void deleteAllEvents();
0048 
0049     std::unique_ptr<FreeBusyCalendarPrivate> const d;
0050 };
0051 }