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