-rw-r--r-- | libkcal/calendar.h | 9 |
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 | |||
@@ -13,128 +13,130 @@ | |||
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 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace 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 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
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. |
@@ -241,126 +243,131 @@ public: | |||
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 ¬i ); | 319 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
315 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 320 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
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 | ||
338 | private: | 344 | private: |
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 |