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