author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libkcal/calendarlocal.cpp | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
-rw-r--r-- | libkcal/calendarlocal.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 8ff8b14..3c572f0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,655 +1,686 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | close(); | 68 | close(); |
69 | } | 69 | } |
70 | 70 | ||
71 | bool CalendarLocal::load( const QString &fileName ) | 71 | bool CalendarLocal::load( const QString &fileName ) |
72 | { | 72 | { |
73 | FileStorage storage( this, fileName ); | 73 | FileStorage storage( this, fileName ); |
74 | return storage.load(); | 74 | return storage.load(); |
75 | } | 75 | } |
76 | 76 | ||
77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
78 | { | 78 | { |
79 | FileStorage storage( this, fileName, format ); | 79 | FileStorage storage( this, fileName, format ); |
80 | return storage.save(); | 80 | return storage.save(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void CalendarLocal::close() | 83 | void CalendarLocal::close() |
84 | { | 84 | { |
85 | mEventList.setAutoDelete( true ); | 85 | mEventList.setAutoDelete( true ); |
86 | mTodoList.setAutoDelete( true ); | 86 | mTodoList.setAutoDelete( true ); |
87 | mJournalList.setAutoDelete( false ); | 87 | mJournalList.setAutoDelete( false ); |
88 | 88 | ||
89 | mEventList.clear(); | 89 | mEventList.clear(); |
90 | mTodoList.clear(); | 90 | mTodoList.clear(); |
91 | mJournalList.clear(); | 91 | mJournalList.clear(); |
92 | 92 | ||
93 | mEventList.setAutoDelete( false ); | 93 | mEventList.setAutoDelete( false ); |
94 | mTodoList.setAutoDelete( false ); | 94 | mTodoList.setAutoDelete( false ); |
95 | mJournalList.setAutoDelete( false ); | 95 | mJournalList.setAutoDelete( false ); |
96 | 96 | ||
97 | setModified( false ); | 97 | setModified( false ); |
98 | } | 98 | } |
99 | |||
100 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | ||
101 | { | ||
102 | QString cat; | ||
103 | bool isBirthday = true; | ||
104 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | ||
105 | isBirthday = false; | ||
106 | cat = i18n( "Anniversary" ); | ||
107 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | ||
108 | isBirthday = true; | ||
109 | cat = i18n( "Birthday" ); | ||
110 | } else { | ||
111 | qDebug("addAnniversaryNoDup called without fitting category! "); | ||
112 | return false; | ||
113 | } | ||
114 | Event * eve; | ||
115 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | ||
116 | if ( !(eve->categories().contains( cat ) )) | ||
117 | continue; | ||
118 | // now we have an event with fitting category | ||
119 | if ( eve->dtStart().date() != event->dtStart().date() ) | ||
120 | continue; | ||
121 | // now we have an event with fitting category+date | ||
122 | if ( eve->summary() != event->summary() ) | ||
123 | continue; | ||
124 | // now we have an event with fitting category+date+summary | ||
125 | return false; | ||
126 | } | ||
127 | return addEvent( event ); | ||
128 | |||
129 | } | ||
99 | bool CalendarLocal::addEventNoDup( Event *event ) | 130 | bool CalendarLocal::addEventNoDup( Event *event ) |
100 | { | 131 | { |
101 | Event * eve; | 132 | Event * eve; |
102 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
103 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
104 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
105 | return false; | 136 | return false; |
106 | } | 137 | } |
107 | } | 138 | } |
108 | return addEvent( event ); | 139 | return addEvent( event ); |
109 | } | 140 | } |
110 | 141 | ||
111 | bool CalendarLocal::addEvent( Event *event ) | 142 | bool CalendarLocal::addEvent( Event *event ) |
112 | { | 143 | { |
113 | insertEvent( event ); | 144 | insertEvent( event ); |
114 | 145 | ||
115 | event->registerObserver( this ); | 146 | event->registerObserver( this ); |
116 | 147 | ||
117 | setModified( true ); | 148 | setModified( true ); |
118 | 149 | ||
119 | return true; | 150 | return true; |
120 | } | 151 | } |
121 | 152 | ||
122 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
123 | { | 154 | { |
124 | 155 | ||
125 | 156 | ||
126 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
127 | setModified( true ); | 158 | setModified( true ); |
128 | } | 159 | } |
129 | } | 160 | } |
130 | 161 | ||
131 | 162 | ||
132 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *CalendarLocal::event( const QString &uid ) |
133 | { | 164 | { |
134 | 165 | ||
135 | Event *event; | 166 | Event *event; |
136 | 167 | ||
137 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
138 | if ( event->uid() == uid ) { | 169 | if ( event->uid() == uid ) { |
139 | return event; | 170 | return event; |
140 | } | 171 | } |
141 | } | 172 | } |
142 | 173 | ||
143 | return 0; | 174 | return 0; |
144 | } | 175 | } |
145 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
146 | { | 177 | { |
147 | Todo * eve; | 178 | Todo * eve; |
148 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
149 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
150 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
151 | return false; | 182 | return false; |
152 | } | 183 | } |
153 | } | 184 | } |
154 | return addTodo( todo ); | 185 | return addTodo( todo ); |
155 | } | 186 | } |
156 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
157 | { | 188 | { |
158 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
159 | 190 | ||
160 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
161 | 192 | ||
162 | // Set up subtask relations | 193 | // Set up subtask relations |
163 | setupRelations( todo ); | 194 | setupRelations( todo ); |
164 | 195 | ||
165 | setModified( true ); | 196 | setModified( true ); |
166 | 197 | ||
167 | return true; | 198 | return true; |
168 | } | 199 | } |
169 | 200 | ||
170 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
171 | { | 202 | { |
172 | // Handle orphaned children | 203 | // Handle orphaned children |
173 | removeRelations( todo ); | 204 | removeRelations( todo ); |
174 | 205 | ||
175 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
176 | setModified( true ); | 207 | setModified( true ); |
177 | } | 208 | } |
178 | } | 209 | } |
179 | 210 | ||
180 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
181 | { | 212 | { |
182 | return mTodoList; | 213 | return mTodoList; |
183 | } | 214 | } |
184 | Todo *CalendarLocal::todo( int id ) | 215 | Todo *CalendarLocal::todo( int id ) |
185 | { | 216 | { |
186 | Todo *todo; | 217 | Todo *todo; |
187 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
188 | if ( todo->zaurusId() == id ) return todo; | 219 | if ( todo->zaurusId() == id ) return todo; |
189 | } | 220 | } |
190 | 221 | ||
191 | return 0; | 222 | return 0; |
192 | } | 223 | } |
193 | 224 | ||
194 | Event *CalendarLocal::event( int id ) | 225 | Event *CalendarLocal::event( int id ) |
195 | { | 226 | { |
196 | Event *todo; | 227 | Event *todo; |
197 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 228 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
198 | if ( todo->zaurusId() == id ) return todo; | 229 | if ( todo->zaurusId() == id ) return todo; |
199 | } | 230 | } |
200 | 231 | ||
201 | return 0; | 232 | return 0; |
202 | } | 233 | } |
203 | Todo *CalendarLocal::todo( const QString &uid ) | 234 | Todo *CalendarLocal::todo( const QString &uid ) |
204 | { | 235 | { |
205 | Todo *todo; | 236 | Todo *todo; |
206 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 237 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
207 | if ( todo->uid() == uid ) return todo; | 238 | if ( todo->uid() == uid ) return todo; |
208 | } | 239 | } |
209 | 240 | ||
210 | return 0; | 241 | return 0; |
211 | } | 242 | } |
212 | QString CalendarLocal::nextSummary() const | 243 | QString CalendarLocal::nextSummary() const |
213 | { | 244 | { |
214 | return mNextSummary; | 245 | return mNextSummary; |
215 | } | 246 | } |
216 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 247 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
217 | { | 248 | { |
218 | return mNextAlarmEventDateTime; | 249 | return mNextAlarmEventDateTime; |
219 | } | 250 | } |
220 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 251 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
221 | { | 252 | { |
222 | //mNextAlarmIncidence | 253 | //mNextAlarmIncidence |
223 | //mNextAlarmDateTime | 254 | //mNextAlarmDateTime |
224 | //return mNextSummary; | 255 | //return mNextSummary; |
225 | //return mNextAlarmEventDateTime; | 256 | //return mNextAlarmEventDateTime; |
226 | bool newNextAlarm = false; | 257 | bool newNextAlarm = false; |
227 | bool computeNextAlarm = false; | 258 | bool computeNextAlarm = false; |
228 | bool ok; | 259 | bool ok; |
229 | int offset; | 260 | int offset; |
230 | QDateTime nextA; | 261 | QDateTime nextA; |
231 | // QString nextSum; | 262 | // QString nextSum; |
232 | //QDateTime nextEvent; | 263 | //QDateTime nextEvent; |
233 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 264 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
234 | computeNextAlarm = true; | 265 | computeNextAlarm = true; |
235 | } else { | 266 | } else { |
236 | if ( ! deleted ) { | 267 | if ( ! deleted ) { |
237 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 268 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
238 | if ( ok ) { | 269 | if ( ok ) { |
239 | if ( nextA < mNextAlarmDateTime ) { | 270 | if ( nextA < mNextAlarmDateTime ) { |
240 | deRegisterAlarm(); | 271 | deRegisterAlarm(); |
241 | mNextAlarmDateTime = nextA; | 272 | mNextAlarmDateTime = nextA; |
242 | mNextSummary = incidence->summary(); | 273 | mNextSummary = incidence->summary(); |
243 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 274 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
244 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 275 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
245 | newNextAlarm = true; | 276 | newNextAlarm = true; |
246 | mNextAlarmIncidence = incidence; | 277 | mNextAlarmIncidence = incidence; |
247 | } else { | 278 | } else { |
248 | if ( incidence == mNextAlarmIncidence ) { | 279 | if ( incidence == mNextAlarmIncidence ) { |
249 | computeNextAlarm = true; | 280 | computeNextAlarm = true; |
250 | } | 281 | } |
251 | } | 282 | } |
252 | } else { | 283 | } else { |
253 | if ( mNextAlarmIncidence == incidence ) { | 284 | if ( mNextAlarmIncidence == incidence ) { |
254 | computeNextAlarm = true; | 285 | computeNextAlarm = true; |
255 | } | 286 | } |
256 | } | 287 | } |
257 | } else { // deleted | 288 | } else { // deleted |
258 | if ( incidence == mNextAlarmIncidence ) { | 289 | if ( incidence == mNextAlarmIncidence ) { |
259 | computeNextAlarm = true; | 290 | computeNextAlarm = true; |
260 | } | 291 | } |
261 | } | 292 | } |
262 | } | 293 | } |
263 | if ( computeNextAlarm ) { | 294 | if ( computeNextAlarm ) { |
264 | deRegisterAlarm(); | 295 | deRegisterAlarm(); |
265 | nextA = nextAlarm( 1000 ); | 296 | nextA = nextAlarm( 1000 ); |
266 | if (! mNextAlarmIncidence ) { | 297 | if (! mNextAlarmIncidence ) { |
267 | return; | 298 | return; |
268 | } | 299 | } |
269 | newNextAlarm = true; | 300 | newNextAlarm = true; |
270 | } | 301 | } |
271 | if ( newNextAlarm ) | 302 | if ( newNextAlarm ) |
272 | registerAlarm(); | 303 | registerAlarm(); |
273 | } | 304 | } |
274 | QString CalendarLocal:: getAlarmNotification() | 305 | QString CalendarLocal:: getAlarmNotification() |
275 | { | 306 | { |
276 | QString ret; | 307 | QString ret; |
277 | // this should not happen | 308 | // this should not happen |
278 | if (! mNextAlarmIncidence ) | 309 | if (! mNextAlarmIncidence ) |
279 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 310 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
280 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 311 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
281 | if ( alarm->type() == Alarm::Procedure ) { | 312 | if ( alarm->type() == Alarm::Procedure ) { |
282 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 313 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
283 | } else { | 314 | } else { |
284 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 315 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
285 | } | 316 | } |
286 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 317 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
287 | if ( mNextSummary.length() > 25 ) | 318 | if ( mNextSummary.length() > 25 ) |
288 | ret += "\n" + mNextSummary.mid(25, 25 ); | 319 | ret += "\n" + mNextSummary.mid(25, 25 ); |
289 | ret+= "\n"+mNextAlarmEventDateTimeString; | 320 | ret+= "\n"+mNextAlarmEventDateTimeString; |
290 | return ret; | 321 | return ret; |
291 | } | 322 | } |
292 | 323 | ||
293 | void CalendarLocal::registerAlarm() | 324 | void CalendarLocal::registerAlarm() |
294 | { | 325 | { |
295 | mLastAlarmNotificationString = getAlarmNotification(); | 326 | mLastAlarmNotificationString = getAlarmNotification(); |
296 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 327 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
297 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 328 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
298 | // #ifndef DESKTOP_VERSION | 329 | // #ifndef DESKTOP_VERSION |
299 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 330 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
300 | // #endif | 331 | // #endif |
301 | } | 332 | } |
302 | void CalendarLocal::deRegisterAlarm() | 333 | void CalendarLocal::deRegisterAlarm() |
303 | { | 334 | { |
304 | if ( mLastAlarmNotificationString.isNull() ) | 335 | if ( mLastAlarmNotificationString.isNull() ) |
305 | return; | 336 | return; |
306 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 337 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
307 | 338 | ||
308 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 339 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
309 | // #ifndef DESKTOP_VERSION | 340 | // #ifndef DESKTOP_VERSION |
310 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 341 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
311 | // #endif | 342 | // #endif |
312 | } | 343 | } |
313 | 344 | ||
314 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 345 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
315 | { | 346 | { |
316 | QPtrList<Todo> todos; | 347 | QPtrList<Todo> todos; |
317 | 348 | ||
318 | Todo *todo; | 349 | Todo *todo; |
319 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 350 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
320 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 351 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
321 | todos.append( todo ); | 352 | todos.append( todo ); |
322 | } | 353 | } |
323 | } | 354 | } |
324 | 355 | ||
325 | filter()->apply( &todos ); | 356 | filter()->apply( &todos ); |
326 | return todos; | 357 | return todos; |
327 | } | 358 | } |
328 | void CalendarLocal::reInitAlarmSettings() | 359 | void CalendarLocal::reInitAlarmSettings() |
329 | { | 360 | { |
330 | if ( !mNextAlarmIncidence ) { | 361 | if ( !mNextAlarmIncidence ) { |
331 | nextAlarm( 1000 ); | 362 | nextAlarm( 1000 ); |
332 | } | 363 | } |
333 | deRegisterAlarm(); | 364 | deRegisterAlarm(); |
334 | mNextAlarmIncidence = 0; | 365 | mNextAlarmIncidence = 0; |
335 | checkAlarmForIncidence( 0, false ); | 366 | checkAlarmForIncidence( 0, false ); |
336 | 367 | ||
337 | } | 368 | } |
338 | 369 | ||
339 | 370 | ||
340 | 371 | ||
341 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 372 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
342 | { | 373 | { |
343 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 374 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
344 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 375 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
345 | QDateTime next; | 376 | QDateTime next; |
346 | Event *e; | 377 | Event *e; |
347 | bool ok; | 378 | bool ok; |
348 | bool found = false; | 379 | bool found = false; |
349 | int offset; | 380 | int offset; |
350 | mNextAlarmIncidence = 0; | 381 | mNextAlarmIncidence = 0; |
351 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 382 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
352 | next = e->getNextAlarmDateTime(& ok, &offset ) ; | 383 | next = e->getNextAlarmDateTime(& ok, &offset ) ; |
353 | if ( ok ) { | 384 | if ( ok ) { |
354 | if ( next < nextA ) { | 385 | if ( next < nextA ) { |
355 | nextA = next; | 386 | nextA = next; |
356 | found = true; | 387 | found = true; |
357 | mNextSummary = e->summary(); | 388 | mNextSummary = e->summary(); |
358 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 389 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
359 | mNextAlarmIncidence = (Incidence *) e; | 390 | mNextAlarmIncidence = (Incidence *) e; |
360 | } | 391 | } |
361 | } | 392 | } |
362 | } | 393 | } |
363 | Todo *t; | 394 | Todo *t; |
364 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 395 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
365 | next = t->getNextAlarmDateTime(& ok, &offset ) ; | 396 | next = t->getNextAlarmDateTime(& ok, &offset ) ; |
366 | if ( ok ) { | 397 | if ( ok ) { |
367 | if ( next < nextA ) { | 398 | if ( next < nextA ) { |
368 | nextA = next; | 399 | nextA = next; |
369 | found = true; | 400 | found = true; |
370 | mNextSummary = t->summary(); | 401 | mNextSummary = t->summary(); |
371 | mNextAlarmEventDateTime = next.addSecs(offset ); | 402 | mNextAlarmEventDateTime = next.addSecs(offset ); |
372 | mNextAlarmIncidence = (Incidence *) t; | 403 | mNextAlarmIncidence = (Incidence *) t; |
373 | } | 404 | } |
374 | } | 405 | } |
375 | } | 406 | } |
376 | if ( mNextAlarmIncidence ) { | 407 | if ( mNextAlarmIncidence ) { |
377 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 408 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
378 | mNextAlarmDateTime = nextA; | 409 | mNextAlarmDateTime = nextA; |
379 | } | 410 | } |
380 | return nextA; | 411 | return nextA; |
381 | } | 412 | } |
382 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 413 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
383 | { | 414 | { |
384 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 415 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
385 | } | 416 | } |
386 | 417 | ||
387 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 418 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
388 | { | 419 | { |
389 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " | 420 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " |
390 | << to.toString() << ")\n"; | 421 | << to.toString() << ")\n"; |
391 | 422 | ||
392 | Alarm::List alarms; | 423 | Alarm::List alarms; |
393 | 424 | ||
394 | Event *e; | 425 | Event *e; |
395 | 426 | ||
396 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 427 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
397 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 428 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
398 | else appendAlarms( alarms, e, from, to ); | 429 | else appendAlarms( alarms, e, from, to ); |
399 | } | 430 | } |
400 | 431 | ||
401 | Todo *t; | 432 | Todo *t; |
402 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 433 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
403 | appendAlarms( alarms, t, from, to ); | 434 | appendAlarms( alarms, t, from, to ); |
404 | } | 435 | } |
405 | 436 | ||
406 | return alarms; | 437 | return alarms; |
407 | } | 438 | } |
408 | 439 | ||
409 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 440 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
410 | const QDateTime &from, const QDateTime &to ) | 441 | const QDateTime &from, const QDateTime &to ) |
411 | { | 442 | { |
412 | QPtrList<Alarm> alarmList = incidence->alarms(); | 443 | QPtrList<Alarm> alarmList = incidence->alarms(); |
413 | Alarm *alarm; | 444 | Alarm *alarm; |
414 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 445 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
415 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 446 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
416 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 447 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
417 | if ( alarm->enabled() ) { | 448 | if ( alarm->enabled() ) { |
418 | if ( alarm->time() >= from && alarm->time() <= to ) { | 449 | if ( alarm->time() >= from && alarm->time() <= to ) { |
419 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() | 450 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() |
420 | << "': " << alarm->time().toString() << endl; | 451 | << "': " << alarm->time().toString() << endl; |
421 | alarms.append( alarm ); | 452 | alarms.append( alarm ); |
422 | } | 453 | } |
423 | } | 454 | } |
424 | } | 455 | } |
425 | } | 456 | } |
426 | 457 | ||
427 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 458 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
428 | Incidence *incidence, | 459 | Incidence *incidence, |
429 | const QDateTime &from, | 460 | const QDateTime &from, |
430 | const QDateTime &to ) | 461 | const QDateTime &to ) |
431 | { | 462 | { |
432 | 463 | ||
433 | QPtrList<Alarm> alarmList = incidence->alarms(); | 464 | QPtrList<Alarm> alarmList = incidence->alarms(); |
434 | Alarm *alarm; | 465 | Alarm *alarm; |
435 | QDateTime qdt; | 466 | QDateTime qdt; |
436 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 467 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
437 | if (incidence->recursOn(from.date())) { | 468 | if (incidence->recursOn(from.date())) { |
438 | qdt.setTime(alarm->time().time()); | 469 | qdt.setTime(alarm->time().time()); |
439 | qdt.setDate(from.date()); | 470 | qdt.setDate(from.date()); |
440 | } | 471 | } |
441 | else qdt = alarm->time(); | 472 | else qdt = alarm->time(); |
442 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 473 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
443 | if ( alarm->enabled() ) { | 474 | if ( alarm->enabled() ) { |
444 | if ( qdt >= from && qdt <= to ) { | 475 | if ( qdt >= from && qdt <= to ) { |
445 | alarms.append( alarm ); | 476 | alarms.append( alarm ); |
446 | } | 477 | } |
447 | } | 478 | } |
448 | } | 479 | } |
449 | } | 480 | } |
450 | 481 | ||
451 | 482 | ||
452 | /****************************** PROTECTED METHODS ****************************/ | 483 | /****************************** PROTECTED METHODS ****************************/ |
453 | 484 | ||
454 | // after changes are made to an event, this should be called. | 485 | // after changes are made to an event, this should be called. |
455 | void CalendarLocal::update( IncidenceBase *incidence ) | 486 | void CalendarLocal::update( IncidenceBase *incidence ) |
456 | { | 487 | { |
457 | incidence->setSyncStatus( Event::SYNCMOD ); | 488 | incidence->setSyncStatus( Event::SYNCMOD ); |
458 | incidence->setLastModified( QDateTime::currentDateTime() ); | 489 | incidence->setLastModified( QDateTime::currentDateTime() ); |
459 | // we should probably update the revision number here, | 490 | // we should probably update the revision number here, |
460 | // or internally in the Event itself when certain things change. | 491 | // or internally in the Event itself when certain things change. |
461 | // need to verify with ical documentation. | 492 | // need to verify with ical documentation. |
462 | 493 | ||
463 | setModified( true ); | 494 | setModified( true ); |
464 | } | 495 | } |
465 | 496 | ||
466 | void CalendarLocal::insertEvent( Event *event ) | 497 | void CalendarLocal::insertEvent( Event *event ) |
467 | { | 498 | { |
468 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 499 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
469 | } | 500 | } |
470 | 501 | ||
471 | 502 | ||
472 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 503 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
473 | { | 504 | { |
474 | QPtrList<Event> eventList; | 505 | QPtrList<Event> eventList; |
475 | 506 | ||
476 | Event *event; | 507 | Event *event; |
477 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 508 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
478 | if ( event->doesRecur() ) { | 509 | if ( event->doesRecur() ) { |
479 | if ( event->isMultiDay() ) { | 510 | if ( event->isMultiDay() ) { |
480 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 511 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
481 | int i; | 512 | int i; |
482 | for ( i = 0; i <= extraDays; i++ ) { | 513 | for ( i = 0; i <= extraDays; i++ ) { |
483 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 514 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
484 | eventList.append( event ); | 515 | eventList.append( event ); |
485 | break; | 516 | break; |
486 | } | 517 | } |
487 | } | 518 | } |
488 | } else { | 519 | } else { |
489 | if ( event->recursOn( qd ) ) | 520 | if ( event->recursOn( qd ) ) |
490 | eventList.append( event ); | 521 | eventList.append( event ); |
491 | } | 522 | } |
492 | } else { | 523 | } else { |
493 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 524 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
494 | eventList.append( event ); | 525 | eventList.append( event ); |
495 | } | 526 | } |
496 | } | 527 | } |
497 | } | 528 | } |
498 | 529 | ||
499 | if ( !sorted ) { | 530 | if ( !sorted ) { |
500 | return eventList; | 531 | return eventList; |
501 | } | 532 | } |
502 | 533 | ||
503 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 534 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
504 | // now, we have to sort it based on dtStart.time() | 535 | // now, we have to sort it based on dtStart.time() |
505 | QPtrList<Event> eventListSorted; | 536 | QPtrList<Event> eventListSorted; |
506 | Event *sortEvent; | 537 | Event *sortEvent; |
507 | for ( event = eventList.first(); event; event = eventList.next() ) { | 538 | for ( event = eventList.first(); event; event = eventList.next() ) { |
508 | sortEvent = eventListSorted.first(); | 539 | sortEvent = eventListSorted.first(); |
509 | int i = 0; | 540 | int i = 0; |
510 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 541 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
511 | { | 542 | { |
512 | i++; | 543 | i++; |
513 | sortEvent = eventListSorted.next(); | 544 | sortEvent = eventListSorted.next(); |
514 | } | 545 | } |
515 | eventListSorted.insert( i, event ); | 546 | eventListSorted.insert( i, event ); |
516 | } | 547 | } |
517 | return eventListSorted; | 548 | return eventListSorted; |
518 | } | 549 | } |
519 | 550 | ||
520 | 551 | ||
521 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 552 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
522 | bool inclusive ) | 553 | bool inclusive ) |
523 | { | 554 | { |
524 | Event *event = 0; | 555 | Event *event = 0; |
525 | 556 | ||
526 | QPtrList<Event> eventList; | 557 | QPtrList<Event> eventList; |
527 | 558 | ||
528 | // Get non-recurring events | 559 | // Get non-recurring events |
529 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 560 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
530 | if ( event->doesRecur() ) { | 561 | if ( event->doesRecur() ) { |
531 | QDate rStart = event->dtStart().date(); | 562 | QDate rStart = event->dtStart().date(); |
532 | bool found = false; | 563 | bool found = false; |
533 | if ( inclusive ) { | 564 | if ( inclusive ) { |
534 | if ( rStart >= start && rStart <= end ) { | 565 | if ( rStart >= start && rStart <= end ) { |
535 | // Start date of event is in range. Now check for end date. | 566 | // Start date of event is in range. Now check for end date. |
536 | // if duration is negative, event recurs forever, so do not include it. | 567 | // if duration is negative, event recurs forever, so do not include it. |
537 | if ( event->recurrence()->duration() == 0 ) { // End date set | 568 | if ( event->recurrence()->duration() == 0 ) { // End date set |
538 | QDate rEnd = event->recurrence()->endDate(); | 569 | QDate rEnd = event->recurrence()->endDate(); |
539 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 570 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
540 | found = true; | 571 | found = true; |
541 | } | 572 | } |
542 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 573 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
543 | // TODO: Calculate end date from duration. Should be done in Event | 574 | // TODO: Calculate end date from duration. Should be done in Event |
544 | // For now exclude all events with a duration. | 575 | // For now exclude all events with a duration. |
545 | } | 576 | } |
546 | } | 577 | } |
547 | } else { | 578 | } else { |
548 | bool founOne; | 579 | bool founOne; |
549 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 580 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
550 | if ( founOne ) { | 581 | if ( founOne ) { |
551 | if ( next <= end ) { | 582 | if ( next <= end ) { |
552 | found = true; | 583 | found = true; |
553 | } | 584 | } |
554 | } | 585 | } |
555 | 586 | ||
556 | /* | 587 | /* |
557 | // crap !!! | 588 | // crap !!! |
558 | if ( rStart <= end ) { // Start date not after range | 589 | if ( rStart <= end ) { // Start date not after range |
559 | if ( rStart >= start ) { // Start date within range | 590 | if ( rStart >= start ) { // Start date within range |
560 | found = true; | 591 | found = true; |
561 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 592 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
562 | found = true; | 593 | found = true; |
563 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 594 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
564 | QDate rEnd = event->recurrence()->endDate(); | 595 | QDate rEnd = event->recurrence()->endDate(); |
565 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 596 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
566 | found = true; | 597 | found = true; |
567 | } | 598 | } |
568 | } else { // Duration set | 599 | } else { // Duration set |
569 | // TODO: Calculate end date from duration. Should be done in Event | 600 | // TODO: Calculate end date from duration. Should be done in Event |
570 | // For now include all events with a duration. | 601 | // For now include all events with a duration. |
571 | found = true; | 602 | found = true; |
572 | } | 603 | } |
573 | } | 604 | } |
574 | */ | 605 | */ |
575 | 606 | ||
576 | } | 607 | } |
577 | 608 | ||
578 | if ( found ) eventList.append( event ); | 609 | if ( found ) eventList.append( event ); |
579 | } else { | 610 | } else { |
580 | QDate s = event->dtStart().date(); | 611 | QDate s = event->dtStart().date(); |
581 | QDate e = event->dtEnd().date(); | 612 | QDate e = event->dtEnd().date(); |
582 | 613 | ||
583 | if ( inclusive ) { | 614 | if ( inclusive ) { |
584 | if ( s >= start && e <= end ) { | 615 | if ( s >= start && e <= end ) { |
585 | eventList.append( event ); | 616 | eventList.append( event ); |
586 | } | 617 | } |
587 | } else { | 618 | } else { |
588 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 619 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
589 | eventList.append( event ); | 620 | eventList.append( event ); |
590 | } | 621 | } |
591 | } | 622 | } |
592 | } | 623 | } |
593 | } | 624 | } |
594 | 625 | ||
595 | return eventList; | 626 | return eventList; |
596 | } | 627 | } |
597 | 628 | ||
598 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 629 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
599 | { | 630 | { |
600 | return rawEventsForDate( qdt.date() ); | 631 | return rawEventsForDate( qdt.date() ); |
601 | } | 632 | } |
602 | 633 | ||
603 | QPtrList<Event> CalendarLocal::rawEvents() | 634 | QPtrList<Event> CalendarLocal::rawEvents() |
604 | { | 635 | { |
605 | return mEventList; | 636 | return mEventList; |
606 | } | 637 | } |
607 | 638 | ||
608 | bool CalendarLocal::addJournal(Journal *journal) | 639 | bool CalendarLocal::addJournal(Journal *journal) |
609 | { | 640 | { |
610 | if ( journal->dtStart().isValid()) | 641 | if ( journal->dtStart().isValid()) |
611 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 642 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
612 | else | 643 | else |
613 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 644 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
614 | 645 | ||
615 | mJournalList.append(journal); | 646 | mJournalList.append(journal); |
616 | 647 | ||
617 | journal->registerObserver( this ); | 648 | journal->registerObserver( this ); |
618 | 649 | ||
619 | setModified( true ); | 650 | setModified( true ); |
620 | 651 | ||
621 | return true; | 652 | return true; |
622 | } | 653 | } |
623 | 654 | ||
624 | void CalendarLocal::deleteJournal( Journal *journal ) | 655 | void CalendarLocal::deleteJournal( Journal *journal ) |
625 | { | 656 | { |
626 | if ( mJournalList.removeRef(journal) ) { | 657 | if ( mJournalList.removeRef(journal) ) { |
627 | setModified( true ); | 658 | setModified( true ); |
628 | } | 659 | } |
629 | } | 660 | } |
630 | 661 | ||
631 | Journal *CalendarLocal::journal( const QDate &date ) | 662 | Journal *CalendarLocal::journal( const QDate &date ) |
632 | { | 663 | { |
633 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 664 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
634 | 665 | ||
635 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 666 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
636 | if ( it->dtStart().date() == date ) | 667 | if ( it->dtStart().date() == date ) |
637 | return it; | 668 | return it; |
638 | 669 | ||
639 | return 0; | 670 | return 0; |
640 | } | 671 | } |
641 | 672 | ||
642 | Journal *CalendarLocal::journal( const QString &uid ) | 673 | Journal *CalendarLocal::journal( const QString &uid ) |
643 | { | 674 | { |
644 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 675 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
645 | if ( it->uid() == uid ) | 676 | if ( it->uid() == uid ) |
646 | return it; | 677 | return it; |
647 | 678 | ||
648 | return 0; | 679 | return 0; |
649 | } | 680 | } |
650 | 681 | ||
651 | QPtrList<Journal> CalendarLocal::journals() | 682 | QPtrList<Journal> CalendarLocal::journals() |
652 | { | 683 | { |
653 | return mJournalList; | 684 | return mJournalList; |
654 | } | 685 | } |
655 | 686 | ||