author | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
commit | 52b1ae9281920cf5a40fe543112d8b00e7699ef6 (patch) (side-by-side diff) | |
tree | 0b0a79ff9a45a66f32fe555ee662b4acc8f6eff9 /libopie2/opiepim/backend | |
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
-...
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 63 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.h | 2 |
2 files changed, 43 insertions, 22 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 107c178..0f99d50 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp @@ -90,3 +90,3 @@ namespace { OPimRecurrence* rec; - OPimRecurrence* recur() { + static OPimRecurrence* recur() { if (!rec) @@ -123,3 +123,3 @@ namespace { // FIXME: Use OPimEvent::toMap() here !! (eilers) - inline void save( const OPimEvent& ev, QString& buf ) { + static void save( const OPimEvent& ev, QString& buf ) { owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl; @@ -129,3 +129,5 @@ namespace { + if (!ev.categories().isEmpty() ) buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; + buf += " uid=\"" + QString::number( ev.uid() ) + "\""; @@ -154,5 +156,5 @@ namespace { */ - OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); - buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OPimTimeZone::utc() ) ) ) + "\""; - buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OPimTimeZone::utc() ) ) ) + "\""; + OPimTimeZone zone( (ev.timeZone().isEmpty()||ev.isAllDay()) ? OPimTimeZone::utc() : OPimTimeZone::current() ); + buf += " start=\"" + QString::number( zone.fromDateTime( ev.startDateTime())) + "\""; + buf += " end=\"" + QString::number( zone.fromDateTime( ev.endDateTime() )) + "\""; if (!ev.note().isEmpty() ) { @@ -161,2 +163,8 @@ namespace { + /* + * Don't save a timezone if AllDay Events + * as they're UTC only anyway + */ + if (!ev.isAllDay() ) { + buf += " timezone=\""; @@ -167,2 +175,3 @@ namespace { buf += "\""; + } @@ -185,3 +194,3 @@ namespace { - inline bool forAll( const QMap<int, OPimEvent>& list, QFile& file ) { + static bool saveEachEvent( const QMap<int, OPimEvent>& list, QFile& file ) { QMap<int, OPimEvent>::ConstIterator it; @@ -240,3 +249,3 @@ bool ODateBookAccessBackend_XML::save() { - if (!forAll( m_raw, f ) ) { + if (!saveEachEvent( m_raw, f ) ) { f.close(); @@ -245,3 +254,3 @@ bool ODateBookAccessBackend_XML::save() { } - if (!forAll( m_rep, f ) ) { + if (!saveEachEvent( m_rep, f ) ) { f.close(); @@ -408,2 +417,6 @@ bool ODateBookAccessBackend_XML::loadFile() { + + // initialiaze db hack + m_noTimeZone = true; + char* dt = (char*)map_addr; @@ -481,2 +494,3 @@ bool ODateBookAccessBackend_XML::loadFile() { delete rec; + m_noTimeZone = true; } @@ -490,2 +504,12 @@ bool ODateBookAccessBackend_XML::loadFile() { void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { + + /* + * quirk to import datebook files. They normally don't have a + * timeZone attribute and we treat this as to use OPimTimeZone::current() + */ + if (m_noTimeZone ) + ev.setTimeZone( OPimTimeZone::current().timeZone() ); + + + /* AllDay is alway in UTC */ @@ -493,15 +517,10 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { OPimTimeZone utc = OPimTimeZone::utc(); - ev.setStartDateTime( utc.fromUTCDateTime( start ) ); - ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); - ev.setTimeZone( "UTC"); // make sure it is really utc + ev.setStartDateTime( utc.toDateTime( start ) ); + ev.setEndDateTime ( utc.toDateTime( end ) ); }else { /* to current date time */ - // owarn << " Start is " << start << "" << oendl; - OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); - QDateTime date = zone.toDateTime( start ); - owarn << " Start is " << date.toString() << "" << oendl; - ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); + OPimTimeZone to_zone( ev.timeZone().isEmpty() ? OPimTimeZone::utc() : OPimTimeZone::current() ); - date = zone.toDateTime( end ); - ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); + ev.setStartDateTime(to_zone.toDateTime( start)); + ev.setEndDateTime (to_zone.toDateTime( end)); } @@ -510,4 +529,4 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { OPimRecurrence recu( *rec ); // call copy c'tor; - recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); - recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); + recu.setEndDate ( utc.toDateTime( rp_end ).date() ); + recu.setCreatedDateTime( utc.toDateTime( created ) ); recu.setStart( ev.startDateTime().date() ); @@ -525,3 +544,3 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { } - owarn << "addind " << ev.uid() << " " << ev.description() << "" << oendl; + if ( ev.hasRecurrence() ) @@ -550,3 +569,2 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& e.setAllDay( true ); - e.setTimeZone( "UTC" ); } @@ -624,2 +642,3 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& case FTimeZone: + m_noTimeZone = false; if ( value != "None" ) diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h index 6823ce6..af5b114 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h @@ -70,2 +70,4 @@ private: bool m_changed :1 ; + bool m_noTimeZone : 1; + bool loadFile(); |