-rw-r--r-- | libkcal/calendarlocal.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3c572f0..09ce9f0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -193,64 +193,77 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | removeRelations( todo ); |
205 | 205 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 207 | setModified( true ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 212 | { |
213 | return mTodoList; | 213 | return mTodoList; |
214 | } | 214 | } |
215 | Todo *CalendarLocal::todo( int id ) | 215 | Todo *CalendarLocal::todo( int id ) |
216 | { | 216 | { |
217 | Todo *todo; | 217 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->zaurusId() == id ) return todo; | 219 | if ( todo->zaurusId() == id ) return todo; |
220 | } | 220 | } |
221 | 221 | ||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | ||
225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | ||
226 | { | ||
227 | QPtrList<Event> el; | ||
228 | Event *todo; | ||
229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | ||
230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | ||
231 | if ( todo->summary().left(3) == "E: " ) | ||
232 | el.append( todo ); | ||
233 | } | ||
234 | |||
235 | return el; | ||
236 | |||
237 | } | ||
225 | Event *CalendarLocal::event( int id ) | 238 | Event *CalendarLocal::event( int id ) |
226 | { | 239 | { |
227 | Event *todo; | 240 | Event *todo; |
228 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
229 | if ( todo->zaurusId() == id ) return todo; | 242 | if ( todo->zaurusId() == id ) return todo; |
230 | } | 243 | } |
231 | 244 | ||
232 | return 0; | 245 | return 0; |
233 | } | 246 | } |
234 | Todo *CalendarLocal::todo( const QString &uid ) | 247 | Todo *CalendarLocal::todo( const QString &uid ) |
235 | { | 248 | { |
236 | Todo *todo; | 249 | Todo *todo; |
237 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
238 | if ( todo->uid() == uid ) return todo; | 251 | if ( todo->uid() == uid ) return todo; |
239 | } | 252 | } |
240 | 253 | ||
241 | return 0; | 254 | return 0; |
242 | } | 255 | } |
243 | QString CalendarLocal::nextSummary() const | 256 | QString CalendarLocal::nextSummary() const |
244 | { | 257 | { |
245 | return mNextSummary; | 258 | return mNextSummary; |
246 | } | 259 | } |
247 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 260 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
248 | { | 261 | { |
249 | return mNextAlarmEventDateTime; | 262 | return mNextAlarmEventDateTime; |
250 | } | 263 | } |
251 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 264 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
252 | { | 265 | { |
253 | //mNextAlarmIncidence | 266 | //mNextAlarmIncidence |
254 | //mNextAlarmDateTime | 267 | //mNextAlarmDateTime |
255 | //return mNextSummary; | 268 | //return mNextSummary; |
256 | //return mNextAlarmEventDateTime; | 269 | //return mNextAlarmEventDateTime; |
@@ -291,65 +304,64 @@ void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted | |||
291 | } | 304 | } |
292 | } | 305 | } |
293 | } | 306 | } |
294 | if ( computeNextAlarm ) { | 307 | if ( computeNextAlarm ) { |
295 | deRegisterAlarm(); | 308 | deRegisterAlarm(); |
296 | nextA = nextAlarm( 1000 ); | 309 | nextA = nextAlarm( 1000 ); |
297 | if (! mNextAlarmIncidence ) { | 310 | if (! mNextAlarmIncidence ) { |
298 | return; | 311 | return; |
299 | } | 312 | } |
300 | newNextAlarm = true; | 313 | newNextAlarm = true; |
301 | } | 314 | } |
302 | if ( newNextAlarm ) | 315 | if ( newNextAlarm ) |
303 | registerAlarm(); | 316 | registerAlarm(); |
304 | } | 317 | } |
305 | QString CalendarLocal:: getAlarmNotification() | 318 | QString CalendarLocal:: getAlarmNotification() |
306 | { | 319 | { |
307 | QString ret; | 320 | QString ret; |
308 | // this should not happen | 321 | // this should not happen |
309 | if (! mNextAlarmIncidence ) | 322 | if (! mNextAlarmIncidence ) |
310 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 323 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
311 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 324 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
312 | if ( alarm->type() == Alarm::Procedure ) { | 325 | if ( alarm->type() == Alarm::Procedure ) { |
313 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 326 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
314 | } else { | 327 | } else { |
315 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 328 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
316 | } | 329 | } |
317 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 330 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
318 | if ( mNextSummary.length() > 25 ) | 331 | if ( mNextSummary.length() > 25 ) |
319 | ret += "\n" + mNextSummary.mid(25, 25 ); | 332 | ret += "\n" + mNextSummary.mid(25, 25 ); |
320 | ret+= "\n"+mNextAlarmEventDateTimeString; | 333 | ret+= "\n"+mNextAlarmEventDateTimeString; |
321 | return ret; | 334 | return ret; |
322 | } | 335 | } |
323 | |||
324 | void CalendarLocal::registerAlarm() | 336 | void CalendarLocal::registerAlarm() |
325 | { | 337 | { |
326 | mLastAlarmNotificationString = getAlarmNotification(); | 338 | mLastAlarmNotificationString = getAlarmNotification(); |
327 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 339 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
328 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 340 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
329 | // #ifndef DESKTOP_VERSION | 341 | // #ifndef DESKTOP_VERSION |
330 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 342 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
331 | // #endif | 343 | // #endif |
332 | } | 344 | } |
333 | void CalendarLocal::deRegisterAlarm() | 345 | void CalendarLocal::deRegisterAlarm() |
334 | { | 346 | { |
335 | if ( mLastAlarmNotificationString.isNull() ) | 347 | if ( mLastAlarmNotificationString.isNull() ) |
336 | return; | 348 | return; |
337 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 349 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
338 | 350 | ||
339 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 351 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
340 | // #ifndef DESKTOP_VERSION | 352 | // #ifndef DESKTOP_VERSION |
341 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 353 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
342 | // #endif | 354 | // #endif |
343 | } | 355 | } |
344 | 356 | ||
345 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 357 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
346 | { | 358 | { |
347 | QPtrList<Todo> todos; | 359 | QPtrList<Todo> todos; |
348 | 360 | ||
349 | Todo *todo; | 361 | Todo *todo; |
350 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 362 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
351 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 363 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
352 | todos.append( todo ); | 364 | todos.append( todo ); |
353 | } | 365 | } |
354 | } | 366 | } |
355 | 367 | ||