-rw-r--r-- | korganizer/calendarview.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ff1db2c..290c0b9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -653,134 +653,128 @@ void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | |||
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | //void setZaurusId(int id); | ||
718 | // int zaurusId() const; | ||
719 | // void setZaurusUid(int id); | ||
720 | // int zaurusUid() const; | ||
721 | // void setZaurusStat(int id); | ||
722 | // int zaurusStat() const; | ||
723 | // 0 equal | 717 | // 0 equal |
724 | // 1 take local | 718 | // 1 take local |
725 | // 2 take remote | 719 | // 2 take remote |
726 | // 3 cancel | 720 | // 3 cancel |
727 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
728 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
729 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
731 | bool remCh, locCh; | 725 | bool remCh, locCh; |
732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
733 | //if ( remCh ) | 727 | //if ( remCh ) |
734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
735 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
736 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
737 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
738 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
739 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
740 | return 0; | 734 | return 0; |
741 | } else { | 735 | } else { |
742 | if ( locCh ) { | 736 | if ( locCh ) { |
743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
744 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
745 | if ( !remCh ) | 739 | if ( !remCh ) |
746 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
747 | } else { | 741 | } else { |
748 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
749 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
750 | if ( remCh ) | 744 | if ( remCh ) |
751 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
752 | 746 | ||
753 | } | 747 | } |
754 | } | 748 | } |
755 | full = true; | 749 | full = true; |
756 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
757 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
758 | } else { | 752 | } else { |
759 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
760 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
761 | return 0; | 755 | return 0; |
762 | 756 | ||
763 | } | 757 | } |
764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
765 | 759 | ||
766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
768 | //full = true; //debug only | 762 | //full = true; //debug only |
769 | if ( full ) { | 763 | if ( full ) { |
770 | bool equ = false; | 764 | bool equ = false; |
771 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
772 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
773 | } | 767 | } |
774 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
775 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
776 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
777 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
778 | if ( equ ) { | 772 | if ( equ ) { |
779 | //qDebug("equal "); | 773 | //qDebug("equal "); |
780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
782 | } | 776 | } |
783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
784 | return 0; | 778 | return 0; |
785 | 779 | ||
786 | }//else //debug only | 780 | }//else //debug only |
@@ -882,219 +876,212 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
882 | { | 876 | { |
883 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
884 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
885 | return; | 879 | return; |
886 | } | 880 | } |
887 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
888 | return; | 882 | return; |
889 | 883 | ||
890 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
891 | 885 | ||
892 | while ( eve ) { | 886 | while ( eve ) { |
893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
894 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
895 | QString des = eve->description(); | 889 | QString des = eve->description(); |
896 | QString pref = "e"; | 890 | QString pref = "e"; |
897 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
898 | pref = "t"; | 892 | pref = "t"; |
899 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
900 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
901 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
902 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
903 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
904 | } | 898 | } |
905 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
906 | } | 900 | } |
907 | 901 | ||
908 | } | 902 | } |
909 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
910 | { | 904 | { |
911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
912 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
913 | 907 | ||
914 | } | 908 | } |
915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
916 | { | 910 | { |
917 | bool syncOK = true; | 911 | bool syncOK = true; |
918 | int addedEvent = 0; | 912 | int addedEvent = 0; |
919 | int addedEventR = 0; | 913 | int addedEventR = 0; |
920 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
921 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
922 | int changedLocal = 0; | 916 | int changedLocal = 0; |
923 | int changedRemote = 0; | 917 | int changedRemote = 0; |
924 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
925 | Event* eventR; | 919 | Event* eventR; |
926 | QString uid; | 920 | QString uid; |
927 | int take; | 921 | int take; |
928 | Event* eventL; | 922 | Event* eventL; |
929 | Event* eventRSync; | 923 | Event* eventRSync; |
930 | Event* eventLSync; | 924 | Event* eventLSync; |
931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
933 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
934 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
935 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
936 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
937 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
938 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
939 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
941 | if ( eventR ) { | 935 | if ( eventR ) { |
942 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
943 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
944 | 938 | ||
945 | } else { | 939 | } else { |
946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
947 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
948 | } else { | 942 | } else { |
949 | fullDateRange = true; | 943 | fullDateRange = true; |
950 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
953 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
955 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
956 | } | 950 | } |
957 | } | 951 | } |
958 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
959 | fullDateRange = true; | 953 | fullDateRange = true; |
960 | 954 | ||
961 | if ( ! fullDateRange ) { | 955 | if ( ! fullDateRange ) { |
962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
963 | 957 | ||
964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
966 | fullDateRange = true; | 960 | fullDateRange = true; |
967 | } | 961 | } |
968 | } | 962 | } |
969 | if ( fullDateRange && !mSyncKDE ) | 963 | if ( fullDateRange && !mSyncKDE ) |
970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
971 | else | 965 | else |
972 | mLastCalendarSync = eventLSync->dtStart(); | 966 | mLastCalendarSync = eventLSync->dtStart(); |
973 | // for resyncing if own file has changed | 967 | // for resyncing if own file has changed |
974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
975 | mLastCalendarSync = loadedFileVersion; | 969 | mLastCalendarSync = loadedFileVersion; |
976 | qDebug("setting mLastCalendarSync "); | 970 | //qDebug("setting mLastCalendarSync "); |
977 | } | 971 | } |
978 | //qDebug("*************************** "); | 972 | //qDebug("*************************** "); |
979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
980 | QPtrList<Incidence> er = remote->rawIncidences(); | 974 | QPtrList<Incidence> er = remote->rawIncidences(); |
981 | Incidence* inR = er.first(); | 975 | Incidence* inR = er.first(); |
982 | Incidence* inL; | 976 | Incidence* inL; |
983 | QProgressBar bar( er.count(),0 ); | 977 | QProgressBar bar( er.count(),0 ); |
984 | bar.setCaption (i18n("Syncing - close to abort!") ); | 978 | bar.setCaption (i18n("Syncing - close to abort!") ); |
985 | 979 | ||
986 | int w = 300; | 980 | int w = 300; |
987 | if ( QApplication::desktop()->width() < 320 ) | 981 | if ( QApplication::desktop()->width() < 320 ) |
988 | w = 220; | 982 | w = 220; |
989 | int h = bar.sizeHint().height() ; | 983 | int h = bar.sizeHint().height() ; |
990 | int dw = QApplication::desktop()->width(); | 984 | int dw = QApplication::desktop()->width(); |
991 | int dh = QApplication::desktop()->height(); | 985 | int dh = QApplication::desktop()->height(); |
992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
993 | bar.show(); | 987 | bar.show(); |
994 | int modulo = (er.count()/10)+1; | 988 | int modulo = (er.count()/10)+1; |
995 | int incCounter = 0; | 989 | int incCounter = 0; |
996 | while ( inR ) { | 990 | while ( inR ) { |
997 | if ( ! bar.isVisible() ) | 991 | if ( ! bar.isVisible() ) |
998 | return false; | 992 | return false; |
999 | if ( incCounter % modulo == 0 ) | 993 | if ( incCounter % modulo == 0 ) |
1000 | bar.setProgress( incCounter ); | 994 | bar.setProgress( incCounter ); |
1001 | ++incCounter; | 995 | ++incCounter; |
1002 | uid = inR->uid(); | 996 | uid = inR->uid(); |
1003 | bool skipIncidence = false; | 997 | bool skipIncidence = false; |
1004 | if ( uid.left(15) == QString("last-syncEvent-") ) | 998 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1005 | skipIncidence = true; | 999 | skipIncidence = true; |
1006 | QString idS; | 1000 | QString idS; |
1007 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
1008 | if ( !skipIncidence ) { | 1002 | if ( !skipIncidence ) { |
1009 | inL = local->incidence( uid ); | 1003 | inL = local->incidence( uid ); |
1010 | if ( inL ) { // maybe conflict - same uid in both calendars | 1004 | if ( inL ) { // maybe conflict - same uid in both calendars |
1011 | int maxrev = inL->revision(); | ||
1012 | if ( maxrev < inR->revision() ) | ||
1013 | maxrev = inR->revision(); | ||
1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1016 | if ( take == 3 ) | 1007 | if ( take == 3 ) |
1017 | return false; | 1008 | return false; |
1018 | if ( take == 1 ) {// take local | 1009 | if ( take == 1 ) {// take local |
1019 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1021 | else | 1012 | else |
1022 | idS = inR->IDStr(); | 1013 | idS = inR->IDStr(); |
1023 | remote->deleteIncidence( inR ); | 1014 | remote->deleteIncidence( inR ); |
1024 | if ( inL->revision() < maxrev ) | ||
1025 | inL->setRevision( maxrev ); | ||
1026 | inR = inL->clone(); | 1015 | inR = inL->clone(); |
1027 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1028 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1029 | inR->setIDStr( idS ); | 1018 | inR->setIDStr( idS ); |
1030 | remote->addIncidence( inR ); | 1019 | remote->addIncidence( inR ); |
1031 | if ( mSyncKDE ) | 1020 | if ( mSyncKDE ) |
1032 | inR->setPilotId( 2 ); | 1021 | inR->setPilotId( 2 ); |
1033 | ++changedRemote; | 1022 | ++changedRemote; |
1034 | } else { | 1023 | } else { |
1035 | if ( inR->revision() < maxrev ) | ||
1036 | inR->setRevision( maxrev ); | ||
1037 | idS = inL->IDStr(); | 1024 | idS = inL->IDStr(); |
1038 | int pid = inL->pilotId(); | 1025 | int pid = inL->pilotId(); |
1039 | local->deleteIncidence( inL ); | 1026 | local->deleteIncidence( inL ); |
1040 | inL = inR->clone(); | 1027 | inL = inR->clone(); |
1041 | if ( mSyncKDE ) | 1028 | if ( mSyncKDE ) |
1042 | inL->setPilotId( pid ); | 1029 | inL->setPilotId( pid ); |
1043 | inL->setIDStr( idS ); | 1030 | inL->setIDStr( idS ); |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1046 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1047 | } | 1034 | } |
1048 | local->addIncidence( inL ); | 1035 | local->addIncidence( inL ); |
1049 | ++changedLocal; | 1036 | ++changedLocal; |
1050 | } | 1037 | } |
1051 | } | 1038 | } |
1052 | } else { // no conflict | 1039 | } else { // no conflict |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | QString des = eventLSync->description(); | 1041 | QString des = eventLSync->description(); |
1055 | QString pref = "e"; | 1042 | QString pref = "e"; |
1056 | if ( inR->type() == "Todo" ) | 1043 | if ( inR->type() == "Todo" ) |
1057 | pref = "t"; | 1044 | pref = "t"; |
1058 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1059 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1060 | //remote->deleteIncidence( inR ); | 1047 | //remote->deleteIncidence( inR ); |
1061 | ++deletedEventR; | 1048 | ++deletedEventR; |
1062 | } else { | 1049 | } else { |
1063 | inR->setLastModified( modifiedCalendar ); | 1050 | inR->setLastModified( modifiedCalendar ); |
1064 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1065 | local->addIncidence( inL ); | 1052 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1053 | ++addedEvent; |
1067 | } | 1054 | } |
1068 | } else { | 1055 | } else { |
1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1070 | inR->setLastModified( modifiedCalendar ); | 1057 | inR->setLastModified( modifiedCalendar ); |
1071 | local->addIncidence( inR->clone() ); | 1058 | local->addIncidence( inR->clone() ); |
1072 | ++addedEvent; | 1059 | ++addedEvent; |
1073 | } else { | 1060 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1061 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1062 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1063 | ++deletedEventR; |
1077 | } | 1064 | } |
1078 | } | 1065 | } |
1079 | } | 1066 | } |
1080 | } | 1067 | } |
1081 | inR = er.next(); | 1068 | inR = er.next(); |
1082 | } | 1069 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1070 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1071 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1072 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1073 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1074 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1075 | bar.show(); |
1089 | incCounter = 0; | 1076 | incCounter = 0; |
1090 | 1077 | ||
1091 | while ( inL ) { | 1078 | while ( inL ) { |
1092 | 1079 | ||
1093 | qApp->processEvents(); | 1080 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1081 | if ( ! bar.isVisible() ) |
1095 | return false; | 1082 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1083 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1084 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1085 | ++incCounter; |
1099 | uid = inL->uid(); | 1086 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1087 | bool skipIncidence = false; |