author | zautrix <zautrix> | 2004-09-14 01:03:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-14 01:03:08 (UTC) |
commit | 30762fe125216362e1a6c1d5ec5d22d9525aa336 (patch) (unidiff) | |
tree | 4ff0fbf43efa921c86d64ff3f50baa9e59d207d9 | |
parent | 8ce7eae438dcd20f9c79fc0a36dfef0a6d3931eb (diff) | |
download | kdepimpi-30762fe125216362e1a6c1d5ec5d22d9525aa336.zip kdepimpi-30762fe125216362e1a6c1d5ec5d22d9525aa336.tar.gz kdepimpi-30762fe125216362e1a6c1d5ec5d22d9525aa336.tar.bz2 |
Many bugfixes
-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | libkcal/alarm.cpp | 36 | ||||
-rw-r--r-- | libkcal/recurrence.cpp | 56 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 7 |
4 files changed, 94 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 258bd43..94cc97d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -693,145 +693,145 @@ void CalendarView::confSync() | |||
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | if ( remCh ) | 732 | if ( remCh ) |
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
736 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
737 | qDebug("both not changed "); | 737 | qDebug("both not changed "); |
738 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
739 | } else { | 739 | } else { |
740 | if ( locCh ) { | 740 | if ( locCh ) { |
741 | qDebug("loc changed %d", local->revision() ); | 741 | qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
742 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
743 | if ( !remCh ) | 743 | if ( !remCh ) |
744 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
745 | } else { | 745 | } else { |
746 | qDebug(" not loc changed "); | 746 | qDebug(" not loc changed "); |
747 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
748 | if ( remCh ) | 748 | if ( remCh ) |
749 | remote->setLastModified( lastSync.addDays( 1 ) ); | 749 | remote->setLastModified( lastSync.addDays( 1 ) ); |
750 | 750 | ||
751 | } | 751 | } |
752 | } | 752 | } |
753 | full = true; | 753 | full = true; |
754 | if ( mode < SYNC_PREF_ASK ) | 754 | if ( mode < SYNC_PREF_ASK ) |
755 | mode = SYNC_PREF_ASK; | 755 | mode = SYNC_PREF_ASK; |
756 | } else { | 756 | } else { |
757 | if ( local->lastModified() == remote->lastModified() ) | 757 | if ( local->lastModified() == remote->lastModified() ) |
758 | if ( local->revision() == remote->revision() ) | 758 | if ( local->revision() == remote->revision() ) |
759 | return 0; | 759 | return 0; |
760 | 760 | ||
761 | } | 761 | } |
762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
763 | 763 | ||
764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
766 | //full = true; //debug only | 766 | //full = true; //debug only |
767 | if ( full ) { | 767 | if ( full ) { |
768 | bool equ = false; | 768 | bool equ = false; |
769 | if ( local->type() == "Event" ) { | 769 | if ( local->type() == "Event" ) { |
770 | equ = (*((Event*) local) == *((Event*) remote)); | 770 | equ = (*((Event*) local) == *((Event*) remote)); |
771 | } | 771 | } |
772 | else if ( local->type() =="Todo" ) | 772 | else if ( local->type() =="Todo" ) |
773 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 773 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
774 | else if ( local->type() =="Journal" ) | 774 | else if ( local->type() =="Journal" ) |
775 | equ = (*((Journal*) local) == *((Journal*) remote)); | 775 | equ = (*((Journal*) local) == *((Journal*) remote)); |
776 | if ( equ ) { | 776 | if ( equ ) { |
777 | //qDebug("equal "); | 777 | //qDebug("equal "); |
778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
780 | } | 780 | } |
781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
782 | return 0; | 782 | return 0; |
783 | 783 | ||
784 | }//else //debug only | 784 | }//else //debug only |
785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
786 | } | 786 | } |
787 | int result; | 787 | int result; |
788 | bool localIsNew; | 788 | bool localIsNew; |
789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 789 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
790 | 790 | ||
791 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
792 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
793 | 793 | ||
794 | switch( mode ) { | 794 | switch( mode ) { |
795 | case SYNC_PREF_LOCAL: | 795 | case SYNC_PREF_LOCAL: |
796 | if ( lastSync > remote->lastModified() ) | 796 | if ( lastSync > remote->lastModified() ) |
797 | return 1; | 797 | return 1; |
798 | if ( lastSync > local->lastModified() ) | 798 | if ( lastSync > local->lastModified() ) |
799 | return 2; | 799 | return 2; |
800 | return 1; | 800 | return 1; |
801 | break; | 801 | break; |
802 | case SYNC_PREF_REMOTE: | 802 | case SYNC_PREF_REMOTE: |
803 | if ( lastSync > remote->lastModified() ) | 803 | if ( lastSync > remote->lastModified() ) |
804 | return 1; | 804 | return 1; |
805 | if ( lastSync > local->lastModified() ) | 805 | if ( lastSync > local->lastModified() ) |
806 | return 2; | 806 | return 2; |
807 | return 2; | 807 | return 2; |
808 | break; | 808 | break; |
809 | case SYNC_PREF_NEWEST: | 809 | case SYNC_PREF_NEWEST: |
810 | if ( local->lastModified() > remote->lastModified() ) | 810 | if ( local->lastModified() > remote->lastModified() ) |
811 | return 1; | 811 | return 1; |
812 | else | 812 | else |
813 | return 2; | 813 | return 2; |
814 | break; | 814 | break; |
815 | case SYNC_PREF_ASK: | 815 | case SYNC_PREF_ASK: |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | if ( lastSync > remote->lastModified() ) | 817 | if ( lastSync > remote->lastModified() ) |
818 | return 1; | 818 | return 1; |
819 | if ( lastSync > local->lastModified() ) | 819 | if ( lastSync > local->lastModified() ) |
820 | return 2; | 820 | return 2; |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
822 | localIsNew = local->lastModified() >= remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
823 | if ( localIsNew ) | 823 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
825 | else | 825 | else |
826 | getEventViewerDialog()->setColorMode( 2 ); | 826 | getEventViewerDialog()->setColorMode( 2 ); |
827 | getEventViewerDialog()->setIncidence(local); | 827 | getEventViewerDialog()->setIncidence(local); |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 1 ); | 831 | getEventViewerDialog()->setColorMode( 1 ); |
832 | getEventViewerDialog()->addIncidence(remote); | 832 | getEventViewerDialog()->addIncidence(remote); |
833 | getEventViewerDialog()->setColorMode( 0 ); | 833 | getEventViewerDialog()->setColorMode( 0 ); |
834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
836 | getEventViewerDialog()->showMe(); | 836 | getEventViewerDialog()->showMe(); |
837 | result = getEventViewerDialog()->executeS( localIsNew ); | 837 | result = getEventViewerDialog()->executeS( localIsNew ); |
@@ -985,171 +985,177 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
985 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
986 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
987 | } | 987 | } |
988 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
990 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
991 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
992 | Incidence* inL; | 992 | Incidence* inL; |
993 | QProgressBar bar( er.count(),0 ); | 993 | QProgressBar bar( er.count(),0 ); |
994 | bar.setCaption (i18n("Syncing - close to abort!") ); | 994 | bar.setCaption (i18n("Syncing - close to abort!") ); |
995 | 995 | ||
996 | int w = 300; | 996 | int w = 300; |
997 | if ( QApplication::desktop()->width() < 320 ) | 997 | if ( QApplication::desktop()->width() < 320 ) |
998 | w = 220; | 998 | w = 220; |
999 | int h = bar.sizeHint().height() ; | 999 | int h = bar.sizeHint().height() ; |
1000 | int dw = QApplication::desktop()->width(); | 1000 | int dw = QApplication::desktop()->width(); |
1001 | int dh = QApplication::desktop()->height(); | 1001 | int dh = QApplication::desktop()->height(); |
1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1003 | bar.show(); | 1003 | bar.show(); |
1004 | int modulo = (er.count()/10)+1; | 1004 | int modulo = (er.count()/10)+1; |
1005 | int incCounter = 0; | 1005 | int incCounter = 0; |
1006 | while ( inR ) { | 1006 | while ( inR ) { |
1007 | if ( ! bar.isVisible() ) | 1007 | if ( ! bar.isVisible() ) |
1008 | return false; | 1008 | return false; |
1009 | if ( incCounter % modulo == 0 ) | 1009 | if ( incCounter % modulo == 0 ) |
1010 | bar.setProgress( incCounter ); | 1010 | bar.setProgress( incCounter ); |
1011 | ++incCounter; | 1011 | ++incCounter; |
1012 | uid = inR->uid(); | 1012 | uid = inR->uid(); |
1013 | bool skipIncidence = false; | 1013 | bool skipIncidence = false; |
1014 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1014 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1015 | skipIncidence = true; | 1015 | skipIncidence = true; |
1016 | 1016 | ||
1017 | qApp->processEvents(); | 1017 | qApp->processEvents(); |
1018 | if ( !skipIncidence ) { | 1018 | if ( !skipIncidence ) { |
1019 | inL = local->incidence( uid ); | 1019 | inL = local->incidence( uid ); |
1020 | if ( inL ) { // maybe conflict - same uid in both calendars | 1020 | if ( inL ) { // maybe conflict - same uid in both calendars |
1021 | int maxrev = inL->revision(); | 1021 | int maxrev = inL->revision(); |
1022 | if ( maxrev < inR->revision() ) | 1022 | if ( maxrev < inR->revision() ) |
1023 | maxrev = inR->revision(); | 1023 | maxrev = inR->revision(); |
1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1026 | if ( take == 3 ) | 1026 | if ( take == 3 ) |
1027 | return false; | 1027 | return false; |
1028 | if ( take == 1 ) {// take local | 1028 | if ( take == 1 ) {// take local |
1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1030 | remote->deleteIncidence( inR ); | 1030 | remote->deleteIncidence( inR ); |
1031 | if ( inL->revision() < maxrev ) | 1031 | if ( inL->revision() < maxrev ) |
1032 | inL->setRevision( maxrev ); | 1032 | inL->setRevision( maxrev ); |
1033 | remote->addIncidence( inL->clone() ); | 1033 | inR = inL->clone(); |
1034 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
1035 | remote->addIncidence( inR ); | ||
1034 | ++changedRemote; | 1036 | ++changedRemote; |
1035 | } else { | 1037 | } else { |
1036 | if ( inR->revision() < maxrev ) | 1038 | if ( inR->revision() < maxrev ) |
1037 | inR->setRevision( maxrev ); | 1039 | inR->setRevision( maxrev ); |
1038 | local->deleteIncidence( inL ); | 1040 | local->deleteIncidence( inL ); |
1039 | local->addIncidence( inR->clone() ); | 1041 | local->addIncidence( inR->clone() ); |
1040 | ++changedLocal; | 1042 | ++changedLocal; |
1041 | } | 1043 | } |
1042 | } | 1044 | } |
1043 | } else { // no conflict | 1045 | } else { // no conflict |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1046 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | QString des = eventLSync->description(); | 1047 | QString des = eventLSync->description(); |
1046 | QString pref = "e"; | 1048 | QString pref = "e"; |
1047 | if ( inR->type() == "Todo" ) | 1049 | if ( inR->type() == "Todo" ) |
1048 | pref = "t"; | 1050 | pref = "t"; |
1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1051 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1052 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1051 | //remote->deleteIncidence( inR ); | 1053 | //remote->deleteIncidence( inR ); |
1052 | ++deletedEventR; | 1054 | ++deletedEventR; |
1053 | } else { | 1055 | } else { |
1054 | inR->setLastModified( modifiedCalendar ); | 1056 | inR->setLastModified( modifiedCalendar ); |
1055 | local->addIncidence( inR->clone() ); | 1057 | inL = inR->clone(); |
1058 | local->addIncidence( inL ); | ||
1056 | ++addedEvent; | 1059 | ++addedEvent; |
1057 | } | 1060 | } |
1058 | } else { | 1061 | } else { |
1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1062 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1060 | inR->setLastModified( modifiedCalendar ); | 1063 | inR->setLastModified( modifiedCalendar ); |
1061 | local->addIncidence( inR->clone() ); | 1064 | local->addIncidence( inR->clone() ); |
1062 | ++addedEvent; | 1065 | ++addedEvent; |
1063 | } else { | 1066 | } else { |
1064 | checkExternSyncEvent(eventRSyncSharp, inR); | 1067 | checkExternSyncEvent(eventRSyncSharp, inR); |
1065 | remote->deleteIncidence( inR ); | 1068 | remote->deleteIncidence( inR ); |
1066 | ++deletedEventR; | 1069 | ++deletedEventR; |
1067 | } | 1070 | } |
1068 | } | 1071 | } |
1069 | } | 1072 | } |
1070 | } | 1073 | } |
1071 | inR = er.next(); | 1074 | inR = er.next(); |
1072 | } | 1075 | } |
1073 | QPtrList<Incidence> el = local->rawIncidences(); | 1076 | QPtrList<Incidence> el = local->rawIncidences(); |
1074 | inL = el.first(); | 1077 | inL = el.first(); |
1075 | modulo = (el.count()/10)+1; | 1078 | modulo = (el.count()/10)+1; |
1076 | bar.setCaption (i18n("Add / remove events") ); | 1079 | bar.setCaption (i18n("Add / remove events") ); |
1077 | bar.setTotalSteps ( el.count() ) ; | 1080 | bar.setTotalSteps ( el.count() ) ; |
1078 | bar.show(); | 1081 | bar.show(); |
1079 | incCounter = 0; | 1082 | incCounter = 0; |
1080 | 1083 | ||
1081 | while ( inL ) { | 1084 | while ( inL ) { |
1082 | 1085 | ||
1083 | qApp->processEvents(); | 1086 | qApp->processEvents(); |
1084 | if ( ! bar.isVisible() ) | 1087 | if ( ! bar.isVisible() ) |
1085 | return false; | 1088 | return false; |
1086 | if ( incCounter % modulo == 0 ) | 1089 | if ( incCounter % modulo == 0 ) |
1087 | bar.setProgress( incCounter ); | 1090 | bar.setProgress( incCounter ); |
1088 | ++incCounter; | 1091 | ++incCounter; |
1089 | uid = inL->uid(); | 1092 | uid = inL->uid(); |
1090 | bool skipIncidence = false; | 1093 | bool skipIncidence = false; |
1091 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1094 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1092 | skipIncidence = true; | 1095 | skipIncidence = true; |
1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1094 | skipIncidence = true; | 1097 | skipIncidence = true; |
1095 | if ( !skipIncidence ) { | 1098 | if ( !skipIncidence ) { |
1096 | inR = remote->incidence( uid ); | 1099 | inR = remote->incidence( uid ); |
1097 | if ( ! inR ) { | 1100 | if ( ! inR ) { |
1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1100 | local->deleteIncidence( inL ); | 1103 | local->deleteIncidence( inL ); |
1101 | ++deletedEventL; | 1104 | ++deletedEventL; |
1102 | } else { | 1105 | } else { |
1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1106 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1104 | inL->removeID(mCurrentSyncDevice ); | 1107 | inL->removeID(mCurrentSyncDevice ); |
1105 | ++addedEventR; | 1108 | ++addedEventR; |
1109 | qDebug("remote added Incidence %s ", inL->summary().latin1()); | ||
1106 | inL->setLastModified( modifiedCalendar ); | 1110 | inL->setLastModified( modifiedCalendar ); |
1107 | remote->addIncidence( inL->clone() ); | 1111 | inR = inL->clone(); |
1112 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
1113 | remote->addIncidence( inR ); | ||
1108 | } | 1114 | } |
1109 | } | 1115 | } |
1110 | } else { | 1116 | } else { |
1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1117 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1118 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1119 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1120 | ++deletedEventL; |
1115 | } else { | 1121 | } else { |
1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1117 | ++addedEventR; | 1123 | ++addedEventR; |
1118 | inL->setLastModified( modifiedCalendar ); | 1124 | inL->setLastModified( modifiedCalendar ); |
1119 | remote->addIncidence( inL->clone() ); | 1125 | remote->addIncidence( inL->clone() ); |
1120 | } | 1126 | } |
1121 | } | 1127 | } |
1122 | } | 1128 | } |
1123 | } | 1129 | } |
1124 | } | 1130 | } |
1125 | inL = el.next(); | 1131 | inL = el.next(); |
1126 | } | 1132 | } |
1127 | int delFut = 0; | 1133 | int delFut = 0; |
1128 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1134 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1129 | er = remote->rawIncidences(); | 1135 | er = remote->rawIncidences(); |
1130 | inR = er.first(); | 1136 | inR = er.first(); |
1131 | QDateTime dt; | 1137 | QDateTime dt; |
1132 | QDateTime cur = QDateTime::currentDateTime(); | 1138 | QDateTime cur = QDateTime::currentDateTime(); |
1133 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1139 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1134 | while ( inR ) { | 1140 | while ( inR ) { |
1135 | if ( inR->type() == "Todo" ) { | 1141 | if ( inR->type() == "Todo" ) { |
1136 | Todo * t = (Todo*)inR; | 1142 | Todo * t = (Todo*)inR; |
1137 | if ( t->hasDueDate() ) | 1143 | if ( t->hasDueDate() ) |
1138 | dt = t->dtDue(); | 1144 | dt = t->dtDue(); |
1139 | else | 1145 | else |
1140 | dt = cur.addSecs( 62 ); | 1146 | dt = cur.addSecs( 62 ); |
1141 | } | 1147 | } |
1142 | else if (inR->type() == "Event" ) { | 1148 | else if (inR->type() == "Event" ) { |
1143 | bool ok; | 1149 | bool ok; |
1144 | dt = inR->getNextOccurence( cur, &ok ); | 1150 | dt = inR->getNextOccurence( cur, &ok ); |
1145 | if ( !ok ) | 1151 | if ( !ok ) |
1146 | dt = cur.addSecs( -62 ); | 1152 | dt = cur.addSecs( -62 ); |
1147 | } | 1153 | } |
1148 | else | 1154 | else |
1149 | dt = inR->dtStart(); | 1155 | dt = inR->dtStart(); |
1150 | if ( dt < cur || dt > end ) { | 1156 | if ( dt < cur || dt > end ) { |
1151 | remote->deleteIncidence( inR ); | 1157 | remote->deleteIncidence( inR ); |
1152 | ++delFut; | 1158 | ++delFut; |
1153 | } | 1159 | } |
1154 | inR = er.next(); | 1160 | inR = er.next(); |
1155 | } | 1161 | } |
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 29e6205..1fc7169 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -4,112 +4,146 @@ | |||
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <kdebug.h> | 22 | #include <kdebug.h> |
23 | 23 | ||
24 | #include "incidence.h" | 24 | #include "incidence.h" |
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | #include "alarm.h" | 27 | #include "alarm.h" |
28 | 28 | ||
29 | using namespace KCal; | 29 | using namespace KCal; |
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | Alarm::Alarm(Incidence *parent) | 31 | Alarm::Alarm(Incidence *parent) |
32 | : mParent(parent), | 32 | : mParent(parent), |
33 | mType(Audio), | 33 | mType(Audio), |
34 | mDescription(""), // to make operator==() not fail | 34 | mDescription(""), // to make operator==() not fail |
35 | mFile(""), // to make operator==() not fail | 35 | mFile(""), // to make operator==() not fail |
36 | mMailSubject(""), // to make operator==() not fail | 36 | mMailSubject(""), // to make operator==() not fail |
37 | mAlarmSnoozeTime(5), | 37 | mAlarmSnoozeTime(5), |
38 | mAlarmRepeatCount(0), | 38 | mAlarmRepeatCount(0), |
39 | mEndOffset(false), | 39 | mEndOffset(false), |
40 | mHasTime(false), | 40 | mHasTime(false), |
41 | mAlarmEnabled(false) | 41 | mAlarmEnabled(false) |
42 | { | 42 | { |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | Alarm::~Alarm() | 46 | Alarm::~Alarm() |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | bool Alarm::operator==( const Alarm& rhs ) const | 50 | bool Alarm::operator==( const Alarm& rhs ) const |
51 | { | 51 | { |
52 | |||
52 | if ( mType != rhs.mType || | 53 | if ( mType != rhs.mType || |
53 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || | 54 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || |
54 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || | 55 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || |
55 | mAlarmEnabled != rhs.mAlarmEnabled || | 56 | mAlarmEnabled != rhs.mAlarmEnabled || |
56 | mHasTime != rhs.mHasTime) | 57 | mHasTime != rhs.mHasTime) |
57 | return false; | 58 | return false; |
58 | 59 | ||
60 | #if 0 | ||
61 | if ( mType != rhs.mType ) { | ||
62 | |||
63 | qDebug("aaa1 "); | ||
64 | return false; | ||
65 | } | ||
66 | |||
67 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { | ||
68 | |||
69 | qDebug("aaa2 "); | ||
70 | return false; | ||
71 | } | ||
72 | |||
73 | |||
74 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { | ||
75 | |||
76 | qDebug("aaa3 "); | ||
77 | return false; | ||
78 | } | ||
79 | |||
80 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { | ||
81 | |||
82 | qDebug("aaa4 "); | ||
83 | return false; | ||
84 | } | ||
85 | |||
86 | if ( mHasTime != rhs.mHasTime ) { | ||
87 | |||
88 | qDebug("aaa5 "); | ||
89 | return false; | ||
90 | } | ||
91 | #endif | ||
92 | |||
93 | |||
59 | if (mHasTime) { | 94 | if (mHasTime) { |
60 | if (mAlarmTime != rhs.mAlarmTime) | 95 | if (mAlarmTime != rhs.mAlarmTime) |
61 | return false; | 96 | return false; |
62 | } else { | 97 | } else { |
63 | if (mOffset != rhs.mOffset || | 98 | if (mOffset != rhs.mOffset || |
64 | mEndOffset != rhs.mEndOffset) | 99 | mEndOffset != rhs.mEndOffset) |
65 | return false; | 100 | return false; |
66 | } | 101 | } |
67 | |||
68 | switch (mType) { | 102 | switch (mType) { |
69 | case Display: | 103 | case Display: |
70 | return mDescription == rhs.mDescription; | 104 | return mDescription == rhs.mDescription; |
71 | 105 | ||
72 | case Email: | 106 | case Email: |
73 | return mDescription == rhs.mDescription && | 107 | return mDescription == rhs.mDescription && |
74 | mMailAttachFiles == rhs.mMailAttachFiles && | 108 | mMailAttachFiles == rhs.mMailAttachFiles && |
75 | mMailAddresses == rhs.mMailAddresses && | 109 | mMailAddresses == rhs.mMailAddresses && |
76 | mMailSubject == rhs.mMailSubject; | 110 | mMailSubject == rhs.mMailSubject; |
77 | 111 | ||
78 | case Procedure: | 112 | case Procedure: |
79 | return mFile == rhs.mFile && | 113 | return mFile == rhs.mFile && |
80 | mDescription == rhs.mDescription; | 114 | mDescription == rhs.mDescription; |
81 | 115 | ||
82 | case Audio: | 116 | case Audio: |
83 | return mFile == rhs.mFile; | 117 | return mFile == rhs.mFile; |
84 | 118 | ||
85 | case Invalid: | 119 | case Invalid: |
86 | break; | 120 | break; |
87 | } | 121 | } |
88 | return false; | 122 | return false; |
89 | } | 123 | } |
90 | 124 | ||
91 | void Alarm::setType(Alarm::Type type) | 125 | void Alarm::setType(Alarm::Type type) |
92 | { | 126 | { |
93 | if (type == mType) | 127 | if (type == mType) |
94 | return; | 128 | return; |
95 | 129 | ||
96 | switch (type) { | 130 | switch (type) { |
97 | case Display: | 131 | case Display: |
98 | mDescription = ""; | 132 | mDescription = ""; |
99 | break; | 133 | break; |
100 | case Procedure: | 134 | case Procedure: |
101 | mFile = mDescription = ""; | 135 | mFile = mDescription = ""; |
102 | break; | 136 | break; |
103 | case Audio: | 137 | case Audio: |
104 | mFile = ""; | 138 | mFile = ""; |
105 | break; | 139 | break; |
106 | case Email: | 140 | case Email: |
107 | mMailSubject = mDescription = ""; | 141 | mMailSubject = mDescription = ""; |
108 | mMailAddresses.clear(); | 142 | mMailAddresses.clear(); |
109 | mMailAttachFiles.clear(); | 143 | mMailAttachFiles.clear(); |
110 | break; | 144 | break; |
111 | case Invalid: | 145 | case Invalid: |
112 | break; | 146 | break; |
113 | default: | 147 | default: |
114 | return; | 148 | return; |
115 | } | 149 | } |
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index dd74e10..e84f672 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp | |||
@@ -61,124 +61,156 @@ Recurrence::Recurrence(const Recurrence &r, Incidence *parent) | |||
61 | rDuration(r.rDuration), | 61 | rDuration(r.rDuration), |
62 | rEndDateTime(r.rEndDateTime), | 62 | rEndDateTime(r.rEndDateTime), |
63 | mRecurStart(r.mRecurStart), | 63 | mRecurStart(r.mRecurStart), |
64 | mFloats(r.mFloats), | 64 | mFloats(r.mFloats), |
65 | mRecurReadOnly(r.mRecurReadOnly), | 65 | mRecurReadOnly(r.mRecurReadOnly), |
66 | mRecurExDatesCount(r.mRecurExDatesCount), | 66 | mRecurExDatesCount(r.mRecurExDatesCount), |
67 | mFeb29YearlyType(r.mFeb29YearlyType), | 67 | mFeb29YearlyType(r.mFeb29YearlyType), |
68 | mCompatVersion(r.mCompatVersion), | 68 | mCompatVersion(r.mCompatVersion), |
69 | mCompatRecurs(r.mCompatRecurs), | 69 | mCompatRecurs(r.mCompatRecurs), |
70 | mCompatDuration(r.mCompatDuration), | 70 | mCompatDuration(r.mCompatDuration), |
71 | mParent(parent) | 71 | mParent(parent) |
72 | { | 72 | { |
73 | for (QPtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) { | 73 | for (QPtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) { |
74 | rMonthPos *tmp = new rMonthPos; | 74 | rMonthPos *tmp = new rMonthPos; |
75 | tmp->rPos = mp.current()->rPos; | 75 | tmp->rPos = mp.current()->rPos; |
76 | tmp->negative = mp.current()->negative; | 76 | tmp->negative = mp.current()->negative; |
77 | tmp->rDays = mp.current()->rDays.copy(); | 77 | tmp->rDays = mp.current()->rDays.copy(); |
78 | rMonthPositions.append(tmp); | 78 | rMonthPositions.append(tmp); |
79 | } | 79 | } |
80 | for (QPtrListIterator<int> md(r.rMonthDays); md.current(); ++md) { | 80 | for (QPtrListIterator<int> md(r.rMonthDays); md.current(); ++md) { |
81 | int *tmp = new int; | 81 | int *tmp = new int; |
82 | *tmp = *md.current(); | 82 | *tmp = *md.current(); |
83 | rMonthDays.append(tmp); | 83 | rMonthDays.append(tmp); |
84 | } | 84 | } |
85 | for (QPtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) { | 85 | for (QPtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) { |
86 | int *tmp = new int; | 86 | int *tmp = new int; |
87 | *tmp = *yn.current(); | 87 | *tmp = *yn.current(); |
88 | rYearNums.append(tmp); | 88 | rYearNums.append(tmp); |
89 | } | 89 | } |
90 | rMonthDays.setAutoDelete( true ); | 90 | rMonthDays.setAutoDelete( true ); |
91 | rMonthPositions.setAutoDelete( true ); | 91 | rMonthPositions.setAutoDelete( true ); |
92 | rYearNums.setAutoDelete( true ); | 92 | rYearNums.setAutoDelete( true ); |
93 | } | 93 | } |
94 | 94 | ||
95 | Recurrence::~Recurrence() | 95 | Recurrence::~Recurrence() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | bool Recurrence::operator==( const Recurrence& r2 ) const | 100 | bool Recurrence::operator==( const Recurrence& r2 ) const |
101 | { | 101 | { |
102 | 102 | ||
103 | // the following line is obvious | 103 | // the following line is obvious |
104 | if ( recurs == rNone && r2.recurs == rNone ) | 104 | if ( recurs == rNone && r2.recurs == rNone ) |
105 | return true; | 105 | return true; |
106 | // we need the above line, because two non recurring events may | 106 | // we need the above line, because two non recurring events may |
107 | // differ in the other settings, because one (or both) | 107 | // differ in the other settings, because one (or both) |
108 | // may be not initialized properly | 108 | // may be not initialized properly |
109 | |||
109 | if ( recurs != r2.recurs | 110 | if ( recurs != r2.recurs |
110 | || rFreq != r2.rFreq | 111 | || rFreq != r2.rFreq |
111 | || rDuration != r2.rDuration | 112 | || rDuration != r2.rDuration |
112 | || !rDuration && rEndDateTime != r2.rEndDateTime | 113 | || !rDuration && rEndDateTime != r2.rEndDateTime |
113 | || mRecurStart != r2.mRecurStart | 114 | || mRecurStart != r2.mRecurStart |
114 | || mFloats != r2.mFloats | 115 | || mFloats != r2.mFloats |
115 | || mRecurReadOnly != r2.mRecurReadOnly | 116 | || mRecurReadOnly != r2.mRecurReadOnly |
116 | || mRecurExDatesCount != r2.mRecurExDatesCount ) | 117 | || mRecurExDatesCount != r2.mRecurExDatesCount ) |
117 | return false; | 118 | return false; |
118 | // no need to compare mCompat* and mParent | 119 | // no need to compare mCompat* and mParent |
119 | // OK to compare the pointers | 120 | // OK to compare the pointers |
120 | switch ( recurs ) | 121 | switch ( recurs ) |
121 | { | 122 | { |
122 | case rWeekly: | 123 | case rWeekly: |
123 | return rDays == r2.rDays | 124 | return rDays == r2.rDays |
124 | && rWeekStart == r2.rWeekStart; | 125 | && rWeekStart == r2.rWeekStart; |
125 | case rMonthlyPos: | 126 | case rMonthlyPos: { |
126 | return rMonthPositions.count() == r2.rMonthPositions.count(); | 127 | QPtrList<rMonthPos> MonthPositions = rMonthPositions; |
127 | case rMonthlyDay: | 128 | QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions; |
128 | return rMonthDays.count() == r2.rMonthDays.count(); | 129 | if ( !MonthPositions.count() ) |
129 | case rYearlyPos: | 130 | return false; |
130 | return rYearNums.count() == r2.rYearNums.count() | 131 | if ( !MonthPositions2.count() ) |
131 | && rMonthPositions.count() == r2.rMonthPositions.count(); | 132 | return false; |
132 | case rYearlyMonth: | 133 | return MonthPositions.first()->rPos == MonthPositions2.first()->rPos; |
133 | return rYearNums.count() == r2.rYearNums.count() | 134 | } |
134 | && mFeb29YearlyType == r2.mFeb29YearlyType; | 135 | case rMonthlyDay: { |
135 | case rYearlyDay: | 136 | QPtrList<int> MonthDays = rMonthDays ; |
136 | return rYearNums == r2.rYearNums; | 137 | QPtrList<int> MonthDays2 = r2.rMonthDays ; |
138 | if ( !MonthDays.count() ) | ||
139 | return false; | ||
140 | if ( !MonthDays2.count() ) | ||
141 | return false; | ||
142 | return *MonthDays.first() == *MonthDays2.first() ; | ||
143 | } | ||
144 | case rYearlyPos: { | ||
145 | |||
146 | QPtrList<int> YearNums = rYearNums; | ||
147 | QPtrList<int> YearNums2 = r2.rYearNums; | ||
148 | if ( *YearNums.first() != *YearNums2.first() ) | ||
149 | return false; | ||
150 | QPtrList<rMonthPos> MonthPositions = rMonthPositions; | ||
151 | QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions; | ||
152 | if ( !MonthPositions.count() ) | ||
153 | return false; | ||
154 | if ( !MonthPositions2.count() ) | ||
155 | return false; | ||
156 | return MonthPositions.first()->rPos == MonthPositions2.first()->rPos; | ||
157 | |||
158 | } | ||
159 | case rYearlyMonth: { | ||
160 | QPtrList<int> YearNums = rYearNums; | ||
161 | QPtrList<int> YearNums2 = r2.rYearNums; | ||
162 | return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType); | ||
163 | } | ||
164 | case rYearlyDay: { | ||
165 | QPtrList<int> YearNums = rYearNums; | ||
166 | QPtrList<int> YearNums2 = r2.rYearNums; | ||
167 | return ( *YearNums.first() == *YearNums2.first() ); | ||
168 | } | ||
137 | case rNone: | 169 | case rNone: |
138 | case rMinutely: | 170 | case rMinutely: |
139 | case rHourly: | 171 | case rHourly: |
140 | case rDaily: | 172 | case rDaily: |
141 | default: | 173 | default: |
142 | return true; | 174 | return true; |
143 | } | 175 | } |
144 | } | 176 | } |
145 | /* | 177 | /* |
146 | bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2) | 178 | bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2) |
147 | { | 179 | { |
148 | if ( l1.count() != l2.count() ) | 180 | if ( l1.count() != l2.count() ) |
149 | return false; | 181 | return false; |
150 | int count = l1.count(); | 182 | int count = l1.count(); |
151 | int i; | 183 | int i; |
152 | for ( i = 0; i < count ; ++i ) { | 184 | for ( i = 0; i < count ; ++i ) { |
153 | // if ( l1.at(i) != l2.at(i) ) | 185 | // if ( l1.at(i) != l2.at(i) ) |
154 | return false; | 186 | return false; |
155 | qDebug("compüare "); | 187 | qDebug("compüare "); |
156 | } | 188 | } |
157 | return true; | 189 | return true; |
158 | } | 190 | } |
159 | */ | 191 | */ |
160 | QString Recurrence::recurrenceText() const | 192 | QString Recurrence::recurrenceText() const |
161 | { | 193 | { |
162 | QString recurText = i18n("No"); | 194 | QString recurText = i18n("No"); |
163 | if ( recurs == Recurrence::rMinutely ) | 195 | if ( recurs == Recurrence::rMinutely ) |
164 | recurText = i18n("minutely"); | 196 | recurText = i18n("minutely"); |
165 | else if ( recurs == Recurrence::rHourly ) | 197 | else if ( recurs == Recurrence::rHourly ) |
166 | recurText = i18n("hourly"); | 198 | recurText = i18n("hourly"); |
167 | else if ( recurs == Recurrence::rDaily ) | 199 | else if ( recurs == Recurrence::rDaily ) |
168 | recurText = i18n("daily"); | 200 | recurText = i18n("daily"); |
169 | else if ( recurs == Recurrence::rWeekly ) | 201 | else if ( recurs == Recurrence::rWeekly ) |
170 | recurText = i18n("weekly"); | 202 | recurText = i18n("weekly"); |
171 | else if ( recurs == Recurrence::rMonthlyPos ) | 203 | else if ( recurs == Recurrence::rMonthlyPos ) |
172 | recurText = i18n("monthly"); | 204 | recurText = i18n("monthly"); |
173 | else if ( recurs == Recurrence::rMonthlyDay ) | 205 | else if ( recurs == Recurrence::rMonthlyDay ) |
174 | recurText = i18n("day-monthly"); | 206 | recurText = i18n("day-monthly"); |
175 | else if ( recurs == Recurrence::rYearlyMonth ) | 207 | else if ( recurs == Recurrence::rYearlyMonth ) |
176 | recurText = i18n("month-yearly"); | 208 | recurText = i18n("month-yearly"); |
177 | else if ( recurs == Recurrence::rYearlyDay ) | 209 | else if ( recurs == Recurrence::rYearlyDay ) |
178 | recurText = i18n("day-yearly"); | 210 | recurText = i18n("day-yearly"); |
179 | else if ( recurs == Recurrence::rYearlyPos ) | 211 | else if ( recurs == Recurrence::rYearlyPos ) |
180 | recurText = i18n("position-yearly"); | 212 | recurText = i18n("position-yearly"); |
181 | return recurText; | 213 | return recurText; |
182 | } | 214 | } |
183 | 215 | ||
184 | void Recurrence::setCompatVersion(int version) | 216 | void Recurrence::setCompatVersion(int version) |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index defdb09..89eb72f 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -135,98 +135,99 @@ class SharpParser : public QObject | |||
135 | // qDebug("next "); | 135 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
139 | 139 | ||
140 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
149 | else | 149 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 155 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
158 | days.fill( false ); | 158 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 164 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | event->recurrence()->unsetRecurs(); | 169 | event->recurrence()->unsetRecurs(); |
170 | } | 170 | } |
171 | 171 | ||
172 | QString categoryList = attList[1] ; | 172 | QString categoryList = attList[1] ; |
173 | event->setCategories( lookupCategories( categoryList ) ); | 173 | event->setCategories( lookupCategories( categoryList ) ); |
174 | 174 | ||
175 | // strange 0 semms to mean: alarm enabled | 175 | // strange 0 semms to mean: alarm enabled |
176 | if ( attList[8] == "0" ) { | 176 | if ( attList[8] == "0" ) { |
177 | Alarm *alarm; | 177 | Alarm *alarm; |
178 | if ( event->alarms().count() > 0 ) | 178 | if ( event->alarms().count() > 0 ) |
179 | alarm = event->alarms().first(); | 179 | alarm = event->alarms().first(); |
180 | else { | 180 | else { |
181 | alarm = new Alarm( event ); | 181 | alarm = new Alarm( event ); |
182 | event->addAlarm( alarm ); | 182 | event->addAlarm( alarm ); |
183 | alarm->setType( Alarm::Audio ); | ||
183 | } | 184 | } |
184 | alarm->setType( Alarm::Audio ); | 185 | //alarm->setType( Alarm::Audio ); |
185 | alarm->setEnabled( true ); | 186 | alarm->setEnabled( true ); |
186 | int alarmOffset = attList[9].toInt(); | 187 | int alarmOffset = attList[9].toInt(); |
187 | alarm->setStartOffset( alarmOffset * -60 ); | 188 | alarm->setStartOffset( alarmOffset * -60 ); |
188 | } else { | 189 | } else { |
189 | Alarm *alarm; | 190 | Alarm *alarm; |
190 | if ( event->alarms().count() > 0 ) { | 191 | if ( event->alarms().count() > 0 ) { |
191 | alarm = event->alarms().first(); | 192 | alarm = event->alarms().first(); |
192 | alarm->setType( Alarm::Audio ); | 193 | alarm->setType( Alarm::Audio ); |
193 | alarm->setStartOffset( -60*15 ); | 194 | alarm->setStartOffset( -60*15 ); |
194 | alarm->setEnabled( false ); | 195 | alarm->setEnabled( false ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | 198 | ||
198 | mCalendar->addEvent( event); | 199 | mCalendar->addEvent( event); |
199 | } else if ( qName == "Todo" ) { | 200 | } else if ( qName == "Todo" ) { |
200 | Todo *todo; | 201 | Todo *todo; |
201 | 202 | ||
202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 203 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
203 | if (todo ) | 204 | if (todo ) |
204 | todo = (Todo*)todo->clone(); | 205 | todo = (Todo*)todo->clone(); |
205 | else | 206 | else |
206 | todo = new Todo; | 207 | todo = new Todo; |
207 | 208 | ||
208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 209 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
209 | // 0 1 2 3 4 5 6 7 8 | 210 | // 0 1 2 3 4 5 6 7 8 |
210 | //1,,,,,1,4,Loch zumachen,"" | 211 | //1,,,,,1,4,Loch zumachen,"" |
211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 212 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 213 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
213 | 214 | ||
214 | todo->setID( "Sharp_DTM", attList[0]); | 215 | todo->setID( "Sharp_DTM", attList[0]); |
215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 216 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 217 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
217 | 218 | ||
218 | todo->setSummary( attList[7] ); | 219 | todo->setSummary( attList[7] ); |
219 | todo->setDescription( attList[8]); | 220 | todo->setDescription( attList[8]); |
220 | 221 | ||
221 | int priority = attList[6].toInt(); | 222 | int priority = attList[6].toInt(); |
222 | if ( priority == 0 ) priority = 3; | 223 | if ( priority == 0 ) priority = 3; |
223 | todo->setPriority( priority ); | 224 | todo->setPriority( priority ); |
224 | 225 | ||
225 | QString categoryList = attList[1]; | 226 | QString categoryList = attList[1]; |
226 | todo->setCategories( lookupCategories( categoryList ) ); | 227 | todo->setCategories( lookupCategories( categoryList ) ); |
227 | 228 | ||
228 | 229 | ||
229 | 230 | ||
230 | QString hasDateStr = attList[3]; // due | 231 | QString hasDateStr = attList[3]; // due |
231 | if ( !hasDateStr.isEmpty() ) { | 232 | if ( !hasDateStr.isEmpty() ) { |
232 | if ( hasDateStr.right(6) == "000000" ) { | 233 | if ( hasDateStr.right(6) == "000000" ) { |
@@ -323,103 +324,103 @@ class SharpParser : public QObject | |||
323 | { | 324 | { |
324 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | 325 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); |
325 | if ( it == mCategoriesMap.end() ) return id; | 326 | if ( it == mCategoriesMap.end() ) return id; |
326 | else return *it; | 327 | else return *it; |
327 | } | 328 | } |
328 | 329 | ||
329 | static void setCategory( const QString &id, const QString &name ) | 330 | static void setCategory( const QString &id, const QString &name ) |
330 | { | 331 | { |
331 | mCategoriesMap.insert( id, name ); | 332 | mCategoriesMap.insert( id, name ); |
332 | } | 333 | } |
333 | 334 | ||
334 | static QMap<QString,QString> mCategoriesMap; | 335 | static QMap<QString,QString> mCategoriesMap; |
335 | }; | 336 | }; |
336 | 337 | ||
337 | QMap<QString,QString> SharpParser::mCategoriesMap; | 338 | QMap<QString,QString> SharpParser::mCategoriesMap; |
338 | 339 | ||
339 | SharpFormat::SharpFormat() | 340 | SharpFormat::SharpFormat() |
340 | { | 341 | { |
341 | mCategories = 0; | 342 | mCategories = 0; |
342 | } | 343 | } |
343 | 344 | ||
344 | SharpFormat::~SharpFormat() | 345 | SharpFormat::~SharpFormat() |
345 | { | 346 | { |
346 | } | 347 | } |
347 | ulong SharpFormat::getCsum( const QStringList & attList) | 348 | ulong SharpFormat::getCsum( const QStringList & attList) |
348 | { | 349 | { |
349 | int max = attList.count() -1; | 350 | int max = attList.count() -1; |
350 | ulong cSum = 0; | 351 | ulong cSum = 0; |
351 | int j,k,i; | 352 | int j,k,i; |
352 | int add; | 353 | int add; |
353 | for ( i = 1; i < max ; ++i ) { | 354 | for ( i = 1; i < max ; ++i ) { |
354 | QString s = attList[i]; | 355 | QString s = attList[i]; |
355 | if ( ! s.isEmpty() ){ | 356 | if ( ! s.isEmpty() ){ |
356 | j = s.length(); | 357 | j = s.length(); |
357 | for ( k = 0; k < j; ++k ) { | 358 | for ( k = 0; k < j; ++k ) { |
358 | int mul = k +1; | 359 | int mul = k +1; |
359 | add = s[k].unicode (); | 360 | add = s[k].unicode (); |
360 | if ( k < 16 ) | 361 | if ( k < 16 ) |
361 | mul = mul * mul; | 362 | mul = mul * mul; |
362 | add = add * mul *i*i*i; | 363 | add = add * mul *i*i*i; |
363 | cSum += add; | 364 | cSum += add; |
364 | } | 365 | } |
365 | } | 366 | } |
366 | } | 367 | } |
367 | return cSum; | 368 | return cSum; |
368 | 369 | ||
369 | } | 370 | } |
370 | #include <stdlib.h> | 371 | #include <stdlib.h> |
371 | #define DEBUGMODE false | 372 | //#define DEBUGMODE false |
373 | #define DEBUGMODE true | ||
372 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 374 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
373 | { | 375 | { |
374 | 376 | ||
375 | 377 | ||
376 | bool debug = DEBUGMODE; | 378 | bool debug = DEBUGMODE; |
377 | //debug = true; | ||
378 | QString text; | 379 | QString text; |
379 | QString codec = "utf8"; | 380 | QString codec = "utf8"; |
380 | QLabel status ( i18n("Reading events ..."), 0 ); | 381 | QLabel status ( i18n("Reading events ..."), 0 ); |
381 | 382 | ||
382 | int w = status.sizeHint().width()+20 ; | 383 | int w = status.sizeHint().width()+20 ; |
383 | if ( w < 200 ) w = 200; | 384 | if ( w < 200 ) w = 200; |
384 | int h = status.sizeHint().height()+20 ; | 385 | int h = status.sizeHint().height()+20 ; |
385 | int dw = QApplication::desktop()->width(); | 386 | int dw = QApplication::desktop()->width(); |
386 | int dh = QApplication::desktop()->height(); | 387 | int dh = QApplication::desktop()->height(); |
387 | status.setCaption(i18n("Reading DTM Data") ); | 388 | status.setCaption(i18n("Reading DTM Data") ); |
388 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 389 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
389 | status.show(); | 390 | status.show(); |
390 | status.raise(); | 391 | status.raise(); |
391 | qApp->processEvents(); | 392 | qApp->processEvents(); |
392 | QString fileName; | 393 | QString fileName; |
393 | if ( ! debug ) { | 394 | if ( ! debug ) { |
394 | fileName = "/tmp/kopitempout"; | 395 | fileName = "/tmp/kopitempout"; |
395 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 396 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
396 | system ( command.latin1() ); | 397 | system ( command.latin1() ); |
397 | } else { | 398 | } else { |
398 | fileName = "/tmp/events.txt"; | 399 | fileName = "/tmp/events.txt"; |
399 | 400 | ||
400 | } | 401 | } |
401 | QFile file( fileName ); | 402 | QFile file( fileName ); |
402 | if (!file.open( IO_ReadOnly ) ) { | 403 | if (!file.open( IO_ReadOnly ) ) { |
403 | return false; | 404 | return false; |
404 | 405 | ||
405 | } | 406 | } |
406 | QTextStream ts( &file ); | 407 | QTextStream ts( &file ); |
407 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 408 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
408 | text = ts.read(); | 409 | text = ts.read(); |
409 | file.close(); | 410 | file.close(); |
410 | status.setText( i18n("Processing events ...") ); | 411 | status.setText( i18n("Processing events ...") ); |
411 | status.raise(); | 412 | status.raise(); |
412 | qApp->processEvents(); | 413 | qApp->processEvents(); |
413 | fromString2Cal( calendar, existngCal, text, "Event" ); | 414 | fromString2Cal( calendar, existngCal, text, "Event" ); |
414 | status.setText( i18n("Reading todos ...") ); | 415 | status.setText( i18n("Reading todos ...") ); |
415 | qApp->processEvents(); | 416 | qApp->processEvents(); |
416 | if ( ! debug ) { | 417 | if ( ! debug ) { |
417 | fileName = "/tmp/kopitempout"; | 418 | fileName = "/tmp/kopitempout"; |
418 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 419 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
419 | system ( command.latin1() ); | 420 | system ( command.latin1() ); |
420 | } else { | 421 | } else { |
421 | fileName = "/tmp/todo.txt"; | 422 | fileName = "/tmp/todo.txt"; |
422 | } | 423 | } |
423 | file.setName( fileName ); | 424 | file.setName( fileName ); |
424 | if (!file.open( IO_ReadOnly ) ) { | 425 | if (!file.open( IO_ReadOnly ) ) { |
425 | return false; | 426 | return false; |