-rw-r--r-- | libkcal/calendarlocal.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 52c298b..5c889c3 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -237,128 +237,129 @@ void CalendarLocal::removeSyncInfo( QString syncProfile) | |||
237 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 237 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
238 | el.append( todo ); | 238 | el.append( todo ); |
239 | } | 239 | } |
240 | for ( todo = el.first(); todo; todo = el.next() ) { | 240 | for ( todo = el.first(); todo; todo = el.next() ) { |
241 | deleteIncidence ( todo ); | 241 | deleteIncidence ( todo ); |
242 | } | 242 | } |
243 | } else { | 243 | } else { |
244 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 244 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
245 | if ( lse ) | 245 | if ( lse ) |
246 | deleteIncidence ( lse ); | 246 | deleteIncidence ( lse ); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 249 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
250 | { | 250 | { |
251 | QPtrList<Event> el; | 251 | QPtrList<Event> el; |
252 | Event *todo; | 252 | Event *todo; |
253 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 253 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
254 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 254 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
255 | if ( todo->summary().left(3) == "E: " ) | 255 | if ( todo->summary().left(3) == "E: " ) |
256 | el.append( todo ); | 256 | el.append( todo ); |
257 | } | 257 | } |
258 | 258 | ||
259 | return el; | 259 | return el; |
260 | 260 | ||
261 | } | 261 | } |
262 | Event *CalendarLocal::event( QString syncProf, QString id ) | 262 | Event *CalendarLocal::event( QString syncProf, QString id ) |
263 | { | 263 | { |
264 | Event *todo; | 264 | Event *todo; |
265 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 265 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
266 | if ( todo->getID( syncProf ) == id ) return todo; | 266 | if ( todo->getID( syncProf ) == id ) return todo; |
267 | } | 267 | } |
268 | 268 | ||
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | Todo *CalendarLocal::todo( const QString &uid ) | 271 | Todo *CalendarLocal::todo( const QString &uid ) |
272 | { | 272 | { |
273 | Todo *todo; | 273 | Todo *todo; |
274 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 274 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
275 | if ( todo->uid() == uid ) return todo; | 275 | if ( todo->uid() == uid ) return todo; |
276 | } | 276 | } |
277 | 277 | ||
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
280 | QString CalendarLocal::nextSummary() const | 280 | QString CalendarLocal::nextSummary() const |
281 | { | 281 | { |
282 | return mNextSummary; | 282 | return mNextSummary; |
283 | } | 283 | } |
284 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 284 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
285 | { | 285 | { |
286 | return mNextAlarmEventDateTime; | 286 | return mNextAlarmEventDateTime; |
287 | } | 287 | } |
288 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 288 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
289 | { | 289 | { |
290 | //mNextAlarmIncidence | 290 | //mNextAlarmIncidence |
291 | //mNextAlarmDateTime | 291 | //mNextAlarmDateTime |
292 | //return mNextSummary; | 292 | //return mNextSummary; |
293 | //return mNextAlarmEventDateTime; | 293 | //return mNextAlarmEventDateTime; |
294 | bool newNextAlarm = false; | 294 | bool newNextAlarm = false; |
295 | bool computeNextAlarm = false; | 295 | bool computeNextAlarm = false; |
296 | bool ok; | 296 | bool ok; |
297 | int offset; | 297 | int offset; |
298 | QDateTime nextA; | 298 | QDateTime nextA; |
299 | // QString nextSum; | 299 | // QString nextSum; |
300 | //QDateTime nextEvent; | 300 | //QDateTime nextEvent; |
301 | mNextAlarmEventDateTime = QDateTime(); | ||
301 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 302 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
302 | computeNextAlarm = true; | 303 | computeNextAlarm = true; |
303 | } else { | 304 | } else { |
304 | if ( ! deleted ) { | 305 | if ( ! deleted ) { |
305 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 306 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
306 | if ( ok ) { | 307 | if ( ok ) { |
307 | if ( nextA < mNextAlarmDateTime ) { | 308 | if ( nextA < mNextAlarmDateTime ) { |
308 | deRegisterAlarm(); | 309 | deRegisterAlarm(); |
309 | mNextAlarmDateTime = nextA; | 310 | mNextAlarmDateTime = nextA; |
310 | mNextSummary = incidence->summary(); | 311 | mNextSummary = incidence->summary(); |
311 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 312 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
312 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 313 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
313 | newNextAlarm = true; | 314 | newNextAlarm = true; |
314 | mNextAlarmIncidence = incidence; | 315 | mNextAlarmIncidence = incidence; |
315 | } else { | 316 | } else { |
316 | if ( incidence == mNextAlarmIncidence ) { | 317 | if ( incidence == mNextAlarmIncidence ) { |
317 | computeNextAlarm = true; | 318 | computeNextAlarm = true; |
318 | } | 319 | } |
319 | } | 320 | } |
320 | } else { | 321 | } else { |
321 | if ( mNextAlarmIncidence == incidence ) { | 322 | if ( mNextAlarmIncidence == incidence ) { |
322 | computeNextAlarm = true; | 323 | computeNextAlarm = true; |
323 | } | 324 | } |
324 | } | 325 | } |
325 | } else { // deleted | 326 | } else { // deleted |
326 | if ( incidence == mNextAlarmIncidence ) { | 327 | if ( incidence == mNextAlarmIncidence ) { |
327 | computeNextAlarm = true; | 328 | computeNextAlarm = true; |
328 | } | 329 | } |
329 | } | 330 | } |
330 | } | 331 | } |
331 | if ( computeNextAlarm ) { | 332 | if ( computeNextAlarm ) { |
332 | deRegisterAlarm(); | 333 | deRegisterAlarm(); |
333 | nextA = nextAlarm( 1000 ); | 334 | nextA = nextAlarm( 1000 ); |
334 | if (! mNextAlarmIncidence ) { | 335 | if (! mNextAlarmIncidence ) { |
335 | return; | 336 | return; |
336 | } | 337 | } |
337 | newNextAlarm = true; | 338 | newNextAlarm = true; |
338 | } | 339 | } |
339 | if ( newNextAlarm ) | 340 | if ( newNextAlarm ) |
340 | registerAlarm(); | 341 | registerAlarm(); |
341 | } | 342 | } |
342 | QString CalendarLocal:: getAlarmNotification() | 343 | QString CalendarLocal:: getAlarmNotification() |
343 | { | 344 | { |
344 | QString ret; | 345 | QString ret; |
345 | // this should not happen | 346 | // this should not happen |
346 | if (! mNextAlarmIncidence ) | 347 | if (! mNextAlarmIncidence ) |
347 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 348 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
348 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 349 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
349 | if ( alarm->type() == Alarm::Procedure ) { | 350 | if ( alarm->type() == Alarm::Procedure ) { |
350 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 351 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
351 | } else { | 352 | } else { |
352 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 353 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
353 | } | 354 | } |
354 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 355 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
355 | if ( mNextSummary.length() > 25 ) | 356 | if ( mNextSummary.length() > 25 ) |
356 | ret += "\n" + mNextSummary.mid(25, 25 ); | 357 | ret += "\n" + mNextSummary.mid(25, 25 ); |
357 | ret+= "\n"+mNextAlarmEventDateTimeString; | 358 | ret+= "\n"+mNextAlarmEventDateTimeString; |
358 | return ret; | 359 | return ret; |
359 | } | 360 | } |
360 | void CalendarLocal::registerAlarm() | 361 | void CalendarLocal::registerAlarm() |
361 | { | 362 | { |
362 | mLastAlarmNotificationString = getAlarmNotification(); | 363 | mLastAlarmNotificationString = getAlarmNotification(); |
363 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 364 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
364 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 365 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |