-rw-r--r-- | libopie/pim/oevent.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index c916297..ec05e77 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -285,193 +285,193 @@ QString OEvent::toRichText()const { | |||
285 | 285 | ||
286 | //notes | 286 | //notes |
287 | if ( !note().isEmpty() ) { | 287 | if ( !note().isEmpty() ) { |
288 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 288 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
289 | text += note(); | 289 | text += note(); |
290 | // text += Qtopia::escapeString(note() ). | 290 | // text += Qtopia::escapeString(note() ). |
291 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 291 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
292 | } | 292 | } |
293 | return text; | 293 | return text; |
294 | } | 294 | } |
295 | QString OEvent::toShortText()const { | 295 | QString OEvent::toShortText()const { |
296 | QString text; | 296 | QString text; |
297 | text += QString::number( startDateTime().date().day() ); | 297 | text += QString::number( startDateTime().date().day() ); |
298 | text += "."; | 298 | text += "."; |
299 | text += QString::number( startDateTime().date().month() ); | 299 | text += QString::number( startDateTime().date().month() ); |
300 | text += "."; | 300 | text += "."; |
301 | text += QString::number( startDateTime().date().year() ); | 301 | text += QString::number( startDateTime().date().year() ); |
302 | text += " "; | 302 | text += " "; |
303 | text += QString::number( startDateTime().time().hour() ); | 303 | text += QString::number( startDateTime().time().hour() ); |
304 | text += ":"; | 304 | text += ":"; |
305 | text += QString::number( startDateTime().time().minute() ); | 305 | text += QString::number( startDateTime().time().minute() ); |
306 | text += " - "; | 306 | text += " - "; |
307 | text += description(); | 307 | text += description(); |
308 | return text; | 308 | return text; |
309 | } | 309 | } |
310 | QString OEvent::type()const { | 310 | QString OEvent::type()const { |
311 | return QString::fromLatin1("OEvent"); | 311 | return QString::fromLatin1("OEvent"); |
312 | } | 312 | } |
313 | QString OEvent::recordField( int /*id */ )const { | 313 | QString OEvent::recordField( int /*id */ )const { |
314 | return QString::null; | 314 | return QString::null; |
315 | } | 315 | } |
316 | int OEvent::rtti() { | 316 | int OEvent::rtti() { |
317 | return OPimResolver::DateBook; | 317 | return OPimResolver::DateBook; |
318 | } | 318 | } |
319 | bool OEvent::loadFromStream( QDataStream& ) { | 319 | bool OEvent::loadFromStream( QDataStream& ) { |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | bool OEvent::saveToStream( QDataStream& )const { | 322 | bool OEvent::saveToStream( QDataStream& )const { |
323 | return true; | 323 | return true; |
324 | } | 324 | } |
325 | void OEvent::changeOrModify() { | 325 | void OEvent::changeOrModify() { |
326 | if ( data->count != 1 ) { | 326 | if ( data->count != 1 ) { |
327 | data->deref(); | 327 | data->deref(); |
328 | Data* d2 = new Data; | 328 | Data* d2 = new Data; |
329 | d2->description = data->description; | 329 | d2->description = data->description; |
330 | d2->location = data->location; | 330 | d2->location = data->location; |
331 | 331 | ||
332 | if (data->manager ) | 332 | if (data->manager ) |
333 | d2->manager = new OPimNotifyManager( *data->manager ); | 333 | d2->manager = new OPimNotifyManager( *data->manager ); |
334 | 334 | ||
335 | if ( data->recur ) | 335 | if ( data->recur ) |
336 | d2->recur = new ORecur( *data->recur ); | 336 | d2->recur = new ORecur( *data->recur ); |
337 | 337 | ||
338 | d2->note = data->note; | 338 | d2->note = data->note; |
339 | d2->created = data->created; | 339 | d2->created = data->created; |
340 | d2->start = data->start; | 340 | d2->start = data->start; |
341 | d2->end = data->end; | 341 | d2->end = data->end; |
342 | d2->isAllDay = data->isAllDay; | 342 | d2->isAllDay = data->isAllDay; |
343 | d2->timezone = data->timezone; | 343 | d2->timezone = data->timezone; |
344 | d2->parent = data->parent; | 344 | d2->parent = data->parent; |
345 | 345 | ||
346 | if ( data->child ) { | 346 | if ( data->child ) { |
347 | d2->child = new QArray<int>( *data->child ); | 347 | d2->child = new QArray<int>( *data->child ); |
348 | d2->child->detach(); | 348 | d2->child->detach(); |
349 | } | 349 | } |
350 | 350 | ||
351 | data = d2; | 351 | data = d2; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | void OEvent::deref() { | 354 | void OEvent::deref() { |
355 | if ( data->deref() ) { | 355 | if ( data->deref() ) { |
356 | delete data; | 356 | delete data; |
357 | data = 0; | 357 | data = 0; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | // Exporting Event data to map. Using the same | 360 | // Exporting Event data to map. Using the same |
361 | // encoding as ODateBookAccessBackend_xml does.. | 361 | // encoding as ODateBookAccessBackend_xml does.. |
362 | // Thus, we could remove the stuff there and use this | 362 | // Thus, we could remove the stuff there and use this |
363 | // for it and for all other places.. | 363 | // for it and for all other places.. |
364 | // Encoding should happen at one place, only ! (eilers) | 364 | // Encoding should happen at one place, only ! (eilers) |
365 | QMap<int, QString> OEvent::toMap()const { | 365 | QMap<int, QString> OEvent::toMap()const { |
366 | QMap<int, QString> retMap; | 366 | QMap<int, QString> retMap; |
367 | 367 | ||
368 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); | 368 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); |
369 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); | 369 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); |
370 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); | 370 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); |
371 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); | 371 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); |
372 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); | 372 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); |
373 | OPimAlarm alarm = notifiers().alarms()[0]; | 373 | OPimAlarm alarm = notifiers().alarms()[0]; |
374 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); | 374 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); |
375 | retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); | 375 | retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); |
376 | 376 | ||
377 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 377 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
378 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); | 378 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); |
379 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); | 379 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); |
380 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); | 380 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); |
381 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? "None" : timeZone() ); | 381 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); |
382 | if( parent() ) | 382 | if( parent() ) |
383 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); | 383 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); |
384 | if( children().count() ){ | 384 | if( children().count() ){ |
385 | QArray<int> childr = children(); | 385 | QArray<int> childr = children(); |
386 | QString buf; | 386 | QString buf; |
387 | for ( uint i = 0; i < childr.count(); i++ ) { | 387 | for ( uint i = 0; i < childr.count(); i++ ) { |
388 | if ( i != 0 ) buf += " "; | 388 | if ( i != 0 ) buf += " "; |
389 | buf += QString::number( childr[i] ); | 389 | buf += QString::number( childr[i] ); |
390 | } | 390 | } |
391 | retMap.insert( OEvent::FRecChildren, buf ); | 391 | retMap.insert( OEvent::FRecChildren, buf ); |
392 | } | 392 | } |
393 | 393 | ||
394 | // Add recurrence stuff | 394 | // Add recurrence stuff |
395 | if( hasRecurrence() ){ | 395 | if( hasRecurrence() ){ |
396 | ORecur recur = recurrence(); | 396 | ORecur recur = recurrence(); |
397 | QMap<int, QString> recFields = recur.toMap(); | 397 | QMap<int, QString> recFields = recur.toMap(); |
398 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); | 398 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); |
399 | retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); | 399 | retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); |
400 | retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); | 400 | retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); |
401 | retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); | 401 | retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); |
402 | retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); | 402 | retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); |
403 | retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); | 403 | retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); |
404 | retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); | 404 | retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); |
405 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); | 405 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); |
406 | } | 406 | } |
407 | 407 | ||
408 | return retMap; | 408 | return retMap; |
409 | } | 409 | } |
410 | 410 | ||
411 | void OEvent::fromMap( const QMap<int, QString>& map ) | 411 | void OEvent::fromMap( const QMap<int, QString>& map ) |
412 | { | 412 | { |
413 | 413 | ||
414 | // We just want to set the UID if it is really stored. | 414 | // We just want to set the UID if it is really stored. |
415 | if ( !map[OEvent::FUid].isEmpty() ) | 415 | if ( !map[OEvent::FUid].isEmpty() ) |
416 | setUid( map[OEvent::FUid].toInt() ); | 416 | setUid( map[OEvent::FUid].toInt() ); |
417 | 417 | ||
418 | setCategories( idsFromString( map[OEvent::FCategories] ) ); | 418 | setCategories( idsFromString( map[OEvent::FCategories] ) ); |
419 | setDescription( map[OEvent::FDescription] ); | 419 | setDescription( map[OEvent::FDescription] ); |
420 | setLocation( map[OEvent::FLocation] ); | 420 | setLocation( map[OEvent::FLocation] ); |
421 | 421 | ||
422 | if ( map[OEvent::FType] == "AllDay" ) | 422 | if ( map[OEvent::FType] == "AllDay" ) |
423 | setAllDay( true ); | 423 | setAllDay( true ); |
424 | else | 424 | else |
425 | setAllDay( false ); | 425 | setAllDay( false ); |
426 | 426 | ||
427 | int alarmTime = -1; | 427 | int alarmTime = -1; |
428 | if( !map[OEvent::FAlarm].isEmpty() ) | 428 | if( !map[OEvent::FAlarm].isEmpty() ) |
429 | alarmTime = map[OEvent::FAlarm].toInt(); | 429 | alarmTime = map[OEvent::FAlarm].toInt(); |
430 | 430 | ||
431 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 431 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
432 | if ( ( alarmTime != -1 ) ){ | 432 | if ( ( alarmTime != -1 ) ){ |
433 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); | 433 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); |
434 | OPimAlarm al( sound , dt ); | 434 | OPimAlarm al( sound , dt ); |
435 | notifiers().add( al ); | 435 | notifiers().add( al ); |
436 | } | 436 | } |
437 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ | 437 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ |
438 | setTimeZone( map[OEvent::FTimeZone] ); | 438 | setTimeZone( map[OEvent::FTimeZone] ); |
439 | } | 439 | } |
440 | 440 | ||
441 | time_t start = (time_t) map[OEvent::FStart].toLong(); | 441 | time_t start = (time_t) map[OEvent::FStart].toLong(); |
442 | time_t end = (time_t) map[OEvent::FEnd].toLong(); | 442 | time_t end = (time_t) map[OEvent::FEnd].toLong(); |
443 | 443 | ||
444 | /* AllDay is always in UTC */ | 444 | /* AllDay is always in UTC */ |
445 | if ( isAllDay() ) { | 445 | if ( isAllDay() ) { |
446 | OTimeZone utc = OTimeZone::utc(); | 446 | OTimeZone utc = OTimeZone::utc(); |
447 | setStartDateTime( utc.fromUTCDateTime( start ) ); | 447 | setStartDateTime( utc.fromUTCDateTime( start ) ); |
448 | setEndDateTime ( utc.fromUTCDateTime( end ) ); | 448 | setEndDateTime ( utc.fromUTCDateTime( end ) ); |
449 | setTimeZone( "UTC"); // make sure it is really utc | 449 | setTimeZone( "UTC"); // make sure it is really utc |
450 | }else { | 450 | }else { |
451 | /* to current date time */ | 451 | /* to current date time */ |
452 | // qWarning(" Start is %d", start ); | 452 | // qWarning(" Start is %d", start ); |
453 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 453 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
454 | QDateTime date = zone.toDateTime( start ); | 454 | QDateTime date = zone.toDateTime( start ); |
455 | qWarning(" Start is %s", date.toString().latin1() ); | 455 | qWarning(" Start is %s", date.toString().latin1() ); |
456 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 456 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
457 | 457 | ||
458 | date = zone.toDateTime( end ); | 458 | date = zone.toDateTime( end ); |
459 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 459 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
460 | } | 460 | } |
461 | 461 | ||
462 | if ( !map[OEvent::FRecParent].isEmpty() ) | 462 | if ( !map[OEvent::FRecParent].isEmpty() ) |
463 | setParent( map[OEvent::FRecParent].toInt() ); | 463 | setParent( map[OEvent::FRecParent].toInt() ); |
464 | 464 | ||
465 | if ( !map[OEvent::FRecChildren].isEmpty() ){ | 465 | if ( !map[OEvent::FRecChildren].isEmpty() ){ |
466 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); | 466 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); |
467 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 467 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
468 | addChild( (*it).toInt() ); | 468 | addChild( (*it).toInt() ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. | 472 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. |
473 | if( !map[OEvent::FRType].isEmpty() ){ | 473 | if( !map[OEvent::FRType].isEmpty() ){ |
474 | QMap<int, QString> recFields; | 474 | QMap<int, QString> recFields; |
475 | recFields.insert( ORecur::RType, map[OEvent::FRType] ); | 475 | recFields.insert( ORecur::RType, map[OEvent::FRType] ); |
476 | recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); | 476 | recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); |
477 | recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); | 477 | recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); |
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index c916297..ec05e77 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -285,193 +285,193 @@ QString OEvent::toRichText()const { | |||
285 | 285 | ||
286 | //notes | 286 | //notes |
287 | if ( !note().isEmpty() ) { | 287 | if ( !note().isEmpty() ) { |
288 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 288 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
289 | text += note(); | 289 | text += note(); |
290 | // text += Qtopia::escapeString(note() ). | 290 | // text += Qtopia::escapeString(note() ). |
291 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 291 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
292 | } | 292 | } |
293 | return text; | 293 | return text; |
294 | } | 294 | } |
295 | QString OEvent::toShortText()const { | 295 | QString OEvent::toShortText()const { |
296 | QString text; | 296 | QString text; |
297 | text += QString::number( startDateTime().date().day() ); | 297 | text += QString::number( startDateTime().date().day() ); |
298 | text += "."; | 298 | text += "."; |
299 | text += QString::number( startDateTime().date().month() ); | 299 | text += QString::number( startDateTime().date().month() ); |
300 | text += "."; | 300 | text += "."; |
301 | text += QString::number( startDateTime().date().year() ); | 301 | text += QString::number( startDateTime().date().year() ); |
302 | text += " "; | 302 | text += " "; |
303 | text += QString::number( startDateTime().time().hour() ); | 303 | text += QString::number( startDateTime().time().hour() ); |
304 | text += ":"; | 304 | text += ":"; |
305 | text += QString::number( startDateTime().time().minute() ); | 305 | text += QString::number( startDateTime().time().minute() ); |
306 | text += " - "; | 306 | text += " - "; |
307 | text += description(); | 307 | text += description(); |
308 | return text; | 308 | return text; |
309 | } | 309 | } |
310 | QString OEvent::type()const { | 310 | QString OEvent::type()const { |
311 | return QString::fromLatin1("OEvent"); | 311 | return QString::fromLatin1("OEvent"); |
312 | } | 312 | } |
313 | QString OEvent::recordField( int /*id */ )const { | 313 | QString OEvent::recordField( int /*id */ )const { |
314 | return QString::null; | 314 | return QString::null; |
315 | } | 315 | } |
316 | int OEvent::rtti() { | 316 | int OEvent::rtti() { |
317 | return OPimResolver::DateBook; | 317 | return OPimResolver::DateBook; |
318 | } | 318 | } |
319 | bool OEvent::loadFromStream( QDataStream& ) { | 319 | bool OEvent::loadFromStream( QDataStream& ) { |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | bool OEvent::saveToStream( QDataStream& )const { | 322 | bool OEvent::saveToStream( QDataStream& )const { |
323 | return true; | 323 | return true; |
324 | } | 324 | } |
325 | void OEvent::changeOrModify() { | 325 | void OEvent::changeOrModify() { |
326 | if ( data->count != 1 ) { | 326 | if ( data->count != 1 ) { |
327 | data->deref(); | 327 | data->deref(); |
328 | Data* d2 = new Data; | 328 | Data* d2 = new Data; |
329 | d2->description = data->description; | 329 | d2->description = data->description; |
330 | d2->location = data->location; | 330 | d2->location = data->location; |
331 | 331 | ||
332 | if (data->manager ) | 332 | if (data->manager ) |
333 | d2->manager = new OPimNotifyManager( *data->manager ); | 333 | d2->manager = new OPimNotifyManager( *data->manager ); |
334 | 334 | ||
335 | if ( data->recur ) | 335 | if ( data->recur ) |
336 | d2->recur = new ORecur( *data->recur ); | 336 | d2->recur = new ORecur( *data->recur ); |
337 | 337 | ||
338 | d2->note = data->note; | 338 | d2->note = data->note; |
339 | d2->created = data->created; | 339 | d2->created = data->created; |
340 | d2->start = data->start; | 340 | d2->start = data->start; |
341 | d2->end = data->end; | 341 | d2->end = data->end; |
342 | d2->isAllDay = data->isAllDay; | 342 | d2->isAllDay = data->isAllDay; |
343 | d2->timezone = data->timezone; | 343 | d2->timezone = data->timezone; |
344 | d2->parent = data->parent; | 344 | d2->parent = data->parent; |
345 | 345 | ||
346 | if ( data->child ) { | 346 | if ( data->child ) { |
347 | d2->child = new QArray<int>( *data->child ); | 347 | d2->child = new QArray<int>( *data->child ); |
348 | d2->child->detach(); | 348 | d2->child->detach(); |
349 | } | 349 | } |
350 | 350 | ||
351 | data = d2; | 351 | data = d2; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | void OEvent::deref() { | 354 | void OEvent::deref() { |
355 | if ( data->deref() ) { | 355 | if ( data->deref() ) { |
356 | delete data; | 356 | delete data; |
357 | data = 0; | 357 | data = 0; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | // Exporting Event data to map. Using the same | 360 | // Exporting Event data to map. Using the same |
361 | // encoding as ODateBookAccessBackend_xml does.. | 361 | // encoding as ODateBookAccessBackend_xml does.. |
362 | // Thus, we could remove the stuff there and use this | 362 | // Thus, we could remove the stuff there and use this |
363 | // for it and for all other places.. | 363 | // for it and for all other places.. |
364 | // Encoding should happen at one place, only ! (eilers) | 364 | // Encoding should happen at one place, only ! (eilers) |
365 | QMap<int, QString> OEvent::toMap()const { | 365 | QMap<int, QString> OEvent::toMap()const { |
366 | QMap<int, QString> retMap; | 366 | QMap<int, QString> retMap; |
367 | 367 | ||
368 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); | 368 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); |
369 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); | 369 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); |
370 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); | 370 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); |
371 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); | 371 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); |
372 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); | 372 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); |
373 | OPimAlarm alarm = notifiers().alarms()[0]; | 373 | OPimAlarm alarm = notifiers().alarms()[0]; |
374 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); | 374 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); |
375 | retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); | 375 | retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); |
376 | 376 | ||
377 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 377 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
378 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); | 378 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); |
379 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); | 379 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); |
380 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); | 380 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); |
381 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? "None" : timeZone() ); | 381 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); |
382 | if( parent() ) | 382 | if( parent() ) |
383 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); | 383 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); |
384 | if( children().count() ){ | 384 | if( children().count() ){ |
385 | QArray<int> childr = children(); | 385 | QArray<int> childr = children(); |
386 | QString buf; | 386 | QString buf; |
387 | for ( uint i = 0; i < childr.count(); i++ ) { | 387 | for ( uint i = 0; i < childr.count(); i++ ) { |
388 | if ( i != 0 ) buf += " "; | 388 | if ( i != 0 ) buf += " "; |
389 | buf += QString::number( childr[i] ); | 389 | buf += QString::number( childr[i] ); |
390 | } | 390 | } |
391 | retMap.insert( OEvent::FRecChildren, buf ); | 391 | retMap.insert( OEvent::FRecChildren, buf ); |
392 | } | 392 | } |
393 | 393 | ||
394 | // Add recurrence stuff | 394 | // Add recurrence stuff |
395 | if( hasRecurrence() ){ | 395 | if( hasRecurrence() ){ |
396 | ORecur recur = recurrence(); | 396 | ORecur recur = recurrence(); |
397 | QMap<int, QString> recFields = recur.toMap(); | 397 | QMap<int, QString> recFields = recur.toMap(); |
398 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); | 398 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); |
399 | retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); | 399 | retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); |
400 | retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); | 400 | retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); |
401 | retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); | 401 | retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); |
402 | retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); | 402 | retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); |
403 | retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); | 403 | retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); |
404 | retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); | 404 | retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); |
405 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); | 405 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); |
406 | } | 406 | } |
407 | 407 | ||
408 | return retMap; | 408 | return retMap; |
409 | } | 409 | } |
410 | 410 | ||
411 | void OEvent::fromMap( const QMap<int, QString>& map ) | 411 | void OEvent::fromMap( const QMap<int, QString>& map ) |
412 | { | 412 | { |
413 | 413 | ||
414 | // We just want to set the UID if it is really stored. | 414 | // We just want to set the UID if it is really stored. |
415 | if ( !map[OEvent::FUid].isEmpty() ) | 415 | if ( !map[OEvent::FUid].isEmpty() ) |
416 | setUid( map[OEvent::FUid].toInt() ); | 416 | setUid( map[OEvent::FUid].toInt() ); |
417 | 417 | ||
418 | setCategories( idsFromString( map[OEvent::FCategories] ) ); | 418 | setCategories( idsFromString( map[OEvent::FCategories] ) ); |
419 | setDescription( map[OEvent::FDescription] ); | 419 | setDescription( map[OEvent::FDescription] ); |
420 | setLocation( map[OEvent::FLocation] ); | 420 | setLocation( map[OEvent::FLocation] ); |
421 | 421 | ||
422 | if ( map[OEvent::FType] == "AllDay" ) | 422 | if ( map[OEvent::FType] == "AllDay" ) |
423 | setAllDay( true ); | 423 | setAllDay( true ); |
424 | else | 424 | else |
425 | setAllDay( false ); | 425 | setAllDay( false ); |
426 | 426 | ||
427 | int alarmTime = -1; | 427 | int alarmTime = -1; |
428 | if( !map[OEvent::FAlarm].isEmpty() ) | 428 | if( !map[OEvent::FAlarm].isEmpty() ) |
429 | alarmTime = map[OEvent::FAlarm].toInt(); | 429 | alarmTime = map[OEvent::FAlarm].toInt(); |
430 | 430 | ||
431 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 431 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
432 | if ( ( alarmTime != -1 ) ){ | 432 | if ( ( alarmTime != -1 ) ){ |
433 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); | 433 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); |
434 | OPimAlarm al( sound , dt ); | 434 | OPimAlarm al( sound , dt ); |
435 | notifiers().add( al ); | 435 | notifiers().add( al ); |
436 | } | 436 | } |
437 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ | 437 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ |
438 | setTimeZone( map[OEvent::FTimeZone] ); | 438 | setTimeZone( map[OEvent::FTimeZone] ); |
439 | } | 439 | } |
440 | 440 | ||
441 | time_t start = (time_t) map[OEvent::FStart].toLong(); | 441 | time_t start = (time_t) map[OEvent::FStart].toLong(); |
442 | time_t end = (time_t) map[OEvent::FEnd].toLong(); | 442 | time_t end = (time_t) map[OEvent::FEnd].toLong(); |
443 | 443 | ||
444 | /* AllDay is always in UTC */ | 444 | /* AllDay is always in UTC */ |
445 | if ( isAllDay() ) { | 445 | if ( isAllDay() ) { |
446 | OTimeZone utc = OTimeZone::utc(); | 446 | OTimeZone utc = OTimeZone::utc(); |
447 | setStartDateTime( utc.fromUTCDateTime( start ) ); | 447 | setStartDateTime( utc.fromUTCDateTime( start ) ); |
448 | setEndDateTime ( utc.fromUTCDateTime( end ) ); | 448 | setEndDateTime ( utc.fromUTCDateTime( end ) ); |
449 | setTimeZone( "UTC"); // make sure it is really utc | 449 | setTimeZone( "UTC"); // make sure it is really utc |
450 | }else { | 450 | }else { |
451 | /* to current date time */ | 451 | /* to current date time */ |
452 | // qWarning(" Start is %d", start ); | 452 | // qWarning(" Start is %d", start ); |
453 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 453 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
454 | QDateTime date = zone.toDateTime( start ); | 454 | QDateTime date = zone.toDateTime( start ); |
455 | qWarning(" Start is %s", date.toString().latin1() ); | 455 | qWarning(" Start is %s", date.toString().latin1() ); |
456 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 456 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
457 | 457 | ||
458 | date = zone.toDateTime( end ); | 458 | date = zone.toDateTime( end ); |
459 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 459 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
460 | } | 460 | } |
461 | 461 | ||
462 | if ( !map[OEvent::FRecParent].isEmpty() ) | 462 | if ( !map[OEvent::FRecParent].isEmpty() ) |
463 | setParent( map[OEvent::FRecParent].toInt() ); | 463 | setParent( map[OEvent::FRecParent].toInt() ); |
464 | 464 | ||
465 | if ( !map[OEvent::FRecChildren].isEmpty() ){ | 465 | if ( !map[OEvent::FRecChildren].isEmpty() ){ |
466 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); | 466 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); |
467 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 467 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
468 | addChild( (*it).toInt() ); | 468 | addChild( (*it).toInt() ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. | 472 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. |
473 | if( !map[OEvent::FRType].isEmpty() ){ | 473 | if( !map[OEvent::FRType].isEmpty() ){ |
474 | QMap<int, QString> recFields; | 474 | QMap<int, QString> recFields; |
475 | recFields.insert( ORecur::RType, map[OEvent::FRType] ); | 475 | recFields.insert( ORecur::RType, map[OEvent::FRType] ); |
476 | recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); | 476 | recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); |
477 | recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); | 477 | recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); |