Akonadi::ETMCalendar Class

A KCalendarCore::Calendar that uses an EntityTreeModel to populate itself. More...

Header: #include <etmcalendar.h>
CMake: find_package(KPim6AkonadiCalendar REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiCalendar)
Inherits: Akonadi::CalendarBase

Public Functions

ETMCalendar(QObject *parent = nullptr)
ETMCalendar(const Akonadi::ETMCalendar *calendar, QObject *parent = nullptr)
ETMCalendar(const QStringList &mimeTypes, QObject *parent = nullptr)
virtual ~ETMCalendar() override
KCheckableProxyModel *checkableProxyModel() const
Akonadi::Collection collection(Akonadi::Collection::Id) const
bool collectionFilteringEnabled() const
Akonadi::EntityTreeModel *entityTreeModel() const
bool hasRight(const Akonadi::Item &item, Akonadi::Collection::Right right) const
bool hasRight(const QString &uid, Akonadi::Collection::Right right) const
QAbstractItemModel *model() const
void setCollectionFilteringEnabled(bool enable)

Reimplemented Public Functions

virtual KCalendarCore::Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const override

Signals

void calendarChanged()
(since 6.1.40) void calendarSelectionEdited()
void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &attributeNames)
void collectionsAdded(const Akonadi::Collection::List &collection)
void collectionsRemoved(const Akonadi::Collection::List &collection)

Detailed Description

All non-idempotent KCalendarCore::Calendar methods interact with Akonadi. If you need a need a non-persistent calendar use FetchJobCalendar.

ETMCalendar allows to be populated with only a subset of your calendar items, by using a KCheckableProxyModel to specify which collections to be used and/or by setting a KCalendarCore::CalFilter.

Author: Sérgio Martins <iamsergio@gmail.com>

See also FetchJobCalendar and CalendarBase.

Member Function Documentation

[explicit] ETMCalendar::ETMCalendar(QObject *parent = nullptr)

Constructs a new ETMCalendar. Loading begins immediately, asynchronously.

[explicit] ETMCalendar::ETMCalendar(const Akonadi::ETMCalendar *calendar, QObject *parent = nullptr)

Constructs a new ETMCalendar.

This overload exists for optimization reasons, it allows to share an EntityTreeModel across several ETMCalendars to save memory.

Usually when having many ETMCalendars, the only bit that's different is the collection selection. The memory hungry EntityTreeModel is the same, so should be shared.

calendar an existing ETMCalendar who's EntityTreeModel is to be used.

[explicit] ETMCalendar::ETMCalendar(const QStringList &mimeTypes, QObject *parent = nullptr)

Constructs a new ETMCalendar that will only load the specified mime types. Use this ctor to ignore journals or to-dos for example. If no mime types are specified, all mime types will be used.

[override virtual noexcept] ETMCalendar::~ETMCalendar()

Destroys this ETMCalendar.

[override virtual] KCalendarCore::Alarm::List ETMCalendar::alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const

Returns all alarms occurring in a specified time interval. from start date of interval to end data of interval excludeBlockedAlarms if true, alarms belonging to blocked collections aren't returned.

[signal] void ETMCalendar::calendarChanged()

Emitted whenever an Item is inserted, removed or modified.

[signal, since 6.1.40] void ETMCalendar::calendarSelectionEdited()

Emitted whenever the set selected (checked) calendars was modified by the user. Typically used to save that new selection to a config file.

This function was introduced in 6.1.40.

KCheckableProxyModel *ETMCalendar::checkableProxyModel() const

Returns the KCheckableProxyModel used to select from which collections should the calendar be populated from.

Akonadi::Collection ETMCalendar::collection(Akonadi::Collection::Id) const

Returns the collection having id. Use this instead of creating a new collection, the returned collection will have the correct right, name, display name, etc all set.

[signal] void ETMCalendar::collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &attributeNames)

This signal is emitted if a collection has been changed (properties or attributes).

collection The changed collection. attributeNames The names of the collection attributes that have been changed.

bool ETMCalendar::collectionFilteringEnabled() const

Returns whether collection filtering is enabled. Default is true.

See also setCollectionFilteringEnabled().

[signal] void ETMCalendar::collectionsAdded(const Akonadi::Collection::List &collection)

This signal is emitted when one or more collections are added to the ETM.

collection non empty list of collections

[signal] void ETMCalendar::collectionsRemoved(const Akonadi::Collection::List &collection)

This signal is emitted when one or more collections are deleted from the ETM.

collection non empty list of collections

Akonadi::EntityTreeModel *ETMCalendar::entityTreeModel() const

Returns the underlying EntityTreeModel.

For most uses, you'll want model() or the KCalendarCore::Calendar interface instead.

It contains every item and collection with calendar mime type, doesn't have KCalendarCore filtering and doesn't honour any collection selection.

This method is exposed for performance reasons only, so you can reuse it, since it's resource savvy.

See also model().

bool ETMCalendar::hasRight(const Akonadi::Item &item, Akonadi::Collection::Right right) const

Returns true if the collection owning incidence has right right

bool ETMCalendar::hasRight(const QString &uid, Akonadi::Collection::Right right) const

This is an overloaded function. uid the identifier for the incidence to check for rights right the access right to check for

See also hasRight().

QAbstractItemModel *ETMCalendar::model() const

Convenience method to access the contents of this KCalendarCore::Calendar through a QAIM interface.

Like through calendar interface, the model only items of selected collections. To select or unselect collections, see checkableProxyModel().

See also checkableProxyModel() and entityTreeModel().

void ETMCalendar::setCollectionFilteringEnabled(bool enable)

Enable or disable collection filtering. If true, the calendar will only contain items of selected collections. enable enables collection filtering if set as \ true

See also checkableProxyModel() and collectionFilteringEnabled().