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