summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.h
Unidiff
Diffstat (limited to 'libkcal/calendar.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 14a1a45..95477cd 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,378 +1,379 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual bool mergeCalendarFile( QString name ) = 0; 79 virtual bool mergeCalendarFile( QString name ) = 0;
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
80 virtual void setSyncEventsReadOnly() = 0; 81 virtual void setSyncEventsReadOnly() = 0;
81 virtual void stopAllTodos() = 0; 82 virtual void stopAllTodos() = 0;
82 83
83 /** 84 /**
84 Sync changes in memory to persistant storage. 85 Sync changes in memory to persistant storage.
85 */ 86 */
86 virtual void save() = 0; 87 virtual void save() = 0;
87 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 88 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
88 virtual void removeSyncInfo( QString syncProfile) = 0; 89 virtual void removeSyncInfo( QString syncProfile) = 0;
89 virtual bool isSaving() { return false; } 90 virtual bool isSaving() { return false; }
90 91
91 /** 92 /**
92 Return the owner of the calendar's full name. 93 Return the owner of the calendar's full name.
93 */ 94 */
94 const QString &getOwner() const; 95 const QString &getOwner() const;
95 /** 96 /**
96 Set the owner of the calendar. Should be owner's full name. 97 Set the owner of the calendar. Should be owner's full name.
97 */ 98 */
98 void setOwner( const QString &os ); 99 void setOwner( const QString &os );
99 /** 100 /**
100 Return the email address of the calendar owner. 101 Return the email address of the calendar owner.
101 */ 102 */
102 const QString &getEmail(); 103 const QString &getEmail();
103 /** 104 /**
104 Set the email address of the calendar owner. 105 Set the email address of the calendar owner.
105 */ 106 */
106 void setEmail( const QString & ); 107 void setEmail( const QString & );
107 108
108 /** 109 /**
109 Set time zone from a timezone string (e.g. -2:00) 110 Set time zone from a timezone string (e.g. -2:00)
110 */ 111 */
111 void setTimeZone( const QString &tz ); 112 void setTimeZone( const QString &tz );
112 /** 113 /**
113 Set time zone from a minutes value (e.g. -60) 114 Set time zone from a minutes value (e.g. -60)
114 */ 115 */
115 void setTimeZone( int tz ); 116 void setTimeZone( int tz );
116 /** 117 /**
117 Return time zone as offest in minutes. 118 Return time zone as offest in minutes.
118 */ 119 */
119 int getTimeZone() const; 120 int getTimeZone() const;
120 /** 121 /**
121 Compute an ISO 8601 format string from the time zone. 122 Compute an ISO 8601 format string from the time zone.
122 */ 123 */
123 QString getTimeZoneStr() const; 124 QString getTimeZoneStr() const;
124 /** 125 /**
125 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 126 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
126 values). 127 values).
127 */ 128 */
128 void setTimeZoneId( const QString & ); 129 void setTimeZoneId( const QString & );
129 /** 130 /**
130 Return time zone id. 131 Return time zone id.
131 */ 132 */
132 QString timeZoneId() const; 133 QString timeZoneId() const;
133 /** 134 /**
134 Use local time, not UTC or a time zone. 135 Use local time, not UTC or a time zone.
135 */ 136 */
136 void setLocalTime(); 137 void setLocalTime();
137 /** 138 /**
138 Return whether local time is being used. 139 Return whether local time is being used.
139 */ 140 */
140 bool isLocalTime() const; 141 bool isLocalTime() const;
141 142
142 /** 143 /**
143 Add an incidence to calendar. 144 Add an incidence to calendar.
144 145
145 @return true on success, false on error. 146 @return true on success, false on error.
146 */ 147 */
147 virtual bool addIncidence( Incidence * ); 148 virtual bool addIncidence( Incidence * );
148 149
149 // Adds an incidence and all relatedto incidences to the cal 150 // Adds an incidence and all relatedto incidences to the cal
150 void addIncidenceBranch( Incidence * ); 151 void addIncidenceBranch( Incidence * );
151 /** 152 /**
152 Return filtered list of all incidences of this calendar. 153 Return filtered list of all incidences of this calendar.
153 */ 154 */
154 virtual QPtrList<Incidence> incidences(); 155 virtual QPtrList<Incidence> incidences();
155 156
156 /** 157 /**
157 Return unfiltered list of all incidences of this calendar. 158 Return unfiltered list of all incidences of this calendar.
158 */ 159 */
159 virtual QPtrList<Incidence> rawIncidences(); 160 virtual QPtrList<Incidence> rawIncidences();
160 161
161 /** 162 /**
162 Adds a Event to this calendar object. 163 Adds a Event to this calendar object.
163 @param anEvent a pointer to the event to add 164 @param anEvent a pointer to the event to add
164 165
165 @return true on success, false on error. 166 @return true on success, false on error.
166 */ 167 */
167 virtual bool addEventNoDup( Event *event ) = 0; 168 virtual bool addEventNoDup( Event *event ) = 0;
168 virtual bool addAnniversaryNoDup( Event *event ) = 0; 169 virtual bool addAnniversaryNoDup( Event *event ) = 0;
169 virtual bool addEvent( Event *anEvent ) = 0; 170 virtual bool addEvent( Event *anEvent ) = 0;
170 /** 171 /**
171 Delete event from calendar. 172 Delete event from calendar.
172 */ 173 */
173 virtual void deleteEvent( Event * ) = 0; 174 virtual void deleteEvent( Event * ) = 0;
174 /** 175 /**
175 Retrieves an event on the basis of the unique string ID. 176 Retrieves an event on the basis of the unique string ID.
176 */ 177 */
177 virtual Event *event( const QString &UniqueStr ) = 0; 178 virtual Event *event( const QString &UniqueStr ) = 0;
178 virtual Event *event( QString, QString ) = 0; 179 virtual Event *event( QString, QString ) = 0;
179 /** 180 /**
180 Builds and then returns a list of all events that match for the 181 Builds and then returns a list of all events that match for the
181 date specified. useful for dayView, etc. etc. 182 date specified. useful for dayView, etc. etc.
182 The calendar filter is applied. 183 The calendar filter is applied.
183 */ 184 */
184 QPtrList<Event> events( const QDate &date, bool sorted = false); 185 QPtrList<Event> events( const QDate &date, bool sorted = false);
185 /** 186 /**
186 Get events, which occur on the given date. 187 Get events, which occur on the given date.
187 The calendar filter is applied. 188 The calendar filter is applied.
188 */ 189 */
189 QPtrList<Event> events( const QDateTime &qdt ); 190 QPtrList<Event> events( const QDateTime &qdt );
190 /** 191 /**
191 Get events in a range of dates. If inclusive is set to true, only events 192 Get events in a range of dates. If inclusive is set to true, only events
192 are returned, which are completely included in the range. 193 are returned, which are completely included in the range.
193 The calendar filter is applied. 194 The calendar filter is applied.
194 */ 195 */
195 QPtrList<Event> events( const QDate &start, const QDate &end, 196 QPtrList<Event> events( const QDate &start, const QDate &end,
196 bool inclusive = false); 197 bool inclusive = false);
197 /** 198 /**
198 Return filtered list of all events in calendar. 199 Return filtered list of all events in calendar.
199 */ 200 */
200 virtual QPtrList<Event> events(); 201 virtual QPtrList<Event> events();
201 /** 202 /**
202 Return unfiltered list of all events in calendar. 203 Return unfiltered list of all events in calendar.
203 */ 204 */
204 virtual QPtrList<Event> rawEvents() = 0; 205 virtual QPtrList<Event> rawEvents() = 0;
205 206
206 /** 207 /**
207 Add a todo to the todolist. 208 Add a todo to the todolist.
208 209
209 @return true on success, false on error. 210 @return true on success, false on error.
210 */ 211 */
211 virtual bool addTodo( Todo *todo ) = 0; 212 virtual bool addTodo( Todo *todo ) = 0;
212 virtual bool addTodoNoDup( Todo *todo ) = 0; 213 virtual bool addTodoNoDup( Todo *todo ) = 0;
213 /** 214 /**
214 Remove a todo from the todolist. 215 Remove a todo from the todolist.
215 */ 216 */
216 virtual void deleteTodo( Todo * ) = 0; 217 virtual void deleteTodo( Todo * ) = 0;
217 virtual void deleteJournal( Journal * ) = 0; 218 virtual void deleteJournal( Journal * ) = 0;
218 /** 219 /**
219 Return filterd list of todos. 220 Return filterd list of todos.
220 */ 221 */
221 virtual QPtrList<Todo> todos(); 222 virtual QPtrList<Todo> todos();
222 /** 223 /**
223 Searches todolist for an event with this unique string identifier, 224 Searches todolist for an event with this unique string identifier,
224 returns a pointer or null. 225 returns a pointer or null.
225 */ 226 */
226 virtual Todo *todo( const QString &uid ) = 0; 227 virtual Todo *todo( const QString &uid ) = 0;
227 virtual Todo *todo( QString, QString ) = 0; 228 virtual Todo *todo( QString, QString ) = 0;
228 /** 229 /**
229 Returns list of todos due on the specified date. 230 Returns list of todos due on the specified date.
230 */ 231 */
231 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 232 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
232 /** 233 /**
233 Return unfiltered list of todos. 234 Return unfiltered list of todos.
234 */ 235 */
235 virtual QPtrList<Todo> rawTodos() = 0; 236 virtual QPtrList<Todo> rawTodos() = 0;
236 237
237 /** 238 /**
238 Add a Journal entry to calendar. 239 Add a Journal entry to calendar.
239 240
240 @return true on success, false on error. 241 @return true on success, false on error.
241 */ 242 */
242 virtual bool addJournal( Journal * ) = 0; 243 virtual bool addJournal( Journal * ) = 0;
243 /** 244 /**
244 Return Journal for given date. 245 Return Journal for given date.
245 */ 246 */
246 virtual Journal *journal( const QDate & ) = 0; 247 virtual Journal *journal( const QDate & ) = 0;
247 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; 248 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0;
248 /** 249 /**
249 Return Journal with given UID. 250 Return Journal with given UID.
250 */ 251 */
251 virtual Journal *journal( const QString &UID ) = 0; 252 virtual Journal *journal( const QString &UID ) = 0;
252 /** 253 /**
253 Return list of all Journal entries. 254 Return list of all Journal entries.
254 */ 255 */
255 virtual QPtrList<Journal> journals() = 0; 256 virtual QPtrList<Journal> journals() = 0;
256 257
257 /** 258 /**
258 Searches all incidence types for an incidence with this unique 259 Searches all incidence types for an incidence with this unique
259 string identifier, returns a pointer or null. 260 string identifier, returns a pointer or null.
260 */ 261 */
261 Incidence* incidence( const QString&UID ); 262 Incidence* incidence( const QString&UID );
262 263
263 /** 264 /**
264 Setup relations for an incidence. 265 Setup relations for an incidence.
265 */ 266 */
266 virtual void setupRelations( Incidence * ); 267 virtual void setupRelations( Incidence * );
267 /** 268 /**
268 Remove all relations to an incidence 269 Remove all relations to an incidence
269 */ 270 */
270 virtual void removeRelations( Incidence * ); 271 virtual void removeRelations( Incidence * );
271 272
272 /** 273 /**
273 Set calendar filter, which filters events for the events() functions. 274 Set calendar filter, which filters events for the events() functions.
274 The Filter object is owned by the caller. 275 The Filter object is owned by the caller.
275 */ 276 */
276 void setFilter( CalFilter * ); 277 void setFilter( CalFilter * );
277 /** 278 /**
278 Return calendar filter. 279 Return calendar filter.
279 */ 280 */
280 CalFilter *filter(); 281 CalFilter *filter();
281 virtual QDateTime nextAlarm( int daysTo ) = 0; 282 virtual QDateTime nextAlarm( int daysTo ) = 0;
282 virtual QString nextSummary( ) const = 0; 283 virtual QString nextSummary( ) const = 0;
283 virtual void reInitAlarmSettings() = 0; 284 virtual void reInitAlarmSettings() = 0;
284 virtual QDateTime nextAlarmEventDateTime() const = 0; 285 virtual QDateTime nextAlarmEventDateTime() const = 0;
285 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 286 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
286 /** 287 /**
287 Return all alarms, which ocur in the given time interval. 288 Return all alarms, which ocur in the given time interval.
288 */ 289 */
289 virtual Alarm::List alarms( const QDateTime &from, 290 virtual Alarm::List alarms( const QDateTime &from,
290 const QDateTime &to ) = 0; 291 const QDateTime &to ) = 0;
291 292
292 class Observer { 293 class Observer {
293 public: 294 public:
294 virtual void calendarModified( bool, Calendar * ) = 0; 295 virtual void calendarModified( bool, Calendar * ) = 0;
295 }; 296 };
296 297
297 void registerObserver( Observer * ); 298 void registerObserver( Observer * );
298 299
299 void setModified( bool ); 300 void setModified( bool );
300 301
301 /** 302 /**
302 Set product id returned by loadedProductId(). This function is only 303 Set product id returned by loadedProductId(). This function is only
303 useful for the calendar loading code. 304 useful for the calendar loading code.
304 */ 305 */
305 void setLoadedProductId( const QString & ); 306 void setLoadedProductId( const QString & );
306 /** 307 /**
307 Return product id taken from file that has been loaded. Returns 308 Return product id taken from file that has been loaded. Returns
308 QString::null, if no calendar has been loaded. 309 QString::null, if no calendar has been loaded.
309 */ 310 */
310 QString loadedProductId(); 311 QString loadedProductId();
311 int defaultCalendar(); 312 int defaultCalendar();
312 void setDontDeleteIncidencesOnClose (); 313 void setDontDeleteIncidencesOnClose ();
313 public slots: 314 public slots:
314 void setDefaultCalendar( int ); 315 void setDefaultCalendar( int );
315 virtual void setCalendarEnabled( int id, bool enable ) = 0; 316 virtual void setCalendarEnabled( int id, bool enable ) = 0;
316 virtual void setAlarmEnabled( int id, bool enable ) = 0; 317 virtual void setAlarmEnabled( int id, bool enable ) = 0;
317 virtual void setReadOnly( int id, bool enable ) = 0; 318 virtual void setReadOnly( int id, bool enable ) = 0;
318 virtual void setDefaultCalendarEnabledOnly() = 0; 319 virtual void setDefaultCalendarEnabledOnly() = 0;
319 virtual void setCalendarRemove( int id ) = 0; 320 virtual void setCalendarRemove( int id ) = 0;
320 signals: 321 signals:
321 void calendarChanged(); 322 void calendarChanged();
322 void calendarSaved(); 323 void calendarSaved();
323 void calendarLoaded(); 324 void calendarLoaded();
324 void addAlarm(const QDateTime &qdt, const QString &noti ); 325 void addAlarm(const QDateTime &qdt, const QString &noti );
325 void removeAlarm(const QDateTime &qdt, const QString &noti ); 326 void removeAlarm(const QDateTime &qdt, const QString &noti );
326 327
327 protected: 328 protected:
328 /** 329 /**
329 Get unfiltered events, which occur on the given date. 330 Get unfiltered events, which occur on the given date.
330 */ 331 */
331 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 332 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
332 /** 333 /**
333 Get unfiltered events, which occur on the given date. 334 Get unfiltered events, which occur on the given date.
334 */ 335 */
335 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 336 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
336 bool sorted = false ) = 0; 337 bool sorted = false ) = 0;
337 /** 338 /**
338 Get events in a range of dates. If inclusive is set to true, only events 339 Get events in a range of dates. If inclusive is set to true, only events
339 are returned, which are completely included in the range. 340 are returned, which are completely included in the range.
340 */ 341 */
341 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 342 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
342 bool inclusive = false ) = 0; 343 bool inclusive = false ) = 0;
343 344
344 Incidence *mNextAlarmIncidence; 345 Incidence *mNextAlarmIncidence;
345 Incidence *mUndoIncidence; 346 Incidence *mUndoIncidence;
346 int mDefaultCalendar; 347 int mDefaultCalendar;
347 bool mDeleteIncidencesOnClose; 348 bool mDeleteIncidencesOnClose;
348 349
349private: 350private:
350 void init(); 351 void init();
351 352
352 QString mOwner; // who the calendar belongs to 353 QString mOwner; // who the calendar belongs to
353 QString mOwnerEmail; // email address of the owner 354 QString mOwnerEmail; // email address of the owner
354 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 355 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
355 bool mLocalTime; // use local time, not UTC or a time zone 356 bool mLocalTime; // use local time, not UTC or a time zone
356 357
357 358
358 CalFilter *mFilter; 359 CalFilter *mFilter;
359 CalFilter *mDefaultFilter; 360 CalFilter *mDefaultFilter;
360 361
361 362
362 QString mTimeZoneId; 363 QString mTimeZoneId;
363 364
364 Observer *mObserver; 365 Observer *mObserver;
365 bool mNewObserver; 366 bool mNewObserver;
366 367
367 bool mModified; 368 bool mModified;
368 369
369 QString mLoadedProductId; 370 QString mLoadedProductId;
370 371
371 // This list is used to put together related todos 372 // This list is used to put together related todos
372 QDict<Incidence> mOrphans; 373 QDict<Incidence> mOrphans;
373 QDict<Incidence> mOrphanUids; 374 QDict<Incidence> mOrphanUids;
374}; 375};
375 376
376} 377}
377 378
378#endif 379#endif