CalendarSupport

utils.h
1/*
2 SPDX-FileCopyrightText: 2009, 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 SPDX-FileContributor: Frank Osterfeld <osterfeld@kde.org>
4 SPDX-FileContributor: Andras Mantia <andras@kdab.com>
5
6 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
7*/
8
9#pragma once
10
11#include "calendarsupport_export.h"
12
13#include <Akonadi/Item>
14
15#include <KCalendarCore/Calendar>
16#include <KCalendarCore/Event>
17#include <KCalendarCore/Incidence>
18#include <KCalendarCore/Journal>
19#include <KCalendarCore/Todo>
20
21#include <QModelIndex>
22
23namespace KCalendarCore
24{
25class CalFilter;
26}
27
29class QDrag;
30class QMimeData;
31
32namespace CalendarSupport
33{
34class Calendar;
35/**
36 * returns the event from an incidence, or a null pointer if the item has no such payload
37 */
38CALENDARSUPPORT_EXPORT KCalendarCore::Event::Ptr event(const KCalendarCore::Incidence::Ptr &incidence);
39
40/**
41 * returns incidence pointers from an akonadi item.
42 */
43CALENDARSUPPORT_EXPORT KCalendarCore::Incidence::List incidencesFromItems(const Akonadi::Item::List &items);
44
45/**
46 * returns the todo from an incidence, or a null pointer if the item has no such payload
47 */
48CALENDARSUPPORT_EXPORT KCalendarCore::Todo::Ptr todo(const KCalendarCore::Incidence::Ptr &incidence);
49
50/**
51 * returns the journal from an incidence, or a null pointer if the item has no such payload
52 */
53CALENDARSUPPORT_EXPORT KCalendarCore::Journal::Ptr journal(const KCalendarCore::Incidence::Ptr &incidence);
54
55/**
56 * returns whether an Akonadi item contains an incidence
57 */
58CALENDARSUPPORT_EXPORT bool hasIncidence(const Akonadi::Item &item);
59
60/**
61 * returns whether an Akonadi item contains an event
62 */
63CALENDARSUPPORT_EXPORT bool hasEvent(const Akonadi::Item &item);
64
65/**
66 * returns whether an incidence contains an event
67 */
68CALENDARSUPPORT_EXPORT bool hasEvent(const KCalendarCore::Incidence::Ptr &incidence);
69
70/**
71 * returns whether an Akonadi item contains a todo
72 */
73CALENDARSUPPORT_EXPORT bool hasTodo(const Akonadi::Item &item);
74
75/**
76 * returns whether an incidence contains a todo
77 */
78CALENDARSUPPORT_EXPORT bool hasTodo(const KCalendarCore::Incidence::Ptr &incidence);
79
80/**
81 * returns whether an Akonadi item contains a journal
82 */
83CALENDARSUPPORT_EXPORT bool hasJournal(const Akonadi::Item &item);
84
85/**
86 * returns whether an incidence contains a journal
87 */
88CALENDARSUPPORT_EXPORT bool hasJournal(const KCalendarCore::Incidence::Ptr &incidence);
89
90/**
91 * returns @p true if the URL represents an Akonadi item and has one of the given mimetypes.
92 */
93bool isValidIncidenceItemUrl(const QUrl &url, const QStringList &supportedMimeTypes);
94
95bool isValidIncidenceItemUrl(const QUrl &url);
96
97/**
98 * returns @p true if the mime data object contains any of the following:
99 *
100 * - an Akonadi item with a supported KCal mimetype
101 * - an iCalendar
102 * - a VCard
103 */
104CALENDARSUPPORT_EXPORT bool canDecode(const QMimeData *mimeData);
105
106CALENDARSUPPORT_EXPORT QList<QUrl> incidenceItemUrls(const QMimeData *mimeData);
107
108CALENDARSUPPORT_EXPORT QList<QUrl> todoItemUrls(const QMimeData *mimeData);
109
110CALENDARSUPPORT_EXPORT bool mimeDataHasIncidence(const QMimeData *mimeData);
111
112CALENDARSUPPORT_EXPORT KCalendarCore::Todo::List todos(const QMimeData *mimeData);
113
114CALENDARSUPPORT_EXPORT KCalendarCore::Incidence::List incidences(const QMimeData *mimeData);
115
116#ifndef QT_NO_DRAGANDDROP
117/**
118 * creates a drag object for dragging an akonadi item containing an incidence
119 */
120CALENDARSUPPORT_EXPORT QDrag *createDrag(const Akonadi::Item &item, QObject *parent);
121
122/**
123 * creates a drag object for dragging akonadi items containing an incidence
124 */
125CALENDARSUPPORT_EXPORT QDrag *createDrag(const Akonadi::Item::List &items, QObject *parent);
126#endif
127/**
128 Applies a filter to a list of items containing incidences.
129 Items not containing incidences or not matching the filter are removed.
130 Helper method anologous to KCalendarCore::CalFilter::apply()
131 @see KCalendarCore::CalFilter::apply()
132 @param items the list of items to filter
133 @param filter the filter to apply to the list of items
134 @return the filtered list of items
135*/
136CALENDARSUPPORT_EXPORT Akonadi::Item::List applyCalFilter(const Akonadi::Item::List &items, const KCalendarCore::CalFilter *filter);
137
138/**
139 Shows a modal dialog that allows to select a collection.
140
141 @param will contain the dialogCode, QDialog::Accepted if the user pressed Ok,
142 QDialog::Rejected otherwise
143 @param parent The optional parent of the modal dialog.
144 @return The select collection or an invalid collection if
145 there was no collection selected.
146*/
147CALENDARSUPPORT_EXPORT Akonadi::Collection
148selectCollection(QWidget *parent, int &dialogCode, const QStringList &mimeTypes, const Akonadi::Collection &defaultCollection = Akonadi::Collection());
149
150CALENDARSUPPORT_EXPORT Akonadi::Item itemFromIndex(const QModelIndex &index);
151
152CALENDARSUPPORT_EXPORT Akonadi::Item::List
153itemsFromModel(const QAbstractItemModel *model, const QModelIndex &parentIndex = QModelIndex(), int start = 0, int end = -1);
154
155CALENDARSUPPORT_EXPORT Akonadi::Collection::List
156collectionsFromModel(const QAbstractItemModel *model, const QModelIndex &parentIndex = QModelIndex(), int start = 0, int end = -1);
157
158CALENDARSUPPORT_EXPORT Akonadi::Collection::Id collectionIdFromIndex(const QModelIndex &index);
159
160CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromIndexes(const QModelIndexList &indexes);
161
162CALENDARSUPPORT_EXPORT QString subMimeTypeForIncidence(const KCalendarCore::Incidence::Ptr &incidence);
163
164/**
165 * Returns a list containing work days between @p start and @end.
166 */
167CALENDARSUPPORT_EXPORT QList<QDate> workDays(QDate start, QDate end);
168
169/**
170 * Creates a nicely formatted toolTip string for a calendar, containing some quick,
171 * useful information to the user.
172 *
173 * @param coll is the Akonadi collection representing the calendar.
174 * @param richText switches off richText (on by default) [CURRENTLY UNIMPLEMENTED]
175 *
176 * @return a QString containing the calendar info suitable for a toolTip.
177 * @since 5.9
178 */
179CALENDARSUPPORT_EXPORT QString toolTipString(const Akonadi::Collection &coll, bool richText = true);
180
181/**
182 * Returns a list of holidays that occur at @param date.
183 */
184CALENDARSUPPORT_EXPORT QStringList holiday(QDate date);
185
186CALENDARSUPPORT_EXPORT QStringList categories(const KCalendarCore::Incidence::List &incidences);
187
188CALENDARSUPPORT_EXPORT bool mergeCalendar(const QString &srcFilename, const KCalendarCore::Calendar::Ptr &destCalendar);
189
190CALENDARSUPPORT_EXPORT bool mergeCalendar(const QString &srcFilename, const KCalendarCore::Calendar::Ptr &destCalendar);
191
192CALENDARSUPPORT_EXPORT void createAlarmReminder(const KCalendarCore::Alarm::Ptr &alarm, KCalendarCore::IncidenceBase::IncidenceType type);
193}
Q_SCRIPTABLE Q_NOREPLY void start()
AKONADI_CALENDAR_EXPORT KCalendarCore::Journal::Ptr journal(const Akonadi::Item &item)
AKONADI_CALENDAR_EXPORT KCalendarCore::Todo::Ptr todo(const Akonadi::Item &item)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
KCALUTILS_EXPORT bool canDecode(const QMimeData *)
KGUIADDONS_EXPORT QDrag * createDrag(const QColor &color, QObject *dragsource)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:32 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.