author | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
commit | 52b1ae9281920cf5a40fe543112d8b00e7699ef6 (patch) (unidiff) | |
tree | 0b0a79ff9a45a66f32fe555ee662b4acc8f6eff9 /libopie2/opiepim/core/opimevent.cpp | |
parent | c170d1f931ae03c2ec917b7abf4bd5d0e94a3760 (diff) | |
download | opie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.zip opie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.tar.gz opie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.tar.bz2 |
-UTC -> Europe/London when referring to no timezone
-special handling for allDay Event in OPImEvent, avoid setting timezone
as it is by default UTC
-No timezone set by default for an Event
-Recurrence is UTC (no timezone)
-Provide upgrade path from DateBook as by default events were in the current timezone but didn't have the timezone attribute
-unified handling of timezones, compatible with QtopiaDesktop
-do less conversions
-...
Diffstat (limited to 'libopie2/opiepim/core/opimevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp index 8752fce..739cb6f 100644 --- a/libopie2/opiepim/core/opimevent.cpp +++ b/libopie2/opiepim/core/opimevent.cpp | |||
@@ -291,18 +291,20 @@ void OPimEvent::setStartDateTime( const QDateTime& dt ) | |||
291 | 291 | ||
292 | 292 | ||
293 | QDateTime OPimEvent::endDateTime() const | 293 | QDateTime OPimEvent::endDateTime() const |
294 | { | 294 | { |
295 | /* | 295 | /* |
296 | * if all Day event the end time needs | 296 | * if all Day event the end time needs |
297 | * to be on the same day as the start | 297 | * to be on the same day as the start |
298 | */ | 298 | */ |
299 | if ( data->isAllDay ) | 299 | if ( data->isAllDay ) { |
300 | return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); | 300 | QDate end = data->end.isValid() ? data->end.date() : data->start.date() ; |
301 | return QDateTime( end, QTime( 23, 59, 59 ) ); | ||
302 | } | ||
301 | return data->end; | 303 | return data->end; |
302 | } | 304 | } |
303 | 305 | ||
304 | 306 | ||
305 | QDateTime OPimEvent::endDateTimeInZone() const | 307 | QDateTime OPimEvent::endDateTimeInZone() const |
306 | { | 308 | { |
307 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 309 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
308 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); | 310 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); |
@@ -330,30 +332,29 @@ bool OPimEvent::isAllDay() const | |||
330 | return data->isAllDay; | 332 | return data->isAllDay; |
331 | } | 333 | } |
332 | 334 | ||
333 | 335 | ||
334 | void OPimEvent::setAllDay( bool allDay ) | 336 | void OPimEvent::setAllDay( bool allDay ) |
335 | { | 337 | { |
336 | changeOrModify(); | 338 | changeOrModify(); |
337 | data->isAllDay = allDay; | 339 | data->isAllDay = allDay; |
338 | if ( allDay ) data->timezone = "UTC"; | ||
339 | } | 340 | } |
340 | 341 | ||
341 | 342 | ||
342 | void OPimEvent::setTimeZone( const QString& tz ) | 343 | void OPimEvent::setTimeZone( const QString& tz ) |
343 | { | 344 | { |
344 | changeOrModify(); | 345 | changeOrModify(); |
345 | data->timezone = tz; | 346 | data->timezone = tz; |
346 | } | 347 | } |
347 | 348 | ||
348 | 349 | ||
349 | QString OPimEvent::timeZone() const | 350 | QString OPimEvent::timeZone() const |
350 | { | 351 | { |
351 | if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); | 352 | if ( data->isAllDay ) return QString::fromLatin1( "Europe/London" ); |
352 | return data->timezone; | 353 | return data->timezone; |
353 | } | 354 | } |
354 | 355 | ||
355 | 356 | ||
356 | bool OPimEvent::match( const QRegExp& re ) const | 357 | bool OPimEvent::match( const QRegExp& re ) const |
357 | { | 358 | { |
358 | if ( re.match( data->description ) != -1 ) | 359 | if ( re.match( data->description ) != -1 ) |
359 | { | 360 | { |
@@ -559,19 +560,20 @@ QMap<int, QString> OPimEvent::toMap() const | |||
559 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); | 560 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); |
560 | if ( notifiers().alarms().count() ){ | 561 | if ( notifiers().alarms().count() ){ |
561 | // Currently we just support one alarm.. (eilers) | 562 | // Currently we just support one alarm.. (eilers) |
562 | OPimAlarm alarm = notifiers().alarms() [ 0 ]; | 563 | OPimAlarm alarm = notifiers().alarms() [ 0 ]; |
563 | retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); | 564 | retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); |
564 | retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); | 565 | retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); |
565 | } | 566 | } |
566 | 567 | ||
567 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); | 568 | /* either use UTC timeZone or current() if there is was a timezone set */ |
568 | retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); | 569 | OPimTimeZone zone( (timeZone().isEmpty()||isAllDay()) ? OPimTimeZone::utc() : OPimTimeZone::current() ); |
569 | retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); | 570 | retMap.insert( OPimEvent::FStart, QString::number( zone.fromDateTime( startDateTime()))); |
571 | retMap.insert( OPimEvent::FEnd, QString::number( zone.fromDateTime( endDateTime() ))); | ||
570 | retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); | 572 | retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); |
571 | retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); | 573 | retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); |
572 | if ( parent() ) | 574 | if ( parent() ) |
573 | retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); | 575 | retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); |
574 | if ( children().count() ) | 576 | if ( children().count() ) |
575 | { | 577 | { |
576 | QArray<int> childr = children(); | 578 | QArray<int> childr = children(); |
577 | QString buf; | 579 | QString buf; |
@@ -625,37 +627,31 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) | |||
625 | setAllDay( false ); | 627 | setAllDay( false ); |
626 | 628 | ||
627 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) | 629 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) |
628 | { | 630 | { |
629 | setTimeZone( map[ OPimEvent::FTimeZone ] ); | 631 | setTimeZone( map[ OPimEvent::FTimeZone ] ); |
630 | } | 632 | } |
631 | 633 | ||
632 | time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); | 634 | time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); |
633 | time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); | 635 | time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); |
634 | 636 | ||
635 | /* AllDay is always in UTC */ | 637 | /* AllDay is always in UTC */ |
636 | if ( isAllDay() ) | 638 | if ( isAllDay() ) |
637 | { | 639 | { |
638 | OPimTimeZone utc = OPimTimeZone::utc(); | 640 | OPimTimeZone utc = OPimTimeZone::utc(); |
639 | setStartDateTime( utc.fromUTCDateTime( start ) ); | 641 | setStartDateTime(utc.toDateTime( start ) ); |
640 | setEndDateTime ( utc.fromUTCDateTime( end ) ); | 642 | setEndDateTime ( utc.toDateTime( end ) ); |
641 | setTimeZone( "UTC" ); // make sure it is really utc | ||
642 | } | 643 | } |
643 | else | 644 | else { |
644 | { | ||
645 | /* to current date time */ | 645 | /* to current date time */ |
646 | // owarn << " Start is " << start << "" << oendl; | 646 | OPimTimeZone to_zone( ev.timeZone().isEmpty() ? OPimTimeZone::utc() : OPimTimeZone::current() ); |
647 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); | 647 | |
648 | QDateTime date = zone.toDateTime( start ); | 648 | ev.setStartDateTime(to_zone.toDateTime( start)); |
649 | owarn << " Start is " << date.toString() << "" << oendl; | 649 | ev.setEndDateTime (to_zone.toDateTime( end)); |
650 | setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); | ||
651 | |||
652 | date = zone.toDateTime( end ); | ||
653 | setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); | ||
654 | } | 650 | } |
655 | 651 | ||
656 | int alarmTime = -1; | 652 | int alarmTime = -1; |
657 | if ( !map[ OPimEvent::FAlarm ].isEmpty() ) | 653 | if ( !map[ OPimEvent::FAlarm ].isEmpty() ) |
658 | alarmTime = map[ OPimEvent::FAlarm ].toInt(); | 654 | alarmTime = map[ OPimEvent::FAlarm ].toInt(); |
659 | 655 | ||
660 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 656 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
661 | if ( ( alarmTime != -1 ) ) | 657 | if ( ( alarmTime != -1 ) ) |