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