-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 23 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 5 |
4 files changed, 28 insertions, 2 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b801186..b7d6a1f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,352 +1,353 @@ | |||
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 | ||
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 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 69 | void resetTempSyncStat(); |
70 | void resetPilotStat(int id); | 70 | void resetPilotStat(int id); |
71 | /** | 71 | /** |
72 | Clears out the current calendar, freeing all used memory etc. | 72 | Clears out the current calendar, freeing all used memory etc. |
73 | */ | 73 | */ |
74 | virtual void close() = 0; | 74 | virtual void close() = 0; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | Sync changes in memory to persistant storage. | 77 | Sync changes in memory to persistant storage. |
78 | */ | 78 | */ |
79 | virtual void save() = 0; | 79 | virtual void save() = 0; |
80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
81 | virtual void removeSyncInfo( QString syncProfile) = 0; | ||
81 | virtual bool isSaving() { return false; } | 82 | virtual bool isSaving() { return false; } |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Return the owner of the calendar's full name. | 85 | Return the owner of the calendar's full name. |
85 | */ | 86 | */ |
86 | const QString &getOwner() const; | 87 | const QString &getOwner() const; |
87 | /** | 88 | /** |
88 | Set the owner of the calendar. Should be owner's full name. | 89 | Set the owner of the calendar. Should be owner's full name. |
89 | */ | 90 | */ |
90 | void setOwner( const QString &os ); | 91 | void setOwner( const QString &os ); |
91 | /** | 92 | /** |
92 | Return the email address of the calendar owner. | 93 | Return the email address of the calendar owner. |
93 | */ | 94 | */ |
94 | const QString &getEmail(); | 95 | const QString &getEmail(); |
95 | /** | 96 | /** |
96 | Set the email address of the calendar owner. | 97 | Set the email address of the calendar owner. |
97 | */ | 98 | */ |
98 | void setEmail( const QString & ); | 99 | void setEmail( const QString & ); |
99 | 100 | ||
100 | /** | 101 | /** |
101 | Set time zone from a timezone string (e.g. -2:00) | 102 | Set time zone from a timezone string (e.g. -2:00) |
102 | */ | 103 | */ |
103 | void setTimeZone( const QString &tz ); | 104 | void setTimeZone( const QString &tz ); |
104 | /** | 105 | /** |
105 | Set time zone from a minutes value (e.g. -60) | 106 | Set time zone from a minutes value (e.g. -60) |
106 | */ | 107 | */ |
107 | void setTimeZone( int tz ); | 108 | void setTimeZone( int tz ); |
108 | /** | 109 | /** |
109 | Return time zone as offest in minutes. | 110 | Return time zone as offest in minutes. |
110 | */ | 111 | */ |
111 | int getTimeZone() const; | 112 | int getTimeZone() const; |
112 | /** | 113 | /** |
113 | Compute an ISO 8601 format string from the time zone. | 114 | Compute an ISO 8601 format string from the time zone. |
114 | */ | 115 | */ |
115 | QString getTimeZoneStr() const; | 116 | QString getTimeZoneStr() const; |
116 | /** | 117 | /** |
117 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 118 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
118 | values). | 119 | values). |
119 | */ | 120 | */ |
120 | void setTimeZoneId( const QString & ); | 121 | void setTimeZoneId( const QString & ); |
121 | /** | 122 | /** |
122 | Return time zone id. | 123 | Return time zone id. |
123 | */ | 124 | */ |
124 | QString timeZoneId() const; | 125 | QString timeZoneId() const; |
125 | /** | 126 | /** |
126 | Use local time, not UTC or a time zone. | 127 | Use local time, not UTC or a time zone. |
127 | */ | 128 | */ |
128 | void setLocalTime(); | 129 | void setLocalTime(); |
129 | /** | 130 | /** |
130 | Return whether local time is being used. | 131 | Return whether local time is being used. |
131 | */ | 132 | */ |
132 | bool isLocalTime() const; | 133 | bool isLocalTime() const; |
133 | 134 | ||
134 | /** | 135 | /** |
135 | Add an incidence to calendar. | 136 | Add an incidence to calendar. |
136 | 137 | ||
137 | @return true on success, false on error. | 138 | @return true on success, false on error. |
138 | */ | 139 | */ |
139 | virtual bool addIncidence( Incidence * ); | 140 | virtual bool addIncidence( Incidence * ); |
140 | /** | 141 | /** |
141 | Return filtered list of all incidences of this calendar. | 142 | Return filtered list of all incidences of this calendar. |
142 | */ | 143 | */ |
143 | virtual QPtrList<Incidence> incidences(); | 144 | virtual QPtrList<Incidence> incidences(); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Return unfiltered list of all incidences of this calendar. | 147 | Return unfiltered list of all incidences of this calendar. |
147 | */ | 148 | */ |
148 | virtual QPtrList<Incidence> rawIncidences(); | 149 | virtual QPtrList<Incidence> rawIncidences(); |
149 | 150 | ||
150 | /** | 151 | /** |
151 | Adds a Event to this calendar object. | 152 | Adds a Event to this calendar object. |
152 | @param anEvent a pointer to the event to add | 153 | @param anEvent a pointer to the event to add |
153 | 154 | ||
154 | @return true on success, false on error. | 155 | @return true on success, false on error. |
155 | */ | 156 | */ |
156 | virtual bool addEventNoDup( Event *event ) = 0; | 157 | virtual bool addEventNoDup( Event *event ) = 0; |
157 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 158 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
158 | virtual bool addEvent( Event *anEvent ) = 0; | 159 | virtual bool addEvent( Event *anEvent ) = 0; |
159 | /** | 160 | /** |
160 | Delete event from calendar. | 161 | Delete event from calendar. |
161 | */ | 162 | */ |
162 | virtual void deleteEvent( Event * ) = 0; | 163 | virtual void deleteEvent( Event * ) = 0; |
163 | /** | 164 | /** |
164 | Retrieves an event on the basis of the unique string ID. | 165 | Retrieves an event on the basis of the unique string ID. |
165 | */ | 166 | */ |
166 | virtual Event *event( const QString &UniqueStr ) = 0; | 167 | virtual Event *event( const QString &UniqueStr ) = 0; |
167 | virtual Event *event( QString, QString ) = 0; | 168 | virtual Event *event( QString, QString ) = 0; |
168 | /** | 169 | /** |
169 | Builds and then returns a list of all events that match for the | 170 | Builds and then returns a list of all events that match for the |
170 | date specified. useful for dayView, etc. etc. | 171 | date specified. useful for dayView, etc. etc. |
171 | The calendar filter is applied. | 172 | The calendar filter is applied. |
172 | */ | 173 | */ |
173 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 174 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
174 | /** | 175 | /** |
175 | Get events, which occur on the given date. | 176 | Get events, which occur on the given date. |
176 | The calendar filter is applied. | 177 | The calendar filter is applied. |
177 | */ | 178 | */ |
178 | QPtrList<Event> events( const QDateTime &qdt ); | 179 | QPtrList<Event> events( const QDateTime &qdt ); |
179 | /** | 180 | /** |
180 | Get events in a range of dates. If inclusive is set to true, only events | 181 | Get events in a range of dates. If inclusive is set to true, only events |
181 | are returned, which are completely included in the range. | 182 | are returned, which are completely included in the range. |
182 | The calendar filter is applied. | 183 | The calendar filter is applied. |
183 | */ | 184 | */ |
184 | QPtrList<Event> events( const QDate &start, const QDate &end, | 185 | QPtrList<Event> events( const QDate &start, const QDate &end, |
185 | bool inclusive = false); | 186 | bool inclusive = false); |
186 | /** | 187 | /** |
187 | Return filtered list of all events in calendar. | 188 | Return filtered list of all events in calendar. |
188 | */ | 189 | */ |
189 | virtual QPtrList<Event> events(); | 190 | virtual QPtrList<Event> events(); |
190 | /** | 191 | /** |
191 | Return unfiltered list of all events in calendar. | 192 | Return unfiltered list of all events in calendar. |
192 | */ | 193 | */ |
193 | virtual QPtrList<Event> rawEvents() = 0; | 194 | virtual QPtrList<Event> rawEvents() = 0; |
194 | 195 | ||
195 | /** | 196 | /** |
196 | Add a todo to the todolist. | 197 | Add a todo to the todolist. |
197 | 198 | ||
198 | @return true on success, false on error. | 199 | @return true on success, false on error. |
199 | */ | 200 | */ |
200 | virtual bool addTodo( Todo *todo ) = 0; | 201 | virtual bool addTodo( Todo *todo ) = 0; |
201 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 202 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
202 | /** | 203 | /** |
203 | Remove a todo from the todolist. | 204 | Remove a todo from the todolist. |
204 | */ | 205 | */ |
205 | virtual void deleteTodo( Todo * ) = 0; | 206 | virtual void deleteTodo( Todo * ) = 0; |
206 | virtual void deleteJournal( Journal * ) = 0; | 207 | virtual void deleteJournal( Journal * ) = 0; |
207 | /** | 208 | /** |
208 | Return filterd list of todos. | 209 | Return filterd list of todos. |
209 | */ | 210 | */ |
210 | virtual QPtrList<Todo> todos(); | 211 | virtual QPtrList<Todo> todos(); |
211 | /** | 212 | /** |
212 | Searches todolist for an event with this unique string identifier, | 213 | Searches todolist for an event with this unique string identifier, |
213 | returns a pointer or null. | 214 | returns a pointer or null. |
214 | */ | 215 | */ |
215 | virtual Todo *todo( const QString &uid ) = 0; | 216 | virtual Todo *todo( const QString &uid ) = 0; |
216 | virtual Todo *todo( QString, QString ) = 0; | 217 | virtual Todo *todo( QString, QString ) = 0; |
217 | /** | 218 | /** |
218 | Returns list of todos due on the specified date. | 219 | Returns list of todos due on the specified date. |
219 | */ | 220 | */ |
220 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 221 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
221 | /** | 222 | /** |
222 | Return unfiltered list of todos. | 223 | Return unfiltered list of todos. |
223 | */ | 224 | */ |
224 | virtual QPtrList<Todo> rawTodos() = 0; | 225 | virtual QPtrList<Todo> rawTodos() = 0; |
225 | 226 | ||
226 | /** | 227 | /** |
227 | Add a Journal entry to calendar. | 228 | Add a Journal entry to calendar. |
228 | 229 | ||
229 | @return true on success, false on error. | 230 | @return true on success, false on error. |
230 | */ | 231 | */ |
231 | virtual bool addJournal( Journal * ) = 0; | 232 | virtual bool addJournal( Journal * ) = 0; |
232 | /** | 233 | /** |
233 | Return Journal for given date. | 234 | Return Journal for given date. |
234 | */ | 235 | */ |
235 | virtual Journal *journal( const QDate & ) = 0; | 236 | virtual Journal *journal( const QDate & ) = 0; |
236 | /** | 237 | /** |
237 | Return Journal with given UID. | 238 | Return Journal with given UID. |
238 | */ | 239 | */ |
239 | virtual Journal *journal( const QString &UID ) = 0; | 240 | virtual Journal *journal( const QString &UID ) = 0; |
240 | /** | 241 | /** |
241 | Return list of all Journal entries. | 242 | Return list of all Journal entries. |
242 | */ | 243 | */ |
243 | virtual QPtrList<Journal> journals() = 0; | 244 | virtual QPtrList<Journal> journals() = 0; |
244 | 245 | ||
245 | /** | 246 | /** |
246 | Searches all incidence types for an incidence with this unique | 247 | Searches all incidence types for an incidence with this unique |
247 | string identifier, returns a pointer or null. | 248 | string identifier, returns a pointer or null. |
248 | */ | 249 | */ |
249 | Incidence* incidence( const QString&UID ); | 250 | Incidence* incidence( const QString&UID ); |
250 | 251 | ||
251 | /** | 252 | /** |
252 | Setup relations for an incidence. | 253 | Setup relations for an incidence. |
253 | */ | 254 | */ |
254 | virtual void setupRelations( Incidence * ); | 255 | virtual void setupRelations( Incidence * ); |
255 | /** | 256 | /** |
256 | Remove all relations to an incidence | 257 | Remove all relations to an incidence |
257 | */ | 258 | */ |
258 | virtual void removeRelations( Incidence * ); | 259 | virtual void removeRelations( Incidence * ); |
259 | 260 | ||
260 | /** | 261 | /** |
261 | Set calendar filter, which filters events for the events() functions. | 262 | Set calendar filter, which filters events for the events() functions. |
262 | The Filter object is owned by the caller. | 263 | The Filter object is owned by the caller. |
263 | */ | 264 | */ |
264 | void setFilter( CalFilter * ); | 265 | void setFilter( CalFilter * ); |
265 | /** | 266 | /** |
266 | Return calendar filter. | 267 | Return calendar filter. |
267 | */ | 268 | */ |
268 | CalFilter *filter(); | 269 | CalFilter *filter(); |
269 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 270 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
270 | virtual QString nextSummary( ) const = 0; | 271 | virtual QString nextSummary( ) const = 0; |
271 | virtual void reInitAlarmSettings() = 0; | 272 | virtual void reInitAlarmSettings() = 0; |
272 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 273 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
273 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 274 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
274 | /** | 275 | /** |
275 | Return all alarms, which ocur in the given time interval. | 276 | Return all alarms, which ocur in the given time interval. |
276 | */ | 277 | */ |
277 | virtual Alarm::List alarms( const QDateTime &from, | 278 | virtual Alarm::List alarms( const QDateTime &from, |
278 | const QDateTime &to ) = 0; | 279 | const QDateTime &to ) = 0; |
279 | 280 | ||
280 | class Observer { | 281 | class Observer { |
281 | public: | 282 | public: |
282 | virtual void calendarModified( bool, Calendar * ) = 0; | 283 | virtual void calendarModified( bool, Calendar * ) = 0; |
283 | }; | 284 | }; |
284 | 285 | ||
285 | void registerObserver( Observer * ); | 286 | void registerObserver( Observer * ); |
286 | 287 | ||
287 | void setModified( bool ); | 288 | void setModified( bool ); |
288 | 289 | ||
289 | /** | 290 | /** |
290 | Set product id returned by loadedProductId(). This function is only | 291 | Set product id returned by loadedProductId(). This function is only |
291 | useful for the calendar loading code. | 292 | useful for the calendar loading code. |
292 | */ | 293 | */ |
293 | void setLoadedProductId( const QString & ); | 294 | void setLoadedProductId( const QString & ); |
294 | /** | 295 | /** |
295 | Return product id taken from file that has been loaded. Returns | 296 | Return product id taken from file that has been loaded. Returns |
296 | QString::null, if no calendar has been loaded. | 297 | QString::null, if no calendar has been loaded. |
297 | */ | 298 | */ |
298 | QString loadedProductId(); | 299 | QString loadedProductId(); |
299 | 300 | ||
300 | signals: | 301 | signals: |
301 | void calendarChanged(); | 302 | void calendarChanged(); |
302 | void calendarSaved(); | 303 | void calendarSaved(); |
303 | void calendarLoaded(); | 304 | void calendarLoaded(); |
304 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 305 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
305 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 306 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
306 | 307 | ||
307 | protected: | 308 | protected: |
308 | /** | 309 | /** |
309 | Get unfiltered events, which occur on the given date. | 310 | Get unfiltered events, which occur on the given date. |
310 | */ | 311 | */ |
311 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 312 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
312 | /** | 313 | /** |
313 | Get unfiltered events, which occur on the given date. | 314 | Get unfiltered events, which occur on the given date. |
314 | */ | 315 | */ |
315 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 316 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
316 | bool sorted = false ) = 0; | 317 | bool sorted = false ) = 0; |
317 | /** | 318 | /** |
318 | Get events in a range of dates. If inclusive is set to true, only events | 319 | Get events in a range of dates. If inclusive is set to true, only events |
319 | are returned, which are completely included in the range. | 320 | are returned, which are completely included in the range. |
320 | */ | 321 | */ |
321 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 322 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
322 | bool inclusive = false ) = 0; | 323 | bool inclusive = false ) = 0; |
323 | Incidence *mNextAlarmIncidence; | 324 | Incidence *mNextAlarmIncidence; |
324 | 325 | ||
325 | private: | 326 | private: |
326 | void init(); | 327 | void init(); |
327 | 328 | ||
328 | QString mOwner; // who the calendar belongs to | 329 | QString mOwner; // who the calendar belongs to |
329 | QString mOwnerEmail; // email address of the owner | 330 | QString mOwnerEmail; // email address of the owner |
330 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 331 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
331 | bool mLocalTime; // use local time, not UTC or a time zone | 332 | bool mLocalTime; // use local time, not UTC or a time zone |
332 | 333 | ||
333 | CalFilter *mFilter; | 334 | CalFilter *mFilter; |
334 | CalFilter *mDefaultFilter; | 335 | CalFilter *mDefaultFilter; |
335 | 336 | ||
336 | QString mTimeZoneId; | 337 | QString mTimeZoneId; |
337 | 338 | ||
338 | Observer *mObserver; | 339 | Observer *mObserver; |
339 | bool mNewObserver; | 340 | bool mNewObserver; |
340 | 341 | ||
341 | bool mModified; | 342 | bool mModified; |
342 | 343 | ||
343 | QString mLoadedProductId; | 344 | QString mLoadedProductId; |
344 | 345 | ||
345 | // This list is used to put together related todos | 346 | // This list is used to put together related todos |
346 | QDict<Incidence> mOrphans; | 347 | QDict<Incidence> mOrphans; |
347 | QDict<Incidence> mOrphanUids; | 348 | QDict<Incidence> mOrphanUids; |
348 | }; | 349 | }; |
349 | 350 | ||
350 | } | 351 | } |
351 | 352 | ||
352 | #endif | 353 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 21b4aaf..3f46d53 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,698 +1,719 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | close(); | 68 | close(); |
69 | } | 69 | } |
70 | 70 | ||
71 | bool CalendarLocal::load( const QString &fileName ) | 71 | bool CalendarLocal::load( const QString &fileName ) |
72 | { | 72 | { |
73 | FileStorage storage( this, fileName ); | 73 | FileStorage storage( this, fileName ); |
74 | return storage.load(); | 74 | return storage.load(); |
75 | } | 75 | } |
76 | 76 | ||
77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
78 | { | 78 | { |
79 | FileStorage storage( this, fileName, format ); | 79 | FileStorage storage( this, fileName, format ); |
80 | return storage.save(); | 80 | return storage.save(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void CalendarLocal::close() | 83 | void CalendarLocal::close() |
84 | { | 84 | { |
85 | mEventList.setAutoDelete( true ); | 85 | mEventList.setAutoDelete( true ); |
86 | mTodoList.setAutoDelete( true ); | 86 | mTodoList.setAutoDelete( true ); |
87 | mJournalList.setAutoDelete( false ); | 87 | mJournalList.setAutoDelete( false ); |
88 | 88 | ||
89 | mEventList.clear(); | 89 | mEventList.clear(); |
90 | mTodoList.clear(); | 90 | mTodoList.clear(); |
91 | mJournalList.clear(); | 91 | mJournalList.clear(); |
92 | 92 | ||
93 | mEventList.setAutoDelete( false ); | 93 | mEventList.setAutoDelete( false ); |
94 | mTodoList.setAutoDelete( false ); | 94 | mTodoList.setAutoDelete( false ); |
95 | mJournalList.setAutoDelete( false ); | 95 | mJournalList.setAutoDelete( false ); |
96 | 96 | ||
97 | setModified( false ); | 97 | setModified( false ); |
98 | } | 98 | } |
99 | 99 | ||
100 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 100 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
101 | { | 101 | { |
102 | QString cat; | 102 | QString cat; |
103 | bool isBirthday = true; | 103 | bool isBirthday = true; |
104 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 104 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
105 | isBirthday = false; | 105 | isBirthday = false; |
106 | cat = i18n( "Anniversary" ); | 106 | cat = i18n( "Anniversary" ); |
107 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 107 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
108 | isBirthday = true; | 108 | isBirthday = true; |
109 | cat = i18n( "Birthday" ); | 109 | cat = i18n( "Birthday" ); |
110 | } else { | 110 | } else { |
111 | qDebug("addAnniversaryNoDup called without fitting category! "); | 111 | qDebug("addAnniversaryNoDup called without fitting category! "); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | Event * eve; | 114 | Event * eve; |
115 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 115 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
116 | if ( !(eve->categories().contains( cat ) )) | 116 | if ( !(eve->categories().contains( cat ) )) |
117 | continue; | 117 | continue; |
118 | // now we have an event with fitting category | 118 | // now we have an event with fitting category |
119 | if ( eve->dtStart().date() != event->dtStart().date() ) | 119 | if ( eve->dtStart().date() != event->dtStart().date() ) |
120 | continue; | 120 | continue; |
121 | // now we have an event with fitting category+date | 121 | // now we have an event with fitting category+date |
122 | if ( eve->summary() != event->summary() ) | 122 | if ( eve->summary() != event->summary() ) |
123 | continue; | 123 | continue; |
124 | // now we have an event with fitting category+date+summary | 124 | // now we have an event with fitting category+date+summary |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | return addEvent( event ); | 127 | return addEvent( event ); |
128 | 128 | ||
129 | } | 129 | } |
130 | bool CalendarLocal::addEventNoDup( Event *event ) | 130 | bool CalendarLocal::addEventNoDup( Event *event ) |
131 | { | 131 | { |
132 | Event * eve; | 132 | Event * eve; |
133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
134 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | return addEvent( event ); | 139 | return addEvent( event ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool CalendarLocal::addEvent( Event *event ) | 142 | bool CalendarLocal::addEvent( Event *event ) |
143 | { | 143 | { |
144 | insertEvent( event ); | 144 | insertEvent( event ); |
145 | 145 | ||
146 | event->registerObserver( this ); | 146 | event->registerObserver( this ); |
147 | 147 | ||
148 | setModified( true ); | 148 | setModified( true ); |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | ||
156 | 156 | ||
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *CalendarLocal::event( const QString &uid ) |
164 | { | 164 | { |
165 | 165 | ||
166 | Event *event; | 166 | Event *event; |
167 | 167 | ||
168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
169 | if ( event->uid() == uid ) { | 169 | if ( event->uid() == uid ) { |
170 | return event; | 170 | return event; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
177 | { | 177 | { |
178 | Todo * eve; | 178 | Todo * eve; |
179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
180 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
181 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | return addTodo( todo ); | 185 | return addTodo( todo ); |
186 | } | 186 | } |
187 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
188 | { | 188 | { |
189 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
190 | 190 | ||
191 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
192 | 192 | ||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | removeRelations( todo ); |
205 | 205 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 207 | setModified( true ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 212 | { |
213 | return mTodoList; | 213 | return mTodoList; |
214 | } | 214 | } |
215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
216 | { | 216 | { |
217 | Todo *todo; | 217 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->getID( syncProf ) == id ) return todo; | 219 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 220 | } |
221 | 221 | ||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | void CalendarLocal::removeSyncInfo( QString syncProfile) | |
225 | { | ||
226 | QPtrList<Incidence> all = rawIncidences() ; | ||
227 | Incidence *inc; | ||
228 | for ( inc = all.first(); inc; inc = all.next() ) { | ||
229 | inc->removeID( syncProfile ); | ||
230 | } | ||
231 | if ( syncProfile.isEmpty() ) { | ||
232 | QPtrList<Event> el; | ||
233 | Event *todo; | ||
234 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | ||
235 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | ||
236 | el.append( todo ); | ||
237 | } | ||
238 | for ( todo = el.first(); todo; todo = el.next() ) { | ||
239 | deleteIncidence ( todo ); | ||
240 | } | ||
241 | } else { | ||
242 | Event *lse = event( "last-syncEvent-"+ syncProfile); | ||
243 | deleteIncidence ( lse ); | ||
244 | } | ||
245 | } | ||
225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 246 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
226 | { | 247 | { |
227 | QPtrList<Event> el; | 248 | QPtrList<Event> el; |
228 | Event *todo; | 249 | Event *todo; |
229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 250 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 251 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
231 | if ( todo->summary().left(3) == "E: " ) | 252 | if ( todo->summary().left(3) == "E: " ) |
232 | el.append( todo ); | 253 | el.append( todo ); |
233 | } | 254 | } |
234 | 255 | ||
235 | return el; | 256 | return el; |
236 | 257 | ||
237 | } | 258 | } |
238 | Event *CalendarLocal::event( QString syncProf, QString id ) | 259 | Event *CalendarLocal::event( QString syncProf, QString id ) |
239 | { | 260 | { |
240 | Event *todo; | 261 | Event *todo; |
241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 262 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
242 | if ( todo->getID( syncProf ) == id ) return todo; | 263 | if ( todo->getID( syncProf ) == id ) return todo; |
243 | } | 264 | } |
244 | 265 | ||
245 | return 0; | 266 | return 0; |
246 | } | 267 | } |
247 | Todo *CalendarLocal::todo( const QString &uid ) | 268 | Todo *CalendarLocal::todo( const QString &uid ) |
248 | { | 269 | { |
249 | Todo *todo; | 270 | Todo *todo; |
250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 271 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
251 | if ( todo->uid() == uid ) return todo; | 272 | if ( todo->uid() == uid ) return todo; |
252 | } | 273 | } |
253 | 274 | ||
254 | return 0; | 275 | return 0; |
255 | } | 276 | } |
256 | QString CalendarLocal::nextSummary() const | 277 | QString CalendarLocal::nextSummary() const |
257 | { | 278 | { |
258 | return mNextSummary; | 279 | return mNextSummary; |
259 | } | 280 | } |
260 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 281 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
261 | { | 282 | { |
262 | return mNextAlarmEventDateTime; | 283 | return mNextAlarmEventDateTime; |
263 | } | 284 | } |
264 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 285 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
265 | { | 286 | { |
266 | //mNextAlarmIncidence | 287 | //mNextAlarmIncidence |
267 | //mNextAlarmDateTime | 288 | //mNextAlarmDateTime |
268 | //return mNextSummary; | 289 | //return mNextSummary; |
269 | //return mNextAlarmEventDateTime; | 290 | //return mNextAlarmEventDateTime; |
270 | bool newNextAlarm = false; | 291 | bool newNextAlarm = false; |
271 | bool computeNextAlarm = false; | 292 | bool computeNextAlarm = false; |
272 | bool ok; | 293 | bool ok; |
273 | int offset; | 294 | int offset; |
274 | QDateTime nextA; | 295 | QDateTime nextA; |
275 | // QString nextSum; | 296 | // QString nextSum; |
276 | //QDateTime nextEvent; | 297 | //QDateTime nextEvent; |
277 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 298 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
278 | computeNextAlarm = true; | 299 | computeNextAlarm = true; |
279 | } else { | 300 | } else { |
280 | if ( ! deleted ) { | 301 | if ( ! deleted ) { |
281 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 302 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
282 | if ( ok ) { | 303 | if ( ok ) { |
283 | if ( nextA < mNextAlarmDateTime ) { | 304 | if ( nextA < mNextAlarmDateTime ) { |
284 | deRegisterAlarm(); | 305 | deRegisterAlarm(); |
285 | mNextAlarmDateTime = nextA; | 306 | mNextAlarmDateTime = nextA; |
286 | mNextSummary = incidence->summary(); | 307 | mNextSummary = incidence->summary(); |
287 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 308 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
288 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 309 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
289 | newNextAlarm = true; | 310 | newNextAlarm = true; |
290 | mNextAlarmIncidence = incidence; | 311 | mNextAlarmIncidence = incidence; |
291 | } else { | 312 | } else { |
292 | if ( incidence == mNextAlarmIncidence ) { | 313 | if ( incidence == mNextAlarmIncidence ) { |
293 | computeNextAlarm = true; | 314 | computeNextAlarm = true; |
294 | } | 315 | } |
295 | } | 316 | } |
296 | } else { | 317 | } else { |
297 | if ( mNextAlarmIncidence == incidence ) { | 318 | if ( mNextAlarmIncidence == incidence ) { |
298 | computeNextAlarm = true; | 319 | computeNextAlarm = true; |
299 | } | 320 | } |
300 | } | 321 | } |
301 | } else { // deleted | 322 | } else { // deleted |
302 | if ( incidence == mNextAlarmIncidence ) { | 323 | if ( incidence == mNextAlarmIncidence ) { |
303 | computeNextAlarm = true; | 324 | computeNextAlarm = true; |
304 | } | 325 | } |
305 | } | 326 | } |
306 | } | 327 | } |
307 | if ( computeNextAlarm ) { | 328 | if ( computeNextAlarm ) { |
308 | deRegisterAlarm(); | 329 | deRegisterAlarm(); |
309 | nextA = nextAlarm( 1000 ); | 330 | nextA = nextAlarm( 1000 ); |
310 | if (! mNextAlarmIncidence ) { | 331 | if (! mNextAlarmIncidence ) { |
311 | return; | 332 | return; |
312 | } | 333 | } |
313 | newNextAlarm = true; | 334 | newNextAlarm = true; |
314 | } | 335 | } |
315 | if ( newNextAlarm ) | 336 | if ( newNextAlarm ) |
316 | registerAlarm(); | 337 | registerAlarm(); |
317 | } | 338 | } |
318 | QString CalendarLocal:: getAlarmNotification() | 339 | QString CalendarLocal:: getAlarmNotification() |
319 | { | 340 | { |
320 | QString ret; | 341 | QString ret; |
321 | // this should not happen | 342 | // this should not happen |
322 | if (! mNextAlarmIncidence ) | 343 | if (! mNextAlarmIncidence ) |
323 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 344 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
324 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 345 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
325 | if ( alarm->type() == Alarm::Procedure ) { | 346 | if ( alarm->type() == Alarm::Procedure ) { |
326 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 347 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
327 | } else { | 348 | } else { |
328 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 349 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
329 | } | 350 | } |
330 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 351 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
331 | if ( mNextSummary.length() > 25 ) | 352 | if ( mNextSummary.length() > 25 ) |
332 | ret += "\n" + mNextSummary.mid(25, 25 ); | 353 | ret += "\n" + mNextSummary.mid(25, 25 ); |
333 | ret+= "\n"+mNextAlarmEventDateTimeString; | 354 | ret+= "\n"+mNextAlarmEventDateTimeString; |
334 | return ret; | 355 | return ret; |
335 | } | 356 | } |
336 | void CalendarLocal::registerAlarm() | 357 | void CalendarLocal::registerAlarm() |
337 | { | 358 | { |
338 | mLastAlarmNotificationString = getAlarmNotification(); | 359 | mLastAlarmNotificationString = getAlarmNotification(); |
339 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 360 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
340 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 361 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
341 | // #ifndef DESKTOP_VERSION | 362 | // #ifndef DESKTOP_VERSION |
342 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 363 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
343 | // #endif | 364 | // #endif |
344 | } | 365 | } |
345 | void CalendarLocal::deRegisterAlarm() | 366 | void CalendarLocal::deRegisterAlarm() |
346 | { | 367 | { |
347 | if ( mLastAlarmNotificationString.isNull() ) | 368 | if ( mLastAlarmNotificationString.isNull() ) |
348 | return; | 369 | return; |
349 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 370 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
350 | 371 | ||
351 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 372 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
352 | // #ifndef DESKTOP_VERSION | 373 | // #ifndef DESKTOP_VERSION |
353 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 374 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
354 | // #endif | 375 | // #endif |
355 | } | 376 | } |
356 | 377 | ||
357 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 378 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
358 | { | 379 | { |
359 | QPtrList<Todo> todos; | 380 | QPtrList<Todo> todos; |
360 | 381 | ||
361 | Todo *todo; | 382 | Todo *todo; |
362 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 383 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
363 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 384 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
364 | todos.append( todo ); | 385 | todos.append( todo ); |
365 | } | 386 | } |
366 | } | 387 | } |
367 | 388 | ||
368 | filter()->apply( &todos ); | 389 | filter()->apply( &todos ); |
369 | return todos; | 390 | return todos; |
370 | } | 391 | } |
371 | void CalendarLocal::reInitAlarmSettings() | 392 | void CalendarLocal::reInitAlarmSettings() |
372 | { | 393 | { |
373 | if ( !mNextAlarmIncidence ) { | 394 | if ( !mNextAlarmIncidence ) { |
374 | nextAlarm( 1000 ); | 395 | nextAlarm( 1000 ); |
375 | } | 396 | } |
376 | deRegisterAlarm(); | 397 | deRegisterAlarm(); |
377 | mNextAlarmIncidence = 0; | 398 | mNextAlarmIncidence = 0; |
378 | checkAlarmForIncidence( 0, false ); | 399 | checkAlarmForIncidence( 0, false ); |
379 | 400 | ||
380 | } | 401 | } |
381 | 402 | ||
382 | 403 | ||
383 | 404 | ||
384 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 405 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
385 | { | 406 | { |
386 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 407 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
387 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 408 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
388 | QDateTime next; | 409 | QDateTime next; |
389 | Event *e; | 410 | Event *e; |
390 | bool ok; | 411 | bool ok; |
391 | bool found = false; | 412 | bool found = false; |
392 | int offset; | 413 | int offset; |
393 | mNextAlarmIncidence = 0; | 414 | mNextAlarmIncidence = 0; |
394 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 415 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
395 | next = e->getNextAlarmDateTime(& ok, &offset ) ; | 416 | next = e->getNextAlarmDateTime(& ok, &offset ) ; |
396 | if ( ok ) { | 417 | if ( ok ) { |
397 | if ( next < nextA ) { | 418 | if ( next < nextA ) { |
398 | nextA = next; | 419 | nextA = next; |
399 | found = true; | 420 | found = true; |
400 | mNextSummary = e->summary(); | 421 | mNextSummary = e->summary(); |
401 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 422 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
402 | mNextAlarmIncidence = (Incidence *) e; | 423 | mNextAlarmIncidence = (Incidence *) e; |
403 | } | 424 | } |
404 | } | 425 | } |
405 | } | 426 | } |
406 | Todo *t; | 427 | Todo *t; |
407 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 428 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
408 | next = t->getNextAlarmDateTime(& ok, &offset ) ; | 429 | next = t->getNextAlarmDateTime(& ok, &offset ) ; |
409 | if ( ok ) { | 430 | if ( ok ) { |
410 | if ( next < nextA ) { | 431 | if ( next < nextA ) { |
411 | nextA = next; | 432 | nextA = next; |
412 | found = true; | 433 | found = true; |
413 | mNextSummary = t->summary(); | 434 | mNextSummary = t->summary(); |
414 | mNextAlarmEventDateTime = next.addSecs(offset ); | 435 | mNextAlarmEventDateTime = next.addSecs(offset ); |
415 | mNextAlarmIncidence = (Incidence *) t; | 436 | mNextAlarmIncidence = (Incidence *) t; |
416 | } | 437 | } |
417 | } | 438 | } |
418 | } | 439 | } |
419 | if ( mNextAlarmIncidence ) { | 440 | if ( mNextAlarmIncidence ) { |
420 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 441 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
421 | mNextAlarmDateTime = nextA; | 442 | mNextAlarmDateTime = nextA; |
422 | } | 443 | } |
423 | return nextA; | 444 | return nextA; |
424 | } | 445 | } |
425 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 446 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
426 | { | 447 | { |
427 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 448 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
428 | } | 449 | } |
429 | 450 | ||
430 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 451 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
431 | { | 452 | { |
432 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " | 453 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " |
433 | << to.toString() << ")\n"; | 454 | << to.toString() << ")\n"; |
434 | 455 | ||
435 | Alarm::List alarms; | 456 | Alarm::List alarms; |
436 | 457 | ||
437 | Event *e; | 458 | Event *e; |
438 | 459 | ||
439 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 460 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
440 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 461 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
441 | else appendAlarms( alarms, e, from, to ); | 462 | else appendAlarms( alarms, e, from, to ); |
442 | } | 463 | } |
443 | 464 | ||
444 | Todo *t; | 465 | Todo *t; |
445 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 466 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
446 | appendAlarms( alarms, t, from, to ); | 467 | appendAlarms( alarms, t, from, to ); |
447 | } | 468 | } |
448 | 469 | ||
449 | return alarms; | 470 | return alarms; |
450 | } | 471 | } |
451 | 472 | ||
452 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 473 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
453 | const QDateTime &from, const QDateTime &to ) | 474 | const QDateTime &from, const QDateTime &to ) |
454 | { | 475 | { |
455 | QPtrList<Alarm> alarmList = incidence->alarms(); | 476 | QPtrList<Alarm> alarmList = incidence->alarms(); |
456 | Alarm *alarm; | 477 | Alarm *alarm; |
457 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 478 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
458 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 479 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
459 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 480 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
460 | if ( alarm->enabled() ) { | 481 | if ( alarm->enabled() ) { |
461 | if ( alarm->time() >= from && alarm->time() <= to ) { | 482 | if ( alarm->time() >= from && alarm->time() <= to ) { |
462 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() | 483 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() |
463 | << "': " << alarm->time().toString() << endl; | 484 | << "': " << alarm->time().toString() << endl; |
464 | alarms.append( alarm ); | 485 | alarms.append( alarm ); |
465 | } | 486 | } |
466 | } | 487 | } |
467 | } | 488 | } |
468 | } | 489 | } |
469 | 490 | ||
470 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 491 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
471 | Incidence *incidence, | 492 | Incidence *incidence, |
472 | const QDateTime &from, | 493 | const QDateTime &from, |
473 | const QDateTime &to ) | 494 | const QDateTime &to ) |
474 | { | 495 | { |
475 | 496 | ||
476 | QPtrList<Alarm> alarmList = incidence->alarms(); | 497 | QPtrList<Alarm> alarmList = incidence->alarms(); |
477 | Alarm *alarm; | 498 | Alarm *alarm; |
478 | QDateTime qdt; | 499 | QDateTime qdt; |
479 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 500 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
480 | if (incidence->recursOn(from.date())) { | 501 | if (incidence->recursOn(from.date())) { |
481 | qdt.setTime(alarm->time().time()); | 502 | qdt.setTime(alarm->time().time()); |
482 | qdt.setDate(from.date()); | 503 | qdt.setDate(from.date()); |
483 | } | 504 | } |
484 | else qdt = alarm->time(); | 505 | else qdt = alarm->time(); |
485 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 506 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
486 | if ( alarm->enabled() ) { | 507 | if ( alarm->enabled() ) { |
487 | if ( qdt >= from && qdt <= to ) { | 508 | if ( qdt >= from && qdt <= to ) { |
488 | alarms.append( alarm ); | 509 | alarms.append( alarm ); |
489 | } | 510 | } |
490 | } | 511 | } |
491 | } | 512 | } |
492 | } | 513 | } |
493 | 514 | ||
494 | 515 | ||
495 | /****************************** PROTECTED METHODS ****************************/ | 516 | /****************************** PROTECTED METHODS ****************************/ |
496 | 517 | ||
497 | // after changes are made to an event, this should be called. | 518 | // after changes are made to an event, this should be called. |
498 | void CalendarLocal::update( IncidenceBase *incidence ) | 519 | void CalendarLocal::update( IncidenceBase *incidence ) |
499 | { | 520 | { |
500 | incidence->setSyncStatus( Event::SYNCMOD ); | 521 | incidence->setSyncStatus( Event::SYNCMOD ); |
501 | incidence->setLastModified( QDateTime::currentDateTime() ); | 522 | incidence->setLastModified( QDateTime::currentDateTime() ); |
502 | // we should probably update the revision number here, | 523 | // we should probably update the revision number here, |
503 | // or internally in the Event itself when certain things change. | 524 | // or internally in the Event itself when certain things change. |
504 | // need to verify with ical documentation. | 525 | // need to verify with ical documentation. |
505 | 526 | ||
506 | setModified( true ); | 527 | setModified( true ); |
507 | } | 528 | } |
508 | 529 | ||
509 | void CalendarLocal::insertEvent( Event *event ) | 530 | void CalendarLocal::insertEvent( Event *event ) |
510 | { | 531 | { |
511 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 532 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
512 | } | 533 | } |
513 | 534 | ||
514 | 535 | ||
515 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 536 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
516 | { | 537 | { |
517 | QPtrList<Event> eventList; | 538 | QPtrList<Event> eventList; |
518 | 539 | ||
519 | Event *event; | 540 | Event *event; |
520 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 541 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
521 | if ( event->doesRecur() ) { | 542 | if ( event->doesRecur() ) { |
522 | if ( event->isMultiDay() ) { | 543 | if ( event->isMultiDay() ) { |
523 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 544 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
524 | int i; | 545 | int i; |
525 | for ( i = 0; i <= extraDays; i++ ) { | 546 | for ( i = 0; i <= extraDays; i++ ) { |
526 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 547 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
527 | eventList.append( event ); | 548 | eventList.append( event ); |
528 | break; | 549 | break; |
529 | } | 550 | } |
530 | } | 551 | } |
531 | } else { | 552 | } else { |
532 | if ( event->recursOn( qd ) ) | 553 | if ( event->recursOn( qd ) ) |
533 | eventList.append( event ); | 554 | eventList.append( event ); |
534 | } | 555 | } |
535 | } else { | 556 | } else { |
536 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 557 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
537 | eventList.append( event ); | 558 | eventList.append( event ); |
538 | } | 559 | } |
539 | } | 560 | } |
540 | } | 561 | } |
541 | 562 | ||
542 | if ( !sorted ) { | 563 | if ( !sorted ) { |
543 | return eventList; | 564 | return eventList; |
544 | } | 565 | } |
545 | 566 | ||
546 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 567 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
547 | // now, we have to sort it based on dtStart.time() | 568 | // now, we have to sort it based on dtStart.time() |
548 | QPtrList<Event> eventListSorted; | 569 | QPtrList<Event> eventListSorted; |
549 | Event *sortEvent; | 570 | Event *sortEvent; |
550 | for ( event = eventList.first(); event; event = eventList.next() ) { | 571 | for ( event = eventList.first(); event; event = eventList.next() ) { |
551 | sortEvent = eventListSorted.first(); | 572 | sortEvent = eventListSorted.first(); |
552 | int i = 0; | 573 | int i = 0; |
553 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 574 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
554 | { | 575 | { |
555 | i++; | 576 | i++; |
556 | sortEvent = eventListSorted.next(); | 577 | sortEvent = eventListSorted.next(); |
557 | } | 578 | } |
558 | eventListSorted.insert( i, event ); | 579 | eventListSorted.insert( i, event ); |
559 | } | 580 | } |
560 | return eventListSorted; | 581 | return eventListSorted; |
561 | } | 582 | } |
562 | 583 | ||
563 | 584 | ||
564 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 585 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
565 | bool inclusive ) | 586 | bool inclusive ) |
566 | { | 587 | { |
567 | Event *event = 0; | 588 | Event *event = 0; |
568 | 589 | ||
569 | QPtrList<Event> eventList; | 590 | QPtrList<Event> eventList; |
570 | 591 | ||
571 | // Get non-recurring events | 592 | // Get non-recurring events |
572 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 593 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
573 | if ( event->doesRecur() ) { | 594 | if ( event->doesRecur() ) { |
574 | QDate rStart = event->dtStart().date(); | 595 | QDate rStart = event->dtStart().date(); |
575 | bool found = false; | 596 | bool found = false; |
576 | if ( inclusive ) { | 597 | if ( inclusive ) { |
577 | if ( rStart >= start && rStart <= end ) { | 598 | if ( rStart >= start && rStart <= end ) { |
578 | // Start date of event is in range. Now check for end date. | 599 | // Start date of event is in range. Now check for end date. |
579 | // if duration is negative, event recurs forever, so do not include it. | 600 | // if duration is negative, event recurs forever, so do not include it. |
580 | if ( event->recurrence()->duration() == 0 ) { // End date set | 601 | if ( event->recurrence()->duration() == 0 ) { // End date set |
581 | QDate rEnd = event->recurrence()->endDate(); | 602 | QDate rEnd = event->recurrence()->endDate(); |
582 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 603 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
583 | found = true; | 604 | found = true; |
584 | } | 605 | } |
585 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 606 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
586 | // TODO: Calculate end date from duration. Should be done in Event | 607 | // TODO: Calculate end date from duration. Should be done in Event |
587 | // For now exclude all events with a duration. | 608 | // For now exclude all events with a duration. |
588 | } | 609 | } |
589 | } | 610 | } |
590 | } else { | 611 | } else { |
591 | bool founOne; | 612 | bool founOne; |
592 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 613 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
593 | if ( founOne ) { | 614 | if ( founOne ) { |
594 | if ( next <= end ) { | 615 | if ( next <= end ) { |
595 | found = true; | 616 | found = true; |
596 | } | 617 | } |
597 | } | 618 | } |
598 | 619 | ||
599 | /* | 620 | /* |
600 | // crap !!! | 621 | // crap !!! |
601 | if ( rStart <= end ) { // Start date not after range | 622 | if ( rStart <= end ) { // Start date not after range |
602 | if ( rStart >= start ) { // Start date within range | 623 | if ( rStart >= start ) { // Start date within range |
603 | found = true; | 624 | found = true; |
604 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 625 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
605 | found = true; | 626 | found = true; |
606 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 627 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
607 | QDate rEnd = event->recurrence()->endDate(); | 628 | QDate rEnd = event->recurrence()->endDate(); |
608 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 629 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
609 | found = true; | 630 | found = true; |
610 | } | 631 | } |
611 | } else { // Duration set | 632 | } else { // Duration set |
612 | // TODO: Calculate end date from duration. Should be done in Event | 633 | // TODO: Calculate end date from duration. Should be done in Event |
613 | // For now include all events with a duration. | 634 | // For now include all events with a duration. |
614 | found = true; | 635 | found = true; |
615 | } | 636 | } |
616 | } | 637 | } |
617 | */ | 638 | */ |
618 | 639 | ||
619 | } | 640 | } |
620 | 641 | ||
621 | if ( found ) eventList.append( event ); | 642 | if ( found ) eventList.append( event ); |
622 | } else { | 643 | } else { |
623 | QDate s = event->dtStart().date(); | 644 | QDate s = event->dtStart().date(); |
624 | QDate e = event->dtEnd().date(); | 645 | QDate e = event->dtEnd().date(); |
625 | 646 | ||
626 | if ( inclusive ) { | 647 | if ( inclusive ) { |
627 | if ( s >= start && e <= end ) { | 648 | if ( s >= start && e <= end ) { |
628 | eventList.append( event ); | 649 | eventList.append( event ); |
629 | } | 650 | } |
630 | } else { | 651 | } else { |
631 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 652 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
632 | eventList.append( event ); | 653 | eventList.append( event ); |
633 | } | 654 | } |
634 | } | 655 | } |
635 | } | 656 | } |
636 | } | 657 | } |
637 | 658 | ||
638 | return eventList; | 659 | return eventList; |
639 | } | 660 | } |
640 | 661 | ||
641 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 662 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
642 | { | 663 | { |
643 | return rawEventsForDate( qdt.date() ); | 664 | return rawEventsForDate( qdt.date() ); |
644 | } | 665 | } |
645 | 666 | ||
646 | QPtrList<Event> CalendarLocal::rawEvents() | 667 | QPtrList<Event> CalendarLocal::rawEvents() |
647 | { | 668 | { |
648 | return mEventList; | 669 | return mEventList; |
649 | } | 670 | } |
650 | 671 | ||
651 | bool CalendarLocal::addJournal(Journal *journal) | 672 | bool CalendarLocal::addJournal(Journal *journal) |
652 | { | 673 | { |
653 | if ( journal->dtStart().isValid()) | 674 | if ( journal->dtStart().isValid()) |
654 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 675 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
655 | else | 676 | else |
656 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 677 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
657 | 678 | ||
658 | mJournalList.append(journal); | 679 | mJournalList.append(journal); |
659 | 680 | ||
660 | journal->registerObserver( this ); | 681 | journal->registerObserver( this ); |
661 | 682 | ||
662 | setModified( true ); | 683 | setModified( true ); |
663 | 684 | ||
664 | return true; | 685 | return true; |
665 | } | 686 | } |
666 | 687 | ||
667 | void CalendarLocal::deleteJournal( Journal *journal ) | 688 | void CalendarLocal::deleteJournal( Journal *journal ) |
668 | { | 689 | { |
669 | if ( mJournalList.removeRef(journal) ) { | 690 | if ( mJournalList.removeRef(journal) ) { |
670 | setModified( true ); | 691 | setModified( true ); |
671 | } | 692 | } |
672 | } | 693 | } |
673 | 694 | ||
674 | Journal *CalendarLocal::journal( const QDate &date ) | 695 | Journal *CalendarLocal::journal( const QDate &date ) |
675 | { | 696 | { |
676 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 697 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
677 | 698 | ||
678 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 699 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
679 | if ( it->dtStart().date() == date ) | 700 | if ( it->dtStart().date() == date ) |
680 | return it; | 701 | return it; |
681 | 702 | ||
682 | return 0; | 703 | return 0; |
683 | } | 704 | } |
684 | 705 | ||
685 | Journal *CalendarLocal::journal( const QString &uid ) | 706 | Journal *CalendarLocal::journal( const QString &uid ) |
686 | { | 707 | { |
687 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 708 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
688 | if ( it->uid() == uid ) | 709 | if ( it->uid() == uid ) |
689 | return it; | 710 | return it; |
690 | 711 | ||
691 | return 0; | 712 | return 0; |
692 | } | 713 | } |
693 | 714 | ||
694 | QPtrList<Journal> CalendarLocal::journals() | 715 | QPtrList<Journal> CalendarLocal::journals() |
695 | { | 716 | { |
696 | return mJournalList; | 717 | return mJournalList; |
697 | } | 718 | } |
698 | 719 | ||
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5b6c64c..98ec710 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,217 +1,218 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | 46 | ||
47 | /** | 47 | /** |
48 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 48 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
49 | calendar. Any information already present is lost. | 49 | calendar. Any information already present is lost. |
50 | @return true, if successfull, false on error. | 50 | @return true, if successfull, false on error. |
51 | @param fileName the name of the calendar on disk. | 51 | @param fileName the name of the calendar on disk. |
52 | */ | 52 | */ |
53 | bool load( const QString &fileName ); | 53 | bool load( const QString &fileName ); |
54 | /** | 54 | /** |
55 | Writes out the calendar to disk in the specified \a format. | 55 | Writes out the calendar to disk in the specified \a format. |
56 | CalendarLocal takes ownership of the CalFormat object. | 56 | CalendarLocal takes ownership of the CalFormat object. |
57 | @return true, if successfull, false on error. | 57 | @return true, if successfull, false on error. |
58 | @param fileName the name of the file | 58 | @param fileName the name of the file |
59 | */ | 59 | */ |
60 | bool save( const QString &fileName, CalFormat *format = 0 ); | 60 | bool save( const QString &fileName, CalFormat *format = 0 ); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Clears out the current calendar, freeing all used memory etc. etc. | 63 | Clears out the current calendar, freeing all used memory etc. etc. |
64 | */ | 64 | */ |
65 | void close(); | 65 | void close(); |
66 | 66 | ||
67 | void save() {} | 67 | void save() {} |
68 | 68 | ||
69 | /** | 69 | /** |
70 | Add Event to calendar. | 70 | Add Event to calendar. |
71 | */ | 71 | */ |
72 | void removeSyncInfo( QString syncProfile); | ||
72 | bool addAnniversaryNoDup( Event *event ); | 73 | bool addAnniversaryNoDup( Event *event ); |
73 | bool addEventNoDup( Event *event ); | 74 | bool addEventNoDup( Event *event ); |
74 | bool addEvent( Event *event ); | 75 | bool addEvent( Event *event ); |
75 | /** | 76 | /** |
76 | Deletes an event from this calendar. | 77 | Deletes an event from this calendar. |
77 | */ | 78 | */ |
78 | void deleteEvent( Event *event ); | 79 | void deleteEvent( Event *event ); |
79 | 80 | ||
80 | /** | 81 | /** |
81 | Retrieves an event on the basis of the unique string ID. | 82 | Retrieves an event on the basis of the unique string ID. |
82 | */ | 83 | */ |
83 | Event *event( const QString &uid ); | 84 | Event *event( const QString &uid ); |
84 | /** | 85 | /** |
85 | Return unfiltered list of all events in calendar. | 86 | Return unfiltered list of all events in calendar. |
86 | */ | 87 | */ |
87 | QPtrList<Event> rawEvents(); | 88 | QPtrList<Event> rawEvents(); |
88 | QPtrList<Event> getExternLastSyncEvents(); | 89 | QPtrList<Event> getExternLastSyncEvents(); |
89 | /** | 90 | /** |
90 | Add a todo to the todolist. | 91 | Add a todo to the todolist. |
91 | */ | 92 | */ |
92 | bool addTodo( Todo *todo ); | 93 | bool addTodo( Todo *todo ); |
93 | bool addTodoNoDup( Todo *todo ); | 94 | bool addTodoNoDup( Todo *todo ); |
94 | /** | 95 | /** |
95 | Remove a todo from the todolist. | 96 | Remove a todo from the todolist. |
96 | */ | 97 | */ |
97 | void deleteTodo( Todo * ); | 98 | void deleteTodo( Todo * ); |
98 | /** | 99 | /** |
99 | Searches todolist for an event with this unique string identifier, | 100 | Searches todolist for an event with this unique string identifier, |
100 | returns a pointer or null. | 101 | returns a pointer or null. |
101 | */ | 102 | */ |
102 | Todo *todo( const QString &uid ); | 103 | Todo *todo( const QString &uid ); |
103 | /** | 104 | /** |
104 | Return list of all todos. | 105 | Return list of all todos. |
105 | */ | 106 | */ |
106 | QPtrList<Todo> rawTodos(); | 107 | QPtrList<Todo> rawTodos(); |
107 | /** | 108 | /** |
108 | Returns list of todos due on the specified date. | 109 | Returns list of todos due on the specified date. |
109 | */ | 110 | */ |
110 | QPtrList<Todo> todos( const QDate &date ); | 111 | QPtrList<Todo> todos( const QDate &date ); |
111 | /** | 112 | /** |
112 | Return list of all todos. | 113 | Return list of all todos. |
113 | 114 | ||
114 | Workaround because compiler does not recognize function of base class. | 115 | Workaround because compiler does not recognize function of base class. |
115 | */ | 116 | */ |
116 | QPtrList<Todo> todos() { return Calendar::todos(); } | 117 | QPtrList<Todo> todos() { return Calendar::todos(); } |
117 | 118 | ||
118 | /** | 119 | /** |
119 | Add a Journal entry to calendar. | 120 | Add a Journal entry to calendar. |
120 | */ | 121 | */ |
121 | bool addJournal( Journal * ); | 122 | bool addJournal( Journal * ); |
122 | /** | 123 | /** |
123 | Remove a Journal from the calendar. | 124 | Remove a Journal from the calendar. |
124 | */ | 125 | */ |
125 | void deleteJournal( Journal * ); | 126 | void deleteJournal( Journal * ); |
126 | /** | 127 | /** |
127 | Return Journal for given date. | 128 | Return Journal for given date. |
128 | */ | 129 | */ |
129 | Journal *journal( const QDate & ); | 130 | Journal *journal( const QDate & ); |
130 | /** | 131 | /** |
131 | Return Journal with given UID. | 132 | Return Journal with given UID. |
132 | */ | 133 | */ |
133 | Journal *journal( const QString &uid ); | 134 | Journal *journal( const QString &uid ); |
134 | /** | 135 | /** |
135 | Return list of all Journals stored in calendar. | 136 | Return list of all Journals stored in calendar. |
136 | */ | 137 | */ |
137 | QPtrList<Journal> journals(); | 138 | QPtrList<Journal> journals(); |
138 | 139 | ||
139 | /** | 140 | /** |
140 | Return all alarms, which ocur in the given time interval. | 141 | Return all alarms, which ocur in the given time interval. |
141 | */ | 142 | */ |
142 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 143 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Return all alarms, which ocur before given date. | 146 | Return all alarms, which ocur before given date. |
146 | */ | 147 | */ |
147 | Alarm::List alarmsTo( const QDateTime &to ); | 148 | Alarm::List alarmsTo( const QDateTime &to ); |
148 | 149 | ||
149 | QDateTime nextAlarm( int daysTo ) ; | 150 | QDateTime nextAlarm( int daysTo ) ; |
150 | QDateTime nextAlarmEventDateTime() const; | 151 | QDateTime nextAlarmEventDateTime() const; |
151 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 152 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
152 | void registerAlarm(); | 153 | void registerAlarm(); |
153 | void deRegisterAlarm(); | 154 | void deRegisterAlarm(); |
154 | QString getAlarmNotification(); | 155 | QString getAlarmNotification(); |
155 | QString nextSummary() const ; | 156 | QString nextSummary() const ; |
156 | /** | 157 | /** |
157 | This method should be called whenever a Event is modified directly | 158 | This method should be called whenever a Event is modified directly |
158 | via it's pointer. It makes sure that the calendar is internally | 159 | via it's pointer. It makes sure that the calendar is internally |
159 | consistent. | 160 | consistent. |
160 | */ | 161 | */ |
161 | void update( IncidenceBase *incidence ); | 162 | void update( IncidenceBase *incidence ); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | Builds and then returns a list of all events that match for the | 165 | Builds and then returns a list of all events that match for the |
165 | date specified. useful for dayView, etc. etc. | 166 | date specified. useful for dayView, etc. etc. |
166 | */ | 167 | */ |
167 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 168 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
168 | /** | 169 | /** |
169 | Get unfiltered events for date \a qdt. | 170 | Get unfiltered events for date \a qdt. |
170 | */ | 171 | */ |
171 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 172 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
172 | /** | 173 | /** |
173 | Get unfiltered events in a range of dates. If inclusive is set to true, | 174 | Get unfiltered events in a range of dates. If inclusive is set to true, |
174 | only events are returned, which are completely included in the range. | 175 | only events are returned, which are completely included in the range. |
175 | */ | 176 | */ |
176 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 177 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
177 | bool inclusive = false ); | 178 | bool inclusive = false ); |
178 | Todo *todo( QString, QString ); | 179 | Todo *todo( QString, QString ); |
179 | Event *event( QString, QString ); | 180 | Event *event( QString, QString ); |
180 | 181 | ||
181 | 182 | ||
182 | 183 | ||
183 | protected: | 184 | protected: |
184 | 185 | ||
185 | // Event* mNextAlarmEvent; | 186 | // Event* mNextAlarmEvent; |
186 | QString mNextSummary; | 187 | QString mNextSummary; |
187 | QString mNextAlarmEventDateTimeString; | 188 | QString mNextAlarmEventDateTimeString; |
188 | QString mLastAlarmNotificationString; | 189 | QString mLastAlarmNotificationString; |
189 | QDateTime mNextAlarmEventDateTime; | 190 | QDateTime mNextAlarmEventDateTime; |
190 | QDateTime mNextAlarmDateTime; | 191 | QDateTime mNextAlarmDateTime; |
191 | void reInitAlarmSettings(); | 192 | void reInitAlarmSettings(); |
192 | 193 | ||
193 | /** Notification function of IncidenceBase::Observer. */ | 194 | /** Notification function of IncidenceBase::Observer. */ |
194 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 195 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
195 | 196 | ||
196 | /** inserts an event into its "proper place" in the calendar. */ | 197 | /** inserts an event into its "proper place" in the calendar. */ |
197 | void insertEvent( Event *event ); | 198 | void insertEvent( Event *event ); |
198 | 199 | ||
199 | /** Append alarms of incidence in interval to list of alarms. */ | 200 | /** Append alarms of incidence in interval to list of alarms. */ |
200 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 201 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
201 | const QDateTime &from, const QDateTime &to ); | 202 | const QDateTime &from, const QDateTime &to ); |
202 | 203 | ||
203 | /** Append alarms of recurring events in interval to list of alarms. */ | 204 | /** Append alarms of recurring events in interval to list of alarms. */ |
204 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 205 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
205 | const QDateTime &from, const QDateTime &to ); | 206 | const QDateTime &from, const QDateTime &to ); |
206 | 207 | ||
207 | private: | 208 | private: |
208 | void init(); | 209 | void init(); |
209 | 210 | ||
210 | QPtrList<Event> mEventList; | 211 | QPtrList<Event> mEventList; |
211 | QPtrList<Todo> mTodoList; | 212 | QPtrList<Todo> mTodoList; |
212 | QPtrList<Journal> mJournalList; | 213 | QPtrList<Journal> mJournalList; |
213 | }; | 214 | }; |
214 | 215 | ||
215 | } | 216 | } |
216 | 217 | ||
217 | #endif | 218 | #endif |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b36dc1a..9aa517c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,407 +1,410 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | #include <kidmanager.h> | 24 | #include <kidmanager.h> |
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | 27 | #include "syncdefines.h" |
28 | 28 | ||
29 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::IncidenceBase() : |
34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 36 | { |
37 | setUid(CalFormat::createUniqueId()); | 37 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 38 | mOrganizer = ""; |
39 | mFloats = false; | 39 | mFloats = false; |
40 | mDuration = 0; | 40 | mDuration = 0; |
41 | mHasDuration = false; | 41 | mHasDuration = false; |
42 | mPilotId = 0; | 42 | mPilotId = 0; |
43 | mExternalId = ":"; | 43 | mExternalId = ":"; |
44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
45 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
46 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
47 | } | 47 | } |
48 | 48 | ||
49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
50 | CustomProperties( i ) | 50 | CustomProperties( i ) |
51 | { | 51 | { |
52 | mReadOnly = i.mReadOnly; | 52 | mReadOnly = i.mReadOnly; |
53 | mDtStart = i.mDtStart; | 53 | mDtStart = i.mDtStart; |
54 | mDuration = i.mDuration; | 54 | mDuration = i.mDuration; |
55 | mHasDuration = i.mHasDuration; | 55 | mHasDuration = i.mHasDuration; |
56 | mOrganizer = i.mOrganizer; | 56 | mOrganizer = i.mOrganizer; |
57 | mUid = i.mUid; | 57 | mUid = i.mUid; |
58 | QPtrList<Attendee> attendees = i.attendees(); | 58 | QPtrList<Attendee> attendees = i.attendees(); |
59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
60 | mAttendees.append( new Attendee( *a ) ); | 60 | mAttendees.append( new Attendee( *a ) ); |
61 | } | 61 | } |
62 | mFloats = i.mFloats; | 62 | mFloats = i.mFloats; |
63 | mLastModified = i.mLastModified; | 63 | mLastModified = i.mLastModified; |
64 | mPilotId = i.mPilotId; | 64 | mPilotId = i.mPilotId; |
65 | mTempSyncStat = i.mTempSyncStat; | 65 | mTempSyncStat = i.mTempSyncStat; |
66 | mSyncStatus = i.mSyncStatus; | 66 | mSyncStatus = i.mSyncStatus; |
67 | mExternalId = i.mExternalId; | 67 | mExternalId = i.mExternalId; |
68 | // The copied object is a new one, so it isn't observed by the observer | 68 | // The copied object is a new one, so it isn't observed by the observer |
69 | // of the original object. | 69 | // of the original object. |
70 | mObservers.clear(); | 70 | mObservers.clear(); |
71 | 71 | ||
72 | mAttendees.setAutoDelete( true ); | 72 | mAttendees.setAutoDelete( true ); |
73 | } | 73 | } |
74 | 74 | ||
75 | IncidenceBase::~IncidenceBase() | 75 | IncidenceBase::~IncidenceBase() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
81 | { | 81 | { |
82 | // do not compare mSyncStatus and mExternalId | 82 | // do not compare mSyncStatus and mExternalId |
83 | if( i1.attendees().count() != i2.attendees().count() ) { | 83 | if( i1.attendees().count() != i2.attendees().count() ) { |
84 | return false; // no need to check further | 84 | return false; // no need to check further |
85 | } | 85 | } |
86 | if ( i1.attendees().count() > 0 ) { | 86 | if ( i1.attendees().count() > 0 ) { |
87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
88 | while ( a1 ) { | 88 | while ( a1 ) { |
89 | if ( !( (*a1) == (*a2)) ) | 89 | if ( !( (*a1) == (*a2)) ) |
90 | { | 90 | { |
91 | //qDebug("Attendee not equal "); | 91 | //qDebug("Attendee not equal "); |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | a1 = i1.attendees().next(); | 94 | a1 = i1.attendees().next(); |
95 | a2 = i2.attendees().next(); | 95 | a2 = i2.attendees().next(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | //if ( i1.dtStart() != i2.dtStart() ) | 98 | //if ( i1.dtStart() != i2.dtStart() ) |
99 | // return false; | 99 | // return false; |
100 | #if 0 | 100 | #if 0 |
101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
102 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 102 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
107 | 107 | ||
108 | #endif | 108 | #endif |
109 | return ( i1.organizer() == i2.organizer() && | 109 | return ( i1.organizer() == i2.organizer() && |
110 | // i1.uid() == i2.uid() && | 110 | // i1.uid() == i2.uid() && |
111 | // Don't compare lastModified, otherwise the operator is not | 111 | // Don't compare lastModified, otherwise the operator is not |
112 | // of much use. We are not comparing for identity, after all. | 112 | // of much use. We are not comparing for identity, after all. |
113 | i1.doesFloat() == i2.doesFloat() && | 113 | i1.doesFloat() == i2.doesFloat() && |
114 | i1.duration() == i2.duration() && | 114 | i1.duration() == i2.duration() && |
115 | i1.hasDuration() == i2.hasDuration() && | 115 | i1.hasDuration() == i2.hasDuration() && |
116 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 116 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
117 | // no need to compare mObserver | 117 | // no need to compare mObserver |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 121 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
122 | { | 122 | { |
123 | QTime t = dt.time(); | 123 | QTime t = dt.time(); |
124 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 124 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
125 | return dt; | 125 | return dt; |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void IncidenceBase::setUid(const QString &uid) | 129 | void IncidenceBase::setUid(const QString &uid) |
130 | { | 130 | { |
131 | mUid = uid; | 131 | mUid = uid; |
132 | updated(); | 132 | updated(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QString IncidenceBase::uid() const | 135 | QString IncidenceBase::uid() const |
136 | { | 136 | { |
137 | return mUid; | 137 | return mUid; |
138 | } | 138 | } |
139 | 139 | ||
140 | void IncidenceBase::setLastModified(const QDateTime &lm) | 140 | void IncidenceBase::setLastModified(const QDateTime &lm) |
141 | { | 141 | { |
142 | // DON'T! updated() because we call this from | 142 | // DON'T! updated() because we call this from |
143 | // Calendar::updateEvent(). | 143 | // Calendar::updateEvent(). |
144 | mLastModified = getEvenTime(lm); | 144 | mLastModified = getEvenTime(lm); |
145 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 145 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
146 | } | 146 | } |
147 | 147 | ||
148 | QDateTime IncidenceBase::lastModified() const | 148 | QDateTime IncidenceBase::lastModified() const |
149 | { | 149 | { |
150 | return mLastModified; | 150 | return mLastModified; |
151 | } | 151 | } |
152 | 152 | ||
153 | void IncidenceBase::setOrganizer(const QString &o) | 153 | void IncidenceBase::setOrganizer(const QString &o) |
154 | { | 154 | { |
155 | // we don't check for readonly here, because it is | 155 | // we don't check for readonly here, because it is |
156 | // possible that by setting the organizer we are changing | 156 | // possible that by setting the organizer we are changing |
157 | // the event's readonly status... | 157 | // the event's readonly status... |
158 | mOrganizer = o; | 158 | mOrganizer = o; |
159 | if (mOrganizer.left(7).upper() == "MAILTO:") | 159 | if (mOrganizer.left(7).upper() == "MAILTO:") |
160 | mOrganizer = mOrganizer.remove(0,7); | 160 | mOrganizer = mOrganizer.remove(0,7); |
161 | 161 | ||
162 | updated(); | 162 | updated(); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString IncidenceBase::organizer() const | 165 | QString IncidenceBase::organizer() const |
166 | { | 166 | { |
167 | return mOrganizer; | 167 | return mOrganizer; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncidenceBase::setReadOnly( bool readOnly ) | 170 | void IncidenceBase::setReadOnly( bool readOnly ) |
171 | { | 171 | { |
172 | mReadOnly = readOnly; | 172 | mReadOnly = readOnly; |
173 | } | 173 | } |
174 | 174 | ||
175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
176 | { | 176 | { |
177 | // if (mReadOnly) return; | 177 | // if (mReadOnly) return; |
178 | mDtStart = getEvenTime(dtStart); | 178 | mDtStart = getEvenTime(dtStart); |
179 | updated(); | 179 | updated(); |
180 | } | 180 | } |
181 | 181 | ||
182 | QDateTime IncidenceBase::dtStart() const | 182 | QDateTime IncidenceBase::dtStart() const |
183 | { | 183 | { |
184 | return mDtStart; | 184 | return mDtStart; |
185 | } | 185 | } |
186 | 186 | ||
187 | QString IncidenceBase::dtStartTimeStr() const | 187 | QString IncidenceBase::dtStartTimeStr() const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatTime(dtStart().time()); | 189 | return KGlobal::locale()->formatTime(dtStart().time()); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
195 | } | 195 | } |
196 | 196 | ||
197 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 197 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
198 | { | 198 | { |
199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | bool IncidenceBase::doesFloat() const | 203 | bool IncidenceBase::doesFloat() const |
204 | { | 204 | { |
205 | return mFloats; | 205 | return mFloats; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IncidenceBase::setFloats(bool f) | 208 | void IncidenceBase::setFloats(bool f) |
209 | { | 209 | { |
210 | if (mReadOnly) return; | 210 | if (mReadOnly) return; |
211 | mFloats = f; | 211 | mFloats = f; |
212 | updated(); | 212 | updated(); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 216 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
217 | { | 217 | { |
218 | if (mReadOnly) return; | 218 | if (mReadOnly) return; |
219 | if (a->name().left(7).upper() == "MAILTO:") | 219 | if (a->name().left(7).upper() == "MAILTO:") |
220 | a->setName(a->name().remove(0,7)); | 220 | a->setName(a->name().remove(0,7)); |
221 | 221 | ||
222 | mAttendees.append(a); | 222 | mAttendees.append(a); |
223 | if (doupdate) updated(); | 223 | if (doupdate) updated(); |
224 | } | 224 | } |
225 | 225 | ||
226 | #if 0 | 226 | #if 0 |
227 | void IncidenceBase::removeAttendee(Attendee *a) | 227 | void IncidenceBase::removeAttendee(Attendee *a) |
228 | { | 228 | { |
229 | if (mReadOnly) return; | 229 | if (mReadOnly) return; |
230 | mAttendees.removeRef(a); | 230 | mAttendees.removeRef(a); |
231 | updated(); | 231 | updated(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void IncidenceBase::removeAttendee(const char *n) | 234 | void IncidenceBase::removeAttendee(const char *n) |
235 | { | 235 | { |
236 | Attendee *a; | 236 | Attendee *a; |
237 | 237 | ||
238 | if (mReadOnly) return; | 238 | if (mReadOnly) return; |
239 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 239 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
240 | if (a->getName() == n) { | 240 | if (a->getName() == n) { |
241 | mAttendees.remove(); | 241 | mAttendees.remove(); |
242 | break; | 242 | break; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | void IncidenceBase::clearAttendees() | 247 | void IncidenceBase::clearAttendees() |
248 | { | 248 | { |
249 | if (mReadOnly) return; | 249 | if (mReadOnly) return; |
250 | mAttendees.clear(); | 250 | mAttendees.clear(); |
251 | } | 251 | } |
252 | 252 | ||
253 | #if 0 | 253 | #if 0 |
254 | Attendee *IncidenceBase::getAttendee(const char *n) const | 254 | Attendee *IncidenceBase::getAttendee(const char *n) const |
255 | { | 255 | { |
256 | QPtrListIterator<Attendee> qli(mAttendees); | 256 | QPtrListIterator<Attendee> qli(mAttendees); |
257 | 257 | ||
258 | qli.toFirst(); | 258 | qli.toFirst(); |
259 | while (qli) { | 259 | while (qli) { |
260 | if (qli.current()->getName() == n) | 260 | if (qli.current()->getName() == n) |
261 | return qli.current(); | 261 | return qli.current(); |
262 | ++qli; | 262 | ++qli; |
263 | } | 263 | } |
264 | return 0L; | 264 | return 0L; |
265 | } | 265 | } |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
269 | { | 269 | { |
270 | QPtrListIterator<Attendee> qli(mAttendees); | 270 | QPtrListIterator<Attendee> qli(mAttendees); |
271 | 271 | ||
272 | qli.toFirst(); | 272 | qli.toFirst(); |
273 | while (qli) { | 273 | while (qli) { |
274 | if (qli.current()->email().lower() == email.lower()) | 274 | if (qli.current()->email().lower() == email.lower()) |
275 | return qli.current(); | 275 | return qli.current(); |
276 | ++qli; | 276 | ++qli; |
277 | } | 277 | } |
278 | return 0L; | 278 | return 0L; |
279 | } | 279 | } |
280 | 280 | ||
281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
282 | { | 282 | { |
283 | QPtrListIterator<Attendee> qli(mAttendees); | 283 | QPtrListIterator<Attendee> qli(mAttendees); |
284 | 284 | ||
285 | QStringList mails = emails; | 285 | QStringList mails = emails; |
286 | if (!email.isEmpty()) { | 286 | if (!email.isEmpty()) { |
287 | mails.append(email); | 287 | mails.append(email); |
288 | } | 288 | } |
289 | qli.toFirst(); | 289 | qli.toFirst(); |
290 | while (qli) { | 290 | while (qli) { |
291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
292 | if (qli.current()->email().lower() == (*it).lower()) | 292 | if (qli.current()->email().lower() == (*it).lower()) |
293 | return qli.current(); | 293 | return qli.current(); |
294 | } | 294 | } |
295 | 295 | ||
296 | ++qli; | 296 | ++qli; |
297 | } | 297 | } |
298 | return 0L; | 298 | return 0L; |
299 | } | 299 | } |
300 | 300 | ||
301 | void IncidenceBase::setDuration(int seconds) | 301 | void IncidenceBase::setDuration(int seconds) |
302 | { | 302 | { |
303 | mDuration = seconds; | 303 | mDuration = seconds; |
304 | setHasDuration(true); | 304 | setHasDuration(true); |
305 | } | 305 | } |
306 | 306 | ||
307 | int IncidenceBase::duration() const | 307 | int IncidenceBase::duration() const |
308 | { | 308 | { |
309 | return mDuration; | 309 | return mDuration; |
310 | } | 310 | } |
311 | 311 | ||
312 | void IncidenceBase::setHasDuration(bool b) | 312 | void IncidenceBase::setHasDuration(bool b) |
313 | { | 313 | { |
314 | mHasDuration = b; | 314 | mHasDuration = b; |
315 | } | 315 | } |
316 | 316 | ||
317 | bool IncidenceBase::hasDuration() const | 317 | bool IncidenceBase::hasDuration() const |
318 | { | 318 | { |
319 | return mHasDuration; | 319 | return mHasDuration; |
320 | } | 320 | } |
321 | 321 | ||
322 | void IncidenceBase::setSyncStatus(int stat) | 322 | void IncidenceBase::setSyncStatus(int stat) |
323 | { | 323 | { |
324 | if (mReadOnly) return; | 324 | if (mReadOnly) return; |
325 | mSyncStatus = stat; | 325 | mSyncStatus = stat; |
326 | } | 326 | } |
327 | 327 | ||
328 | int IncidenceBase::syncStatus() const | 328 | int IncidenceBase::syncStatus() const |
329 | { | 329 | { |
330 | return mSyncStatus; | 330 | return mSyncStatus; |
331 | } | 331 | } |
332 | 332 | ||
333 | void IncidenceBase::setPilotId( int id ) | 333 | void IncidenceBase::setPilotId( int id ) |
334 | { | 334 | { |
335 | if (mReadOnly) return; | 335 | if (mReadOnly) return; |
336 | mPilotId = id; | 336 | mPilotId = id; |
337 | } | 337 | } |
338 | 338 | ||
339 | int IncidenceBase::pilotId() const | 339 | int IncidenceBase::pilotId() const |
340 | { | 340 | { |
341 | return mPilotId; | 341 | return mPilotId; |
342 | } | 342 | } |
343 | 343 | ||
344 | int IncidenceBase::tempSyncStat() const | 344 | int IncidenceBase::tempSyncStat() const |
345 | { | 345 | { |
346 | return mTempSyncStat; | 346 | return mTempSyncStat; |
347 | } | 347 | } |
348 | void IncidenceBase::setTempSyncStat( int id ) | 348 | void IncidenceBase::setTempSyncStat( int id ) |
349 | { | 349 | { |
350 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
351 | mTempSyncStat = id; | 351 | mTempSyncStat = id; |
352 | } | 352 | } |
353 | 353 | ||
354 | void IncidenceBase::removeID(const QString &prof) | 354 | void IncidenceBase::removeID(const QString &prof) |
355 | { | 355 | { |
356 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 356 | if ( prof.isEmpty() ) |
357 | mExternalId = ":"; | ||
358 | else | ||
359 | mExternalId = KIdManager::removeId ( mExternalId, prof); | ||
357 | 360 | ||
358 | } | 361 | } |
359 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 362 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
360 | { | 363 | { |
361 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 364 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
362 | } | 365 | } |
363 | QString IncidenceBase::getID( const QString & prof) | 366 | QString IncidenceBase::getID( const QString & prof) |
364 | { | 367 | { |
365 | return KIdManager::getId ( mExternalId, prof ); | 368 | return KIdManager::getId ( mExternalId, prof ); |
366 | } | 369 | } |
367 | 370 | ||
368 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 371 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
369 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 372 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
370 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 373 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
371 | { | 374 | { |
372 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 375 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
373 | } | 376 | } |
374 | QString IncidenceBase::getCsum( const QString & prof) | 377 | QString IncidenceBase::getCsum( const QString & prof) |
375 | { | 378 | { |
376 | return KIdManager::getCsum ( mExternalId, prof ); | 379 | return KIdManager::getCsum ( mExternalId, prof ); |
377 | } | 380 | } |
378 | 381 | ||
379 | void IncidenceBase::setIDStr( const QString & s ) | 382 | void IncidenceBase::setIDStr( const QString & s ) |
380 | { | 383 | { |
381 | if (mReadOnly) return; | 384 | if (mReadOnly) return; |
382 | mExternalId = s; | 385 | mExternalId = s; |
383 | } | 386 | } |
384 | 387 | ||
385 | QString IncidenceBase::IDStr() const | 388 | QString IncidenceBase::IDStr() const |
386 | { | 389 | { |
387 | return mExternalId ; | 390 | return mExternalId ; |
388 | } | 391 | } |
389 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 392 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
390 | { | 393 | { |
391 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 394 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
392 | } | 395 | } |
393 | 396 | ||
394 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 397 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
395 | { | 398 | { |
396 | mObservers.remove( observer ); | 399 | mObservers.remove( observer ); |
397 | } | 400 | } |
398 | 401 | ||
399 | void IncidenceBase::updated() | 402 | void IncidenceBase::updated() |
400 | { | 403 | { |
401 | QPtrListIterator<Observer> it(mObservers); | 404 | QPtrListIterator<Observer> it(mObservers); |
402 | while( it.current() ) { | 405 | while( it.current() ) { |
403 | Observer *o = it.current(); | 406 | Observer *o = it.current(); |
404 | ++it; | 407 | ++it; |
405 | o->incidenceUpdated( this ); | 408 | o->incidenceUpdated( this ); |
406 | } | 409 | } |
407 | } | 410 | } |