author | zecke <zecke> | 2003-05-12 13:20:21 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-12 13:20:21 (UTC) |
commit | a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d (patch) (unidiff) | |
tree | aee89fa76cc9e71a67d8ae9462b567e3f91f284f | |
parent | c2602b4c290a14f4655d7e07eea20b55c1f38c8e (diff) | |
download | opie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.zip opie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.tar.gz opie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.tar.bz2 |
Hospital Hacking Session
kill warnings
implement storing of reminders and alarms...
Nach viel Eiter und Gestank...
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 71 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 71 |
2 files changed, 130 insertions, 12 deletions
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 69b7ab4..2b62f0d 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -1,44 +1,45 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | 3 | ||
4 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | 7 | ||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qvector.h> | 12 | #include <qvector.h> |
13 | 13 | ||
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/stringutil.h> | 15 | #include <qpe/stringutil.h> |
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "oconversion.h" | 18 | #include "oconversion.h" |
19 | #include "opimstate.h" | 19 | #include "opimstate.h" |
20 | #include "otimezone.h" | 20 | #include "otimezone.h" |
21 | #include "opimnotifymanager.h" | ||
21 | #include "orecur.h" | 22 | #include "orecur.h" |
22 | #include "otodoaccessxml.h" | 23 | #include "otodoaccessxml.h" |
23 | 24 | ||
24 | namespace { | 25 | namespace { |
25 | time_t rp_end; | 26 | time_t rp_end; |
26 | ORecur* rec; | 27 | ORecur* rec; |
27 | ORecur *recur() { | 28 | ORecur *recur() { |
28 | if (!rec ) rec = new ORecur; | 29 | if (!rec ) rec = new ORecur; |
29 | return rec; | 30 | return rec; |
30 | } | 31 | } |
31 | int snd; | 32 | int snd; |
32 | enum MoreAttributes { | 33 | enum MoreAttributes { |
33 | FRType = OTodo::CompletedDate + 2, | 34 | FRType = OTodo::CompletedDate + 2, |
34 | FRWeekdays, | 35 | FRWeekdays, |
35 | FRPosition, | 36 | FRPosition, |
36 | FRFreq, | 37 | FRFreq, |
37 | FRHasEndDate, | 38 | FRHasEndDate, |
38 | FREndDate, | 39 | FREndDate, |
39 | FRStart, | 40 | FRStart, |
40 | FREnd | 41 | FREnd |
41 | }; | 42 | }; |
42 | // FROM TT again | 43 | // FROM TT again |
43 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
44 | { | 45 | { |
@@ -405,48 +406,69 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
405 | case OTodo::Priority: | 406 | case OTodo::Priority: |
406 | ev.setPriority( val.toInt() ); | 407 | ev.setPriority( val.toInt() ); |
407 | break; | 408 | break; |
408 | case OTodo::DateDay: | 409 | case OTodo::DateDay: |
409 | m_day = val.toInt(); | 410 | m_day = val.toInt(); |
410 | break; | 411 | break; |
411 | case OTodo::DateMonth: | 412 | case OTodo::DateMonth: |
412 | m_month = val.toInt(); | 413 | m_month = val.toInt(); |
413 | break; | 414 | break; |
414 | case OTodo::DateYear: | 415 | case OTodo::DateYear: |
415 | m_year = val.toInt(); | 416 | m_year = val.toInt(); |
416 | break; | 417 | break; |
417 | case OTodo::Progress: | 418 | case OTodo::Progress: |
418 | ev.setProgress( val.toInt() ); | 419 | ev.setProgress( val.toInt() ); |
419 | break; | 420 | break; |
420 | case OTodo::CompletedDate: | 421 | case OTodo::CompletedDate: |
421 | ev.setCompletedDate( OConversion::dateFromString( val ) ); | 422 | ev.setCompletedDate( OConversion::dateFromString( val ) ); |
422 | break; | 423 | break; |
423 | case OTodo::StartDate: | 424 | case OTodo::StartDate: |
424 | ev.setStartDate( OConversion::dateFromString( val ) ); | 425 | ev.setStartDate( OConversion::dateFromString( val ) ); |
425 | break; | 426 | break; |
426 | case OTodo::State: | 427 | case OTodo::State: |
427 | ev.setState( val.toInt() ); | 428 | ev.setState( val.toInt() ); |
428 | break; | 429 | break; |
430 | case OTodo::Alarms:{ | ||
431 | OPimNotifyManager &manager = ev.notifiers(); | ||
432 | QStringList als = QStringList::split(";", val ); | ||
433 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | ||
434 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | ||
435 | qWarning("alarm: %s", alarm.join("___").latin1() ); | ||
436 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | ||
437 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); | ||
438 | manager.add( al ); | ||
439 | } | ||
440 | } | ||
441 | break; | ||
442 | case OTodo::Reminders:{ | ||
443 | OPimNotifyManager &manager = ev.notifiers(); | ||
444 | QStringList rems = QStringList::split(";", val ); | ||
445 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | ||
446 | OPimReminder rem( (*it).toInt() ); | ||
447 | manager.add( rem ); | ||
448 | } | ||
449 | } | ||
450 | break; | ||
429 | case OTodo::CrossReference: | 451 | case OTodo::CrossReference: |
430 | { | 452 | { |
431 | /* | 453 | /* |
432 | * A cross refernce looks like | 454 | * A cross refernce looks like |
433 | * appname,id;appname,id | 455 | * appname,id;appname,id |
434 | * we need to split it up | 456 | * we need to split it up |
435 | */ | 457 | */ |
436 | QStringList refs = QStringList::split(';', val ); | 458 | QStringList refs = QStringList::split(';', val ); |
437 | QStringList::Iterator strIt; | 459 | QStringList::Iterator strIt; |
438 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | 460 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { |
439 | int pos = (*strIt).find(','); | 461 | int pos = (*strIt).find(','); |
440 | if ( pos > -1 ) | 462 | if ( pos > -1 ) |
441 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 463 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
442 | 464 | ||
443 | } | 465 | } |
444 | break; | 466 | break; |
445 | } | 467 | } |
446 | /* Recurrence stuff below + post processing later */ | 468 | /* Recurrence stuff below + post processing later */ |
447 | case FRType: | 469 | case FRType: |
448 | if ( val == "Daily" ) | 470 | if ( val == "Daily" ) |
449 | recur()->setType( ORecur::Daily ); | 471 | recur()->setType( ORecur::Daily ); |
450 | else if ( val == "Weekly" ) | 472 | else if ( val == "Weekly" ) |
451 | recur()->setType( ORecur::Weekly); | 473 | recur()->setType( ORecur::Weekly); |
452 | else if ( val == "MonthlyDay" ) | 474 | else if ( val == "MonthlyDay" ) |
@@ -501,48 +523,86 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
501 | // append the extra options | 523 | // append the extra options |
502 | /* FIXME Qtopia::Record this is currently not | 524 | /* FIXME Qtopia::Record this is currently not |
503 | * possible you can set custom fields | 525 | * possible you can set custom fields |
504 | * but don' iterate over the list | 526 | * but don' iterate over the list |
505 | * I may do #define private protected | 527 | * I may do #define private protected |
506 | * for this case - cough --zecke | 528 | * for this case - cough --zecke |
507 | */ | 529 | */ |
508 | /* | 530 | /* |
509 | QMap<QString, QString> extras = ev.extras(); | 531 | QMap<QString, QString> extras = ev.extras(); |
510 | QMap<QString, QString>::Iterator extIt; | 532 | QMap<QString, QString>::Iterator extIt; |
511 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | 533 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) |
512 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | 534 | str += extIt.key() + "=\"" + extIt.data() + "\" "; |
513 | */ | 535 | */ |
514 | // cross refernce | 536 | // cross refernce |
515 | if ( ev.hasRecurrence() ) { | 537 | if ( ev.hasRecurrence() ) { |
516 | str += ev.recurrence().toString(); | 538 | str += ev.recurrence().toString(); |
517 | } | 539 | } |
518 | if ( ev.hasStartDate() ) | 540 | if ( ev.hasStartDate() ) |
519 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; | 541 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; |
520 | if ( ev.hasCompletedDate() ) | 542 | if ( ev.hasCompletedDate() ) |
521 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; | 543 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; |
522 | if ( ev.hasState() ) | 544 | if ( ev.hasState() ) |
523 | str += "State=\""+QString::number( ev.state().state() )+"\" "; | 545 | str += "State=\""+QString::number( ev.state().state() )+"\" "; |
524 | 546 | ||
547 | /* | ||
548 | * save reminders and notifiers! | ||
549 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... | ||
550 | */ | ||
551 | if ( ev.hasNotifiers() ) { | ||
552 | OPimNotifyManager manager = ev.notifiers(); | ||
553 | OPimNotifyManager::Alarms alarms = manager.alarms(); | ||
554 | if (!alarms.isEmpty() ) { | ||
555 | QStringList als; | ||
556 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | ||
557 | for ( ; it != alarms.end(); ++it ) { | ||
558 | /* only if time is valid */ | ||
559 | if ( (*it).dateTime().isValid() ) { | ||
560 | als << OConversion::dateTimeToString( (*it).dateTime() ) | ||
561 | + ":" + QString::number( (*it).duration() ) | ||
562 | + ":" + QString::number( (*it).sound() ) | ||
563 | + ":"; | ||
564 | } | ||
565 | } | ||
566 | // now write the list | ||
567 | qWarning("als: %s", als.join("____________").latin1() ); | ||
568 | str += "Alarms=\""+als.join(";") +"\" "; | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | * now the same for reminders but more easy. We just save the uid of the OEvent. | ||
573 | */ | ||
574 | OPimNotifyManager::Reminders reminders = manager.reminders(); | ||
575 | if (!reminders.isEmpty() ) { | ||
576 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | ||
577 | QStringList records; | ||
578 | for ( ; it != reminders.end(); ++it ) { | ||
579 | records << QString::number( (*it).recordUid() ); | ||
580 | } | ||
581 | str += "Reminders=\""+ records.join(";") +"\" "; | ||
582 | } | ||
583 | } | ||
584 | |||
525 | 585 | ||
526 | return str; | 586 | return str; |
527 | } | 587 | } |
528 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 588 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { |
529 | return Qtopia::Record::idsToString( ints ); | 589 | return Qtopia::Record::idsToString( ints ); |
530 | } | 590 | } |
531 | 591 | ||
532 | /* internal class for sorting | 592 | /* internal class for sorting |
533 | * | 593 | * |
534 | * Inspired by todoxmlio.cpp from TT | 594 | * Inspired by todoxmlio.cpp from TT |
535 | */ | 595 | */ |
536 | 596 | ||
537 | struct OTodoXMLContainer { | 597 | struct OTodoXMLContainer { |
538 | OTodo todo; | 598 | OTodo todo; |
539 | }; | 599 | }; |
540 | 600 | ||
541 | namespace { | 601 | namespace { |
542 | inline QString string( const OTodo& todo) { | 602 | inline QString string( const OTodo& todo) { |
543 | return todo.summary().isEmpty() ? | 603 | return todo.summary().isEmpty() ? |
544 | todo.description().left(20 ) : | 604 | todo.description().left(20 ) : |
545 | todo.summary(); | 605 | todo.summary(); |
546 | } | 606 | } |
547 | inline int completed( const OTodo& todo1, const OTodo& todo2) { | 607 | inline int completed( const OTodo& todo1, const OTodo& todo2) { |
548 | int ret = 0; | 608 | int ret = 0; |
@@ -683,87 +743,86 @@ public: | |||
683 | } | 743 | } |
684 | if (!seDesc ) { | 744 | if (!seDesc ) { |
685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 745 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
686 | if (!m_asc) ret *= -1; | 746 | if (!m_asc) ret *= -1; |
687 | return ret; | 747 | return ret; |
688 | } | 748 | } |
689 | } | 749 | } |
690 | if (!seDeadline) { | 750 | if (!seDeadline) { |
691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 751 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
692 | if (!m_asc) ret *= -1; | 752 | if (!m_asc) ret *= -1; |
693 | return ret; | 753 | return ret; |
694 | } | 754 | } |
695 | } | 755 | } |
696 | 756 | ||
697 | return 0; | 757 | return 0; |
698 | } | 758 | } |
699 | private: | 759 | private: |
700 | bool m_asc; | 760 | bool m_asc; |
701 | int m_sort; | 761 | int m_sort; |
702 | 762 | ||
703 | }; | 763 | }; |
704 | 764 | ||
705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 765 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
706 | int sortFilter, int cat ) { | 766 | int sortFilter, int cat ) { |
707 | qWarning("sorted! %d cat", cat); | ||
708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 767 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
709 | QMap<int, OTodo>::Iterator it; | 768 | QMap<int, OTodo>::Iterator it; |
710 | int item = 0; | 769 | int item = 0; |
711 | 770 | ||
712 | bool bCat = sortFilter & 1 ? true : false; | 771 | bool bCat = sortFilter & 1 ? true : false; |
713 | bool bOnly = sortFilter & 2 ? true : false; | 772 | bool bOnly = sortFilter & 2 ? true : false; |
714 | bool comp = sortFilter & 4 ? true : false; | 773 | bool comp = sortFilter & 4 ? true : false; |
715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 774 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
716 | 775 | ||
717 | /* show category */ | 776 | /* show category */ |
718 | if ( bCat && cat != 0) | 777 | /* -1 == unfiled */ |
778 | if ( bCat && cat == -1 ) { | ||
779 | if(!(*it).categories().isEmpty() ) | ||
780 | continue; | ||
781 | }else if ( bCat && cat != 0) | ||
719 | if (!(*it).categories().contains( cat ) ) { | 782 | if (!(*it).categories().contains( cat ) ) { |
720 | qWarning("category mis match"); | ||
721 | continue; | 783 | continue; |
722 | } | 784 | } |
723 | /* isOverdue but we should not show overdue - why?*/ | 785 | /* isOverdue but we should not show overdue - why?*/ |
724 | /* if ( (*it).isOverdue() && !bOnly ) { | 786 | /* if ( (*it).isOverdue() && !bOnly ) { |
725 | qWarning("item is overdue but !bOnly"); | 787 | qWarning("item is overdue but !bOnly"); |
726 | continue; | 788 | continue; |
727 | } | 789 | } |
728 | */ | 790 | */ |
729 | if ( !(*it).isOverdue() && bOnly ) { | 791 | if ( !(*it).isOverdue() && bOnly ) { |
730 | qWarning("item is not overdue but bOnly checked"); | ||
731 | continue; | 792 | continue; |
732 | } | 793 | } |
733 | 794 | ||
734 | if ((*it).isCompleted() && comp ) { | 795 | if ((*it).isCompleted() && comp ) { |
735 | qWarning("completed continue!"); | ||
736 | continue; | 796 | continue; |
737 | } | 797 | } |
738 | 798 | ||
739 | 799 | ||
740 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 800 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
741 | con->todo = (*it); | 801 | con->todo = (*it); |
742 | vector.insert(item, con ); | 802 | vector.insert(item, con ); |
743 | item++; | 803 | item++; |
744 | } | 804 | } |
745 | qWarning("XXX %d Items added", item); | ||
746 | vector.resize( item ); | 805 | vector.resize( item ); |
747 | /* sort it now */ | 806 | /* sort it now */ |
748 | vector.sort(); | 807 | vector.sort(); |
749 | /* now get the uids */ | 808 | /* now get the uids */ |
750 | QArray<int> array( vector.count() ); | 809 | QArray<int> array( vector.count() ); |
751 | for (uint i= 0; i < vector.count(); i++ ) { | 810 | for (uint i= 0; i < vector.count(); i++ ) { |
752 | array[i] = ( vector.at(i) )->todo.uid(); | 811 | array[i] = ( vector.at(i) )->todo.uid(); |
753 | } | 812 | } |
754 | return array; | 813 | return array; |
755 | }; | 814 | }; |
756 | void OTodoAccessXML::removeAllCompleted() { | 815 | void OTodoAccessXML::removeAllCompleted() { |
757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 816 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
758 | if ( (*it).isCompleted() ) | 817 | if ( (*it).isCompleted() ) |
759 | m_events.remove( it ); | 818 | m_events.remove( it ); |
760 | } | 819 | } |
761 | } | 820 | } |
762 | QBitArray OTodoAccessXML::supports()const { | 821 | QBitArray OTodoAccessXML::supports()const { |
763 | static QBitArray ar = sup(); | 822 | static QBitArray ar = sup(); |
764 | return ar; | 823 | return ar; |
765 | } | 824 | } |
766 | QBitArray OTodoAccessXML::sup() { | 825 | QBitArray OTodoAccessXML::sup() { |
767 | QBitArray ar( OTodo::CompletedDate +1 ); | 826 | QBitArray ar( OTodo::CompletedDate +1 ); |
768 | ar.fill( true ); | 827 | ar.fill( true ); |
769 | ar[OTodo::CrossReference] = false; | 828 | ar[OTodo::CrossReference] = false; |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 69b7ab4..2b62f0d 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -1,44 +1,45 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | 3 | ||
4 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | 7 | ||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qvector.h> | 12 | #include <qvector.h> |
13 | 13 | ||
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/stringutil.h> | 15 | #include <qpe/stringutil.h> |
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "oconversion.h" | 18 | #include "oconversion.h" |
19 | #include "opimstate.h" | 19 | #include "opimstate.h" |
20 | #include "otimezone.h" | 20 | #include "otimezone.h" |
21 | #include "opimnotifymanager.h" | ||
21 | #include "orecur.h" | 22 | #include "orecur.h" |
22 | #include "otodoaccessxml.h" | 23 | #include "otodoaccessxml.h" |
23 | 24 | ||
24 | namespace { | 25 | namespace { |
25 | time_t rp_end; | 26 | time_t rp_end; |
26 | ORecur* rec; | 27 | ORecur* rec; |
27 | ORecur *recur() { | 28 | ORecur *recur() { |
28 | if (!rec ) rec = new ORecur; | 29 | if (!rec ) rec = new ORecur; |
29 | return rec; | 30 | return rec; |
30 | } | 31 | } |
31 | int snd; | 32 | int snd; |
32 | enum MoreAttributes { | 33 | enum MoreAttributes { |
33 | FRType = OTodo::CompletedDate + 2, | 34 | FRType = OTodo::CompletedDate + 2, |
34 | FRWeekdays, | 35 | FRWeekdays, |
35 | FRPosition, | 36 | FRPosition, |
36 | FRFreq, | 37 | FRFreq, |
37 | FRHasEndDate, | 38 | FRHasEndDate, |
38 | FREndDate, | 39 | FREndDate, |
39 | FRStart, | 40 | FRStart, |
40 | FREnd | 41 | FREnd |
41 | }; | 42 | }; |
42 | // FROM TT again | 43 | // FROM TT again |
43 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
44 | { | 45 | { |
@@ -405,48 +406,69 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
405 | case OTodo::Priority: | 406 | case OTodo::Priority: |
406 | ev.setPriority( val.toInt() ); | 407 | ev.setPriority( val.toInt() ); |
407 | break; | 408 | break; |
408 | case OTodo::DateDay: | 409 | case OTodo::DateDay: |
409 | m_day = val.toInt(); | 410 | m_day = val.toInt(); |
410 | break; | 411 | break; |
411 | case OTodo::DateMonth: | 412 | case OTodo::DateMonth: |
412 | m_month = val.toInt(); | 413 | m_month = val.toInt(); |
413 | break; | 414 | break; |
414 | case OTodo::DateYear: | 415 | case OTodo::DateYear: |
415 | m_year = val.toInt(); | 416 | m_year = val.toInt(); |
416 | break; | 417 | break; |
417 | case OTodo::Progress: | 418 | case OTodo::Progress: |
418 | ev.setProgress( val.toInt() ); | 419 | ev.setProgress( val.toInt() ); |
419 | break; | 420 | break; |
420 | case OTodo::CompletedDate: | 421 | case OTodo::CompletedDate: |
421 | ev.setCompletedDate( OConversion::dateFromString( val ) ); | 422 | ev.setCompletedDate( OConversion::dateFromString( val ) ); |
422 | break; | 423 | break; |
423 | case OTodo::StartDate: | 424 | case OTodo::StartDate: |
424 | ev.setStartDate( OConversion::dateFromString( val ) ); | 425 | ev.setStartDate( OConversion::dateFromString( val ) ); |
425 | break; | 426 | break; |
426 | case OTodo::State: | 427 | case OTodo::State: |
427 | ev.setState( val.toInt() ); | 428 | ev.setState( val.toInt() ); |
428 | break; | 429 | break; |
430 | case OTodo::Alarms:{ | ||
431 | OPimNotifyManager &manager = ev.notifiers(); | ||
432 | QStringList als = QStringList::split(";", val ); | ||
433 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | ||
434 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | ||
435 | qWarning("alarm: %s", alarm.join("___").latin1() ); | ||
436 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | ||
437 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); | ||
438 | manager.add( al ); | ||
439 | } | ||
440 | } | ||
441 | break; | ||
442 | case OTodo::Reminders:{ | ||
443 | OPimNotifyManager &manager = ev.notifiers(); | ||
444 | QStringList rems = QStringList::split(";", val ); | ||
445 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | ||
446 | OPimReminder rem( (*it).toInt() ); | ||
447 | manager.add( rem ); | ||
448 | } | ||
449 | } | ||
450 | break; | ||
429 | case OTodo::CrossReference: | 451 | case OTodo::CrossReference: |
430 | { | 452 | { |
431 | /* | 453 | /* |
432 | * A cross refernce looks like | 454 | * A cross refernce looks like |
433 | * appname,id;appname,id | 455 | * appname,id;appname,id |
434 | * we need to split it up | 456 | * we need to split it up |
435 | */ | 457 | */ |
436 | QStringList refs = QStringList::split(';', val ); | 458 | QStringList refs = QStringList::split(';', val ); |
437 | QStringList::Iterator strIt; | 459 | QStringList::Iterator strIt; |
438 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | 460 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { |
439 | int pos = (*strIt).find(','); | 461 | int pos = (*strIt).find(','); |
440 | if ( pos > -1 ) | 462 | if ( pos > -1 ) |
441 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 463 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
442 | 464 | ||
443 | } | 465 | } |
444 | break; | 466 | break; |
445 | } | 467 | } |
446 | /* Recurrence stuff below + post processing later */ | 468 | /* Recurrence stuff below + post processing later */ |
447 | case FRType: | 469 | case FRType: |
448 | if ( val == "Daily" ) | 470 | if ( val == "Daily" ) |
449 | recur()->setType( ORecur::Daily ); | 471 | recur()->setType( ORecur::Daily ); |
450 | else if ( val == "Weekly" ) | 472 | else if ( val == "Weekly" ) |
451 | recur()->setType( ORecur::Weekly); | 473 | recur()->setType( ORecur::Weekly); |
452 | else if ( val == "MonthlyDay" ) | 474 | else if ( val == "MonthlyDay" ) |
@@ -501,48 +523,86 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
501 | // append the extra options | 523 | // append the extra options |
502 | /* FIXME Qtopia::Record this is currently not | 524 | /* FIXME Qtopia::Record this is currently not |
503 | * possible you can set custom fields | 525 | * possible you can set custom fields |
504 | * but don' iterate over the list | 526 | * but don' iterate over the list |
505 | * I may do #define private protected | 527 | * I may do #define private protected |
506 | * for this case - cough --zecke | 528 | * for this case - cough --zecke |
507 | */ | 529 | */ |
508 | /* | 530 | /* |
509 | QMap<QString, QString> extras = ev.extras(); | 531 | QMap<QString, QString> extras = ev.extras(); |
510 | QMap<QString, QString>::Iterator extIt; | 532 | QMap<QString, QString>::Iterator extIt; |
511 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | 533 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) |
512 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | 534 | str += extIt.key() + "=\"" + extIt.data() + "\" "; |
513 | */ | 535 | */ |
514 | // cross refernce | 536 | // cross refernce |
515 | if ( ev.hasRecurrence() ) { | 537 | if ( ev.hasRecurrence() ) { |
516 | str += ev.recurrence().toString(); | 538 | str += ev.recurrence().toString(); |
517 | } | 539 | } |
518 | if ( ev.hasStartDate() ) | 540 | if ( ev.hasStartDate() ) |
519 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; | 541 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; |
520 | if ( ev.hasCompletedDate() ) | 542 | if ( ev.hasCompletedDate() ) |
521 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; | 543 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; |
522 | if ( ev.hasState() ) | 544 | if ( ev.hasState() ) |
523 | str += "State=\""+QString::number( ev.state().state() )+"\" "; | 545 | str += "State=\""+QString::number( ev.state().state() )+"\" "; |
524 | 546 | ||
547 | /* | ||
548 | * save reminders and notifiers! | ||
549 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... | ||
550 | */ | ||
551 | if ( ev.hasNotifiers() ) { | ||
552 | OPimNotifyManager manager = ev.notifiers(); | ||
553 | OPimNotifyManager::Alarms alarms = manager.alarms(); | ||
554 | if (!alarms.isEmpty() ) { | ||
555 | QStringList als; | ||
556 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | ||
557 | for ( ; it != alarms.end(); ++it ) { | ||
558 | /* only if time is valid */ | ||
559 | if ( (*it).dateTime().isValid() ) { | ||
560 | als << OConversion::dateTimeToString( (*it).dateTime() ) | ||
561 | + ":" + QString::number( (*it).duration() ) | ||
562 | + ":" + QString::number( (*it).sound() ) | ||
563 | + ":"; | ||
564 | } | ||
565 | } | ||
566 | // now write the list | ||
567 | qWarning("als: %s", als.join("____________").latin1() ); | ||
568 | str += "Alarms=\""+als.join(";") +"\" "; | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | * now the same for reminders but more easy. We just save the uid of the OEvent. | ||
573 | */ | ||
574 | OPimNotifyManager::Reminders reminders = manager.reminders(); | ||
575 | if (!reminders.isEmpty() ) { | ||
576 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | ||
577 | QStringList records; | ||
578 | for ( ; it != reminders.end(); ++it ) { | ||
579 | records << QString::number( (*it).recordUid() ); | ||
580 | } | ||
581 | str += "Reminders=\""+ records.join(";") +"\" "; | ||
582 | } | ||
583 | } | ||
584 | |||
525 | 585 | ||
526 | return str; | 586 | return str; |
527 | } | 587 | } |
528 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 588 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { |
529 | return Qtopia::Record::idsToString( ints ); | 589 | return Qtopia::Record::idsToString( ints ); |
530 | } | 590 | } |
531 | 591 | ||
532 | /* internal class for sorting | 592 | /* internal class for sorting |
533 | * | 593 | * |
534 | * Inspired by todoxmlio.cpp from TT | 594 | * Inspired by todoxmlio.cpp from TT |
535 | */ | 595 | */ |
536 | 596 | ||
537 | struct OTodoXMLContainer { | 597 | struct OTodoXMLContainer { |
538 | OTodo todo; | 598 | OTodo todo; |
539 | }; | 599 | }; |
540 | 600 | ||
541 | namespace { | 601 | namespace { |
542 | inline QString string( const OTodo& todo) { | 602 | inline QString string( const OTodo& todo) { |
543 | return todo.summary().isEmpty() ? | 603 | return todo.summary().isEmpty() ? |
544 | todo.description().left(20 ) : | 604 | todo.description().left(20 ) : |
545 | todo.summary(); | 605 | todo.summary(); |
546 | } | 606 | } |
547 | inline int completed( const OTodo& todo1, const OTodo& todo2) { | 607 | inline int completed( const OTodo& todo1, const OTodo& todo2) { |
548 | int ret = 0; | 608 | int ret = 0; |
@@ -683,87 +743,86 @@ public: | |||
683 | } | 743 | } |
684 | if (!seDesc ) { | 744 | if (!seDesc ) { |
685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 745 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
686 | if (!m_asc) ret *= -1; | 746 | if (!m_asc) ret *= -1; |
687 | return ret; | 747 | return ret; |
688 | } | 748 | } |
689 | } | 749 | } |
690 | if (!seDeadline) { | 750 | if (!seDeadline) { |
691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 751 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
692 | if (!m_asc) ret *= -1; | 752 | if (!m_asc) ret *= -1; |
693 | return ret; | 753 | return ret; |
694 | } | 754 | } |
695 | } | 755 | } |
696 | 756 | ||
697 | return 0; | 757 | return 0; |
698 | } | 758 | } |
699 | private: | 759 | private: |
700 | bool m_asc; | 760 | bool m_asc; |
701 | int m_sort; | 761 | int m_sort; |
702 | 762 | ||
703 | }; | 763 | }; |
704 | 764 | ||
705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 765 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
706 | int sortFilter, int cat ) { | 766 | int sortFilter, int cat ) { |
707 | qWarning("sorted! %d cat", cat); | ||
708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 767 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
709 | QMap<int, OTodo>::Iterator it; | 768 | QMap<int, OTodo>::Iterator it; |
710 | int item = 0; | 769 | int item = 0; |
711 | 770 | ||
712 | bool bCat = sortFilter & 1 ? true : false; | 771 | bool bCat = sortFilter & 1 ? true : false; |
713 | bool bOnly = sortFilter & 2 ? true : false; | 772 | bool bOnly = sortFilter & 2 ? true : false; |
714 | bool comp = sortFilter & 4 ? true : false; | 773 | bool comp = sortFilter & 4 ? true : false; |
715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 774 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
716 | 775 | ||
717 | /* show category */ | 776 | /* show category */ |
718 | if ( bCat && cat != 0) | 777 | /* -1 == unfiled */ |
778 | if ( bCat && cat == -1 ) { | ||
779 | if(!(*it).categories().isEmpty() ) | ||
780 | continue; | ||
781 | }else if ( bCat && cat != 0) | ||
719 | if (!(*it).categories().contains( cat ) ) { | 782 | if (!(*it).categories().contains( cat ) ) { |
720 | qWarning("category mis match"); | ||
721 | continue; | 783 | continue; |
722 | } | 784 | } |
723 | /* isOverdue but we should not show overdue - why?*/ | 785 | /* isOverdue but we should not show overdue - why?*/ |
724 | /* if ( (*it).isOverdue() && !bOnly ) { | 786 | /* if ( (*it).isOverdue() && !bOnly ) { |
725 | qWarning("item is overdue but !bOnly"); | 787 | qWarning("item is overdue but !bOnly"); |
726 | continue; | 788 | continue; |
727 | } | 789 | } |
728 | */ | 790 | */ |
729 | if ( !(*it).isOverdue() && bOnly ) { | 791 | if ( !(*it).isOverdue() && bOnly ) { |
730 | qWarning("item is not overdue but bOnly checked"); | ||
731 | continue; | 792 | continue; |
732 | } | 793 | } |
733 | 794 | ||
734 | if ((*it).isCompleted() && comp ) { | 795 | if ((*it).isCompleted() && comp ) { |
735 | qWarning("completed continue!"); | ||
736 | continue; | 796 | continue; |
737 | } | 797 | } |
738 | 798 | ||
739 | 799 | ||
740 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 800 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
741 | con->todo = (*it); | 801 | con->todo = (*it); |
742 | vector.insert(item, con ); | 802 | vector.insert(item, con ); |
743 | item++; | 803 | item++; |
744 | } | 804 | } |
745 | qWarning("XXX %d Items added", item); | ||
746 | vector.resize( item ); | 805 | vector.resize( item ); |
747 | /* sort it now */ | 806 | /* sort it now */ |
748 | vector.sort(); | 807 | vector.sort(); |
749 | /* now get the uids */ | 808 | /* now get the uids */ |
750 | QArray<int> array( vector.count() ); | 809 | QArray<int> array( vector.count() ); |
751 | for (uint i= 0; i < vector.count(); i++ ) { | 810 | for (uint i= 0; i < vector.count(); i++ ) { |
752 | array[i] = ( vector.at(i) )->todo.uid(); | 811 | array[i] = ( vector.at(i) )->todo.uid(); |
753 | } | 812 | } |
754 | return array; | 813 | return array; |
755 | }; | 814 | }; |
756 | void OTodoAccessXML::removeAllCompleted() { | 815 | void OTodoAccessXML::removeAllCompleted() { |
757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 816 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
758 | if ( (*it).isCompleted() ) | 817 | if ( (*it).isCompleted() ) |
759 | m_events.remove( it ); | 818 | m_events.remove( it ); |
760 | } | 819 | } |
761 | } | 820 | } |
762 | QBitArray OTodoAccessXML::supports()const { | 821 | QBitArray OTodoAccessXML::supports()const { |
763 | static QBitArray ar = sup(); | 822 | static QBitArray ar = sup(); |
764 | return ar; | 823 | return ar; |
765 | } | 824 | } |
766 | QBitArray OTodoAccessXML::sup() { | 825 | QBitArray OTodoAccessXML::sup() { |
767 | QBitArray ar( OTodo::CompletedDate +1 ); | 826 | QBitArray ar( OTodo::CompletedDate +1 ); |
768 | ar.fill( true ); | 827 | ar.fill( true ); |
769 | ar[OTodo::CrossReference] = false; | 828 | ar[OTodo::CrossReference] = false; |