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