MauiKit Calendar

calendarmanager.h
1// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
2// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#pragma once
6
7#include <QObject>
8#include <QQmlEngine>
9
10#include <akonadi-calendar_version.h>
11#if AKONADICALENDAR_VERSION > QT_VERSION_CHECK(5, 19, 41)
12#include <Akonadi/ETMCalendar>
13#include <Akonadi/IncidenceChanger>
14#else
15#include <Akonadi/Calendar/ETMCalendar>
16#include <Akonadi/Calendar/IncidenceChanger>
17#endif
18
19#include <Akonadi/CollectionFilterProxyModel>
20#include <KConfigWatcher>
21#include <QObject>
22#include <akonadi-calendar_version.h>
23
25
26namespace Akonadi
27{
28class ETMViewStateSaver;
29class EntityRightsFilterModel;
30}
31
36class ColorProxyModel;
37
38class CalendarManager : public QObject
39{
41 QML_ELEMENT
42 QML_SINGLETON
43
44 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
45 Q_PROPERTY(QAbstractProxyModel *collections READ collections CONSTANT)
46 Q_PROPERTY(QAbstractItemModel *todoCollections READ todoCollections CONSTANT)
47 Q_PROPERTY(QAbstractItemModel *viewCollections READ viewCollections CONSTANT)
48 Q_PROPERTY(QVector<qint64> enabledTodoCollections READ enabledTodoCollections NOTIFY enabledTodoCollectionsChanged)
49 Q_PROPERTY(Akonadi::CollectionFilterProxyModel *allCalendars READ allCalendars CONSTANT)
50 Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableCalendars READ selectableCalendars CONSTANT)
51 Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableEventCalendars READ selectableEventCalendars CONSTANT)
52 Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableTodoCalendars READ selectableTodoCalendars CONSTANT)
53 Q_PROPERTY(Akonadi::ETMCalendar::Ptr calendar READ calendar CONSTANT)
54 Q_PROPERTY(Akonadi::IncidenceChanger *incidenceChanger READ incidenceChanger CONSTANT)
55 Q_PROPERTY(QVariantMap undoRedoData READ undoRedoData NOTIFY undoRedoDataChanged)
56
57public:
58 static CalendarManager *instance();
59 explicit CalendarManager(QObject *parent = nullptr);
60 ~CalendarManager() override;
61
62 KCheckableProxyModel *collectionSelectionProxyModel() const;
63 void setCollectionSelectionProxyModel(KCheckableProxyModel *);
64
65 bool loading() const;
66 QAbstractProxyModel *collections();
67 QAbstractItemModel *todoCollections();
68 QAbstractItemModel *viewCollections();
69 QVector<qint64> enabledTodoCollections();
70 void refreshEnabledTodoCollections();
71
72 Q_INVOKABLE void save();
73 Akonadi::ETMCalendar::Ptr calendar() const;
74 Akonadi::IncidenceChanger *incidenceChanger() const;
76 Akonadi::CollectionFilterProxyModel *selectableCalendars() const;
77 Akonadi::CollectionFilterProxyModel *selectableEventCalendars() const;
78 Akonadi::CollectionFilterProxyModel *selectableTodoCalendars() const;
79 Q_INVOKABLE qint64 defaultCalendarId(IncidenceWrapper *incidenceWrapper);
80 Q_INVOKABLE int getCalendarSelectableIndex(IncidenceWrapper *incidenceWrapper);
81 QVariantMap undoRedoData();
82
83 Q_INVOKABLE Akonadi::Item incidenceItem(KCalendarCore::Incidence::Ptr incidence) const;
84 Akonadi::Item incidenceItem(const QString &uid) const;
85 KCalendarCore::Incidence::List childIncidences(const QString &uid) const;
86
87 Q_INVOKABLE void addIncidence(IncidenceWrapper *incidenceWrapper);
88 Q_INVOKABLE void editIncidence(IncidenceWrapper *incidenceWrapper);
89 Q_INVOKABLE void updateIncidenceDates(IncidenceWrapper *incidenceWrapper,
90 int startOffset,
91 int endOffset,
92 int occurrences = -1,
93 const QDateTime &occurrenceDate = QDateTime());
94 Q_INVOKABLE bool hasChildren(KCalendarCore::Incidence::Ptr incidence);
95 void deleteAllChildren(KCalendarCore::Incidence::Ptr incidence);
96 Q_INVOKABLE void deleteIncidence(KCalendarCore::Incidence::Ptr incidence, bool deleteChildren = false);
97 Q_INVOKABLE void changeIncidenceCollection(KCalendarCore::Incidence::Ptr incidence, qint64 collectionId);
98 void changeIncidenceCollection(Akonadi::Item item, qint64 collectionId);
99 Q_INVOKABLE QVariantMap getCollectionDetails(QVariant collectionId);
100 Q_INVOKABLE void setCollectionColor(qint64 collectionId, const QColor &color);
101 Q_INVOKABLE QVariant getIncidenceSubclassed(KCalendarCore::Incidence::Ptr incidencePtr);
102 Q_INVOKABLE void undoAction();
103 Q_INVOKABLE void redoAction();
104
105 Q_INVOKABLE void updateAllCollections();
106 Q_INVOKABLE void updateCollection(qint64 collectionId);
107 Q_INVOKABLE void deleteCollection(qint64 collectionId);
108 Q_INVOKABLE void editCollection(qint64 collectionId);
109 Q_INVOKABLE void toggleCollection(qint64 collectionId);
110
111private Q_SLOTS:
112 void delayedInit();
113
115 void loadingChanged();
116 void calendarChanged();
117 void undoRedoDataChanged();
118 void enabledTodoCollectionsChanged();
119 void updateIncidenceDatesCompleted();
120 void collectionColorsChanged();
121 void incidenceAdded();
122
123private:
124 Akonadi::ETMCalendar::Ptr m_calendar = nullptr;
125 Akonadi::IncidenceChanger *m_changer = nullptr;
126 KDescendantsProxyModel *m_flatCollectionTreeModel = nullptr;
127 ColorProxyModel *m_baseModel = nullptr;
128 KCheckableProxyModel *m_selectionProxyModel = nullptr;
129 Akonadi::ETMViewStateSaver *mCollectionSelectionModelStateSaver = nullptr;
130 Akonadi::CollectionFilterProxyModel *m_allCalendars = nullptr;
131 Akonadi::CollectionFilterProxyModel *m_eventMimeTypeFilterModel = nullptr;
132 // Akonadi::CollectionFilterProxyModel *m_todoMimeTypeFilterModel = nullptr;
133 Akonadi::EntityRightsFilterModel *m_allCollectionsRightsFilterModel = nullptr;
134 Akonadi::EntityRightsFilterModel *m_eventRightsFilterModel = nullptr;
135 Akonadi::EntityRightsFilterModel *m_todoRightsFilterModel = nullptr;
136 Akonadi::CollectionFilterProxyModel *m_selectableCollectionsModel = nullptr;
137 Akonadi::CollectionFilterProxyModel *m_selectableEventCollectionsModel = nullptr;
138 Akonadi::CollectionFilterProxyModel *m_selectableTodoCollectionsModel = nullptr;
139 Akonadi::CollectionFilterProxyModel *m_todoViewCollectionModel = nullptr;
140 Akonadi::CollectionFilterProxyModel *m_viewCollectionModel = nullptr;
141 QVector<qint64> m_enabledTodoCollections;
142 KConfigWatcher::Ptr m_colorWatcher;
143};
144
145Q_DECLARE_METATYPE(Akonadi::ETMCalendar::Ptr)
Despite the name, this handles the presentation of collections including display text and icons,...
This class is a wrapper for a KCalendarCore::Incidence::Ptr object.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.