author | zautrix <zautrix> | 2005-01-16 10:26:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 10:26:46 (UTC) |
commit | 5138d4edea4189100ddc8bf6bd82bccbdcaebf95 (patch) (unidiff) | |
tree | c4ec0d0552d06065a1e9f8eb12c44fcbfdd19f4a /korganizer/calendarview.cpp | |
parent | 62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0 (diff) | |
download | kdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.zip kdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.tar.gz kdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.tar.bz2 |
filter setings changed
-rw-r--r-- | korganizer/calendarview.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 378c7d4..8258c74 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -807,384 +807,395 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
807 | case SYNC_PREF_REMOTE: | 807 | case SYNC_PREF_REMOTE: |
808 | if ( lastSync > remoteMod ) | 808 | if ( lastSync > remoteMod ) |
809 | return 1; | 809 | return 1; |
810 | if ( lastSync > localMod ) | 810 | if ( lastSync > localMod ) |
811 | return 2; | 811 | return 2; |
812 | return 2; | 812 | return 2; |
813 | break; | 813 | break; |
814 | case SYNC_PREF_NEWEST: | 814 | case SYNC_PREF_NEWEST: |
815 | if ( localMod > remoteMod ) | 815 | if ( localMod > remoteMod ) |
816 | return 1; | 816 | return 1; |
817 | else | 817 | else |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_ASK: | 820 | case SYNC_PREF_ASK: |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
822 | if ( lastSync > remoteMod ) | 822 | if ( lastSync > remoteMod ) |
823 | return 1; | 823 | return 1; |
824 | if ( lastSync > localMod ) | 824 | if ( lastSync > localMod ) |
825 | return 2; | 825 | return 2; |
826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
827 | localIsNew = localMod >= remoteMod; | 827 | localIsNew = localMod >= remoteMod; |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 1 ); | 829 | getEventViewerDialog()->setColorMode( 1 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
832 | getEventViewerDialog()->setIncidence(local); | 832 | getEventViewerDialog()->setIncidence(local); |
833 | if ( localIsNew ) | 833 | if ( localIsNew ) |
834 | getEventViewerDialog()->setColorMode( 2 ); | 834 | getEventViewerDialog()->setColorMode( 2 ); |
835 | else | 835 | else |
836 | getEventViewerDialog()->setColorMode( 1 ); | 836 | getEventViewerDialog()->setColorMode( 1 ); |
837 | getEventViewerDialog()->addIncidence(remote); | 837 | getEventViewerDialog()->addIncidence(remote); |
838 | getEventViewerDialog()->setColorMode( 0 ); | 838 | getEventViewerDialog()->setColorMode( 0 ); |
839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
841 | getEventViewerDialog()->showMe(); | 841 | getEventViewerDialog()->showMe(); |
842 | result = getEventViewerDialog()->executeS( localIsNew ); | 842 | result = getEventViewerDialog()->executeS( localIsNew ); |
843 | return result; | 843 | return result; |
844 | 844 | ||
845 | break; | 845 | break; |
846 | case SYNC_PREF_FORCE_LOCAL: | 846 | case SYNC_PREF_FORCE_LOCAL: |
847 | return 1; | 847 | return 1; |
848 | break; | 848 | break; |
849 | case SYNC_PREF_FORCE_REMOTE: | 849 | case SYNC_PREF_FORCE_REMOTE: |
850 | return 2; | 850 | return 2; |
851 | break; | 851 | break; |
852 | 852 | ||
853 | default: | 853 | default: |
854 | // SYNC_PREF_TAKE_BOTH not implemented | 854 | // SYNC_PREF_TAKE_BOTH not implemented |
855 | break; | 855 | break; |
856 | } | 856 | } |
857 | return 0; | 857 | return 0; |
858 | } | 858 | } |
859 | Event* CalendarView::getLastSyncEvent() | 859 | Event* CalendarView::getLastSyncEvent() |
860 | { | 860 | { |
861 | Event* lse; | 861 | Event* lse; |
862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | if (!lse) { | 864 | if (!lse) { |
865 | lse = new Event(); | 865 | lse = new Event(); |
866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
867 | QString sum = ""; | 867 | QString sum = ""; |
868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
869 | sum = "E: "; | 869 | sum = "E: "; |
870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
871 | lse->setDtStart( mLastCalendarSync ); | 871 | lse->setDtStart( mLastCalendarSync ); |
872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
873 | lse->setCategories( i18n("SyncEvent") ); | 873 | lse->setCategories( i18n("SyncEvent") ); |
874 | lse->setReadOnly( true ); | 874 | lse->setReadOnly( true ); |
875 | mCalendar->addEvent( lse ); | 875 | mCalendar->addEvent( lse ); |
876 | } | 876 | } |
877 | 877 | ||
878 | return lse; | 878 | return lse; |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | // we check, if the to delete event has a id for a profile | 882 | // we check, if the to delete event has a id for a profile |
883 | // if yes, we set this id in the profile to delete | 883 | // if yes, we set this id in the profile to delete |
884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
885 | { | 885 | { |
886 | if ( lastSync.count() == 0 ) { | 886 | if ( lastSync.count() == 0 ) { |
887 | //qDebug(" lastSync.count() == 0"); | 887 | //qDebug(" lastSync.count() == 0"); |
888 | return; | 888 | return; |
889 | } | 889 | } |
890 | if ( toDelete->type() == "Journal" ) | 890 | if ( toDelete->type() == "Journal" ) |
891 | return; | 891 | return; |
892 | 892 | ||
893 | Event* eve = lastSync.first(); | 893 | Event* eve = lastSync.first(); |
894 | 894 | ||
895 | while ( eve ) { | 895 | while ( eve ) { |
896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
897 | if ( !id.isEmpty() ) { | 897 | if ( !id.isEmpty() ) { |
898 | QString des = eve->description(); | 898 | QString des = eve->description(); |
899 | QString pref = "e"; | 899 | QString pref = "e"; |
900 | if ( toDelete->type() == "Todo" ) | 900 | if ( toDelete->type() == "Todo" ) |
901 | pref = "t"; | 901 | pref = "t"; |
902 | des += pref+ id + ","; | 902 | des += pref+ id + ","; |
903 | eve->setReadOnly( false ); | 903 | eve->setReadOnly( false ); |
904 | eve->setDescription( des ); | 904 | eve->setDescription( des ); |
905 | //qDebug("setdes %s ", des.latin1()); | 905 | //qDebug("setdes %s ", des.latin1()); |
906 | eve->setReadOnly( true ); | 906 | eve->setReadOnly( true ); |
907 | } | 907 | } |
908 | eve = lastSync.next(); | 908 | eve = lastSync.next(); |
909 | } | 909 | } |
910 | 910 | ||
911 | } | 911 | } |
912 | void CalendarView::checkExternalId( Incidence * inc ) | 912 | void CalendarView::checkExternalId( Incidence * inc ) |
913 | { | 913 | { |
914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
915 | checkExternSyncEvent( lastSync, inc ); | 915 | checkExternSyncEvent( lastSync, inc ); |
916 | 916 | ||
917 | } | 917 | } |
918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
919 | { | 919 | { |
920 | bool syncOK = true; | 920 | bool syncOK = true; |
921 | int addedEvent = 0; | 921 | int addedEvent = 0; |
922 | int addedEventR = 0; | 922 | int addedEventR = 0; |
923 | int deletedEventR = 0; | 923 | int deletedEventR = 0; |
924 | int deletedEventL = 0; | 924 | int deletedEventL = 0; |
925 | int changedLocal = 0; | 925 | int changedLocal = 0; |
926 | int changedRemote = 0; | 926 | int changedRemote = 0; |
927 | //QPtrList<Event> el = local->rawEvents(); | 927 | //QPtrList<Event> el = local->rawEvents(); |
928 | Event* eventR; | 928 | Event* eventR; |
929 | QString uid; | 929 | QString uid; |
930 | int take; | 930 | int take; |
931 | Event* eventL; | 931 | Event* eventL; |
932 | Event* eventRSync; | 932 | Event* eventRSync; |
933 | Event* eventLSync; | 933 | Event* eventLSync; |
934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
936 | bool fullDateRange = false; | 936 | bool fullDateRange = false; |
937 | local->resetTempSyncStat(); | 937 | local->resetTempSyncStat(); |
938 | mLastCalendarSync = QDateTime::currentDateTime(); | 938 | mLastCalendarSync = QDateTime::currentDateTime(); |
939 | if ( mSyncManager->syncWithDesktop() ) { | 939 | if ( mSyncManager->syncWithDesktop() ) { |
940 | remote->resetPilotStat(1); | 940 | remote->resetPilotStat(1); |
941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
944 | } else { | 944 | } else { |
945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | QDateTime modifiedCalendar = mLastCalendarSync; | 948 | QDateTime modifiedCalendar = mLastCalendarSync; |
949 | eventLSync = getLastSyncEvent(); | 949 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 951 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
954 | 954 | ||
955 | } else { | 955 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 958 | } else { |
959 | fullDateRange = true; | 959 | fullDateRange = true; |
960 | eventRSync = new Event(); | 960 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 963 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 965 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | 970 | ||
971 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 973 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 976 | fullDateRange = true; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | if ( mSyncManager->syncWithDesktop() ) { | 979 | if ( mSyncManager->syncWithDesktop() ) { |
980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
981 | } | 981 | } |
982 | if ( fullDateRange ) | 982 | if ( fullDateRange ) |
983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
984 | else | 984 | else |
985 | mLastCalendarSync = eventLSync->dtStart(); | 985 | mLastCalendarSync = eventLSync->dtStart(); |
986 | // for resyncing if own file has changed | 986 | // for resyncing if own file has changed |
987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
988 | mLastCalendarSync = loadedFileVersion; | 988 | mLastCalendarSync = loadedFileVersion; |
989 | //qDebug("setting mLastCalendarSync "); | 989 | //qDebug("setting mLastCalendarSync "); |
990 | } | 990 | } |
991 | //qDebug("*************************** "); | 991 | //qDebug("*************************** "); |
992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
993 | QPtrList<Incidence> er = remote->rawIncidences(); | 993 | QPtrList<Incidence> er = remote->rawIncidences(); |
994 | Incidence* inR = er.first(); | 994 | Incidence* inR = er.first(); |
995 | Incidence* inL; | 995 | Incidence* inL; |
996 | QProgressBar bar( er.count(),0 ); | 996 | QProgressBar bar( er.count(),0 ); |
997 | bar.setCaption (i18n("Syncing - close to abort!") ); | 997 | bar.setCaption (i18n("Syncing - close to abort!") ); |
998 | 998 | ||
999 | // ************** setting up filter ************* | ||
1000 | CalFilter *filterIN = 0; | ||
1001 | CalFilter *filterOUT = 0; | ||
1002 | CalFilter *filter = mFilters.first(); | ||
1003 | while(filter) { | ||
1004 | if ( filter->name() == mSyncManager->mFilterInCal ) | ||
1005 | filterIN = filter; | ||
1006 | if ( filter->name() == mSyncManager->mFilterOutCal ) | ||
1007 | filterOUT = filter; | ||
1008 | filter = mFilters.next(); | ||
1009 | } | ||
999 | int w = 300; | 1010 | int w = 300; |
1000 | if ( QApplication::desktop()->width() < 320 ) | 1011 | if ( QApplication::desktop()->width() < 320 ) |
1001 | w = 220; | 1012 | w = 220; |
1002 | int h = bar.sizeHint().height() ; | 1013 | int h = bar.sizeHint().height() ; |
1003 | int dw = QApplication::desktop()->width(); | 1014 | int dw = QApplication::desktop()->width(); |
1004 | int dh = QApplication::desktop()->height(); | 1015 | int dh = QApplication::desktop()->height(); |
1005 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1016 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1006 | bar.show(); | 1017 | bar.show(); |
1007 | int modulo = (er.count()/10)+1; | 1018 | int modulo = (er.count()/10)+1; |
1008 | int incCounter = 0; | 1019 | int incCounter = 0; |
1009 | while ( inR ) { | 1020 | while ( inR ) { |
1010 | if ( ! bar.isVisible() ) | 1021 | if ( ! bar.isVisible() ) |
1011 | return false; | 1022 | return false; |
1012 | if ( incCounter % modulo == 0 ) | 1023 | if ( incCounter % modulo == 0 ) |
1013 | bar.setProgress( incCounter ); | 1024 | bar.setProgress( incCounter ); |
1014 | ++incCounter; | 1025 | ++incCounter; |
1015 | uid = inR->uid(); | 1026 | uid = inR->uid(); |
1016 | bool skipIncidence = false; | 1027 | bool skipIncidence = false; |
1017 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1028 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1018 | skipIncidence = true; | 1029 | skipIncidence = true; |
1019 | QString idS; | 1030 | QString idS; |
1020 | qApp->processEvents(); | 1031 | qApp->processEvents(); |
1021 | if ( !skipIncidence ) { | 1032 | if ( !skipIncidence ) { |
1022 | inL = local->incidence( uid ); | 1033 | inL = local->incidence( uid ); |
1023 | if ( inL ) { // maybe conflict - same uid in both calendars | 1034 | if ( inL ) { // maybe conflict - same uid in both calendars |
1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1026 | if ( take == 3 ) | 1037 | if ( take == 3 ) |
1027 | return false; | 1038 | return false; |
1028 | if ( take == 1 ) {// take local ********************** | 1039 | if ( take == 1 ) {// take local ********************** |
1029 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1030 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1031 | else | 1042 | else |
1032 | idS = inR->IDStr(); | 1043 | idS = inR->IDStr(); |
1033 | remote->deleteIncidence( inR ); | 1044 | remote->deleteIncidence( inR ); |
1034 | inR = inL->clone(); | 1045 | inR = inL->clone(); |
1035 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1036 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1037 | inR->setIDStr( idS ); | 1048 | inR->setIDStr( idS ); |
1038 | remote->addIncidence( inR ); | 1049 | remote->addIncidence( inR ); |
1039 | if ( mSyncManager->syncWithDesktop() ) | 1050 | if ( mSyncManager->syncWithDesktop() ) |
1040 | inR->setPilotId( 2 ); | 1051 | inR->setPilotId( 2 ); |
1041 | ++changedRemote; | 1052 | ++changedRemote; |
1042 | } else {// take remote ********************** | 1053 | } else {// take remote ********************** |
1043 | idS = inL->IDStr(); | 1054 | idS = inL->IDStr(); |
1044 | int pid = inL->pilotId(); | 1055 | int pid = inL->pilotId(); |
1045 | local->deleteIncidence( inL ); | 1056 | local->deleteIncidence( inL ); |
1046 | inL = inR->clone(); | 1057 | inL = inR->clone(); |
1047 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1048 | inL->setPilotId( pid ); | 1059 | inL->setPilotId( pid ); |
1049 | inL->setIDStr( idS ); | 1060 | inL->setIDStr( idS ); |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1052 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1053 | } | 1064 | } |
1054 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1055 | ++changedLocal; | 1066 | ++changedLocal; |
1056 | } | 1067 | } |
1057 | } | 1068 | } |
1058 | } else { // no conflict ********** add or delete remote | 1069 | } else { // no conflict ********** add or delete remote |
1059 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1070 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1060 | QString des = eventLSync->description(); | 1071 | QString des = eventLSync->description(); |
1061 | QString pref = "e"; | 1072 | QString pref = "e"; |
1062 | if ( inR->type() == "Todo" ) | 1073 | if ( inR->type() == "Todo" ) |
1063 | pref = "t"; | 1074 | pref = "t"; |
1064 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1065 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1066 | //remote->deleteIncidence( inR ); | 1077 | //remote->deleteIncidence( inR ); |
1067 | ++deletedEventR; | 1078 | ++deletedEventR; |
1068 | } else { | 1079 | } else { |
1069 | inR->setLastModified( modifiedCalendar ); | 1080 | inR->setLastModified( modifiedCalendar ); |
1070 | inL = inR->clone(); | 1081 | inL = inR->clone(); |
1071 | inL->setIDStr( ":" ); | 1082 | inL->setIDStr( ":" ); |
1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1083 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1084 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1074 | local->addIncidence( inL ); | 1085 | local->addIncidence( inL ); |
1075 | ++addedEvent; | 1086 | ++addedEvent; |
1076 | } | 1087 | } |
1077 | } else { | 1088 | } else { |
1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1089 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1079 | inR->setLastModified( modifiedCalendar ); | 1090 | inR->setLastModified( modifiedCalendar ); |
1080 | inL = inR->clone(); | 1091 | inL = inR->clone(); |
1081 | inL->setIDStr( ":" ); | 1092 | inL->setIDStr( ":" ); |
1082 | local->addIncidence( inL ); | 1093 | local->addIncidence( inL ); |
1083 | ++addedEvent; | 1094 | ++addedEvent; |
1084 | } else { | 1095 | } else { |
1085 | checkExternSyncEvent(eventRSyncSharp, inR); | 1096 | checkExternSyncEvent(eventRSyncSharp, inR); |
1086 | remote->deleteIncidence( inR ); | 1097 | remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1098 | ++deletedEventR; |
1088 | } | 1099 | } |
1089 | } | 1100 | } |
1090 | } | 1101 | } |
1091 | } | 1102 | } |
1092 | inR = er.next(); | 1103 | inR = er.next(); |
1093 | } | 1104 | } |
1094 | QPtrList<Incidence> el = local->rawIncidences(); | 1105 | QPtrList<Incidence> el = local->rawIncidences(); |
1095 | inL = el.first(); | 1106 | inL = el.first(); |
1096 | modulo = (el.count()/10)+1; | 1107 | modulo = (el.count()/10)+1; |
1097 | bar.setCaption (i18n("Add / remove events") ); | 1108 | bar.setCaption (i18n("Add / remove events") ); |
1098 | bar.setTotalSteps ( el.count() ) ; | 1109 | bar.setTotalSteps ( el.count() ) ; |
1099 | bar.show(); | 1110 | bar.show(); |
1100 | incCounter = 0; | 1111 | incCounter = 0; |
1101 | 1112 | ||
1102 | while ( inL ) { | 1113 | while ( inL ) { |
1103 | 1114 | ||
1104 | qApp->processEvents(); | 1115 | qApp->processEvents(); |
1105 | if ( ! bar.isVisible() ) | 1116 | if ( ! bar.isVisible() ) |
1106 | return false; | 1117 | return false; |
1107 | if ( incCounter % modulo == 0 ) | 1118 | if ( incCounter % modulo == 0 ) |
1108 | bar.setProgress( incCounter ); | 1119 | bar.setProgress( incCounter ); |
1109 | ++incCounter; | 1120 | ++incCounter; |
1110 | uid = inL->uid(); | 1121 | uid = inL->uid(); |
1111 | bool skipIncidence = false; | 1122 | bool skipIncidence = false; |
1112 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1123 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1113 | skipIncidence = true; | 1124 | skipIncidence = true; |
1114 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1125 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1115 | skipIncidence = true; | 1126 | skipIncidence = true; |
1116 | if ( !skipIncidence ) { | 1127 | if ( !skipIncidence ) { |
1117 | inR = remote->incidence( uid ); | 1128 | inR = remote->incidence( uid ); |
1118 | if ( ! inR ) { // no conflict ********** add or delete local | 1129 | if ( ! inR ) { // no conflict ********** add or delete local |
1119 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1130 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1120 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1131 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1121 | checkExternSyncEvent(eventLSyncSharp, inL); | 1132 | checkExternSyncEvent(eventLSyncSharp, inL); |
1122 | local->deleteIncidence( inL ); | 1133 | local->deleteIncidence( inL ); |
1123 | ++deletedEventL; | 1134 | ++deletedEventL; |
1124 | } else { | 1135 | } else { |
1125 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1136 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1126 | inL->removeID(mCurrentSyncDevice ); | 1137 | inL->removeID(mCurrentSyncDevice ); |
1127 | ++addedEventR; | 1138 | ++addedEventR; |
1128 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1139 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1129 | inL->setLastModified( modifiedCalendar ); | 1140 | inL->setLastModified( modifiedCalendar ); |
1130 | inR = inL->clone(); | 1141 | inR = inL->clone(); |
1131 | inR->setIDStr( ":" ); | 1142 | inR->setIDStr( ":" ); |
1132 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1143 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1133 | remote->addIncidence( inR ); | 1144 | remote->addIncidence( inR ); |
1134 | } | 1145 | } |
1135 | } | 1146 | } |
1136 | } else { | 1147 | } else { |
1137 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1148 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1138 | checkExternSyncEvent(eventLSyncSharp, inL); | 1149 | checkExternSyncEvent(eventLSyncSharp, inL); |
1139 | local->deleteIncidence( inL ); | 1150 | local->deleteIncidence( inL ); |
1140 | ++deletedEventL; | 1151 | ++deletedEventL; |
1141 | } else { | 1152 | } else { |
1142 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1153 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1143 | ++addedEventR; | 1154 | ++addedEventR; |
1144 | inL->setLastModified( modifiedCalendar ); | 1155 | inL->setLastModified( modifiedCalendar ); |
1145 | inR = inL->clone(); | 1156 | inR = inL->clone(); |
1146 | inR->setIDStr( ":" ); | 1157 | inR->setIDStr( ":" ); |
1147 | remote->addIncidence( inR ); | 1158 | remote->addIncidence( inR ); |
1148 | } | 1159 | } |
1149 | } | 1160 | } |
1150 | } | 1161 | } |
1151 | } | 1162 | } |
1152 | } | 1163 | } |
1153 | inL = el.next(); | 1164 | inL = el.next(); |
1154 | } | 1165 | } |
1155 | int delFut = 0; | 1166 | int delFut = 0; |
1156 | int remRem = 0; | 1167 | int remRem = 0; |
1157 | if ( mSyncManager->mWriteBackInFuture ) { | 1168 | if ( mSyncManager->mWriteBackInFuture ) { |
1158 | er = remote->rawIncidences(); | 1169 | er = remote->rawIncidences(); |
1159 | remRem = er.count(); | 1170 | remRem = er.count(); |
1160 | inR = er.first(); | 1171 | inR = er.first(); |
1161 | QDateTime dt; | 1172 | QDateTime dt; |
1162 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1173 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1163 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1174 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1164 | while ( inR ) { | 1175 | while ( inR ) { |
1165 | if ( inR->type() == "Todo" ) { | 1176 | if ( inR->type() == "Todo" ) { |
1166 | Todo * t = (Todo*)inR; | 1177 | Todo * t = (Todo*)inR; |
1167 | if ( t->hasDueDate() ) | 1178 | if ( t->hasDueDate() ) |
1168 | dt = t->dtDue(); | 1179 | dt = t->dtDue(); |
1169 | else | 1180 | else |
1170 | dt = cur.addSecs( 62 ); | 1181 | dt = cur.addSecs( 62 ); |
1171 | } | 1182 | } |
1172 | else if (inR->type() == "Event" ) { | 1183 | else if (inR->type() == "Event" ) { |
1173 | bool ok; | 1184 | bool ok; |
1174 | dt = inR->getNextOccurence( cur, &ok ); | 1185 | dt = inR->getNextOccurence( cur, &ok ); |
1175 | if ( !ok ) | 1186 | if ( !ok ) |
1176 | dt = cur.addSecs( -62 ); | 1187 | dt = cur.addSecs( -62 ); |
1177 | } | 1188 | } |
1178 | else | 1189 | else |
1179 | dt = inR->dtStart(); | 1190 | dt = inR->dtStart(); |
1180 | if ( dt < cur || dt > end ) { | 1191 | if ( dt < cur || dt > end ) { |
1181 | remote->deleteIncidence( inR ); | 1192 | remote->deleteIncidence( inR ); |
1182 | ++delFut; | 1193 | ++delFut; |
1183 | } | 1194 | } |
1184 | inR = er.next(); | 1195 | inR = er.next(); |
1185 | } | 1196 | } |
1186 | } | 1197 | } |
1187 | bar.hide(); | 1198 | bar.hide(); |
1188 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1199 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1189 | eventLSync->setReadOnly( false ); | 1200 | eventLSync->setReadOnly( false ); |
1190 | eventLSync->setDtStart( mLastCalendarSync ); | 1201 | eventLSync->setDtStart( mLastCalendarSync ); |