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