summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 0f99d50..55e47e2 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -113,25 +113,24 @@ namespace {
113 FRStart, 113 FRStart,
114 FREnd, 114 FREnd,
115 FNote, 115 FNote,
116 FCreated, // Should't this be called FRCreated ? 116 FCreated, // Should't this be called FRCreated ?
117 FTimeZone, 117 FTimeZone,
118 FRecParent, 118 FRecParent,
119 FRecChildren, 119 FRecChildren,
120 FExceptions 120 FExceptions
121 }; 121 };
122 122
123 // FIXME: Use OPimEvent::toMap() here !! (eilers) 123 // FIXME: Use OPimEvent::toMap() here !! (eilers)
124 static void save( const OPimEvent& ev, QString& buf ) { 124 static void save( const OPimEvent& ev, QString& buf ) {
125 owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl;
126 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; 125 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
127 if (!ev.location().isEmpty() ) 126 if (!ev.location().isEmpty() )
128 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; 127 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\"";
129 128
130 if (!ev.categories().isEmpty() ) 129 if (!ev.categories().isEmpty() )
131 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; 130 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\"";
132 131
133 buf += " uid=\"" + QString::number( ev.uid() ) + "\""; 132 buf += " uid=\"" + QString::number( ev.uid() ) + "\"";
134 133
135 if (ev.isAllDay() ) 134 if (ev.isAllDay() )
136 buf += " type=\"AllDay\""; // is that all ?? (eilers) 135 buf += " type=\"AllDay\""; // is that all ?? (eilers)
137 136
@@ -317,60 +316,58 @@ bool ODateBookAccessBackend_XML::add( const OPimEvent& ev ) {
317} 316}
318bool ODateBookAccessBackend_XML::remove( int uid ) { 317bool ODateBookAccessBackend_XML::remove( int uid ) {
319 m_changed = true; 318 m_changed = true;
320 m_raw.remove( uid ); 319 m_raw.remove( uid );
321 m_rep.remove( uid ); 320 m_rep.remove( uid );
322 321
323 return true; 322 return true;
324} 323}
325bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) { 324bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) {
326 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) 325 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers)
327 return add( ev ); 326 return add( ev );
328} 327}
329QArray<int> ODateBookAccessBackend_XML::rawEvents()const { 328
330 return allRecords();
331}
332QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { 329QArray<int> ODateBookAccessBackend_XML::rawRepeats()const {
333 QArray<int> ints( m_rep.count() ); 330 QArray<int> ints( m_rep.count() );
334 uint i = 0; 331 uint i = 0;
335 QMap<int, OPimEvent>::ConstIterator it; 332 QMap<int, OPimEvent>::ConstIterator it;
336 333
337 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { 334 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) {
338 ints[i] = it.key(); 335 ints[i] = it.key();
339 i++; 336 i++;
340 } 337 }
341 338
342 return ints; 339 return ints;
343} 340}
344QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { 341QArray<int> ODateBookAccessBackend_XML::nonRepeats()const {
345 QArray<int> ints( m_raw.count() ); 342 QArray<int> ints( m_raw.count() );
346 uint i = 0; 343 uint i = 0;
347 QMap<int, OPimEvent>::ConstIterator it; 344 QMap<int, OPimEvent>::ConstIterator it;
348 345
349 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { 346 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) {
350 ints[i] = it.key(); 347 ints[i] = it.key();
351 i++; 348 i++;
352 } 349 }
353 350
354 return ints; 351 return ints;
355} 352}
356OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { 353OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats()const {
357 OPimEvent::ValueList list; 354 OPimEvent::ValueList list;
358 QMap<int, OPimEvent>::ConstIterator it; 355 QMap<int, OPimEvent>::ConstIterator it;
359 for (it = m_raw.begin(); it != m_raw.end(); ++it ) 356 for (it = m_raw.begin(); it != m_raw.end(); ++it )
360 list.append( it.data() ); 357 list.append( it.data() );
361 358
362 return list; 359 return list;
363} 360}
364OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { 361OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats()const {
365 OPimEvent::ValueList list; 362 OPimEvent::ValueList list;
366 QMap<int, OPimEvent>::ConstIterator it; 363 QMap<int, OPimEvent>::ConstIterator it;
367 for (it = m_rep.begin(); it != m_rep.end(); ++it ) 364 for (it = m_rep.begin(); it != m_rep.end(); ++it )
368 list.append( it.data() ); 365 list.append( it.data() );
369 366
370 return list; 367 return list;
371} 368}
372 369
373// FIXME: Use OPimEvent::fromMap() (eilers) 370// FIXME: Use OPimEvent::fromMap() (eilers)
374bool ODateBookAccessBackend_XML::loadFile() { 371bool ODateBookAccessBackend_XML::loadFile() {
375 m_changed = false; 372 m_changed = false;
376 373
@@ -530,36 +527,34 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
530 recu.setEndDate ( utc.toDateTime( rp_end ).date() ); 527 recu.setEndDate ( utc.toDateTime( rp_end ).date() );
531 recu.setCreatedDateTime( utc.toDateTime( created ) ); 528 recu.setCreatedDateTime( utc.toDateTime( created ) );
532 recu.setStart( ev.startDateTime().date() ); 529 recu.setStart( ev.startDateTime().date() );
533 ev.setRecurrence( recu ); 530 ev.setRecurrence( recu );
534 } 531 }
535 532
536 if (alarmTime != -1 ) { 533 if (alarmTime != -1 ) {
537 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 534 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
538 OPimAlarm al( snd , dt ); 535 OPimAlarm al( snd , dt );
539 ev.notifiers().add( al ); 536 ev.notifiers().add( al );
540 } 537 }
541 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 538 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
542 owarn << "already contains assign uid" << oendl;
543 ev.setUid( 1 ); 539 ev.setUid( 1 );
544 } 540 }
545 541
546 if ( ev.hasRecurrence() ) 542 if ( ev.hasRecurrence() )
547 m_rep.insert( ev.uid(), ev ); 543 m_rep.insert( ev.uid(), ev );
548 else 544 else
549 m_raw.insert( ev.uid(), ev ); 545 m_raw.insert( ev.uid(), ev );
550 546
551} 547}
552void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) { 548void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) {
553// owarn << " setting " << value << "" << oendl;
554 switch( id ) { 549 switch( id ) {
555 case FDescription: 550 case FDescription:
556 e.setDescription( value ); 551 e.setDescription( value );
557 break; 552 break;
558 case FLocation: 553 case FLocation:
559 e.setLocation( value ); 554 e.setLocation( value );
560 break; 555 break;
561 case FCategories: 556 case FCategories:
562 e.setCategories( e.idsFromString( value ) ); 557 e.setCategories( e.idsFromString( value ) );
563 break; 558 break;
564 case FUid: 559 case FUid:
565 e.setUid( value.toInt() ); 560 e.setUid( value.toInt() );
@@ -625,25 +620,24 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
625 break; 620 break;
626 case FRecChildren:{ 621 case FRecChildren:{
627 QStringList list = QStringList::split(' ', value ); 622 QStringList list = QStringList::split(' ', value );
628 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 623 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
629 e.addChild( (*it).toInt() ); 624 e.addChild( (*it).toInt() );
630 } 625 }
631 } 626 }
632 break; 627 break;
633 case FExceptions:{ 628 case FExceptions:{
634 QStringList list = QStringList::split(' ', value ); 629 QStringList list = QStringList::split(' ', value );
635 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 630 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
636 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 631 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
637 owarn << "adding exception " << date.toString() << "" << oendl;
638 recur()->exceptions().append( date ); 632 recur()->exceptions().append( date );
639 } 633 }
640 } 634 }
641 break; 635 break;
642 case FTimeZone: 636 case FTimeZone:
643 m_noTimeZone = false; 637 m_noTimeZone = false;
644 if ( value != "None" ) 638 if ( value != "None" )
645 e.setTimeZone( value ); 639 e.setTimeZone( value );
646 break; 640 break;
647 default: 641 default:
648 break; 642 break;
649 } 643 }