author | zecke <zecke> | 2003-02-22 18:51:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-22 18:51:44 (UTC) |
commit | 7b04887e382227c80c8985495f01dad2b1890719 (patch) (unidiff) | |
tree | 31db88fd0519c7f03ff05560f21ba69256765d5e /libopie/pim/odatebookaccessbackend_xml.cpp | |
parent | 2424bcd292444b3a03c9b92dbc7f5b392c355755 (diff) | |
download | opie-7b04887e382227c80c8985495f01dad2b1890719.zip opie-7b04887e382227c80c8985495f01dad2b1890719.tar.gz opie-7b04887e382227c80c8985495f01dad2b1890719.tar.bz2 |
Fix saving
remove the transport medium from the opimmainwindow
Diffstat (limited to 'libopie/pim/odatebookaccessbackend_xml.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/pim/odatebookaccessbackend_xml.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index 24b69fe..4a6b7b8 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp | |||
@@ -75,24 +75,25 @@ namespace { | |||
75 | FRHasEndDate, | 75 | FRHasEndDate, |
76 | FREndDate, | 76 | FREndDate, |
77 | FRStart, | 77 | FRStart, |
78 | FREnd, | 78 | FREnd, |
79 | FNote, | 79 | FNote, |
80 | FCreated, | 80 | FCreated, |
81 | FTimeZone, | 81 | FTimeZone, |
82 | FRecParent, | 82 | FRecParent, |
83 | FRecChildren, | 83 | FRecChildren, |
84 | FExceptions | 84 | FExceptions |
85 | }; | 85 | }; |
86 | inline void save( const OEvent& ev, QString& buf ) { | 86 | inline void save( const OEvent& ev, QString& buf ) { |
87 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | ||
87 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 88 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
88 | if (!ev.location().isEmpty() ) | 89 | if (!ev.location().isEmpty() ) |
89 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 90 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
90 | 91 | ||
91 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 92 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
92 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; | 93 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; |
93 | 94 | ||
94 | if (ev.isAllDay() ) | 95 | if (ev.isAllDay() ) |
95 | buf += " type=\"AllDay\""; | 96 | buf += " type=\"AllDay\""; |
96 | 97 | ||
97 | if (ev.hasNotifiers() ) { | 98 | if (ev.hasNotifiers() ) { |
98 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first | 99 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first |
@@ -116,24 +117,25 @@ namespace { | |||
116 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 117 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
117 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; | 118 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; |
118 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; | 119 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; |
119 | if (!ev.note().isEmpty() ) { | 120 | if (!ev.note().isEmpty() ) { |
120 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; | 121 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; |
121 | } | 122 | } |
122 | 123 | ||
123 | buf += " timezone=\""; | 124 | buf += " timezone=\""; |
124 | if ( ev.timeZone().isEmpty() ) | 125 | if ( ev.timeZone().isEmpty() ) |
125 | buf += "None"; | 126 | buf += "None"; |
126 | else | 127 | else |
127 | buf += ev.timeZone(); | 128 | buf += ev.timeZone(); |
129 | buf += "\""; | ||
128 | 130 | ||
129 | if (ev.parent() != 0 ) { | 131 | if (ev.parent() != 0 ) { |
130 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; | 132 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; |
131 | } | 133 | } |
132 | 134 | ||
133 | if (ev.children().count() != 0 ) { | 135 | if (ev.children().count() != 0 ) { |
134 | QArray<int> children = ev.children(); | 136 | QArray<int> children = ev.children(); |
135 | buf += " recchildren=\""; | 137 | buf += " recchildren=\""; |
136 | for ( uint i = 0; i < children.count(); i++ ) { | 138 | for ( uint i = 0; i < children.count(); i++ ) { |
137 | if ( i != 0 ) buf += " "; | 139 | if ( i != 0 ) buf += " "; |
138 | buf += QString::number( children[i] ); | 140 | buf += QString::number( children[i] ); |
139 | } | 141 | } |
@@ -425,65 +427,68 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
425 | /* | 427 | /* |
426 | * add key + value | 428 | * add key + value |
427 | */ | 429 | */ |
428 | find = dict[attr.data()]; | 430 | find = dict[attr.data()]; |
429 | if (!find) | 431 | if (!find) |
430 | ev.setCustomField( attr, value ); | 432 | ev.setCustomField( attr, value ); |
431 | else { | 433 | else { |
432 | setField( ev, *find, value ); | 434 | setField( ev, *find, value ); |
433 | } | 435 | } |
434 | } | 436 | } |
435 | /* time to finalize */ | 437 | /* time to finalize */ |
436 | finalizeRecord( ev ); | 438 | finalizeRecord( ev ); |
437 | add( ev ); | ||
438 | delete rec; | 439 | delete rec; |
439 | } | 440 | } |
440 | ::munmap(map_addr, attribute.st_size ); | 441 | ::munmap(map_addr, attribute.st_size ); |
441 | m_changed = false; // changed during add | 442 | m_changed = false; // changed during add |
442 | 443 | ||
443 | return true; | 444 | return true; |
444 | } | 445 | } |
445 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 446 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
446 | /* AllDay is alway in UTC */ | 447 | /* AllDay is alway in UTC */ |
447 | if ( ev.isAllDay() ) { | 448 | if ( ev.isAllDay() ) { |
448 | OTimeZone utc = OTimeZone::utc(); | 449 | OTimeZone utc = OTimeZone::utc(); |
449 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 450 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
450 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 451 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
451 | ev.setTimeZone( "UTC"); // make sure it is really utc | 452 | ev.setTimeZone( "UTC"); // make sure it is really utc |
452 | }else { | 453 | }else { |
453 | /* to current date time */ | 454 | /* to current date time */ |
455 | qWarning(" Start is %d", start ); | ||
454 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 456 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
455 | QDateTime date = zone.toDateTime( start ); | 457 | QDateTime date = zone.toDateTime( start ); |
458 | qWarning(" Start is %s", date.toString().latin1() ); | ||
456 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 459 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
457 | 460 | ||
458 | date = zone.toDateTime( end ); | 461 | date = zone.toDateTime( end ); |
459 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 462 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
460 | } | 463 | } |
461 | if ( rec && rec->doesRecur() ) { | 464 | if ( rec && rec->doesRecur() ) { |
462 | OTimeZone utc = OTimeZone::utc(); | 465 | OTimeZone utc = OTimeZone::utc(); |
463 | ORecur recu( *rec ); // call copy c'tor; | 466 | ORecur recu( *rec ); // call copy c'tor; |
464 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 467 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
465 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 468 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
466 | recu.setStart( ev.startDateTime().date() ); | 469 | recu.setStart( ev.startDateTime().date() ); |
467 | ev.setRecurrence( recu ); | 470 | ev.setRecurrence( recu ); |
468 | } | 471 | } |
469 | 472 | ||
470 | if (alarmTime != -1 ) { | 473 | if (alarmTime != -1 ) { |
471 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 474 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
472 | OPimAlarm al( snd , dt ); | 475 | OPimAlarm al( snd , dt ); |
473 | ev.notifiers().add( al ); | 476 | ev.notifiers().add( al ); |
474 | } | 477 | } |
475 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 478 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
479 | qWarning("already contains assign uid"); | ||
476 | ev.setUid( 1 ); | 480 | ev.setUid( 1 ); |
477 | } | 481 | } |
482 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | ||
478 | if ( ev.hasRecurrence() ) | 483 | if ( ev.hasRecurrence() ) |
479 | m_rep.insert( ev.uid(), ev ); | 484 | m_rep.insert( ev.uid(), ev ); |
480 | else | 485 | else |
481 | m_raw.insert( ev.uid(), ev ); | 486 | m_raw.insert( ev.uid(), ev ); |
482 | 487 | ||
483 | } | 488 | } |
484 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 489 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { |
485 | // qWarning(" setting %s", value.latin1() ); | 490 | // qWarning(" setting %s", value.latin1() ); |
486 | switch( id ) { | 491 | switch( id ) { |
487 | case FDescription: | 492 | case FDescription: |
488 | e.setDescription( value ); | 493 | e.setDescription( value ); |
489 | break; | 494 | break; |