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