-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 10 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 2 |
4 files changed, 14 insertions, 0 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2243e28..3b7b183 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,374 +1,375 @@ | |||
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 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual void setSyncEventsReadOnly() = 0; | ||
79 | 80 | ||
80 | /** | 81 | /** |
81 | Sync changes in memory to persistant storage. | 82 | Sync changes in memory to persistant storage. |
82 | */ | 83 | */ |
83 | virtual void save() = 0; | 84 | virtual void save() = 0; |
84 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 85 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
85 | virtual void removeSyncInfo( QString syncProfile) = 0; | 86 | virtual void removeSyncInfo( QString syncProfile) = 0; |
86 | virtual bool isSaving() { return false; } | 87 | virtual bool isSaving() { return false; } |
87 | 88 | ||
88 | /** | 89 | /** |
89 | Return the owner of the calendar's full name. | 90 | Return the owner of the calendar's full name. |
90 | */ | 91 | */ |
91 | const QString &getOwner() const; | 92 | const QString &getOwner() const; |
92 | /** | 93 | /** |
93 | Set the owner of the calendar. Should be owner's full name. | 94 | Set the owner of the calendar. Should be owner's full name. |
94 | */ | 95 | */ |
95 | void setOwner( const QString &os ); | 96 | void setOwner( const QString &os ); |
96 | /** | 97 | /** |
97 | Return the email address of the calendar owner. | 98 | Return the email address of the calendar owner. |
98 | */ | 99 | */ |
99 | const QString &getEmail(); | 100 | const QString &getEmail(); |
100 | /** | 101 | /** |
101 | Set the email address of the calendar owner. | 102 | Set the email address of the calendar owner. |
102 | */ | 103 | */ |
103 | void setEmail( const QString & ); | 104 | void setEmail( const QString & ); |
104 | 105 | ||
105 | /** | 106 | /** |
106 | Set time zone from a timezone string (e.g. -2:00) | 107 | Set time zone from a timezone string (e.g. -2:00) |
107 | */ | 108 | */ |
108 | void setTimeZone( const QString &tz ); | 109 | void setTimeZone( const QString &tz ); |
109 | /** | 110 | /** |
110 | Set time zone from a minutes value (e.g. -60) | 111 | Set time zone from a minutes value (e.g. -60) |
111 | */ | 112 | */ |
112 | void setTimeZone( int tz ); | 113 | void setTimeZone( int tz ); |
113 | /** | 114 | /** |
114 | Return time zone as offest in minutes. | 115 | Return time zone as offest in minutes. |
115 | */ | 116 | */ |
116 | int getTimeZone() const; | 117 | int getTimeZone() const; |
117 | /** | 118 | /** |
118 | Compute an ISO 8601 format string from the time zone. | 119 | Compute an ISO 8601 format string from the time zone. |
119 | */ | 120 | */ |
120 | QString getTimeZoneStr() const; | 121 | QString getTimeZoneStr() const; |
121 | /** | 122 | /** |
122 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 123 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
123 | values). | 124 | values). |
124 | */ | 125 | */ |
125 | void setTimeZoneId( const QString & ); | 126 | void setTimeZoneId( const QString & ); |
126 | /** | 127 | /** |
127 | Return time zone id. | 128 | Return time zone id. |
128 | */ | 129 | */ |
129 | QString timeZoneId() const; | 130 | QString timeZoneId() const; |
130 | /** | 131 | /** |
131 | Use local time, not UTC or a time zone. | 132 | Use local time, not UTC or a time zone. |
132 | */ | 133 | */ |
133 | void setLocalTime(); | 134 | void setLocalTime(); |
134 | /** | 135 | /** |
135 | Return whether local time is being used. | 136 | Return whether local time is being used. |
136 | */ | 137 | */ |
137 | bool isLocalTime() const; | 138 | bool isLocalTime() const; |
138 | 139 | ||
139 | /** | 140 | /** |
140 | Add an incidence to calendar. | 141 | Add an incidence to calendar. |
141 | 142 | ||
142 | @return true on success, false on error. | 143 | @return true on success, false on error. |
143 | */ | 144 | */ |
144 | virtual bool addIncidence( Incidence * ); | 145 | virtual bool addIncidence( Incidence * ); |
145 | 146 | ||
146 | // Adds an incidence and all relatedto incidences to the cal | 147 | // Adds an incidence and all relatedto incidences to the cal |
147 | void addIncidenceBranch( Incidence * ); | 148 | void addIncidenceBranch( Incidence * ); |
148 | /** | 149 | /** |
149 | Return filtered list of all incidences of this calendar. | 150 | Return filtered list of all incidences of this calendar. |
150 | */ | 151 | */ |
151 | virtual QPtrList<Incidence> incidences(); | 152 | virtual QPtrList<Incidence> incidences(); |
152 | 153 | ||
153 | /** | 154 | /** |
154 | Return unfiltered list of all incidences of this calendar. | 155 | Return unfiltered list of all incidences of this calendar. |
155 | */ | 156 | */ |
156 | virtual QPtrList<Incidence> rawIncidences(); | 157 | virtual QPtrList<Incidence> rawIncidences(); |
157 | 158 | ||
158 | /** | 159 | /** |
159 | Adds a Event to this calendar object. | 160 | Adds a Event to this calendar object. |
160 | @param anEvent a pointer to the event to add | 161 | @param anEvent a pointer to the event to add |
161 | 162 | ||
162 | @return true on success, false on error. | 163 | @return true on success, false on error. |
163 | */ | 164 | */ |
164 | virtual bool addEventNoDup( Event *event ) = 0; | 165 | virtual bool addEventNoDup( Event *event ) = 0; |
165 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 166 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
166 | virtual bool addEvent( Event *anEvent ) = 0; | 167 | virtual bool addEvent( Event *anEvent ) = 0; |
167 | /** | 168 | /** |
168 | Delete event from calendar. | 169 | Delete event from calendar. |
169 | */ | 170 | */ |
170 | virtual void deleteEvent( Event * ) = 0; | 171 | virtual void deleteEvent( Event * ) = 0; |
171 | /** | 172 | /** |
172 | Retrieves an event on the basis of the unique string ID. | 173 | Retrieves an event on the basis of the unique string ID. |
173 | */ | 174 | */ |
174 | virtual Event *event( const QString &UniqueStr ) = 0; | 175 | virtual Event *event( const QString &UniqueStr ) = 0; |
175 | virtual Event *event( QString, QString ) = 0; | 176 | virtual Event *event( QString, QString ) = 0; |
176 | /** | 177 | /** |
177 | Builds and then returns a list of all events that match for the | 178 | Builds and then returns a list of all events that match for the |
178 | date specified. useful for dayView, etc. etc. | 179 | date specified. useful for dayView, etc. etc. |
179 | The calendar filter is applied. | 180 | The calendar filter is applied. |
180 | */ | 181 | */ |
181 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 182 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
182 | /** | 183 | /** |
183 | Get events, which occur on the given date. | 184 | Get events, which occur on the given date. |
184 | The calendar filter is applied. | 185 | The calendar filter is applied. |
185 | */ | 186 | */ |
186 | QPtrList<Event> events( const QDateTime &qdt ); | 187 | QPtrList<Event> events( const QDateTime &qdt ); |
187 | /** | 188 | /** |
188 | Get events in a range of dates. If inclusive is set to true, only events | 189 | Get events in a range of dates. If inclusive is set to true, only events |
189 | are returned, which are completely included in the range. | 190 | are returned, which are completely included in the range. |
190 | The calendar filter is applied. | 191 | The calendar filter is applied. |
191 | */ | 192 | */ |
192 | QPtrList<Event> events( const QDate &start, const QDate &end, | 193 | QPtrList<Event> events( const QDate &start, const QDate &end, |
193 | bool inclusive = false); | 194 | bool inclusive = false); |
194 | /** | 195 | /** |
195 | Return filtered list of all events in calendar. | 196 | Return filtered list of all events in calendar. |
196 | */ | 197 | */ |
197 | virtual QPtrList<Event> events(); | 198 | virtual QPtrList<Event> events(); |
198 | /** | 199 | /** |
199 | Return unfiltered list of all events in calendar. | 200 | Return unfiltered list of all events in calendar. |
200 | */ | 201 | */ |
201 | virtual QPtrList<Event> rawEvents() = 0; | 202 | virtual QPtrList<Event> rawEvents() = 0; |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Add a todo to the todolist. | 205 | Add a todo to the todolist. |
205 | 206 | ||
206 | @return true on success, false on error. | 207 | @return true on success, false on error. |
207 | */ | 208 | */ |
208 | virtual bool addTodo( Todo *todo ) = 0; | 209 | virtual bool addTodo( Todo *todo ) = 0; |
209 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 210 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
210 | /** | 211 | /** |
211 | Remove a todo from the todolist. | 212 | Remove a todo from the todolist. |
212 | */ | 213 | */ |
213 | virtual void deleteTodo( Todo * ) = 0; | 214 | virtual void deleteTodo( Todo * ) = 0; |
214 | virtual void deleteJournal( Journal * ) = 0; | 215 | virtual void deleteJournal( Journal * ) = 0; |
215 | /** | 216 | /** |
216 | Return filterd list of todos. | 217 | Return filterd list of todos. |
217 | */ | 218 | */ |
218 | virtual QPtrList<Todo> todos(); | 219 | virtual QPtrList<Todo> todos(); |
219 | /** | 220 | /** |
220 | Searches todolist for an event with this unique string identifier, | 221 | Searches todolist for an event with this unique string identifier, |
221 | returns a pointer or null. | 222 | returns a pointer or null. |
222 | */ | 223 | */ |
223 | virtual Todo *todo( const QString &uid ) = 0; | 224 | virtual Todo *todo( const QString &uid ) = 0; |
224 | virtual Todo *todo( QString, QString ) = 0; | 225 | virtual Todo *todo( QString, QString ) = 0; |
225 | /** | 226 | /** |
226 | Returns list of todos due on the specified date. | 227 | Returns list of todos due on the specified date. |
227 | */ | 228 | */ |
228 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 229 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
229 | /** | 230 | /** |
230 | Return unfiltered list of todos. | 231 | Return unfiltered list of todos. |
231 | */ | 232 | */ |
232 | virtual QPtrList<Todo> rawTodos() = 0; | 233 | virtual QPtrList<Todo> rawTodos() = 0; |
233 | 234 | ||
234 | /** | 235 | /** |
235 | Add a Journal entry to calendar. | 236 | Add a Journal entry to calendar. |
236 | 237 | ||
237 | @return true on success, false on error. | 238 | @return true on success, false on error. |
238 | */ | 239 | */ |
239 | virtual bool addJournal( Journal * ) = 0; | 240 | virtual bool addJournal( Journal * ) = 0; |
240 | /** | 241 | /** |
241 | Return Journal for given date. | 242 | Return Journal for given date. |
242 | */ | 243 | */ |
243 | virtual Journal *journal( const QDate & ) = 0; | 244 | virtual Journal *journal( const QDate & ) = 0; |
244 | /** | 245 | /** |
245 | Return Journal with given UID. | 246 | Return Journal with given UID. |
246 | */ | 247 | */ |
247 | virtual Journal *journal( const QString &UID ) = 0; | 248 | virtual Journal *journal( const QString &UID ) = 0; |
248 | /** | 249 | /** |
249 | Return list of all Journal entries. | 250 | Return list of all Journal entries. |
250 | */ | 251 | */ |
251 | virtual QPtrList<Journal> journals() = 0; | 252 | virtual QPtrList<Journal> journals() = 0; |
252 | 253 | ||
253 | /** | 254 | /** |
254 | Searches all incidence types for an incidence with this unique | 255 | Searches all incidence types for an incidence with this unique |
255 | string identifier, returns a pointer or null. | 256 | string identifier, returns a pointer or null. |
256 | */ | 257 | */ |
257 | Incidence* incidence( const QString&UID ); | 258 | Incidence* incidence( const QString&UID ); |
258 | 259 | ||
259 | /** | 260 | /** |
260 | Setup relations for an incidence. | 261 | Setup relations for an incidence. |
261 | */ | 262 | */ |
262 | virtual void setupRelations( Incidence * ); | 263 | virtual void setupRelations( Incidence * ); |
263 | /** | 264 | /** |
264 | Remove all relations to an incidence | 265 | Remove all relations to an incidence |
265 | */ | 266 | */ |
266 | virtual void removeRelations( Incidence * ); | 267 | virtual void removeRelations( Incidence * ); |
267 | 268 | ||
268 | /** | 269 | /** |
269 | Set calendar filter, which filters events for the events() functions. | 270 | Set calendar filter, which filters events for the events() functions. |
270 | The Filter object is owned by the caller. | 271 | The Filter object is owned by the caller. |
271 | */ | 272 | */ |
272 | void setFilter( CalFilter * ); | 273 | void setFilter( CalFilter * ); |
273 | /** | 274 | /** |
274 | Return calendar filter. | 275 | Return calendar filter. |
275 | */ | 276 | */ |
276 | CalFilter *filter(); | 277 | CalFilter *filter(); |
277 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 278 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
278 | virtual QString nextSummary( ) const = 0; | 279 | virtual QString nextSummary( ) const = 0; |
279 | virtual void reInitAlarmSettings() = 0; | 280 | virtual void reInitAlarmSettings() = 0; |
280 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 281 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
281 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 282 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
282 | /** | 283 | /** |
283 | Return all alarms, which ocur in the given time interval. | 284 | Return all alarms, which ocur in the given time interval. |
284 | */ | 285 | */ |
285 | virtual Alarm::List alarms( const QDateTime &from, | 286 | virtual Alarm::List alarms( const QDateTime &from, |
286 | const QDateTime &to ) = 0; | 287 | const QDateTime &to ) = 0; |
287 | 288 | ||
288 | class Observer { | 289 | class Observer { |
289 | public: | 290 | public: |
290 | virtual void calendarModified( bool, Calendar * ) = 0; | 291 | virtual void calendarModified( bool, Calendar * ) = 0; |
291 | }; | 292 | }; |
292 | 293 | ||
293 | void registerObserver( Observer * ); | 294 | void registerObserver( Observer * ); |
294 | 295 | ||
295 | void setModified( bool ); | 296 | void setModified( bool ); |
296 | 297 | ||
297 | /** | 298 | /** |
298 | Set product id returned by loadedProductId(). This function is only | 299 | Set product id returned by loadedProductId(). This function is only |
299 | useful for the calendar loading code. | 300 | useful for the calendar loading code. |
300 | */ | 301 | */ |
301 | void setLoadedProductId( const QString & ); | 302 | void setLoadedProductId( const QString & ); |
302 | /** | 303 | /** |
303 | Return product id taken from file that has been loaded. Returns | 304 | Return product id taken from file that has been loaded. Returns |
304 | QString::null, if no calendar has been loaded. | 305 | QString::null, if no calendar has been loaded. |
305 | */ | 306 | */ |
306 | QString loadedProductId(); | 307 | QString loadedProductId(); |
307 | int defaultCalendar(); | 308 | int defaultCalendar(); |
308 | void setDontDeleteIncidencesOnClose (); | 309 | void setDontDeleteIncidencesOnClose (); |
309 | public slots: | 310 | public slots: |
310 | void setDefaultCalendar( int ); | 311 | void setDefaultCalendar( int ); |
311 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 312 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
312 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 313 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
313 | virtual void setReadOnly( int id, bool enable ) = 0; | 314 | virtual void setReadOnly( int id, bool enable ) = 0; |
314 | virtual void setDefaultCalendarEnabledOnly() = 0; | 315 | virtual void setDefaultCalendarEnabledOnly() = 0; |
315 | virtual void setCalendarRemove( int id ) = 0; | 316 | virtual void setCalendarRemove( int id ) = 0; |
316 | signals: | 317 | signals: |
317 | void calendarChanged(); | 318 | void calendarChanged(); |
318 | void calendarSaved(); | 319 | void calendarSaved(); |
319 | void calendarLoaded(); | 320 | void calendarLoaded(); |
320 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 321 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
321 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 322 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
322 | 323 | ||
323 | protected: | 324 | protected: |
324 | /** | 325 | /** |
325 | Get unfiltered events, which occur on the given date. | 326 | Get unfiltered events, which occur on the given date. |
326 | */ | 327 | */ |
327 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 328 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
328 | /** | 329 | /** |
329 | Get unfiltered events, which occur on the given date. | 330 | Get unfiltered events, which occur on the given date. |
330 | */ | 331 | */ |
331 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 332 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
332 | bool sorted = false ) = 0; | 333 | bool sorted = false ) = 0; |
333 | /** | 334 | /** |
334 | Get events in a range of dates. If inclusive is set to true, only events | 335 | Get events in a range of dates. If inclusive is set to true, only events |
335 | are returned, which are completely included in the range. | 336 | are returned, which are completely included in the range. |
336 | */ | 337 | */ |
337 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 338 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
338 | bool inclusive = false ) = 0; | 339 | bool inclusive = false ) = 0; |
339 | 340 | ||
340 | Incidence *mNextAlarmIncidence; | 341 | Incidence *mNextAlarmIncidence; |
341 | Incidence *mUndoIncidence; | 342 | Incidence *mUndoIncidence; |
342 | int mDefaultCalendar; | 343 | int mDefaultCalendar; |
343 | bool mDeleteIncidencesOnClose; | 344 | bool mDeleteIncidencesOnClose; |
344 | 345 | ||
345 | private: | 346 | private: |
346 | void init(); | 347 | void init(); |
347 | 348 | ||
348 | QString mOwner; // who the calendar belongs to | 349 | QString mOwner; // who the calendar belongs to |
349 | QString mOwnerEmail; // email address of the owner | 350 | QString mOwnerEmail; // email address of the owner |
350 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 351 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
351 | bool mLocalTime; // use local time, not UTC or a time zone | 352 | bool mLocalTime; // use local time, not UTC or a time zone |
352 | 353 | ||
353 | 354 | ||
354 | CalFilter *mFilter; | 355 | CalFilter *mFilter; |
355 | CalFilter *mDefaultFilter; | 356 | CalFilter *mDefaultFilter; |
356 | 357 | ||
357 | 358 | ||
358 | QString mTimeZoneId; | 359 | QString mTimeZoneId; |
359 | 360 | ||
360 | Observer *mObserver; | 361 | Observer *mObserver; |
361 | bool mNewObserver; | 362 | bool mNewObserver; |
362 | 363 | ||
363 | bool mModified; | 364 | bool mModified; |
364 | 365 | ||
365 | QString mLoadedProductId; | 366 | QString mLoadedProductId; |
366 | 367 | ||
367 | // This list is used to put together related todos | 368 | // This list is used to put together related todos |
368 | QDict<Incidence> mOrphans; | 369 | QDict<Incidence> mOrphans; |
369 | QDict<Incidence> mOrphanUids; | 370 | QDict<Incidence> mOrphanUids; |
370 | }; | 371 | }; |
371 | 372 | ||
372 | } | 373 | } |
373 | 374 | ||
374 | #endif | 375 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 336c3e8..8c4dde1 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,909 +1,919 @@ | |||
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 | if ( mDeleteIncidencesOnClose ) | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | 69 | close(); |
70 | } | 70 | } |
71 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 71 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
72 | { | 72 | { |
73 | CalendarLocal calendar( timeZoneId() ); | 73 | CalendarLocal calendar( timeZoneId() ); |
74 | calendar.setDefaultCalendar( id ); | 74 | calendar.setDefaultCalendar( id ); |
75 | if ( calendar.load( name ) ) { | 75 | if ( calendar.load( name ) ) { |
76 | addCalendar( &calendar ); | 76 | addCalendar( &calendar ); |
77 | return true; | 77 | return true; |
78 | } | 78 | } |
79 | return false; | 79 | return false; |
80 | } | 80 | } |
81 | void CalendarLocal::setSyncEventsReadOnly() | ||
82 | { | ||
83 | Event * ev; | ||
84 | ev = mEventList.first(); | ||
85 | while ( ev ) { | ||
86 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | ||
87 | ev->setReadOnly( true ); | ||
88 | ev = mEventList.next(); | ||
89 | } | ||
90 | } | ||
81 | void CalendarLocal::addCalendar( Calendar* cal ) | 91 | void CalendarLocal::addCalendar( Calendar* cal ) |
82 | { | 92 | { |
83 | cal->setDontDeleteIncidencesOnClose(); | 93 | cal->setDontDeleteIncidencesOnClose(); |
84 | { | 94 | { |
85 | QPtrList<Event> EventList = cal->rawEvents(); | 95 | QPtrList<Event> EventList = cal->rawEvents(); |
86 | Event * ev = EventList.first(); | 96 | Event * ev = EventList.first(); |
87 | while ( ev ) { | 97 | while ( ev ) { |
88 | ev->unRegisterObserver( cal ); | 98 | ev->unRegisterObserver( cal ); |
89 | ev->registerObserver( this ); | 99 | ev->registerObserver( this ); |
90 | mEventList.append( ev ); | 100 | mEventList.append( ev ); |
91 | ev = EventList.next(); | 101 | ev = EventList.next(); |
92 | } | 102 | } |
93 | } | 103 | } |
94 | { | 104 | { |
95 | 105 | ||
96 | QPtrList<Todo> TodoList = cal->rawTodos(); | 106 | QPtrList<Todo> TodoList = cal->rawTodos(); |
97 | Todo * ev = TodoList.first(); | 107 | Todo * ev = TodoList.first(); |
98 | while ( ev ) { | 108 | while ( ev ) { |
99 | QString rel = ev->relatedToUid(); | 109 | QString rel = ev->relatedToUid(); |
100 | if ( !rel.isEmpty() ){ | 110 | if ( !rel.isEmpty() ){ |
101 | ev->setRelatedTo ( 0 ); | 111 | ev->setRelatedTo ( 0 ); |
102 | ev->setRelatedToUid( rel ); | 112 | ev->setRelatedToUid( rel ); |
103 | } | 113 | } |
104 | ev = TodoList.next(); | 114 | ev = TodoList.next(); |
105 | } | 115 | } |
106 | //TodoList = cal->rawTodos(); | 116 | //TodoList = cal->rawTodos(); |
107 | ev = TodoList.first(); | 117 | ev = TodoList.first(); |
108 | while ( ev ) { | 118 | while ( ev ) { |
109 | ev->unRegisterObserver( cal ); | 119 | ev->unRegisterObserver( cal ); |
110 | ev->registerObserver( this ); | 120 | ev->registerObserver( this ); |
111 | mTodoList.append( ev ); | 121 | mTodoList.append( ev ); |
112 | setupRelations( ev ); | 122 | setupRelations( ev ); |
113 | ev = TodoList.next(); | 123 | ev = TodoList.next(); |
114 | } | 124 | } |
115 | } | 125 | } |
116 | { | 126 | { |
117 | QPtrList<Journal> JournalList = cal->journals(); | 127 | QPtrList<Journal> JournalList = cal->journals(); |
118 | Journal * ev = JournalList.first(); | 128 | Journal * ev = JournalList.first(); |
119 | while ( ev ) { | 129 | while ( ev ) { |
120 | ev->unRegisterObserver( cal ); | 130 | ev->unRegisterObserver( cal ); |
121 | ev->registerObserver( this ); | 131 | ev->registerObserver( this ); |
122 | mJournalList.append( ev ); | 132 | mJournalList.append( ev ); |
123 | ev = JournalList.next(); | 133 | ev = JournalList.next(); |
124 | } | 134 | } |
125 | } | 135 | } |
126 | setModified( true ); | 136 | setModified( true ); |
127 | } | 137 | } |
128 | bool CalendarLocal::load( const QString &fileName ) | 138 | bool CalendarLocal::load( const QString &fileName ) |
129 | { | 139 | { |
130 | FileStorage storage( this, fileName ); | 140 | FileStorage storage( this, fileName ); |
131 | return storage.load(); | 141 | return storage.load(); |
132 | } | 142 | } |
133 | 143 | ||
134 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 144 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
135 | { | 145 | { |
136 | FileStorage storage( this, fileName, format ); | 146 | FileStorage storage( this, fileName, format ); |
137 | return storage.save(); | 147 | return storage.save(); |
138 | } | 148 | } |
139 | 149 | ||
140 | void CalendarLocal::close() | 150 | void CalendarLocal::close() |
141 | { | 151 | { |
142 | 152 | ||
143 | Todo * i; | 153 | Todo * i; |
144 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 154 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
145 | 155 | ||
146 | mEventList.setAutoDelete( true ); | 156 | mEventList.setAutoDelete( true ); |
147 | mTodoList.setAutoDelete( true ); | 157 | mTodoList.setAutoDelete( true ); |
148 | mJournalList.setAutoDelete( false ); | 158 | mJournalList.setAutoDelete( false ); |
149 | 159 | ||
150 | mEventList.clear(); | 160 | mEventList.clear(); |
151 | mTodoList.clear(); | 161 | mTodoList.clear(); |
152 | mJournalList.clear(); | 162 | mJournalList.clear(); |
153 | 163 | ||
154 | mEventList.setAutoDelete( false ); | 164 | mEventList.setAutoDelete( false ); |
155 | mTodoList.setAutoDelete( false ); | 165 | mTodoList.setAutoDelete( false ); |
156 | mJournalList.setAutoDelete( false ); | 166 | mJournalList.setAutoDelete( false ); |
157 | 167 | ||
158 | setModified( false ); | 168 | setModified( false ); |
159 | } | 169 | } |
160 | 170 | ||
161 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 171 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
162 | { | 172 | { |
163 | QString cat; | 173 | QString cat; |
164 | bool isBirthday = true; | 174 | bool isBirthday = true; |
165 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 175 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
166 | isBirthday = false; | 176 | isBirthday = false; |
167 | cat = i18n( "Anniversary" ); | 177 | cat = i18n( "Anniversary" ); |
168 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 178 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
169 | isBirthday = true; | 179 | isBirthday = true; |
170 | cat = i18n( "Birthday" ); | 180 | cat = i18n( "Birthday" ); |
171 | } else { | 181 | } else { |
172 | qDebug("addAnniversaryNoDup called without fitting category! "); | 182 | qDebug("addAnniversaryNoDup called without fitting category! "); |
173 | return false; | 183 | return false; |
174 | } | 184 | } |
175 | Event * eve; | 185 | Event * eve; |
176 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 186 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
177 | if ( !(eve->categories().contains( cat ) )) | 187 | if ( !(eve->categories().contains( cat ) )) |
178 | continue; | 188 | continue; |
179 | // now we have an event with fitting category | 189 | // now we have an event with fitting category |
180 | if ( eve->dtStart().date() != event->dtStart().date() ) | 190 | if ( eve->dtStart().date() != event->dtStart().date() ) |
181 | continue; | 191 | continue; |
182 | // now we have an event with fitting category+date | 192 | // now we have an event with fitting category+date |
183 | if ( eve->summary() != event->summary() ) | 193 | if ( eve->summary() != event->summary() ) |
184 | continue; | 194 | continue; |
185 | // now we have an event with fitting category+date+summary | 195 | // now we have an event with fitting category+date+summary |
186 | return false; | 196 | return false; |
187 | } | 197 | } |
188 | return addEvent( event ); | 198 | return addEvent( event ); |
189 | 199 | ||
190 | } | 200 | } |
191 | bool CalendarLocal::addEventNoDup( Event *event ) | 201 | bool CalendarLocal::addEventNoDup( Event *event ) |
192 | { | 202 | { |
193 | Event * eve; | 203 | Event * eve; |
194 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 204 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
195 | if ( *eve == *event ) { | 205 | if ( *eve == *event ) { |
196 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 206 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
197 | return false; | 207 | return false; |
198 | } | 208 | } |
199 | } | 209 | } |
200 | return addEvent( event ); | 210 | return addEvent( event ); |
201 | } | 211 | } |
202 | 212 | ||
203 | bool CalendarLocal::addEvent( Event *event ) | 213 | bool CalendarLocal::addEvent( Event *event ) |
204 | { | 214 | { |
205 | insertEvent( event ); | 215 | insertEvent( event ); |
206 | 216 | ||
207 | event->registerObserver( this ); | 217 | event->registerObserver( this ); |
208 | 218 | ||
209 | setModified( true ); | 219 | setModified( true ); |
210 | event->setCalID( mDefaultCalendar ); | 220 | event->setCalID( mDefaultCalendar ); |
211 | event->setCalEnabled( true ); | 221 | event->setCalEnabled( true ); |
212 | 222 | ||
213 | return true; | 223 | return true; |
214 | } | 224 | } |
215 | 225 | ||
216 | void CalendarLocal::deleteEvent( Event *event ) | 226 | void CalendarLocal::deleteEvent( Event *event ) |
217 | { | 227 | { |
218 | if ( mUndoIncidence ) delete mUndoIncidence; | 228 | if ( mUndoIncidence ) delete mUndoIncidence; |
219 | mUndoIncidence = event->clone(); | 229 | mUndoIncidence = event->clone(); |
220 | if ( mEventList.removeRef( event ) ) { | 230 | if ( mEventList.removeRef( event ) ) { |
221 | setModified( true ); | 231 | setModified( true ); |
222 | } | 232 | } |
223 | } | 233 | } |
224 | 234 | ||
225 | 235 | ||
226 | Event *CalendarLocal::event( const QString &uid ) | 236 | Event *CalendarLocal::event( const QString &uid ) |
227 | { | 237 | { |
228 | Event *event; | 238 | Event *event; |
229 | Event *retVal = 0; | 239 | Event *retVal = 0; |
230 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 240 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
231 | if ( event->calEnabled() && event->uid() == uid ) { | 241 | if ( event->calEnabled() && event->uid() == uid ) { |
232 | if ( retVal ) { | 242 | if ( retVal ) { |
233 | if ( retVal->calID() > event->calID() ) { | 243 | if ( retVal->calID() > event->calID() ) { |
234 | retVal = event; | 244 | retVal = event; |
235 | } | 245 | } |
236 | } else { | 246 | } else { |
237 | retVal = event; | 247 | retVal = event; |
238 | } | 248 | } |
239 | } | 249 | } |
240 | } | 250 | } |
241 | return retVal; | 251 | return retVal; |
242 | } | 252 | } |
243 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 253 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
244 | { | 254 | { |
245 | Todo * eve; | 255 | Todo * eve; |
246 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 256 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
247 | if ( *eve == *todo ) { | 257 | if ( *eve == *todo ) { |
248 | //qDebug("duplicate todo found! not inserted! "); | 258 | //qDebug("duplicate todo found! not inserted! "); |
249 | return false; | 259 | return false; |
250 | } | 260 | } |
251 | } | 261 | } |
252 | return addTodo( todo ); | 262 | return addTodo( todo ); |
253 | } | 263 | } |
254 | bool CalendarLocal::addTodo( Todo *todo ) | 264 | bool CalendarLocal::addTodo( Todo *todo ) |
255 | { | 265 | { |
256 | mTodoList.append( todo ); | 266 | mTodoList.append( todo ); |
257 | 267 | ||
258 | todo->registerObserver( this ); | 268 | todo->registerObserver( this ); |
259 | 269 | ||
260 | // Set up subtask relations | 270 | // Set up subtask relations |
261 | setupRelations( todo ); | 271 | setupRelations( todo ); |
262 | 272 | ||
263 | setModified( true ); | 273 | setModified( true ); |
264 | todo->setCalID( mDefaultCalendar ); | 274 | todo->setCalID( mDefaultCalendar ); |
265 | todo->setCalEnabled( true ); | 275 | todo->setCalEnabled( true ); |
266 | return true; | 276 | return true; |
267 | } | 277 | } |
268 | 278 | ||
269 | void CalendarLocal::deleteTodo( Todo *todo ) | 279 | void CalendarLocal::deleteTodo( Todo *todo ) |
270 | { | 280 | { |
271 | // Handle orphaned children | 281 | // Handle orphaned children |
272 | if ( mUndoIncidence ) delete mUndoIncidence; | 282 | if ( mUndoIncidence ) delete mUndoIncidence; |
273 | removeRelations( todo ); | 283 | removeRelations( todo ); |
274 | mUndoIncidence = todo->clone(); | 284 | mUndoIncidence = todo->clone(); |
275 | 285 | ||
276 | if ( mTodoList.removeRef( todo ) ) { | 286 | if ( mTodoList.removeRef( todo ) ) { |
277 | setModified( true ); | 287 | setModified( true ); |
278 | } | 288 | } |
279 | } | 289 | } |
280 | 290 | ||
281 | QPtrList<Todo> CalendarLocal::rawTodos() | 291 | QPtrList<Todo> CalendarLocal::rawTodos() |
282 | { | 292 | { |
283 | QPtrList<Todo> el; | 293 | QPtrList<Todo> el; |
284 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 294 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
285 | if ( it->calEnabled() ) el.append( it ); | 295 | if ( it->calEnabled() ) el.append( it ); |
286 | return el; | 296 | return el; |
287 | } | 297 | } |
288 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 298 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
289 | { | 299 | { |
290 | Todo *todo; | 300 | Todo *todo; |
291 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 301 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
292 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 302 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
293 | } | 303 | } |
294 | 304 | ||
295 | return 0; | 305 | return 0; |
296 | } | 306 | } |
297 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 307 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
298 | { | 308 | { |
299 | QPtrList<Incidence> all = rawIncidences() ; | 309 | QPtrList<Incidence> all = rawIncidences() ; |
300 | Incidence *inc; | 310 | Incidence *inc; |
301 | for ( inc = all.first(); inc; inc = all.next() ) { | 311 | for ( inc = all.first(); inc; inc = all.next() ) { |
302 | inc->removeID( syncProfile ); | 312 | inc->removeID( syncProfile ); |
303 | } | 313 | } |
304 | if ( syncProfile.isEmpty() ) { | 314 | if ( syncProfile.isEmpty() ) { |
305 | QPtrList<Event> el; | 315 | QPtrList<Event> el; |
306 | Event *todo; | 316 | Event *todo; |
307 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 317 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
308 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 318 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
309 | el.append( todo ); | 319 | el.append( todo ); |
310 | } | 320 | } |
311 | for ( todo = el.first(); todo; todo = el.next() ) { | 321 | for ( todo = el.first(); todo; todo = el.next() ) { |
312 | deleteIncidence ( todo ); | 322 | deleteIncidence ( todo ); |
313 | } | 323 | } |
314 | } else { | 324 | } else { |
315 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 325 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
316 | if ( lse ) | 326 | if ( lse ) |
317 | deleteIncidence ( lse ); | 327 | deleteIncidence ( lse ); |
318 | } | 328 | } |
319 | } | 329 | } |
320 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 330 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
321 | { | 331 | { |
322 | QPtrList<Event> el; | 332 | QPtrList<Event> el; |
323 | Event *todo; | 333 | Event *todo; |
324 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 334 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
325 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 335 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
326 | if ( todo->summary().left(3) == "E: " ) | 336 | if ( todo->summary().left(3) == "E: " ) |
327 | el.append( todo ); | 337 | el.append( todo ); |
328 | } | 338 | } |
329 | 339 | ||
330 | return el; | 340 | return el; |
331 | 341 | ||
332 | } | 342 | } |
333 | Event *CalendarLocal::event( QString syncProf, QString id ) | 343 | Event *CalendarLocal::event( QString syncProf, QString id ) |
334 | { | 344 | { |
335 | Event *todo; | 345 | Event *todo; |
336 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 346 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
337 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 347 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
338 | } | 348 | } |
339 | 349 | ||
340 | return 0; | 350 | return 0; |
341 | } | 351 | } |
342 | Todo *CalendarLocal::todo( const QString &uid ) | 352 | Todo *CalendarLocal::todo( const QString &uid ) |
343 | { | 353 | { |
344 | Todo *todo;; | 354 | Todo *todo;; |
345 | Todo *retVal = 0; | 355 | Todo *retVal = 0; |
346 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 356 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
347 | if ( todo->calEnabled() && todo->uid() == uid ) { | 357 | if ( todo->calEnabled() && todo->uid() == uid ) { |
348 | if ( retVal ) { | 358 | if ( retVal ) { |
349 | if ( retVal->calID() > todo->calID() ) { | 359 | if ( retVal->calID() > todo->calID() ) { |
350 | retVal = todo; | 360 | retVal = todo; |
351 | } | 361 | } |
352 | } else { | 362 | } else { |
353 | retVal = todo; | 363 | retVal = todo; |
354 | } | 364 | } |
355 | } | 365 | } |
356 | } | 366 | } |
357 | return retVal; | 367 | return retVal; |
358 | } | 368 | } |
359 | QString CalendarLocal::nextSummary() const | 369 | QString CalendarLocal::nextSummary() const |
360 | { | 370 | { |
361 | return mNextSummary; | 371 | return mNextSummary; |
362 | } | 372 | } |
363 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 373 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
364 | { | 374 | { |
365 | return mNextAlarmEventDateTime; | 375 | return mNextAlarmEventDateTime; |
366 | } | 376 | } |
367 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 377 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
368 | { | 378 | { |
369 | //mNextAlarmIncidence | 379 | //mNextAlarmIncidence |
370 | //mNextAlarmDateTime | 380 | //mNextAlarmDateTime |
371 | //return mNextSummary; | 381 | //return mNextSummary; |
372 | //return mNextAlarmEventDateTime; | 382 | //return mNextAlarmEventDateTime; |
373 | bool newNextAlarm = false; | 383 | bool newNextAlarm = false; |
374 | bool computeNextAlarm = false; | 384 | bool computeNextAlarm = false; |
375 | bool ok; | 385 | bool ok; |
376 | int offset; | 386 | int offset; |
377 | QDateTime nextA; | 387 | QDateTime nextA; |
378 | // QString nextSum; | 388 | // QString nextSum; |
379 | //QDateTime nextEvent; | 389 | //QDateTime nextEvent; |
380 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 390 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
381 | computeNextAlarm = true; | 391 | computeNextAlarm = true; |
382 | } else { | 392 | } else { |
383 | if ( ! deleted ) { | 393 | if ( ! deleted ) { |
384 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 394 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
385 | if ( ok ) { | 395 | if ( ok ) { |
386 | if ( nextA < mNextAlarmDateTime ) { | 396 | if ( nextA < mNextAlarmDateTime ) { |
387 | deRegisterAlarm(); | 397 | deRegisterAlarm(); |
388 | mNextAlarmDateTime = nextA; | 398 | mNextAlarmDateTime = nextA; |
389 | mNextSummary = incidence->summary(); | 399 | mNextSummary = incidence->summary(); |
390 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 400 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
391 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 401 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
392 | newNextAlarm = true; | 402 | newNextAlarm = true; |
393 | mNextAlarmIncidence = incidence; | 403 | mNextAlarmIncidence = incidence; |
394 | } else { | 404 | } else { |
395 | if ( incidence == mNextAlarmIncidence ) { | 405 | if ( incidence == mNextAlarmIncidence ) { |
396 | computeNextAlarm = true; | 406 | computeNextAlarm = true; |
397 | } | 407 | } |
398 | } | 408 | } |
399 | } else { | 409 | } else { |
400 | if ( mNextAlarmIncidence == incidence ) { | 410 | if ( mNextAlarmIncidence == incidence ) { |
401 | computeNextAlarm = true; | 411 | computeNextAlarm = true; |
402 | } | 412 | } |
403 | } | 413 | } |
404 | } else { // deleted | 414 | } else { // deleted |
405 | if ( incidence == mNextAlarmIncidence ) { | 415 | if ( incidence == mNextAlarmIncidence ) { |
406 | computeNextAlarm = true; | 416 | computeNextAlarm = true; |
407 | } | 417 | } |
408 | } | 418 | } |
409 | } | 419 | } |
410 | if ( computeNextAlarm ) { | 420 | if ( computeNextAlarm ) { |
411 | deRegisterAlarm(); | 421 | deRegisterAlarm(); |
412 | nextA = nextAlarm( 1000 ); | 422 | nextA = nextAlarm( 1000 ); |
413 | if (! mNextAlarmIncidence ) { | 423 | if (! mNextAlarmIncidence ) { |
414 | return; | 424 | return; |
415 | } | 425 | } |
416 | newNextAlarm = true; | 426 | newNextAlarm = true; |
417 | } | 427 | } |
418 | if ( newNextAlarm ) | 428 | if ( newNextAlarm ) |
419 | registerAlarm(); | 429 | registerAlarm(); |
420 | } | 430 | } |
421 | QString CalendarLocal:: getAlarmNotification() | 431 | QString CalendarLocal:: getAlarmNotification() |
422 | { | 432 | { |
423 | QString ret; | 433 | QString ret; |
424 | // this should not happen | 434 | // this should not happen |
425 | if (! mNextAlarmIncidence ) | 435 | if (! mNextAlarmIncidence ) |
426 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 436 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
427 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 437 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
428 | if ( alarm->type() == Alarm::Procedure ) { | 438 | if ( alarm->type() == Alarm::Procedure ) { |
429 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 439 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
430 | } else { | 440 | } else { |
431 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 441 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
432 | } | 442 | } |
433 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 443 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
434 | if ( mNextSummary.length() > 25 ) | 444 | if ( mNextSummary.length() > 25 ) |
435 | ret += "\n" + mNextSummary.mid(25, 25 ); | 445 | ret += "\n" + mNextSummary.mid(25, 25 ); |
436 | ret+= "\n"+mNextAlarmEventDateTimeString; | 446 | ret+= "\n"+mNextAlarmEventDateTimeString; |
437 | return ret; | 447 | return ret; |
438 | } | 448 | } |
439 | void CalendarLocal::registerAlarm() | 449 | void CalendarLocal::registerAlarm() |
440 | { | 450 | { |
441 | mLastAlarmNotificationString = getAlarmNotification(); | 451 | mLastAlarmNotificationString = getAlarmNotification(); |
442 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 452 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
443 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 453 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
444 | // #ifndef DESKTOP_VERSION | 454 | // #ifndef DESKTOP_VERSION |
445 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 455 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
446 | // #endif | 456 | // #endif |
447 | } | 457 | } |
448 | void CalendarLocal::deRegisterAlarm() | 458 | void CalendarLocal::deRegisterAlarm() |
449 | { | 459 | { |
450 | if ( mLastAlarmNotificationString.isNull() ) | 460 | if ( mLastAlarmNotificationString.isNull() ) |
451 | return; | 461 | return; |
452 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 462 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
453 | 463 | ||
454 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 464 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
455 | mNextAlarmEventDateTime = QDateTime(); | 465 | mNextAlarmEventDateTime = QDateTime(); |
456 | // #ifndef DESKTOP_VERSION | 466 | // #ifndef DESKTOP_VERSION |
457 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 467 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
458 | // #endif | 468 | // #endif |
459 | } | 469 | } |
460 | 470 | ||
461 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 471 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
462 | { | 472 | { |
463 | QPtrList<Todo> todos; | 473 | QPtrList<Todo> todos; |
464 | 474 | ||
465 | Todo *todo; | 475 | Todo *todo; |
466 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 476 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
467 | if ( !todo->calEnabled() ) continue; | 477 | if ( !todo->calEnabled() ) continue; |
468 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 478 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
469 | todos.append( todo ); | 479 | todos.append( todo ); |
470 | } | 480 | } |
471 | } | 481 | } |
472 | 482 | ||
473 | filter()->apply( &todos ); | 483 | filter()->apply( &todos ); |
474 | return todos; | 484 | return todos; |
475 | } | 485 | } |
476 | void CalendarLocal::reInitAlarmSettings() | 486 | void CalendarLocal::reInitAlarmSettings() |
477 | { | 487 | { |
478 | if ( !mNextAlarmIncidence ) { | 488 | if ( !mNextAlarmIncidence ) { |
479 | nextAlarm( 1000 ); | 489 | nextAlarm( 1000 ); |
480 | } | 490 | } |
481 | deRegisterAlarm(); | 491 | deRegisterAlarm(); |
482 | mNextAlarmIncidence = 0; | 492 | mNextAlarmIncidence = 0; |
483 | checkAlarmForIncidence( 0, false ); | 493 | checkAlarmForIncidence( 0, false ); |
484 | 494 | ||
485 | } | 495 | } |
486 | 496 | ||
487 | 497 | ||
488 | 498 | ||
489 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 499 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
490 | { | 500 | { |
491 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 501 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
492 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 502 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
493 | QDateTime next; | 503 | QDateTime next; |
494 | Event *e; | 504 | Event *e; |
495 | bool ok; | 505 | bool ok; |
496 | bool found = false; | 506 | bool found = false; |
497 | int offset; | 507 | int offset; |
498 | mNextAlarmIncidence = 0; | 508 | mNextAlarmIncidence = 0; |
499 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 509 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
500 | if ( !e->calEnabled() ) continue; | 510 | if ( !e->calEnabled() ) continue; |
501 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 511 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
502 | if ( ok ) { | 512 | if ( ok ) { |
503 | if ( next < nextA ) { | 513 | if ( next < nextA ) { |
504 | nextA = next; | 514 | nextA = next; |
505 | found = true; | 515 | found = true; |
506 | mNextSummary = e->summary(); | 516 | mNextSummary = e->summary(); |
507 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 517 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
508 | mNextAlarmIncidence = (Incidence *) e; | 518 | mNextAlarmIncidence = (Incidence *) e; |
509 | } | 519 | } |
510 | } | 520 | } |
511 | } | 521 | } |
512 | Todo *t; | 522 | Todo *t; |
513 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 523 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
514 | if ( !t->calEnabled() ) continue; | 524 | if ( !t->calEnabled() ) continue; |
515 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 525 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
516 | if ( ok ) { | 526 | if ( ok ) { |
517 | if ( next < nextA ) { | 527 | if ( next < nextA ) { |
518 | nextA = next; | 528 | nextA = next; |
519 | found = true; | 529 | found = true; |
520 | mNextSummary = t->summary(); | 530 | mNextSummary = t->summary(); |
521 | mNextAlarmEventDateTime = next.addSecs(offset ); | 531 | mNextAlarmEventDateTime = next.addSecs(offset ); |
522 | mNextAlarmIncidence = (Incidence *) t; | 532 | mNextAlarmIncidence = (Incidence *) t; |
523 | } | 533 | } |
524 | } | 534 | } |
525 | } | 535 | } |
526 | if ( mNextAlarmIncidence ) { | 536 | if ( mNextAlarmIncidence ) { |
527 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 537 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
528 | mNextAlarmDateTime = nextA; | 538 | mNextAlarmDateTime = nextA; |
529 | } | 539 | } |
530 | return nextA; | 540 | return nextA; |
531 | } | 541 | } |
532 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 542 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
533 | { | 543 | { |
534 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 544 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
535 | } | 545 | } |
536 | 546 | ||
537 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 547 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
538 | { | 548 | { |
539 | 549 | ||
540 | Alarm::List alarms; | 550 | Alarm::List alarms; |
541 | 551 | ||
542 | Event *e; | 552 | Event *e; |
543 | 553 | ||
544 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 554 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
545 | if ( !e->calEnabled() ) continue; | 555 | if ( !e->calEnabled() ) continue; |
546 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 556 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
547 | else appendAlarms( alarms, e, from, to ); | 557 | else appendAlarms( alarms, e, from, to ); |
548 | } | 558 | } |
549 | 559 | ||
550 | Todo *t; | 560 | Todo *t; |
551 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 561 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
552 | if ( !t->calEnabled() ) continue; | 562 | if ( !t->calEnabled() ) continue; |
553 | appendAlarms( alarms, t, from, to ); | 563 | appendAlarms( alarms, t, from, to ); |
554 | } | 564 | } |
555 | 565 | ||
556 | return alarms; | 566 | return alarms; |
557 | } | 567 | } |
558 | 568 | ||
559 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 569 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
560 | const QDateTime &from, const QDateTime &to ) | 570 | const QDateTime &from, const QDateTime &to ) |
561 | { | 571 | { |
562 | QPtrList<Alarm> alarmList = incidence->alarms(); | 572 | QPtrList<Alarm> alarmList = incidence->alarms(); |
563 | Alarm *alarm; | 573 | Alarm *alarm; |
564 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 574 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
565 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 575 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
566 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 576 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
567 | if ( alarm->enabled() ) { | 577 | if ( alarm->enabled() ) { |
568 | if ( alarm->time() >= from && alarm->time() <= to ) { | 578 | if ( alarm->time() >= from && alarm->time() <= to ) { |
569 | alarms.append( alarm ); | 579 | alarms.append( alarm ); |
570 | } | 580 | } |
571 | } | 581 | } |
572 | } | 582 | } |
573 | } | 583 | } |
574 | 584 | ||
575 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 585 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
576 | Incidence *incidence, | 586 | Incidence *incidence, |
577 | const QDateTime &from, | 587 | const QDateTime &from, |
578 | const QDateTime &to ) | 588 | const QDateTime &to ) |
579 | { | 589 | { |
580 | 590 | ||
581 | QPtrList<Alarm> alarmList = incidence->alarms(); | 591 | QPtrList<Alarm> alarmList = incidence->alarms(); |
582 | Alarm *alarm; | 592 | Alarm *alarm; |
583 | QDateTime qdt; | 593 | QDateTime qdt; |
584 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 594 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
585 | if (incidence->recursOn(from.date())) { | 595 | if (incidence->recursOn(from.date())) { |
586 | qdt.setTime(alarm->time().time()); | 596 | qdt.setTime(alarm->time().time()); |
587 | qdt.setDate(from.date()); | 597 | qdt.setDate(from.date()); |
588 | } | 598 | } |
589 | else qdt = alarm->time(); | 599 | else qdt = alarm->time(); |
590 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 600 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
591 | if ( alarm->enabled() ) { | 601 | if ( alarm->enabled() ) { |
592 | if ( qdt >= from && qdt <= to ) { | 602 | if ( qdt >= from && qdt <= to ) { |
593 | alarms.append( alarm ); | 603 | alarms.append( alarm ); |
594 | } | 604 | } |
595 | } | 605 | } |
596 | } | 606 | } |
597 | } | 607 | } |
598 | 608 | ||
599 | 609 | ||
600 | /****************************** PROTECTED METHODS ****************************/ | 610 | /****************************** PROTECTED METHODS ****************************/ |
601 | 611 | ||
602 | // after changes are made to an event, this should be called. | 612 | // after changes are made to an event, this should be called. |
603 | void CalendarLocal::update( IncidenceBase *incidence ) | 613 | void CalendarLocal::update( IncidenceBase *incidence ) |
604 | { | 614 | { |
605 | incidence->setSyncStatus( Event::SYNCMOD ); | 615 | incidence->setSyncStatus( Event::SYNCMOD ); |
606 | incidence->setLastModified( QDateTime::currentDateTime() ); | 616 | incidence->setLastModified( QDateTime::currentDateTime() ); |
607 | // we should probably update the revision number here, | 617 | // we should probably update the revision number here, |
608 | // or internally in the Event itself when certain things change. | 618 | // or internally in the Event itself when certain things change. |
609 | // need to verify with ical documentation. | 619 | // need to verify with ical documentation. |
610 | 620 | ||
611 | setModified( true ); | 621 | setModified( true ); |
612 | } | 622 | } |
613 | 623 | ||
614 | void CalendarLocal::insertEvent( Event *event ) | 624 | void CalendarLocal::insertEvent( Event *event ) |
615 | { | 625 | { |
616 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 626 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
617 | } | 627 | } |
618 | 628 | ||
619 | 629 | ||
620 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 630 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
621 | { | 631 | { |
622 | QPtrList<Event> eventList; | 632 | QPtrList<Event> eventList; |
623 | 633 | ||
624 | Event *event; | 634 | Event *event; |
625 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 635 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
626 | if ( !event->calEnabled() ) continue; | 636 | if ( !event->calEnabled() ) continue; |
627 | if ( event->doesRecur() ) { | 637 | if ( event->doesRecur() ) { |
628 | if ( event->isMultiDay() ) { | 638 | if ( event->isMultiDay() ) { |
629 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 639 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
630 | int i; | 640 | int i; |
631 | for ( i = 0; i <= extraDays; i++ ) { | 641 | for ( i = 0; i <= extraDays; i++ ) { |
632 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 642 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
633 | eventList.append( event ); | 643 | eventList.append( event ); |
634 | break; | 644 | break; |
635 | } | 645 | } |
636 | } | 646 | } |
637 | } else { | 647 | } else { |
638 | if ( event->recursOn( qd ) ) | 648 | if ( event->recursOn( qd ) ) |
639 | eventList.append( event ); | 649 | eventList.append( event ); |
640 | } | 650 | } |
641 | } else { | 651 | } else { |
642 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 652 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
643 | eventList.append( event ); | 653 | eventList.append( event ); |
644 | } | 654 | } |
645 | } | 655 | } |
646 | } | 656 | } |
647 | 657 | ||
648 | if ( !sorted ) { | 658 | if ( !sorted ) { |
649 | return eventList; | 659 | return eventList; |
650 | } | 660 | } |
651 | 661 | ||
652 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 662 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
653 | // now, we have to sort it based on dtStart.time() | 663 | // now, we have to sort it based on dtStart.time() |
654 | QPtrList<Event> eventListSorted; | 664 | QPtrList<Event> eventListSorted; |
655 | Event *sortEvent; | 665 | Event *sortEvent; |
656 | for ( event = eventList.first(); event; event = eventList.next() ) { | 666 | for ( event = eventList.first(); event; event = eventList.next() ) { |
657 | sortEvent = eventListSorted.first(); | 667 | sortEvent = eventListSorted.first(); |
658 | int i = 0; | 668 | int i = 0; |
659 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 669 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
660 | { | 670 | { |
661 | i++; | 671 | i++; |
662 | sortEvent = eventListSorted.next(); | 672 | sortEvent = eventListSorted.next(); |
663 | } | 673 | } |
664 | eventListSorted.insert( i, event ); | 674 | eventListSorted.insert( i, event ); |
665 | } | 675 | } |
666 | return eventListSorted; | 676 | return eventListSorted; |
667 | } | 677 | } |
668 | 678 | ||
669 | 679 | ||
670 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 680 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
671 | bool inclusive ) | 681 | bool inclusive ) |
672 | { | 682 | { |
673 | Event *event = 0; | 683 | Event *event = 0; |
674 | 684 | ||
675 | QPtrList<Event> eventList; | 685 | QPtrList<Event> eventList; |
676 | 686 | ||
677 | // Get non-recurring events | 687 | // Get non-recurring events |
678 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 688 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
679 | if ( !event->calEnabled() ) continue; | 689 | if ( !event->calEnabled() ) continue; |
680 | if ( event->doesRecur() ) { | 690 | if ( event->doesRecur() ) { |
681 | QDate rStart = event->dtStart().date(); | 691 | QDate rStart = event->dtStart().date(); |
682 | bool found = false; | 692 | bool found = false; |
683 | if ( inclusive ) { | 693 | if ( inclusive ) { |
684 | if ( rStart >= start && rStart <= end ) { | 694 | if ( rStart >= start && rStart <= end ) { |
685 | // Start date of event is in range. Now check for end date. | 695 | // Start date of event is in range. Now check for end date. |
686 | // if duration is negative, event recurs forever, so do not include it. | 696 | // if duration is negative, event recurs forever, so do not include it. |
687 | if ( event->recurrence()->duration() == 0 ) { // End date set | 697 | if ( event->recurrence()->duration() == 0 ) { // End date set |
688 | QDate rEnd = event->recurrence()->endDate(); | 698 | QDate rEnd = event->recurrence()->endDate(); |
689 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 699 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
690 | found = true; | 700 | found = true; |
691 | } | 701 | } |
692 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 702 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
693 | // TODO: Calculate end date from duration. Should be done in Event | 703 | // TODO: Calculate end date from duration. Should be done in Event |
694 | // For now exclude all events with a duration. | 704 | // For now exclude all events with a duration. |
695 | } | 705 | } |
696 | } | 706 | } |
697 | } else { | 707 | } else { |
698 | bool founOne; | 708 | bool founOne; |
699 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 709 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
700 | if ( founOne ) { | 710 | if ( founOne ) { |
701 | if ( next <= end ) { | 711 | if ( next <= end ) { |
702 | found = true; | 712 | found = true; |
703 | } | 713 | } |
704 | } | 714 | } |
705 | 715 | ||
706 | /* | 716 | /* |
707 | // crap !!! | 717 | // crap !!! |
708 | if ( rStart <= end ) { // Start date not after range | 718 | if ( rStart <= end ) { // Start date not after range |
709 | if ( rStart >= start ) { // Start date within range | 719 | if ( rStart >= start ) { // Start date within range |
710 | found = true; | 720 | found = true; |
711 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 721 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
712 | found = true; | 722 | found = true; |
713 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 723 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
714 | QDate rEnd = event->recurrence()->endDate(); | 724 | QDate rEnd = event->recurrence()->endDate(); |
715 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 725 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
716 | found = true; | 726 | found = true; |
717 | } | 727 | } |
718 | } else { // Duration set | 728 | } else { // Duration set |
719 | // TODO: Calculate end date from duration. Should be done in Event | 729 | // TODO: Calculate end date from duration. Should be done in Event |
720 | // For now include all events with a duration. | 730 | // For now include all events with a duration. |
721 | found = true; | 731 | found = true; |
722 | } | 732 | } |
723 | } | 733 | } |
724 | */ | 734 | */ |
725 | 735 | ||
726 | } | 736 | } |
727 | 737 | ||
728 | if ( found ) eventList.append( event ); | 738 | if ( found ) eventList.append( event ); |
729 | } else { | 739 | } else { |
730 | QDate s = event->dtStart().date(); | 740 | QDate s = event->dtStart().date(); |
731 | QDate e = event->dtEnd().date(); | 741 | QDate e = event->dtEnd().date(); |
732 | 742 | ||
733 | if ( inclusive ) { | 743 | if ( inclusive ) { |
734 | if ( s >= start && e <= end ) { | 744 | if ( s >= start && e <= end ) { |
735 | eventList.append( event ); | 745 | eventList.append( event ); |
736 | } | 746 | } |
737 | } else { | 747 | } else { |
738 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 748 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
739 | eventList.append( event ); | 749 | eventList.append( event ); |
740 | } | 750 | } |
741 | } | 751 | } |
742 | } | 752 | } |
743 | } | 753 | } |
744 | 754 | ||
745 | return eventList; | 755 | return eventList; |
746 | } | 756 | } |
747 | 757 | ||
748 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 758 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
749 | { | 759 | { |
750 | return rawEventsForDate( qdt.date() ); | 760 | return rawEventsForDate( qdt.date() ); |
751 | } | 761 | } |
752 | 762 | ||
753 | QPtrList<Event> CalendarLocal::rawEvents() | 763 | QPtrList<Event> CalendarLocal::rawEvents() |
754 | { | 764 | { |
755 | QPtrList<Event> el; | 765 | QPtrList<Event> el; |
756 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 766 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
757 | if ( it->calEnabled() ) el.append( it ); | 767 | if ( it->calEnabled() ) el.append( it ); |
758 | return el; | 768 | return el; |
759 | } | 769 | } |
760 | 770 | ||
761 | bool CalendarLocal::addJournal(Journal *journal) | 771 | bool CalendarLocal::addJournal(Journal *journal) |
762 | { | 772 | { |
763 | if ( journal->dtStart().isValid()) | 773 | if ( journal->dtStart().isValid()) |
764 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 774 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
765 | else | 775 | else |
766 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 776 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
767 | 777 | ||
768 | mJournalList.append(journal); | 778 | mJournalList.append(journal); |
769 | 779 | ||
770 | journal->registerObserver( this ); | 780 | journal->registerObserver( this ); |
771 | 781 | ||
772 | setModified( true ); | 782 | setModified( true ); |
773 | journal->setCalID( mDefaultCalendar ); | 783 | journal->setCalID( mDefaultCalendar ); |
774 | journal->setCalEnabled( true ); | 784 | journal->setCalEnabled( true ); |
775 | return true; | 785 | return true; |
776 | } | 786 | } |
777 | 787 | ||
778 | void CalendarLocal::deleteJournal( Journal *journal ) | 788 | void CalendarLocal::deleteJournal( Journal *journal ) |
779 | { | 789 | { |
780 | if ( mUndoIncidence ) delete mUndoIncidence; | 790 | if ( mUndoIncidence ) delete mUndoIncidence; |
781 | mUndoIncidence = journal->clone(); | 791 | mUndoIncidence = journal->clone(); |
782 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 792 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
783 | if ( mJournalList.removeRef(journal) ) { | 793 | if ( mJournalList.removeRef(journal) ) { |
784 | setModified( true ); | 794 | setModified( true ); |
785 | } | 795 | } |
786 | } | 796 | } |
787 | 797 | ||
788 | Journal *CalendarLocal::journal( const QDate &date ) | 798 | Journal *CalendarLocal::journal( const QDate &date ) |
789 | { | 799 | { |
790 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 800 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
791 | 801 | ||
792 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 802 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
793 | if ( it->calEnabled() && it->dtStart().date() == date ) | 803 | if ( it->calEnabled() && it->dtStart().date() == date ) |
794 | return it; | 804 | return it; |
795 | 805 | ||
796 | return 0; | 806 | return 0; |
797 | } | 807 | } |
798 | 808 | ||
799 | Journal *CalendarLocal::journal( const QString &uid ) | 809 | Journal *CalendarLocal::journal( const QString &uid ) |
800 | { | 810 | { |
801 | Journal * retVal = 0; | 811 | Journal * retVal = 0; |
802 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 812 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
803 | if ( it->calEnabled() && it->uid() == uid ) { | 813 | if ( it->calEnabled() && it->uid() == uid ) { |
804 | if ( retVal ) { | 814 | if ( retVal ) { |
805 | if ( retVal->calID() > it->calID() ) { | 815 | if ( retVal->calID() > it->calID() ) { |
806 | retVal = it; | 816 | retVal = it; |
807 | } | 817 | } |
808 | } else { | 818 | } else { |
809 | retVal = it; | 819 | retVal = it; |
810 | } | 820 | } |
811 | } | 821 | } |
812 | return retVal; | 822 | return retVal; |
813 | } | 823 | } |
814 | 824 | ||
815 | QPtrList<Journal> CalendarLocal::journals() | 825 | QPtrList<Journal> CalendarLocal::journals() |
816 | { | 826 | { |
817 | QPtrList<Journal> el; | 827 | QPtrList<Journal> el; |
818 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 828 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
819 | if ( it->calEnabled() ) el.append( it ); | 829 | if ( it->calEnabled() ) el.append( it ); |
820 | return el; | 830 | return el; |
821 | } | 831 | } |
822 | void CalendarLocal::setCalendarRemove( int id ) | 832 | void CalendarLocal::setCalendarRemove( int id ) |
823 | { | 833 | { |
824 | 834 | ||
825 | { | 835 | { |
826 | QPtrList<Event> EventList = mEventList; | 836 | QPtrList<Event> EventList = mEventList; |
827 | Event * ev = EventList.first(); | 837 | Event * ev = EventList.first(); |
828 | while ( ev ) { | 838 | while ( ev ) { |
829 | if ( ev->calID() == id ) | 839 | if ( ev->calID() == id ) |
830 | deleteEvent( ev ); | 840 | deleteEvent( ev ); |
831 | ev = EventList.next(); | 841 | ev = EventList.next(); |
832 | } | 842 | } |
833 | } | 843 | } |
834 | { | 844 | { |
835 | 845 | ||
836 | QPtrList<Todo> TodoList = mTodoList; | 846 | QPtrList<Todo> TodoList = mTodoList; |
837 | Todo * ev = TodoList.first(); | 847 | Todo * ev = TodoList.first(); |
838 | while ( ev ) { | 848 | while ( ev ) { |
839 | if ( ev->calID() == id ) | 849 | if ( ev->calID() == id ) |
840 | deleteTodo( ev ); | 850 | deleteTodo( ev ); |
841 | ev = TodoList.next(); | 851 | ev = TodoList.next(); |
842 | } | 852 | } |
843 | } | 853 | } |
844 | { | 854 | { |
845 | QPtrList<Journal> JournalList = mJournalList; | 855 | QPtrList<Journal> JournalList = mJournalList; |
846 | Journal * ev = JournalList.first(); | 856 | Journal * ev = JournalList.first(); |
847 | while ( ev ) { | 857 | while ( ev ) { |
848 | if ( ev->calID() == id ) | 858 | if ( ev->calID() == id ) |
849 | deleteJournal( ev ); | 859 | deleteJournal( ev ); |
850 | ev = JournalList.next(); | 860 | ev = JournalList.next(); |
851 | } | 861 | } |
852 | } | 862 | } |
853 | 863 | ||
854 | if ( mUndoIncidence ) delete mUndoIncidence; | 864 | if ( mUndoIncidence ) delete mUndoIncidence; |
855 | mUndoIncidence = 0; | 865 | mUndoIncidence = 0; |
856 | 866 | ||
857 | } | 867 | } |
858 | 868 | ||
859 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 869 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
860 | { | 870 | { |
861 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 871 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
862 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 872 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
863 | 873 | ||
864 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 874 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
865 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 875 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
866 | 876 | ||
867 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 877 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
868 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 878 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
869 | 879 | ||
870 | } | 880 | } |
871 | 881 | ||
872 | void CalendarLocal::setReadOnly( int id, bool enable ) | 882 | void CalendarLocal::setReadOnly( int id, bool enable ) |
873 | { | 883 | { |
874 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 884 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
875 | if ( it->calID() == id ) it->setReadOnly( enable ); | 885 | if ( it->calID() == id ) it->setReadOnly( enable ); |
876 | 886 | ||
877 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 887 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
878 | if ( it->calID() == id ) it->setReadOnly( enable ); | 888 | if ( it->calID() == id ) it->setReadOnly( enable ); |
879 | 889 | ||
880 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 890 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
881 | if ( it->calID() == id ) it->setReadOnly( enable ); | 891 | if ( it->calID() == id ) it->setReadOnly( enable ); |
882 | 892 | ||
883 | } | 893 | } |
884 | 894 | ||
885 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 895 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
886 | { | 896 | { |
887 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 897 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
888 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 898 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
889 | 899 | ||
890 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 900 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
891 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 901 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
892 | 902 | ||
893 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 903 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
894 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 904 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
895 | reInitAlarmSettings(); | 905 | reInitAlarmSettings(); |
896 | 906 | ||
897 | } | 907 | } |
898 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 908 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
899 | { | 909 | { |
900 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 910 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
901 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 911 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
902 | 912 | ||
903 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 913 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
904 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 914 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
905 | 915 | ||
906 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 916 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
907 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 917 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
908 | 918 | ||
909 | } | 919 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5bbe55f..0286b48 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,224 +1,225 @@ | |||
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 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | void setSyncEventsReadOnly(); | ||
48 | /** | 49 | /** |
49 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 50 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
50 | calendar. Any information already present is lost. | 51 | calendar. Any information already present is lost. |
51 | @return true, if successfull, false on error. | 52 | @return true, if successfull, false on error. |
52 | @param fileName the name of the calendar on disk. | 53 | @param fileName the name of the calendar on disk. |
53 | */ | 54 | */ |
54 | bool load( const QString &fileName ); | 55 | bool load( const QString &fileName ); |
55 | /** | 56 | /** |
56 | Writes out the calendar to disk in the specified \a format. | 57 | Writes out the calendar to disk in the specified \a format. |
57 | CalendarLocal takes ownership of the CalFormat object. | 58 | CalendarLocal takes ownership of the CalFormat object. |
58 | @return true, if successfull, false on error. | 59 | @return true, if successfull, false on error. |
59 | @param fileName the name of the file | 60 | @param fileName the name of the file |
60 | */ | 61 | */ |
61 | bool save( const QString &fileName, CalFormat *format = 0 ); | 62 | bool save( const QString &fileName, CalFormat *format = 0 ); |
62 | 63 | ||
63 | /** | 64 | /** |
64 | Clears out the current calendar, freeing all used memory etc. etc. | 65 | Clears out the current calendar, freeing all used memory etc. etc. |
65 | */ | 66 | */ |
66 | void close(); | 67 | void close(); |
67 | 68 | ||
68 | void save() {} | 69 | void save() {} |
69 | 70 | ||
70 | /** | 71 | /** |
71 | Add Event to calendar. | 72 | Add Event to calendar. |
72 | */ | 73 | */ |
73 | void removeSyncInfo( QString syncProfile); | 74 | void removeSyncInfo( QString syncProfile); |
74 | bool addAnniversaryNoDup( Event *event ); | 75 | bool addAnniversaryNoDup( Event *event ); |
75 | bool addEventNoDup( Event *event ); | 76 | bool addEventNoDup( Event *event ); |
76 | bool addEvent( Event *event ); | 77 | bool addEvent( Event *event ); |
77 | /** | 78 | /** |
78 | Deletes an event from this calendar. | 79 | Deletes an event from this calendar. |
79 | */ | 80 | */ |
80 | void deleteEvent( Event *event ); | 81 | void deleteEvent( Event *event ); |
81 | 82 | ||
82 | /** | 83 | /** |
83 | Retrieves an event on the basis of the unique string ID. | 84 | Retrieves an event on the basis of the unique string ID. |
84 | */ | 85 | */ |
85 | Event *event( const QString &uid ); | 86 | Event *event( const QString &uid ); |
86 | /** | 87 | /** |
87 | Return unfiltered list of all events in calendar. | 88 | Return unfiltered list of all events in calendar. |
88 | */ | 89 | */ |
89 | QPtrList<Event> rawEvents(); | 90 | QPtrList<Event> rawEvents(); |
90 | QPtrList<Event> getExternLastSyncEvents(); | 91 | QPtrList<Event> getExternLastSyncEvents(); |
91 | /** | 92 | /** |
92 | Add a todo to the todolist. | 93 | Add a todo to the todolist. |
93 | */ | 94 | */ |
94 | bool addTodo( Todo *todo ); | 95 | bool addTodo( Todo *todo ); |
95 | bool addTodoNoDup( Todo *todo ); | 96 | bool addTodoNoDup( Todo *todo ); |
96 | /** | 97 | /** |
97 | Remove a todo from the todolist. | 98 | Remove a todo from the todolist. |
98 | */ | 99 | */ |
99 | void deleteTodo( Todo * ); | 100 | void deleteTodo( Todo * ); |
100 | /** | 101 | /** |
101 | Searches todolist for an event with this unique string identifier, | 102 | Searches todolist for an event with this unique string identifier, |
102 | returns a pointer or null. | 103 | returns a pointer or null. |
103 | */ | 104 | */ |
104 | Todo *todo( const QString &uid ); | 105 | Todo *todo( const QString &uid ); |
105 | /** | 106 | /** |
106 | Return list of all todos. | 107 | Return list of all todos. |
107 | */ | 108 | */ |
108 | QPtrList<Todo> rawTodos(); | 109 | QPtrList<Todo> rawTodos(); |
109 | /** | 110 | /** |
110 | Returns list of todos due on the specified date. | 111 | Returns list of todos due on the specified date. |
111 | */ | 112 | */ |
112 | QPtrList<Todo> todos( const QDate &date ); | 113 | QPtrList<Todo> todos( const QDate &date ); |
113 | /** | 114 | /** |
114 | Return list of all todos. | 115 | Return list of all todos. |
115 | 116 | ||
116 | Workaround because compiler does not recognize function of base class. | 117 | Workaround because compiler does not recognize function of base class. |
117 | */ | 118 | */ |
118 | QPtrList<Todo> todos() { return Calendar::todos(); } | 119 | QPtrList<Todo> todos() { return Calendar::todos(); } |
119 | 120 | ||
120 | /** | 121 | /** |
121 | Add a Journal entry to calendar. | 122 | Add a Journal entry to calendar. |
122 | */ | 123 | */ |
123 | bool addJournal( Journal * ); | 124 | bool addJournal( Journal * ); |
124 | /** | 125 | /** |
125 | Remove a Journal from the calendar. | 126 | Remove a Journal from the calendar. |
126 | */ | 127 | */ |
127 | void deleteJournal( Journal * ); | 128 | void deleteJournal( Journal * ); |
128 | /** | 129 | /** |
129 | Return Journal for given date. | 130 | Return Journal for given date. |
130 | */ | 131 | */ |
131 | Journal *journal( const QDate & ); | 132 | Journal *journal( const QDate & ); |
132 | /** | 133 | /** |
133 | Return Journal with given UID. | 134 | Return Journal with given UID. |
134 | */ | 135 | */ |
135 | Journal *journal( const QString &uid ); | 136 | Journal *journal( const QString &uid ); |
136 | /** | 137 | /** |
137 | Return list of all Journals stored in calendar. | 138 | Return list of all Journals stored in calendar. |
138 | */ | 139 | */ |
139 | QPtrList<Journal> journals(); | 140 | QPtrList<Journal> journals(); |
140 | 141 | ||
141 | /** | 142 | /** |
142 | Return all alarms, which ocur in the given time interval. | 143 | Return all alarms, which ocur in the given time interval. |
143 | */ | 144 | */ |
144 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 145 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
145 | 146 | ||
146 | /** | 147 | /** |
147 | Return all alarms, which ocur before given date. | 148 | Return all alarms, which ocur before given date. |
148 | */ | 149 | */ |
149 | Alarm::List alarmsTo( const QDateTime &to ); | 150 | Alarm::List alarmsTo( const QDateTime &to ); |
150 | 151 | ||
151 | QDateTime nextAlarm( int daysTo ) ; | 152 | QDateTime nextAlarm( int daysTo ) ; |
152 | QDateTime nextAlarmEventDateTime() const; | 153 | QDateTime nextAlarmEventDateTime() const; |
153 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 154 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
154 | void registerAlarm(); | 155 | void registerAlarm(); |
155 | void deRegisterAlarm(); | 156 | void deRegisterAlarm(); |
156 | QString getAlarmNotification(); | 157 | QString getAlarmNotification(); |
157 | QString nextSummary() const ; | 158 | QString nextSummary() const ; |
158 | /** | 159 | /** |
159 | This method should be called whenever a Event is modified directly | 160 | This method should be called whenever a Event is modified directly |
160 | via it's pointer. It makes sure that the calendar is internally | 161 | via it's pointer. It makes sure that the calendar is internally |
161 | consistent. | 162 | consistent. |
162 | */ | 163 | */ |
163 | void update( IncidenceBase *incidence ); | 164 | void update( IncidenceBase *incidence ); |
164 | 165 | ||
165 | /** | 166 | /** |
166 | Builds and then returns a list of all events that match for the | 167 | Builds and then returns a list of all events that match for the |
167 | date specified. useful for dayView, etc. etc. | 168 | date specified. useful for dayView, etc. etc. |
168 | */ | 169 | */ |
169 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 170 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
170 | /** | 171 | /** |
171 | Get unfiltered events for date \a qdt. | 172 | Get unfiltered events for date \a qdt. |
172 | */ | 173 | */ |
173 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 174 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
174 | /** | 175 | /** |
175 | Get unfiltered events in a range of dates. If inclusive is set to true, | 176 | Get unfiltered events in a range of dates. If inclusive is set to true, |
176 | only events are returned, which are completely included in the range. | 177 | only events are returned, which are completely included in the range. |
177 | */ | 178 | */ |
178 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 179 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
179 | bool inclusive = false ); | 180 | bool inclusive = false ); |
180 | Todo *todo( QString, QString ); | 181 | Todo *todo( QString, QString ); |
181 | Event *event( QString, QString ); | 182 | Event *event( QString, QString ); |
182 | 183 | ||
183 | public slots: | 184 | public slots: |
184 | void setCalendarEnabled( int id, bool enable ); | 185 | void setCalendarEnabled( int id, bool enable ); |
185 | void setAlarmEnabled( int id, bool enable ); | 186 | void setAlarmEnabled( int id, bool enable ); |
186 | void setReadOnly( int id, bool enable ); | 187 | void setReadOnly( int id, bool enable ); |
187 | void setDefaultCalendarEnabledOnly(); | 188 | void setDefaultCalendarEnabledOnly(); |
188 | void setCalendarRemove( int id ); | 189 | void setCalendarRemove( int id ); |
189 | 190 | ||
190 | protected: | 191 | protected: |
191 | 192 | ||
192 | // Event* mNextAlarmEvent; | 193 | // Event* mNextAlarmEvent; |
193 | QString mNextSummary; | 194 | QString mNextSummary; |
194 | QString mNextAlarmEventDateTimeString; | 195 | QString mNextAlarmEventDateTimeString; |
195 | QString mLastAlarmNotificationString; | 196 | QString mLastAlarmNotificationString; |
196 | QDateTime mNextAlarmEventDateTime; | 197 | QDateTime mNextAlarmEventDateTime; |
197 | QDateTime mNextAlarmDateTime; | 198 | QDateTime mNextAlarmDateTime; |
198 | void reInitAlarmSettings(); | 199 | void reInitAlarmSettings(); |
199 | 200 | ||
200 | /** Notification function of IncidenceBase::Observer. */ | 201 | /** Notification function of IncidenceBase::Observer. */ |
201 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 202 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
202 | 203 | ||
203 | /** inserts an event into its "proper place" in the calendar. */ | 204 | /** inserts an event into its "proper place" in the calendar. */ |
204 | void insertEvent( Event *event ); | 205 | void insertEvent( Event *event ); |
205 | 206 | ||
206 | /** Append alarms of incidence in interval to list of alarms. */ | 207 | /** Append alarms of incidence in interval to list of alarms. */ |
207 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 208 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
208 | const QDateTime &from, const QDateTime &to ); | 209 | const QDateTime &from, const QDateTime &to ); |
209 | 210 | ||
210 | /** Append alarms of recurring events in interval to list of alarms. */ | 211 | /** Append alarms of recurring events in interval to list of alarms. */ |
211 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 212 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
212 | const QDateTime &from, const QDateTime &to ); | 213 | const QDateTime &from, const QDateTime &to ); |
213 | 214 | ||
214 | private: | 215 | private: |
215 | void init(); | 216 | void init(); |
216 | 217 | ||
217 | QPtrList<Event> mEventList; | 218 | QPtrList<Event> mEventList; |
218 | QPtrList<Todo> mTodoList; | 219 | QPtrList<Todo> mTodoList; |
219 | QPtrList<Journal> mJournalList; | 220 | QPtrList<Journal> mJournalList; |
220 | }; | 221 | }; |
221 | 222 | ||
222 | } | 223 | } |
223 | 224 | ||
224 | #endif | 225 | #endif |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 2ddbb01..96039df 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,462 +1,464 @@ | |||
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 | mCalEnabled = true; | 47 | mCalEnabled = true; |
48 | mAlarmEnabled = true; | 48 | mAlarmEnabled = true; |
49 | mCalID = 0; | 49 | mCalID = 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 52 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
53 | CustomProperties( i ) | 53 | CustomProperties( i ) |
54 | { | 54 | { |
55 | 55 | ||
56 | mReadOnly = i.mReadOnly; | 56 | mReadOnly = i.mReadOnly; |
57 | mDtStart = i.mDtStart; | 57 | mDtStart = i.mDtStart; |
58 | mDuration = i.mDuration; | 58 | mDuration = i.mDuration; |
59 | mHasDuration = i.mHasDuration; | 59 | mHasDuration = i.mHasDuration; |
60 | mOrganizer = i.mOrganizer; | 60 | mOrganizer = i.mOrganizer; |
61 | mUid = i.mUid; | 61 | mUid = i.mUid; |
62 | mCalEnabled = i.mCalEnabled; | 62 | mCalEnabled = i.mCalEnabled; |
63 | mAlarmEnabled = i.mAlarmEnabled; | 63 | mAlarmEnabled = i.mAlarmEnabled; |
64 | mCalID = i.mCalID; | 64 | mCalID = i.mCalID; |
65 | QPtrList<Attendee> attendees = i.attendees(); | 65 | QPtrList<Attendee> attendees = i.attendees(); |
66 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 66 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
67 | mAttendees.append( new Attendee( *a ) ); | 67 | mAttendees.append( new Attendee( *a ) ); |
68 | } | 68 | } |
69 | mFloats = i.mFloats; | 69 | mFloats = i.mFloats; |
70 | mLastModified = i.mLastModified; | 70 | mLastModified = i.mLastModified; |
71 | mPilotId = i.mPilotId; | 71 | mPilotId = i.mPilotId; |
72 | mTempSyncStat = i.mTempSyncStat; | 72 | mTempSyncStat = i.mTempSyncStat; |
73 | mSyncStatus = i.mSyncStatus; | 73 | mSyncStatus = i.mSyncStatus; |
74 | mExternalId = i.mExternalId; | 74 | mExternalId = i.mExternalId; |
75 | // The copied object is a new one, so it isn't observed by the observer | 75 | // The copied object is a new one, so it isn't observed by the observer |
76 | // of the original object. | 76 | // of the original object. |
77 | mObservers.clear(); | 77 | mObservers.clear(); |
78 | 78 | ||
79 | mAttendees.setAutoDelete( true ); | 79 | mAttendees.setAutoDelete( true ); |
80 | } | 80 | } |
81 | 81 | ||
82 | IncidenceBase::~IncidenceBase() | 82 | IncidenceBase::~IncidenceBase() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 87 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
88 | { | 88 | { |
89 | // do not compare mSyncStatus and mExternalId | 89 | // do not compare mSyncStatus and mExternalId |
90 | if( i1.attendees().count() != i2.attendees().count() ) { | 90 | if( i1.attendees().count() != i2.attendees().count() ) { |
91 | return false; // no need to check further | 91 | return false; // no need to check further |
92 | } | 92 | } |
93 | if ( i1.attendees().count() > 0 ) { | 93 | if ( i1.attendees().count() > 0 ) { |
94 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 94 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
95 | while ( a1 ) { | 95 | while ( a1 ) { |
96 | if ( !( (*a1) == (*a2)) ) | 96 | if ( !( (*a1) == (*a2)) ) |
97 | { | 97 | { |
98 | //qDebug("Attendee not equal "); | 98 | //qDebug("Attendee not equal "); |
99 | return false; | 99 | return false; |
100 | } | 100 | } |
101 | a1 = i1.attendees().next(); | 101 | a1 = i1.attendees().next(); |
102 | a2 = i2.attendees().next(); | 102 | a2 = i2.attendees().next(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | //if ( i1.dtStart() != i2.dtStart() ) | 105 | //if ( i1.dtStart() != i2.dtStart() ) |
106 | // return false; | 106 | // return false; |
107 | #if 0 | 107 | #if 0 |
108 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 108 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
109 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 109 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
110 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 110 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
111 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 111 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
114 | 114 | ||
115 | #endif | 115 | #endif |
116 | if ( i1.hasDuration() == i2.hasDuration() ) { | 116 | if ( i1.hasDuration() == i2.hasDuration() ) { |
117 | if ( i1.hasDuration() ) { | 117 | if ( i1.hasDuration() ) { |
118 | if ( i1.duration() != i2.duration() ) | 118 | if ( i1.duration() != i2.duration() ) |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | } else { | 121 | } else { |
122 | return false; | 122 | return false; |
123 | } | 123 | } |
124 | 124 | ||
125 | return ( i1.organizer() == i2.organizer() && | 125 | return ( i1.organizer() == i2.organizer() && |
126 | // i1.uid() == i2.uid() && | 126 | // i1.uid() == i2.uid() && |
127 | // Don't compare lastModified, otherwise the operator is not | 127 | // Don't compare lastModified, otherwise the operator is not |
128 | // of much use. We are not comparing for identity, after all. | 128 | // of much use. We are not comparing for identity, after all. |
129 | i1.doesFloat() == i2.doesFloat() && | 129 | i1.doesFloat() == i2.doesFloat() && |
130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
131 | // no need to compare mObserver | 131 | // no need to compare mObserver |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
136 | { | 136 | { |
137 | QTime t = dt.time(); | 137 | QTime t = dt.time(); |
138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
139 | return dt; | 139 | return dt; |
140 | } | 140 | } |
141 | 141 | ||
142 | void IncidenceBase::setCalID( int id ) | 142 | void IncidenceBase::setCalID( int id ) |
143 | { | 143 | { |
144 | if ( mCalID > 0 ) | ||
145 | updated(); | ||
144 | mCalID = id; | 146 | mCalID = id; |
145 | } | 147 | } |
146 | int IncidenceBase::calID() const | 148 | int IncidenceBase::calID() const |
147 | { | 149 | { |
148 | return mCalID; | 150 | return mCalID; |
149 | } | 151 | } |
150 | void IncidenceBase::setCalEnabled( bool b ) | 152 | void IncidenceBase::setCalEnabled( bool b ) |
151 | { | 153 | { |
152 | mCalEnabled = b; | 154 | mCalEnabled = b; |
153 | } | 155 | } |
154 | bool IncidenceBase::calEnabled() const | 156 | bool IncidenceBase::calEnabled() const |
155 | { | 157 | { |
156 | return mCalEnabled; | 158 | return mCalEnabled; |
157 | } | 159 | } |
158 | 160 | ||
159 | void IncidenceBase::setAlarmEnabled( bool b ) | 161 | void IncidenceBase::setAlarmEnabled( bool b ) |
160 | { | 162 | { |
161 | mAlarmEnabled = b; | 163 | mAlarmEnabled = b; |
162 | } | 164 | } |
163 | bool IncidenceBase::alarmEnabled() const | 165 | bool IncidenceBase::alarmEnabled() const |
164 | { | 166 | { |
165 | return mAlarmEnabled; | 167 | return mAlarmEnabled; |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | void IncidenceBase::setUid(const QString &uid) | 171 | void IncidenceBase::setUid(const QString &uid) |
170 | { | 172 | { |
171 | mUid = uid; | 173 | mUid = uid; |
172 | updated(); | 174 | updated(); |
173 | } | 175 | } |
174 | 176 | ||
175 | QString IncidenceBase::uid() const | 177 | QString IncidenceBase::uid() const |
176 | { | 178 | { |
177 | return mUid; | 179 | return mUid; |
178 | } | 180 | } |
179 | 181 | ||
180 | void IncidenceBase::setLastModified(const QDateTime &lm) | 182 | void IncidenceBase::setLastModified(const QDateTime &lm) |
181 | { | 183 | { |
182 | // DON'T! updated() because we call this from | 184 | // DON'T! updated() because we call this from |
183 | // Calendar::updateEvent(). | 185 | // Calendar::updateEvent(). |
184 | mLastModified = getEvenTime(lm); | 186 | mLastModified = getEvenTime(lm); |
185 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 187 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
186 | } | 188 | } |
187 | 189 | ||
188 | QDateTime IncidenceBase::lastModified() const | 190 | QDateTime IncidenceBase::lastModified() const |
189 | { | 191 | { |
190 | return mLastModified; | 192 | return mLastModified; |
191 | } | 193 | } |
192 | 194 | ||
193 | void IncidenceBase::setOrganizer(const QString &o) | 195 | void IncidenceBase::setOrganizer(const QString &o) |
194 | { | 196 | { |
195 | // we don't check for readonly here, because it is | 197 | // we don't check for readonly here, because it is |
196 | // possible that by setting the organizer we are changing | 198 | // possible that by setting the organizer we are changing |
197 | // the event's readonly status... | 199 | // the event's readonly status... |
198 | mOrganizer = o; | 200 | mOrganizer = o; |
199 | if (mOrganizer.left(7).upper() == "MAILTO:") | 201 | if (mOrganizer.left(7).upper() == "MAILTO:") |
200 | mOrganizer = mOrganizer.remove(0,7); | 202 | mOrganizer = mOrganizer.remove(0,7); |
201 | 203 | ||
202 | updated(); | 204 | updated(); |
203 | } | 205 | } |
204 | 206 | ||
205 | QString IncidenceBase::organizer() const | 207 | QString IncidenceBase::organizer() const |
206 | { | 208 | { |
207 | return mOrganizer; | 209 | return mOrganizer; |
208 | } | 210 | } |
209 | 211 | ||
210 | void IncidenceBase::setReadOnly( bool readOnly ) | 212 | void IncidenceBase::setReadOnly( bool readOnly ) |
211 | { | 213 | { |
212 | mReadOnly = readOnly; | 214 | mReadOnly = readOnly; |
213 | } | 215 | } |
214 | 216 | ||
215 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 217 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
216 | { | 218 | { |
217 | // if (mReadOnly) return; | 219 | // if (mReadOnly) return; |
218 | mDtStart = getEvenTime(dtStart); | 220 | mDtStart = getEvenTime(dtStart); |
219 | updated(); | 221 | updated(); |
220 | } | 222 | } |
221 | 223 | ||
222 | 224 | ||
223 | QDateTime IncidenceBase::dtStart() const | 225 | QDateTime IncidenceBase::dtStart() const |
224 | { | 226 | { |
225 | return mDtStart; | 227 | return mDtStart; |
226 | } | 228 | } |
227 | 229 | ||
228 | QString IncidenceBase::dtStartTimeStr() const | 230 | QString IncidenceBase::dtStartTimeStr() const |
229 | { | 231 | { |
230 | return KGlobal::locale()->formatTime(dtStart().time()); | 232 | return KGlobal::locale()->formatTime(dtStart().time()); |
231 | } | 233 | } |
232 | 234 | ||
233 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 235 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
234 | { | 236 | { |
235 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 237 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
236 | } | 238 | } |
237 | 239 | ||
238 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 240 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
239 | { | 241 | { |
240 | if ( doesFloat() ) | 242 | if ( doesFloat() ) |
241 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 243 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
242 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 244 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
243 | } | 245 | } |
244 | 246 | ||
245 | 247 | ||
246 | bool IncidenceBase::doesFloat() const | 248 | bool IncidenceBase::doesFloat() const |
247 | { | 249 | { |
248 | return mFloats; | 250 | return mFloats; |
249 | } | 251 | } |
250 | 252 | ||
251 | void IncidenceBase::setFloats(bool f) | 253 | void IncidenceBase::setFloats(bool f) |
252 | { | 254 | { |
253 | if (mReadOnly) return; | 255 | if (mReadOnly) return; |
254 | mFloats = f; | 256 | mFloats = f; |
255 | updated(); | 257 | updated(); |
256 | } | 258 | } |
257 | 259 | ||
258 | 260 | ||
259 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 261 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
260 | { | 262 | { |
261 | if (mReadOnly) return false; | 263 | if (mReadOnly) return false; |
262 | if (a->name().left(7).upper() == "MAILTO:") | 264 | if (a->name().left(7).upper() == "MAILTO:") |
263 | a->setName(a->name().remove(0,7)); | 265 | a->setName(a->name().remove(0,7)); |
264 | 266 | ||
265 | QPtrListIterator<Attendee> qli(mAttendees); | 267 | QPtrListIterator<Attendee> qli(mAttendees); |
266 | 268 | ||
267 | qli.toFirst(); | 269 | qli.toFirst(); |
268 | while (qli) { | 270 | while (qli) { |
269 | if (*qli.current() == *a) | 271 | if (*qli.current() == *a) |
270 | return false; | 272 | return false; |
271 | ++qli; | 273 | ++qli; |
272 | } | 274 | } |
273 | mAttendees.append(a); | 275 | mAttendees.append(a); |
274 | if (doupdate) updated(); | 276 | if (doupdate) updated(); |
275 | return true; | 277 | return true; |
276 | } | 278 | } |
277 | 279 | ||
278 | #if 0 | 280 | #if 0 |
279 | void IncidenceBase::removeAttendee(Attendee *a) | 281 | void IncidenceBase::removeAttendee(Attendee *a) |
280 | { | 282 | { |
281 | if (mReadOnly) return; | 283 | if (mReadOnly) return; |
282 | mAttendees.removeRef(a); | 284 | mAttendees.removeRef(a); |
283 | updated(); | 285 | updated(); |
284 | } | 286 | } |
285 | 287 | ||
286 | void IncidenceBase::removeAttendee(const char *n) | 288 | void IncidenceBase::removeAttendee(const char *n) |
287 | { | 289 | { |
288 | Attendee *a; | 290 | Attendee *a; |
289 | 291 | ||
290 | if (mReadOnly) return; | 292 | if (mReadOnly) return; |
291 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 293 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
292 | if (a->getName() == n) { | 294 | if (a->getName() == n) { |
293 | mAttendees.remove(); | 295 | mAttendees.remove(); |
294 | break; | 296 | break; |
295 | } | 297 | } |
296 | } | 298 | } |
297 | #endif | 299 | #endif |
298 | 300 | ||
299 | void IncidenceBase::clearAttendees() | 301 | void IncidenceBase::clearAttendees() |
300 | { | 302 | { |
301 | if (mReadOnly) return; | 303 | if (mReadOnly) return; |
302 | mAttendees.clear(); | 304 | mAttendees.clear(); |
303 | } | 305 | } |
304 | 306 | ||
305 | #if 0 | 307 | #if 0 |
306 | Attendee *IncidenceBase::getAttendee(const char *n) const | 308 | Attendee *IncidenceBase::getAttendee(const char *n) const |
307 | { | 309 | { |
308 | QPtrListIterator<Attendee> qli(mAttendees); | 310 | QPtrListIterator<Attendee> qli(mAttendees); |
309 | 311 | ||
310 | qli.toFirst(); | 312 | qli.toFirst(); |
311 | while (qli) { | 313 | while (qli) { |
312 | if (qli.current()->getName() == n) | 314 | if (qli.current()->getName() == n) |
313 | return qli.current(); | 315 | return qli.current(); |
314 | ++qli; | 316 | ++qli; |
315 | } | 317 | } |
316 | return 0L; | 318 | return 0L; |
317 | } | 319 | } |
318 | #endif | 320 | #endif |
319 | 321 | ||
320 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 322 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
321 | { | 323 | { |
322 | QPtrListIterator<Attendee> qli(mAttendees); | 324 | QPtrListIterator<Attendee> qli(mAttendees); |
323 | 325 | ||
324 | qli.toFirst(); | 326 | qli.toFirst(); |
325 | while (qli) { | 327 | while (qli) { |
326 | if (qli.current()->email().lower() == email.lower()) | 328 | if (qli.current()->email().lower() == email.lower()) |
327 | return qli.current(); | 329 | return qli.current(); |
328 | ++qli; | 330 | ++qli; |
329 | } | 331 | } |
330 | return 0L; | 332 | return 0L; |
331 | } | 333 | } |
332 | 334 | ||
333 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 335 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
334 | { | 336 | { |
335 | QPtrListIterator<Attendee> qli(mAttendees); | 337 | QPtrListIterator<Attendee> qli(mAttendees); |
336 | 338 | ||
337 | QStringList mails = emails; | 339 | QStringList mails = emails; |
338 | if (!email.isEmpty()) { | 340 | if (!email.isEmpty()) { |
339 | mails.append(email); | 341 | mails.append(email); |
340 | } | 342 | } |
341 | qli.toFirst(); | 343 | qli.toFirst(); |
342 | while (qli) { | 344 | while (qli) { |
343 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 345 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
344 | if (qli.current()->email().lower() == (*it).lower()) | 346 | if (qli.current()->email().lower() == (*it).lower()) |
345 | return qli.current(); | 347 | return qli.current(); |
346 | } | 348 | } |
347 | 349 | ||
348 | ++qli; | 350 | ++qli; |
349 | } | 351 | } |
350 | return 0L; | 352 | return 0L; |
351 | } | 353 | } |
352 | 354 | ||
353 | void IncidenceBase::setDuration(int seconds) | 355 | void IncidenceBase::setDuration(int seconds) |
354 | { | 356 | { |
355 | mDuration = seconds; | 357 | mDuration = seconds; |
356 | setHasDuration(true); | 358 | setHasDuration(true); |
357 | } | 359 | } |
358 | 360 | ||
359 | int IncidenceBase::duration() const | 361 | int IncidenceBase::duration() const |
360 | { | 362 | { |
361 | return mDuration; | 363 | return mDuration; |
362 | } | 364 | } |
363 | 365 | ||
364 | void IncidenceBase::setHasDuration(bool b) | 366 | void IncidenceBase::setHasDuration(bool b) |
365 | { | 367 | { |
366 | mHasDuration = b; | 368 | mHasDuration = b; |
367 | } | 369 | } |
368 | 370 | ||
369 | bool IncidenceBase::hasDuration() const | 371 | bool IncidenceBase::hasDuration() const |
370 | { | 372 | { |
371 | return mHasDuration; | 373 | return mHasDuration; |
372 | } | 374 | } |
373 | 375 | ||
374 | void IncidenceBase::setSyncStatus(int stat) | 376 | void IncidenceBase::setSyncStatus(int stat) |
375 | { | 377 | { |
376 | if (mReadOnly) return; | 378 | if (mReadOnly) return; |
377 | mSyncStatus = stat; | 379 | mSyncStatus = stat; |
378 | } | 380 | } |
379 | 381 | ||
380 | int IncidenceBase::syncStatus() const | 382 | int IncidenceBase::syncStatus() const |
381 | { | 383 | { |
382 | return mSyncStatus; | 384 | return mSyncStatus; |
383 | } | 385 | } |
384 | 386 | ||
385 | void IncidenceBase::setPilotId( int id ) | 387 | void IncidenceBase::setPilotId( int id ) |
386 | { | 388 | { |
387 | if (mReadOnly) return; | 389 | if (mReadOnly) return; |
388 | mPilotId = id; | 390 | mPilotId = id; |
389 | } | 391 | } |
390 | 392 | ||
391 | int IncidenceBase::pilotId() const | 393 | int IncidenceBase::pilotId() const |
392 | { | 394 | { |
393 | return mPilotId; | 395 | return mPilotId; |
394 | } | 396 | } |
395 | 397 | ||
396 | int IncidenceBase::tempSyncStat() const | 398 | int IncidenceBase::tempSyncStat() const |
397 | { | 399 | { |
398 | return mTempSyncStat; | 400 | return mTempSyncStat; |
399 | } | 401 | } |
400 | void IncidenceBase::setTempSyncStat( int id ) | 402 | void IncidenceBase::setTempSyncStat( int id ) |
401 | { | 403 | { |
402 | if (mReadOnly) return; | 404 | if (mReadOnly) return; |
403 | mTempSyncStat = id; | 405 | mTempSyncStat = id; |
404 | } | 406 | } |
405 | 407 | ||
406 | void IncidenceBase::removeID(const QString &prof) | 408 | void IncidenceBase::removeID(const QString &prof) |
407 | { | 409 | { |
408 | if ( prof.isEmpty() ) | 410 | if ( prof.isEmpty() ) |
409 | mExternalId = ":"; | 411 | mExternalId = ":"; |
410 | else | 412 | else |
411 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 413 | mExternalId = KIdManager::removeId ( mExternalId, prof); |
412 | 414 | ||
413 | } | 415 | } |
414 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 416 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
415 | { | 417 | { |
416 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 418 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
417 | } | 419 | } |
418 | QString IncidenceBase::getID( const QString & prof) | 420 | QString IncidenceBase::getID( const QString & prof) |
419 | { | 421 | { |
420 | return KIdManager::getId ( mExternalId, prof ); | 422 | return KIdManager::getId ( mExternalId, prof ); |
421 | } | 423 | } |
422 | 424 | ||
423 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 425 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
424 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 426 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
425 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 427 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
426 | { | 428 | { |
427 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 429 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
428 | } | 430 | } |
429 | QString IncidenceBase::getCsum( const QString & prof) | 431 | QString IncidenceBase::getCsum( const QString & prof) |
430 | { | 432 | { |
431 | return KIdManager::getCsum ( mExternalId, prof ); | 433 | return KIdManager::getCsum ( mExternalId, prof ); |
432 | } | 434 | } |
433 | 435 | ||
434 | void IncidenceBase::setIDStr( const QString & s ) | 436 | void IncidenceBase::setIDStr( const QString & s ) |
435 | { | 437 | { |
436 | if (mReadOnly) return; | 438 | if (mReadOnly) return; |
437 | mExternalId = s; | 439 | mExternalId = s; |
438 | } | 440 | } |
439 | 441 | ||
440 | QString IncidenceBase::IDStr() const | 442 | QString IncidenceBase::IDStr() const |
441 | { | 443 | { |
442 | return mExternalId ; | 444 | return mExternalId ; |
443 | } | 445 | } |
444 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 446 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
445 | { | 447 | { |
446 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 448 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
447 | } | 449 | } |
448 | 450 | ||
449 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 451 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
450 | { | 452 | { |
451 | mObservers.remove( observer ); | 453 | mObservers.remove( observer ); |
452 | } | 454 | } |
453 | 455 | ||
454 | void IncidenceBase::updated() | 456 | void IncidenceBase::updated() |
455 | { | 457 | { |
456 | QPtrListIterator<Observer> it(mObservers); | 458 | QPtrListIterator<Observer> it(mObservers); |
457 | while( it.current() ) { | 459 | while( it.current() ) { |
458 | Observer *o = it.current(); | 460 | Observer *o = it.current(); |
459 | ++it; | 461 | ++it; |
460 | o->incidenceUpdated( this ); | 462 | o->incidenceUpdated( this ); |
461 | } | 463 | } |
462 | } | 464 | } |