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