~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to calendarsupport/utils.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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>
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
19
 
 
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.
 
23
*/
 
24
#ifndef CALENDARSUPPORT_UTILS_H
 
25
#define CALENDARSUPPORT_UTILS_H
 
26
 
 
27
#include "calendarsupport_export.h"
 
28
 
 
29
#include <Akonadi/Collection>
 
30
#include <Akonadi/Item>
 
31
 
 
32
#include <KCalCore/Event>
 
33
#include <KCalCore/Incidence>
 
34
#include <KCalCore/Journal>
 
35
#include <KCalCore/ScheduleMessage>
 
36
#include <KCalCore/Todo>
 
37
 
 
38
#include <KDateTime>
 
39
 
 
40
#include <QModelIndex>
 
41
 
 
42
namespace KPIMIdentities {
 
43
class IdentityManager;
 
44
}
 
45
 
 
46
namespace KCalCore {
 
47
  class CalFilter;
 
48
}
 
49
 
 
50
class QAbstractItemModel;
 
51
class QDrag;
 
52
class QMimeData;
 
53
 
 
54
typedef QList<QModelIndex> QModelIndexList;
 
55
 
 
56
namespace CalendarSupport
 
57
{
 
58
 
 
59
class Calendar;
 
60
 
 
61
  /**
 
62
   * returns the incidence from an akonadi item, or a null pointer if the item has no such payload
 
63
   */
 
64
  CALENDARSUPPORT_EXPORT KCalCore::Incidence::Ptr incidence( const Akonadi::Item &item );
 
65
 
 
66
  /**
 
67
   * returns the event from an akonadi item, or a null pointer if the item has no such payload
 
68
   */
 
69
  CALENDARSUPPORT_EXPORT KCalCore::Event::Ptr event( const Akonadi::Item &item );
 
70
 
 
71
  /**
 
72
   * returns event pointers from an akonadi item, or a null pointer if the item has no such payload
 
73
   */
 
74
  CALENDARSUPPORT_EXPORT KCalCore::Event::List eventsFromItems(
 
75
    const Akonadi::Item::List &items );
 
76
 
 
77
  /**
 
78
   * returns incidence pointers from an akonadi item.
 
79
   */
 
80
  CALENDARSUPPORT_EXPORT KCalCore::Incidence::List incidencesFromItems(
 
81
    const Akonadi::Item::List &items );
 
82
 
 
83
 
 
84
  /**
 
85
  * returns the todo from an akonadi item, or a null pointer if the item has no such payload
 
86
  */
 
87
  CALENDARSUPPORT_EXPORT KCalCore::Todo::Ptr todo( const Akonadi::Item &item );
 
88
 
 
89
  /**
 
90
  * returns the journal from an akonadi item, or a null pointer if the item has no such payload
 
91
  */
 
92
  CALENDARSUPPORT_EXPORT KCalCore::Journal::Ptr journal( const Akonadi::Item &item );
 
93
 
 
94
  /**
 
95
   * returns whether an Akonadi item contains an incidence
 
96
   */
 
97
  CALENDARSUPPORT_EXPORT bool hasIncidence( const Akonadi::Item &item );
 
98
 
 
99
  /**
 
100
   * returns whether an Akonadi item contains an event
 
101
   */
 
102
  CALENDARSUPPORT_EXPORT bool hasEvent( const Akonadi::Item &item );
 
103
 
 
104
  /**
 
105
   * returns whether an Akonadi item contains a todo
 
106
   */
 
107
  CALENDARSUPPORT_EXPORT bool hasTodo( const Akonadi::Item &item );
 
108
 
 
109
  /**
 
110
   * returns whether an Akonadi item contains a journal
 
111
   */
 
112
  CALENDARSUPPORT_EXPORT bool hasJournal( const Akonadi::Item &item );
 
113
 
 
114
  /**
 
115
   * returns whether this item can be deleted
 
116
   */
 
117
  CALENDARSUPPORT_EXPORT bool hasDeleteRights( const Akonadi::Item &item );
 
118
 
 
119
  /**
 
120
   * returns whether this item can be changed
 
121
   */
 
122
  CALENDARSUPPORT_EXPORT bool hasChangeRights( const Akonadi::Item &item );
 
123
 
 
124
  /**
 
125
  * returns @p true if the URL represents an Akonadi item and has one of the given mimetypes.
 
126
  */
 
127
  CALENDARSUPPORT_EXPORT bool isValidIncidenceItemUrl( const KUrl &url,
 
128
                                                       const QStringList &supportedMimeTypes );
 
129
 
 
130
  CALENDARSUPPORT_EXPORT bool isValidIncidenceItemUrl( const KUrl &url );
 
131
 
 
132
  /**
 
133
  * returns @p true if the mime data object contains any of the following:
 
134
  *
 
135
  * * An akonadi item with a supported KCal mimetype
 
136
  * * an iCalendar
 
137
  * * a VCard
 
138
  */
 
139
  CALENDARSUPPORT_EXPORT bool canDecode( const QMimeData *mimeData );
 
140
 
 
141
  CALENDARSUPPORT_EXPORT QList<KUrl> incidenceItemUrls( const QMimeData *mimeData );
 
142
 
 
143
  CALENDARSUPPORT_EXPORT QList<KUrl> todoItemUrls( const QMimeData *mimeData );
 
144
 
 
145
  CALENDARSUPPORT_EXPORT bool mimeDataHasTodo( const QMimeData *mimeData );
 
146
 
 
147
  CALENDARSUPPORT_EXPORT KCalCore::Todo::List todos( const QMimeData *mimeData,
 
148
                                                     const KDateTime::Spec &timeSpec );
 
149
 
 
150
  /**
 
151
  * returns @p true if the URL represents an Akonadi item and has one of the given mimetypes.
 
152
  */
 
153
  CALENDARSUPPORT_EXPORT bool isValidTodoItemUrl( const KUrl &url );
 
154
 
 
155
  /**
 
156
  * creates mime data object for dragging an akonadi item containing an incidence
 
157
  */
 
158
  CALENDARSUPPORT_EXPORT QMimeData *createMimeData( const Akonadi::Item &item,
 
159
                                                    const KDateTime::Spec &timeSpec );
 
160
 
 
161
  /**
 
162
  * creates mime data object for dragging akonadi items containing an incidence
 
163
  */
 
164
  CALENDARSUPPORT_EXPORT QMimeData *createMimeData( const Akonadi::Item::List &items,
 
165
                                                    const KDateTime::Spec &timeSpec );
 
166
 
 
167
#ifndef QT_NO_DRAGANDDROP
 
168
  /**
 
169
  * creates a drag object for dragging an akonadi item containing an incidence
 
170
  */
 
171
  CALENDARSUPPORT_EXPORT QDrag *createDrag( const Akonadi::Item &item,
 
172
                                            const KDateTime::Spec &timeSpec, QWidget *parent );
 
173
 
 
174
  /**
 
175
  * creates a drag object for dragging akonadi items containing an incidence
 
176
  */
 
177
  CALENDARSUPPORT_EXPORT QDrag *createDrag( const Akonadi::Item::List &items,
 
178
                                            const KDateTime::Spec &timeSpec, QWidget *parent );
 
179
#endif
 
180
  /**
 
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
 
188
  */
 
189
  CALENDARSUPPORT_EXPORT Akonadi::Item::List applyCalFilter( const Akonadi::Item::List &items,
 
190
                                                             const KCalCore::CalFilter *filter );
 
191
 
 
192
  /**
 
193
    Shows a modal dialog that allows to select a collection.
 
194
 
 
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.
 
200
  */
 
201
  CALENDARSUPPORT_EXPORT Akonadi::Collection selectCollection(
 
202
    QWidget *parent, int &dialogCode,
 
203
    const QStringList &mimeTypes,
 
204
    const Akonadi::Collection &defaultCollection = Akonadi::Collection() );
 
205
 
 
206
  CALENDARSUPPORT_EXPORT Akonadi::Item itemFromIndex( const QModelIndex &index );
 
207
 
 
208
  CALENDARSUPPORT_EXPORT Akonadi::Item::List itemsFromModel(
 
209
    const QAbstractItemModel *model,
 
210
    const QModelIndex &parentIndex = QModelIndex(),
 
211
    int start = 0,
 
212
    int end = -1 );
 
213
 
 
214
  CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromModel(
 
215
    const QAbstractItemModel *model,
 
216
    const QModelIndex &parentIndex = QModelIndex(),
 
217
    int start = 0,
 
218
    int end = -1 );
 
219
 
 
220
  CALENDARSUPPORT_EXPORT Akonadi::Collection collectionFromIndex( const QModelIndex &index );
 
221
 
 
222
  CALENDARSUPPORT_EXPORT Akonadi::Collection::Id collectionIdFromIndex( const QModelIndex &index );
 
223
 
 
224
  CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromIndexes(
 
225
    const QModelIndexList &indexes );
 
226
 
 
227
  CALENDARSUPPORT_EXPORT QString displayName( const Akonadi::Collection &coll );
 
228
 
 
229
  CALENDARSUPPORT_EXPORT QString subMimeTypeForIncidence(
 
230
    const KCalCore::Incidence::Ptr &incidence );
 
231
 
 
232
  /**
 
233
      Returns a list containing work days between @p start and @end.
 
234
  */
 
235
  CALENDARSUPPORT_EXPORT QList<QDate> workDays( const QDate &start, const QDate &end );
 
236
 
 
237
  /**
 
238
    Returns a list of holidays that occur at @param date.
 
239
  */
 
240
  CALENDARSUPPORT_EXPORT QStringList holiday( const QDate &date );
 
241
 
 
242
  CALENDARSUPPORT_EXPORT void sendAsICalendar( const Akonadi::Item& item, KPIMIdentities::IdentityManager *identityManager, QWidget* parentWidget = 0 );
 
243
 
 
244
  CALENDARSUPPORT_EXPORT void publishItemInformation( const Akonadi::Item& item, Calendar* calendar, QWidget* parentWidget = 0 );
 
245
 
 
246
  CALENDARSUPPORT_EXPORT void scheduleiTIPMethods( KCalCore::iTIPMethod method, const Akonadi::Item &item, Calendar* calendar, QWidget *parentWidget = 0 );
 
247
 
 
248
  CALENDARSUPPORT_EXPORT void saveAttachments( const Akonadi::Item& item, QWidget* parentWidget = 0 );
 
249
 
 
250
}
 
251
 
 
252
#endif