2
Copyright (c) 2009, 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
3
Copyright (C) 2009 KDAB (author: Frank Osterfeld <osterfeld@kde.org>)
4
Copyright (c) 2010 Andras Mantia <andras@kdab.com>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
As a special exception, permission is given to link this program
21
with any edition of Qt, and distribute the resulting executable,
22
without including the source code for Qt in the source distribution.
24
#ifndef CALENDARSUPPORT_UTILS_H
25
#define CALENDARSUPPORT_UTILS_H
27
#include "calendarsupport_export.h"
29
#include <Akonadi/Collection>
30
#include <Akonadi/Item>
32
#include <KCalCore/Event>
33
#include <KCalCore/Incidence>
34
#include <KCalCore/Journal>
35
#include <KCalCore/ScheduleMessage>
36
#include <KCalCore/Todo>
40
#include <QModelIndex>
42
namespace KPIMIdentities {
43
class IdentityManager;
50
class QAbstractItemModel;
54
typedef QList<QModelIndex> QModelIndexList;
56
namespace CalendarSupport
62
* returns the incidence from an akonadi item, or a null pointer if the item has no such payload
64
CALENDARSUPPORT_EXPORT KCalCore::Incidence::Ptr incidence( const Akonadi::Item &item );
67
* returns the event from an akonadi item, or a null pointer if the item has no such payload
69
CALENDARSUPPORT_EXPORT KCalCore::Event::Ptr event( const Akonadi::Item &item );
72
* returns event pointers from an akonadi item, or a null pointer if the item has no such payload
74
CALENDARSUPPORT_EXPORT KCalCore::Event::List eventsFromItems(
75
const Akonadi::Item::List &items );
78
* returns incidence pointers from an akonadi item.
80
CALENDARSUPPORT_EXPORT KCalCore::Incidence::List incidencesFromItems(
81
const Akonadi::Item::List &items );
85
* returns the todo from an akonadi item, or a null pointer if the item has no such payload
87
CALENDARSUPPORT_EXPORT KCalCore::Todo::Ptr todo( const Akonadi::Item &item );
90
* returns the journal from an akonadi item, or a null pointer if the item has no such payload
92
CALENDARSUPPORT_EXPORT KCalCore::Journal::Ptr journal( const Akonadi::Item &item );
95
* returns whether an Akonadi item contains an incidence
97
CALENDARSUPPORT_EXPORT bool hasIncidence( const Akonadi::Item &item );
100
* returns whether an Akonadi item contains an event
102
CALENDARSUPPORT_EXPORT bool hasEvent( const Akonadi::Item &item );
105
* returns whether an Akonadi item contains a todo
107
CALENDARSUPPORT_EXPORT bool hasTodo( const Akonadi::Item &item );
110
* returns whether an Akonadi item contains a journal
112
CALENDARSUPPORT_EXPORT bool hasJournal( const Akonadi::Item &item );
115
* returns whether this item can be deleted
117
CALENDARSUPPORT_EXPORT bool hasDeleteRights( const Akonadi::Item &item );
120
* returns whether this item can be changed
122
CALENDARSUPPORT_EXPORT bool hasChangeRights( const Akonadi::Item &item );
125
* returns @p true if the URL represents an Akonadi item and has one of the given mimetypes.
127
CALENDARSUPPORT_EXPORT bool isValidIncidenceItemUrl( const KUrl &url,
128
const QStringList &supportedMimeTypes );
130
CALENDARSUPPORT_EXPORT bool isValidIncidenceItemUrl( const KUrl &url );
133
* returns @p true if the mime data object contains any of the following:
135
* * An akonadi item with a supported KCal mimetype
139
CALENDARSUPPORT_EXPORT bool canDecode( const QMimeData *mimeData );
141
CALENDARSUPPORT_EXPORT QList<KUrl> incidenceItemUrls( const QMimeData *mimeData );
143
CALENDARSUPPORT_EXPORT QList<KUrl> todoItemUrls( const QMimeData *mimeData );
145
CALENDARSUPPORT_EXPORT bool mimeDataHasTodo( const QMimeData *mimeData );
147
CALENDARSUPPORT_EXPORT KCalCore::Todo::List todos( const QMimeData *mimeData,
148
const KDateTime::Spec &timeSpec );
151
* returns @p true if the URL represents an Akonadi item and has one of the given mimetypes.
153
CALENDARSUPPORT_EXPORT bool isValidTodoItemUrl( const KUrl &url );
156
* creates mime data object for dragging an akonadi item containing an incidence
158
CALENDARSUPPORT_EXPORT QMimeData *createMimeData( const Akonadi::Item &item,
159
const KDateTime::Spec &timeSpec );
162
* creates mime data object for dragging akonadi items containing an incidence
164
CALENDARSUPPORT_EXPORT QMimeData *createMimeData( const Akonadi::Item::List &items,
165
const KDateTime::Spec &timeSpec );
167
#ifndef QT_NO_DRAGANDDROP
169
* creates a drag object for dragging an akonadi item containing an incidence
171
CALENDARSUPPORT_EXPORT QDrag *createDrag( const Akonadi::Item &item,
172
const KDateTime::Spec &timeSpec, QWidget *parent );
175
* creates a drag object for dragging akonadi items containing an incidence
177
CALENDARSUPPORT_EXPORT QDrag *createDrag( const Akonadi::Item::List &items,
178
const KDateTime::Spec &timeSpec, QWidget *parent );
181
Applies a filter to a list of items containing incidences.
182
Items not containing incidences or not matching the filter are removed.
183
Helper method anologous to KCalCore::CalFilter::apply()
184
@see KCalCore::CalFilter::apply()
185
@param items the list of items to filter
186
@param filter the filter to apply to the list of items
187
@return the filtered list of items
189
CALENDARSUPPORT_EXPORT Akonadi::Item::List applyCalFilter( const Akonadi::Item::List &items,
190
const KCalCore::CalFilter *filter );
193
Shows a modal dialog that allows to select a collection.
195
@param will contain the dialogCode, QDialog::Accepted if the user pressed Ok,
196
QDialog::Rejected otherwise
197
@param parent The optional parent of the modal dialog.
198
@return The select collection or an invalid collection if
199
there was no collection selected.
201
CALENDARSUPPORT_EXPORT Akonadi::Collection selectCollection(
202
QWidget *parent, int &dialogCode,
203
const QStringList &mimeTypes,
204
const Akonadi::Collection &defaultCollection = Akonadi::Collection() );
206
CALENDARSUPPORT_EXPORT Akonadi::Item itemFromIndex( const QModelIndex &index );
208
CALENDARSUPPORT_EXPORT Akonadi::Item::List itemsFromModel(
209
const QAbstractItemModel *model,
210
const QModelIndex &parentIndex = QModelIndex(),
214
CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromModel(
215
const QAbstractItemModel *model,
216
const QModelIndex &parentIndex = QModelIndex(),
220
CALENDARSUPPORT_EXPORT Akonadi::Collection collectionFromIndex( const QModelIndex &index );
222
CALENDARSUPPORT_EXPORT Akonadi::Collection::Id collectionIdFromIndex( const QModelIndex &index );
224
CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromIndexes(
225
const QModelIndexList &indexes );
227
CALENDARSUPPORT_EXPORT QString displayName( const Akonadi::Collection &coll );
229
CALENDARSUPPORT_EXPORT QString subMimeTypeForIncidence(
230
const KCalCore::Incidence::Ptr &incidence );
233
Returns a list containing work days between @p start and @end.
235
CALENDARSUPPORT_EXPORT QList<QDate> workDays( const QDate &start, const QDate &end );
238
Returns a list of holidays that occur at @param date.
240
CALENDARSUPPORT_EXPORT QStringList holiday( const QDate &date );
242
CALENDARSUPPORT_EXPORT void sendAsICalendar( const Akonadi::Item& item, KPIMIdentities::IdentityManager *identityManager, QWidget* parentWidget = 0 );
244
CALENDARSUPPORT_EXPORT void publishItemInformation( const Akonadi::Item& item, Calendar* calendar, QWidget* parentWidget = 0 );
246
CALENDARSUPPORT_EXPORT void scheduleiTIPMethods( KCalCore::iTIPMethod method, const Akonadi::Item &item, Calendar* calendar, QWidget *parentWidget = 0 );
248
CALENDARSUPPORT_EXPORT void saveAttachments( const Akonadi::Item& item, QWidget* parentWidget = 0 );