-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,334 +1,335 @@ | |||
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 |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 336c3e8..8c4dde1 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,336 +1,346 @@ | |||
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() ) { |
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,399 +1,401 @@ | |||
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 | } |