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 95477cd..3f6895d 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,379 +1,380 @@
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 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
81 virtual void setSyncEventsReadOnly() = 0; 81 virtual void setSyncEventsReadOnly() = 0;
82 virtual void stopAllTodos() = 0; 82 virtual void stopAllTodos() = 0;
83 virtual void clearUndo( Incidence * newUndo );
83 84
84 /** 85 /**
85 Sync changes in memory to persistant storage. 86 Sync changes in memory to persistant storage.
86 */ 87 */
87 virtual void save() = 0; 88 virtual void save() = 0;
88 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 89 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
89 virtual void removeSyncInfo( QString syncProfile) = 0; 90 virtual void removeSyncInfo( QString syncProfile) = 0;
90 virtual bool isSaving() { return false; } 91 virtual bool isSaving() { return false; }
91 92
92 /** 93 /**
93 Return the owner of the calendar's full name. 94 Return the owner of the calendar's full name.
94 */ 95 */
95 const QString &getOwner() const; 96 const QString &getOwner() const;
96 /** 97 /**
97 Set the owner of the calendar. Should be owner's full name. 98 Set the owner of the calendar. Should be owner's full name.
98 */ 99 */
99 void setOwner( const QString &os ); 100 void setOwner( const QString &os );
100 /** 101 /**
101 Return the email address of the calendar owner. 102 Return the email address of the calendar owner.
102 */ 103 */
103 const QString &getEmail(); 104 const QString &getEmail();
104 /** 105 /**
105 Set the email address of the calendar owner. 106 Set the email address of the calendar owner.
106 */ 107 */
107 void setEmail( const QString & ); 108 void setEmail( const QString & );
108 109
109 /** 110 /**
110 Set time zone from a timezone string (e.g. -2:00) 111 Set time zone from a timezone string (e.g. -2:00)
111 */ 112 */
112 void setTimeZone( const QString &tz ); 113 void setTimeZone( const QString &tz );
113 /** 114 /**
114 Set time zone from a minutes value (e.g. -60) 115 Set time zone from a minutes value (e.g. -60)
115 */ 116 */
116 void setTimeZone( int tz ); 117 void setTimeZone( int tz );
117 /** 118 /**
118 Return time zone as offest in minutes. 119 Return time zone as offest in minutes.
119 */ 120 */
120 int getTimeZone() const; 121 int getTimeZone() const;
121 /** 122 /**
122 Compute an ISO 8601 format string from the time zone. 123 Compute an ISO 8601 format string from the time zone.
123 */ 124 */
124 QString getTimeZoneStr() const; 125 QString getTimeZoneStr() const;
125 /** 126 /**
126 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 127 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
127 values). 128 values).
128 */ 129 */
129 void setTimeZoneId( const QString & ); 130 void setTimeZoneId( const QString & );
130 /** 131 /**
131 Return time zone id. 132 Return time zone id.
132 */ 133 */
133 QString timeZoneId() const; 134 QString timeZoneId() const;
134 /** 135 /**
135 Use local time, not UTC or a time zone. 136 Use local time, not UTC or a time zone.
136 */ 137 */
137 void setLocalTime(); 138 void setLocalTime();
138 /** 139 /**
139 Return whether local time is being used. 140 Return whether local time is being used.
140 */ 141 */
141 bool isLocalTime() const; 142 bool isLocalTime() const;
142 143
143 /** 144 /**
144 Add an incidence to calendar. 145 Add an incidence to calendar.
145 146
146 @return true on success, false on error. 147 @return true on success, false on error.
147 */ 148 */
148 virtual bool addIncidence( Incidence * ); 149 virtual bool addIncidence( Incidence * );
149 150
150 // Adds an incidence and all relatedto incidences to the cal 151 // Adds an incidence and all relatedto incidences to the cal
151 void addIncidenceBranch( Incidence * ); 152 void addIncidenceBranch( Incidence * );
152 /** 153 /**
153 Return filtered list of all incidences of this calendar. 154 Return filtered list of all incidences of this calendar.
154 */ 155 */
155 virtual QPtrList<Incidence> incidences(); 156 virtual QPtrList<Incidence> incidences();
156 157
157 /** 158 /**
158 Return unfiltered list of all incidences of this calendar. 159 Return unfiltered list of all incidences of this calendar.
159 */ 160 */
160 virtual QPtrList<Incidence> rawIncidences(); 161 virtual QPtrList<Incidence> rawIncidences();
161 162
162 /** 163 /**
163 Adds a Event to this calendar object. 164 Adds a Event to this calendar object.
164 @param anEvent a pointer to the event to add 165 @param anEvent a pointer to the event to add
165 166
166 @return true on success, false on error. 167 @return true on success, false on error.
167 */ 168 */
168 virtual bool addEventNoDup( Event *event ) = 0; 169 virtual bool addEventNoDup( Event *event ) = 0;
169 virtual bool addAnniversaryNoDup( Event *event ) = 0; 170 virtual bool addAnniversaryNoDup( Event *event ) = 0;
170 virtual bool addEvent( Event *anEvent ) = 0; 171 virtual bool addEvent( Event *anEvent ) = 0;
171 /** 172 /**
172 Delete event from calendar. 173 Delete event from calendar.
173 */ 174 */
174 virtual void deleteEvent( Event * ) = 0; 175 virtual void deleteEvent( Event * ) = 0;
175 /** 176 /**
176 Retrieves an event on the basis of the unique string ID. 177 Retrieves an event on the basis of the unique string ID.
177 */ 178 */
178 virtual Event *event( const QString &UniqueStr ) = 0; 179 virtual Event *event( const QString &UniqueStr ) = 0;
179 virtual Event *event( QString, QString ) = 0; 180 virtual Event *event( QString, QString ) = 0;
180 /** 181 /**
181 Builds and then returns a list of all events that match for the 182 Builds and then returns a list of all events that match for the
182 date specified. useful for dayView, etc. etc. 183 date specified. useful for dayView, etc. etc.
183 The calendar filter is applied. 184 The calendar filter is applied.
184 */ 185 */
185 QPtrList<Event> events( const QDate &date, bool sorted = false); 186 QPtrList<Event> events( const QDate &date, bool sorted = false);
186 /** 187 /**
187 Get events, which occur on the given date. 188 Get events, which occur on the given date.
188 The calendar filter is applied. 189 The calendar filter is applied.
189 */ 190 */
190 QPtrList<Event> events( const QDateTime &qdt ); 191 QPtrList<Event> events( const QDateTime &qdt );
191 /** 192 /**
192 Get events in a range of dates. If inclusive is set to true, only events 193 Get events in a range of dates. If inclusive is set to true, only events
193 are returned, which are completely included in the range. 194 are returned, which are completely included in the range.
194 The calendar filter is applied. 195 The calendar filter is applied.
195 */ 196 */
196 QPtrList<Event> events( const QDate &start, const QDate &end, 197 QPtrList<Event> events( const QDate &start, const QDate &end,
197 bool inclusive = false); 198 bool inclusive = false);
198 /** 199 /**
199 Return filtered list of all events in calendar. 200 Return filtered list of all events in calendar.
200 */ 201 */
201 virtual QPtrList<Event> events(); 202 virtual QPtrList<Event> events();
202 /** 203 /**
203 Return unfiltered list of all events in calendar. 204 Return unfiltered list of all events in calendar.
204 */ 205 */
205 virtual QPtrList<Event> rawEvents() = 0; 206 virtual QPtrList<Event> rawEvents() = 0;
206 207
207 /** 208 /**
208 Add a todo to the todolist. 209 Add a todo to the todolist.
209 210
210 @return true on success, false on error. 211 @return true on success, false on error.
211 */ 212 */
212 virtual bool addTodo( Todo *todo ) = 0; 213 virtual bool addTodo( Todo *todo ) = 0;
213 virtual bool addTodoNoDup( Todo *todo ) = 0; 214 virtual bool addTodoNoDup( Todo *todo ) = 0;
214 /** 215 /**
215 Remove a todo from the todolist. 216 Remove a todo from the todolist.
216 */ 217 */
217 virtual void deleteTodo( Todo * ) = 0; 218 virtual void deleteTodo( Todo * ) = 0;
218 virtual void deleteJournal( Journal * ) = 0; 219 virtual void deleteJournal( Journal * ) = 0;
219 /** 220 /**
220 Return filterd list of todos. 221 Return filterd list of todos.
221 */ 222 */
222 virtual QPtrList<Todo> todos(); 223 virtual QPtrList<Todo> todos();
223 /** 224 /**
224 Searches todolist for an event with this unique string identifier, 225 Searches todolist for an event with this unique string identifier,
225 returns a pointer or null. 226 returns a pointer or null.
226 */ 227 */
227 virtual Todo *todo( const QString &uid ) = 0; 228 virtual Todo *todo( const QString &uid ) = 0;
228 virtual Todo *todo( QString, QString ) = 0; 229 virtual Todo *todo( QString, QString ) = 0;
229 /** 230 /**
230 Returns list of todos due on the specified date. 231 Returns list of todos due on the specified date.
231 */ 232 */
232 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 233 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
233 /** 234 /**
234 Return unfiltered list of todos. 235 Return unfiltered list of todos.
235 */ 236 */
236 virtual QPtrList<Todo> rawTodos() = 0; 237 virtual QPtrList<Todo> rawTodos() = 0;
237 238
238 /** 239 /**
239 Add a Journal entry to calendar. 240 Add a Journal entry to calendar.
240 241
241 @return true on success, false on error. 242 @return true on success, false on error.
242 */ 243 */
243 virtual bool addJournal( Journal * ) = 0; 244 virtual bool addJournal( Journal * ) = 0;
244 /** 245 /**
245 Return Journal for given date. 246 Return Journal for given date.
246 */ 247 */
247 virtual Journal *journal( const QDate & ) = 0; 248 virtual Journal *journal( const QDate & ) = 0;
248 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; 249 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0;
249 /** 250 /**
250 Return Journal with given UID. 251 Return Journal with given UID.
251 */ 252 */
252 virtual Journal *journal( const QString &UID ) = 0; 253 virtual Journal *journal( const QString &UID ) = 0;
253 /** 254 /**
254 Return list of all Journal entries. 255 Return list of all Journal entries.
255 */ 256 */
256 virtual QPtrList<Journal> journals() = 0; 257 virtual QPtrList<Journal> journals() = 0;
257 258
258 /** 259 /**
259 Searches all incidence types for an incidence with this unique 260 Searches all incidence types for an incidence with this unique
260 string identifier, returns a pointer or null. 261 string identifier, returns a pointer or null.
261 */ 262 */
262 Incidence* incidence( const QString&UID ); 263 Incidence* incidence( const QString&UID );
263 264
264 /** 265 /**
265 Setup relations for an incidence. 266 Setup relations for an incidence.
266 */ 267 */
267 virtual void setupRelations( Incidence * ); 268 virtual void setupRelations( Incidence * );
268 /** 269 /**
269 Remove all relations to an incidence 270 Remove all relations to an incidence
270 */ 271 */
271 virtual void removeRelations( Incidence * ); 272 virtual void removeRelations( Incidence * );
272 273
273 /** 274 /**
274 Set calendar filter, which filters events for the events() functions. 275 Set calendar filter, which filters events for the events() functions.
275 The Filter object is owned by the caller. 276 The Filter object is owned by the caller.
276 */ 277 */
277 void setFilter( CalFilter * ); 278 void setFilter( CalFilter * );
278 /** 279 /**
279 Return calendar filter. 280 Return calendar filter.
280 */ 281 */
281 CalFilter *filter(); 282 CalFilter *filter();
282 virtual QDateTime nextAlarm( int daysTo ) = 0; 283 virtual QDateTime nextAlarm( int daysTo ) = 0;
283 virtual QString nextSummary( ) const = 0; 284 virtual QString nextSummary( ) const = 0;
284 virtual void reInitAlarmSettings() = 0; 285 virtual void reInitAlarmSettings() = 0;
285 virtual QDateTime nextAlarmEventDateTime() const = 0; 286 virtual QDateTime nextAlarmEventDateTime() const = 0;
286 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 287 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
287 /** 288 /**
288 Return all alarms, which ocur in the given time interval. 289 Return all alarms, which ocur in the given time interval.
289 */ 290 */
290 virtual Alarm::List alarms( const QDateTime &from, 291 virtual Alarm::List alarms( const QDateTime &from,
291 const QDateTime &to ) = 0; 292 const QDateTime &to ) = 0;
292 293
293 class Observer { 294 class Observer {
294 public: 295 public:
295 virtual void calendarModified( bool, Calendar * ) = 0; 296 virtual void calendarModified( bool, Calendar * ) = 0;
296 }; 297 };
297 298
298 void registerObserver( Observer * ); 299 void registerObserver( Observer * );
299 300
300 void setModified( bool ); 301 void setModified( bool );
301 302
302 /** 303 /**
303 Set product id returned by loadedProductId(). This function is only 304 Set product id returned by loadedProductId(). This function is only
304 useful for the calendar loading code. 305 useful for the calendar loading code.
305 */ 306 */
306 void setLoadedProductId( const QString & ); 307 void setLoadedProductId( const QString & );
307 /** 308 /**
308 Return product id taken from file that has been loaded. Returns 309 Return product id taken from file that has been loaded. Returns
309 QString::null, if no calendar has been loaded. 310 QString::null, if no calendar has been loaded.
310 */ 311 */
311 QString loadedProductId(); 312 QString loadedProductId();
312 int defaultCalendar(); 313 int defaultCalendar();
313 void setDontDeleteIncidencesOnClose (); 314 void setDontDeleteIncidencesOnClose ();
314 public slots: 315 public slots:
315 void setDefaultCalendar( int ); 316 void setDefaultCalendar( int );
316 virtual void setCalendarEnabled( int id, bool enable ) = 0; 317 virtual void setCalendarEnabled( int id, bool enable ) = 0;
317 virtual void setAlarmEnabled( int id, bool enable ) = 0; 318 virtual void setAlarmEnabled( int id, bool enable ) = 0;
318 virtual void setReadOnly( int id, bool enable ) = 0; 319 virtual void setReadOnly( int id, bool enable ) = 0;
319 virtual void setDefaultCalendarEnabledOnly() = 0; 320 virtual void setDefaultCalendarEnabledOnly() = 0;
320 virtual void setCalendarRemove( int id ) = 0; 321 virtual void setCalendarRemove( int id ) = 0;
321 signals: 322 signals:
322 void calendarChanged(); 323 void calendarChanged();
323 void calendarSaved(); 324 void calendarSaved();
324 void calendarLoaded(); 325 void calendarLoaded();
325 void addAlarm(const QDateTime &qdt, const QString &noti ); 326 void addAlarm(const QDateTime &qdt, const QString &noti );
326 void removeAlarm(const QDateTime &qdt, const QString &noti ); 327 void removeAlarm(const QDateTime &qdt, const QString &noti );
327 328
328 protected: 329 protected:
329 /** 330 /**
330 Get unfiltered events, which occur on the given date. 331 Get unfiltered events, which occur on the given date.
331 */ 332 */
332 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 333 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
333 /** 334 /**
334 Get unfiltered events, which occur on the given date. 335 Get unfiltered events, which occur on the given date.
335 */ 336 */
336 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 337 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
337 bool sorted = false ) = 0; 338 bool sorted = false ) = 0;
338 /** 339 /**
339 Get events in a range of dates. If inclusive is set to true, only events 340 Get events in a range of dates. If inclusive is set to true, only events
340 are returned, which are completely included in the range. 341 are returned, which are completely included in the range.
341 */ 342 */
342 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 343 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
343 bool inclusive = false ) = 0; 344 bool inclusive = false ) = 0;
344 345
345 Incidence *mNextAlarmIncidence; 346 Incidence *mNextAlarmIncidence;
346 Incidence *mUndoIncidence; 347 Incidence *mUndoIncidence;
347 int mDefaultCalendar; 348 int mDefaultCalendar;
348 bool mDeleteIncidencesOnClose; 349 bool mDeleteIncidencesOnClose;
349 350
350private: 351private:
351 void init(); 352 void init();
352 353
353 QString mOwner; // who the calendar belongs to 354 QString mOwner; // who the calendar belongs to
354 QString mOwnerEmail; // email address of the owner 355 QString mOwnerEmail; // email address of the owner
355 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 356 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
356 bool mLocalTime; // use local time, not UTC or a time zone 357 bool mLocalTime; // use local time, not UTC or a time zone
357 358
358 359
359 CalFilter *mFilter; 360 CalFilter *mFilter;
360 CalFilter *mDefaultFilter; 361 CalFilter *mDefaultFilter;
361 362
362 363
363 QString mTimeZoneId; 364 QString mTimeZoneId;
364 365
365 Observer *mObserver; 366 Observer *mObserver;
366 bool mNewObserver; 367 bool mNewObserver;
367 368
368 bool mModified; 369 bool mModified;
369 370
370 QString mLoadedProductId; 371 QString mLoadedProductId;
371 372
372 // This list is used to put together related todos 373 // This list is used to put together related todos
373 QDict<Incidence> mOrphans; 374 QDict<Incidence> mOrphans;
374 QDict<Incidence> mOrphanUids; 375 QDict<Incidence> mOrphanUids;
375}; 376};
376 377
377} 378}
378 379
379#endif 380#endif