summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccessxml.cpp
authorerik <erik>2007-01-10 02:48:16 (UTC)
committer erik <erik>2007-01-10 02:48:16 (UTC)
commit3c4c894bcdb1e49ce4d3e8167c8a21b1c617037d (patch) (unidiff)
tree116c28349992668c69756a46fa90838889b21a6b /libopie2/opiepim/backend/otodoaccessxml.cpp
parent5e9659c695af1d1afb20a377775f1349b83eca53 (diff)
downloadopie-3c4c894bcdb1e49ce4d3e8167c8a21b1c617037d.zip
opie-3c4c894bcdb1e49ce4d3e8167c8a21b1c617037d.tar.gz
opie-3c4c894bcdb1e49ce4d3e8167c8a21b1c617037d.tar.bz2
BUG: The todo program was printing bad XML output of recurring items
because the code lacked a space between two entities. FIX: Add a space. NOTE: The code was additionally reworked to make the spaces more noticable to the author of the patch. Thanks goes to Paul Eggleton who provided the patch! This fixes Opie bug 1753: http://opie-bugs.oszine.de/view.php?id=1753
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index ab50604..7a08f12 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -498,170 +498,170 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
498 else if ( val == "Yearly" ) 498 else if ( val == "Yearly" )
499 recur()->setType( OPimRecurrence::Yearly ); 499 recur()->setType( OPimRecurrence::Yearly );
500 else 500 else
501 recur()->setType( OPimRecurrence::NoRepeat ); 501 recur()->setType( OPimRecurrence::NoRepeat );
502 break; 502 break;
503 case FRWeekdays: 503 case FRWeekdays:
504 recur()->setDays( val.toInt() ); 504 recur()->setDays( val.toInt() );
505 break; 505 break;
506 case FRPosition: 506 case FRPosition:
507 recur()->setPosition( val.toInt() ); 507 recur()->setPosition( val.toInt() );
508 break; 508 break;
509 case FRFreq: 509 case FRFreq:
510 recur()->setFrequency( val.toInt() ); 510 recur()->setFrequency( val.toInt() );
511 break; 511 break;
512 case FRHasEndDate: 512 case FRHasEndDate:
513 recur()->setHasEndDate( val.toInt() ); 513 recur()->setHasEndDate( val.toInt() );
514 break; 514 break;
515 case FREndDate: { 515 case FREndDate: {
516 rp_end = (time_t) val.toLong(); 516 rp_end = (time_t) val.toLong();
517 break; 517 break;
518 } 518 }
519 default: 519 default:
520 ev.setCustomField( attr, val ); 520 ev.setCustomField( attr, val );
521 break; 521 break;
522 } 522 }
523} 523}
524 524
525// from PalmtopRecord... GPL ### FIXME 525// from PalmtopRecord... GPL ### FIXME
526namespace { 526namespace {
527QString customToXml(const QMap<QString, QString>& customMap ) 527QString customToXml(const QMap<QString, QString>& customMap )
528{ 528{
529 QString buf(" "); 529 QString buf(" ");
530 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 530 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
531 cit != customMap.end(); ++cit) { 531 cit != customMap.end(); ++cit) {
532 buf += cit.key(); 532 buf += cit.key();
533 buf += "=\""; 533 buf += "=\"";
534 buf += Qtopia::escapeString(cit.data()); 534 buf += Qtopia::escapeString(cit.data());
535 buf += "\" "; 535 buf += "\" ";
536 } 536 }
537 return buf; 537 return buf;
538} 538}
539 539
540 540
541} 541}
542 542
543QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { 543QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
544 QString str; 544 QString str;
545 545
546 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 546 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\"";
547 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 547 str += " HasDate=\"" + QString::number( ev.hasDueDate() ) + "\"";
548 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 548 str += " Priority=\"" + QString::number( ev.priority() ) + "\"";
549 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 549 str += " Progress=\"" + QString::number(ev.progress() ) + "\"";
550 550
551 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 551 str += " Categories=\"" + toString( ev.categories() ) + "\"";
552 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 552 str += " Description=\"" + Qtopia::escapeString( ev.description() ) + "\"";
553 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 553 str += " Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\"";
554 554
555 if ( ev.hasDueDate() ) { 555 if ( ev.hasDueDate() ) {
556 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 556 str += " DateYear=\"" + QString::number( ev.dueDate().year() ) + "\"";
557 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 557 str += " DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\"";
558 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 558 str += " DateDay=\"" + QString::number( ev.dueDate().day() ) + "\"";
559 } 559 }
560 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 560 str += " Uid=\"" + QString::number( ev.uid() ) + "\"";
561 561
562// append the extra options 562// append the extra options
563 /* FIXME Qtopia::Record this is currently not 563 /* FIXME Qtopia::Record this is currently not
564 * possible you can set custom fields 564 * possible you can set custom fields
565 * but don' iterate over the list 565 * but don' iterate over the list
566 * I may do #define private protected 566 * I may do #define private protected
567 * for this case - cough --zecke 567 * for this case - cough --zecke
568 */ 568 */
569 /* 569 /*
570 QMap<QString, QString> extras = ev.extras(); 570 QMap<QString, QString> extras = ev.extras();
571 QMap<QString, QString>::Iterator extIt; 571 QMap<QString, QString>::Iterator extIt;
572 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 572 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
573 str += extIt.key() + "=\"" + extIt.data() + "\" "; 573 str += " " + extIt.key() + "=\"" + extIt.data() + "\"";
574 */ 574 */
575 // cross refernce 575 // cross refernce
576 if ( ev.hasRecurrence() ) { 576 if ( ev.hasRecurrence() ) {
577 str += ev.recurrence().toString(); 577 str += ev.recurrence().toString();
578 } 578 }
579 if ( ev.hasStartDate() ) 579 if ( ev.hasStartDate() )
580 str += "StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\" "; 580 str += " StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\"";
581 if ( ev.hasCompletedDate() ) 581 if ( ev.hasCompletedDate() )
582 str += "CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\" "; 582 str += " CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\"";
583 if ( ev.hasState() ) 583 if ( ev.hasState() )
584 str += "State=\""+QString::number( ev.state().state() )+"\" "; 584 str += " State=\""+QString::number( ev.state().state() )+"\"";
585 585
586 /* 586 /*
587 * save reminders and notifiers! 587 * save reminders and notifiers!
588 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... 588 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:....
589 */ 589 */
590 if ( ev.hasNotifiers() ) { 590 if ( ev.hasNotifiers() ) {
591 OPimNotifyManager manager = ev.notifiers(); 591 OPimNotifyManager manager = ev.notifiers();
592 OPimNotifyManager::Alarms alarms = manager.alarms(); 592 OPimNotifyManager::Alarms alarms = manager.alarms();
593 if (!alarms.isEmpty() ) { 593 if (!alarms.isEmpty() ) {
594 QStringList als; 594 QStringList als;
595 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 595 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
596 for ( ; it != alarms.end(); ++it ) { 596 for ( ; it != alarms.end(); ++it ) {
597 /* only if time is valid */ 597 /* only if time is valid */
598 if ( (*it).dateTime().isValid() ) { 598 if ( (*it).dateTime().isValid() ) {
599 als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) 599 als << OPimDateConversion::dateTimeToString( (*it).dateTime() )
600 + ":" + QString::number( (*it).duration() ) 600 + ":" + QString::number( (*it).duration() )
601 + ":" + QString::number( (*it).sound() ) 601 + ":" + QString::number( (*it).sound() )
602 + ":"; 602 + ":";
603 } 603 }
604 } 604 }
605 // now write the list 605 // now write the list
606 str += "Alarms=\""+als.join(";") +"\" "; 606 str += " Alarms=\""+als.join(";") +"\"";
607 } 607 }
608 608
609 /* 609 /*
610 * now the same for reminders but more easy. We just save the uid of the OPimEvent. 610 * now the same for reminders but more easy. We just save the uid of the OPimEvent.
611 */ 611 */
612 OPimNotifyManager::Reminders reminders = manager.reminders(); 612 OPimNotifyManager::Reminders reminders = manager.reminders();
613 if (!reminders.isEmpty() ) { 613 if (!reminders.isEmpty() ) {
614 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 614 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
615 QStringList records; 615 QStringList records;
616 for ( ; it != reminders.end(); ++it ) { 616 for ( ; it != reminders.end(); ++it ) {
617 records << QString::number( (*it).recordUid() ); 617 records << QString::number( (*it).recordUid() );
618 } 618 }
619 str += "Reminders=\""+ records.join(";") +"\" "; 619 str += " Reminders=\""+ records.join(";") +"\"";
620 } 620 }
621 } 621 }
622 str += customToXml( ev.toExtraMap() ); 622 str += customToXml( ev.toExtraMap() );
623 623
624 624
625 return str; 625 return str;
626} 626}
627QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const { 627QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const {
628 return Qtopia::Record::idsToString( ints ); 628 return Qtopia::Record::idsToString( ints );
629} 629}
630 630
631 631
632QArray<int> OPimTodoAccessXML::sorted( const UIDArray& events, bool asc, 632QArray<int> OPimTodoAccessXML::sorted( const UIDArray& events, bool asc,
633 int sortOrder,int sortFilter, 633 int sortOrder,int sortFilter,
634 const QArray<int>& categories )const { 634 const QArray<int>& categories )const {
635 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder ); 635 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder );
636 int item = 0; 636 int item = 0;
637 637
638 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false; 638 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false;
639 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false; 639 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false;
640 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false; 640 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false;
641 bool catPassed = false; 641 bool catPassed = false;
642 int cat; 642 int cat;
643 643
644 for ( uint i = 0; i < events.count(); ++i ) { 644 for ( uint i = 0; i < events.count(); ++i ) {
645 /* Guard against creating a new item... */ 645 /* Guard against creating a new item... */
646 if ( !m_events.contains( events[i] ) ) 646 if ( !m_events.contains( events[i] ) )
647 continue; 647 continue;
648 648
649 OPimTodo todo = m_events[events[i]]; 649 OPimTodo todo = m_events[events[i]];
650 650
651 /* show category */ 651 /* show category */
652 /* -1 == unfiled */ 652 /* -1 == unfiled */
653 catPassed = false; 653 catPassed = false;
654 for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) { 654 for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) {
655 cat = categories[cat_nu]; 655 cat = categories[cat_nu];
656 if ( bCat && cat == -1 ) { 656 if ( bCat && cat == -1 ) {
657 if(!todo.categories().isEmpty() ) 657 if(!todo.categories().isEmpty() )
658 continue; 658 continue;
659 } else if ( bCat && cat != 0) 659 } else if ( bCat && cat != 0)
660 if (!todo.categories().contains( cat ) ) 660 if (!todo.categories().contains( cat ) )
661 continue; 661 continue;
662 catPassed = true; 662 catPassed = true;
663 break; 663 break;
664 } 664 }
665 665
666 /* 666 /*
667 * If none of the Categories matched 667 * If none of the Categories matched