summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bbed05b..7fae4a9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -988,128 +988,132 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
988 mLastCalendarSync = loadedFileVersion; 988 mLastCalendarSync = loadedFileVersion;
989 qDebug("setting mLastCalendarSync "); 989 qDebug("setting mLastCalendarSync ");
990 } 990 }
991 //qDebug("*************************** "); 991 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 992 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
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 int w = 300; 999 int w = 300;
1000 if ( QApplication::desktop()->width() < 320 ) 1000 if ( QApplication::desktop()->width() < 320 )
1001 w = 220; 1001 w = 220;
1002 int h = bar.sizeHint().height() ; 1002 int h = bar.sizeHint().height() ;
1003 int dw = QApplication::desktop()->width(); 1003 int dw = QApplication::desktop()->width();
1004 int dh = QApplication::desktop()->height(); 1004 int dh = QApplication::desktop()->height();
1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1006 bar.show(); 1006 bar.show();
1007 int modulo = (er.count()/10)+1; 1007 int modulo = (er.count()/10)+1;
1008 int incCounter = 0; 1008 int incCounter = 0;
1009 while ( inR ) { 1009 while ( inR ) {
1010 if ( ! bar.isVisible() ) 1010 if ( ! bar.isVisible() )
1011 return false; 1011 return false;
1012 if ( incCounter % modulo == 0 ) 1012 if ( incCounter % modulo == 0 )
1013 bar.setProgress( incCounter ); 1013 bar.setProgress( incCounter );
1014 ++incCounter; 1014 ++incCounter;
1015 uid = inR->uid(); 1015 uid = inR->uid();
1016 bool skipIncidence = false; 1016 bool skipIncidence = false;
1017 if ( uid.left(15) == QString("last-syncEvent-") ) 1017 if ( uid.left(15) == QString("last-syncEvent-") )
1018 skipIncidence = true; 1018 skipIncidence = true;
1019 QString idS; 1019 QString idS;
1020 qApp->processEvents(); 1020 qApp->processEvents();
1021 if ( !skipIncidence ) { 1021 if ( !skipIncidence ) {
1022 inL = local->incidence( uid ); 1022 inL = local->incidence( uid );
1023 if ( inL ) { // maybe conflict - same uid in both calendars 1023 if ( inL ) { // maybe conflict - same uid in both calendars
1024 int maxrev = inL->revision(); 1024 int maxrev = inL->revision();
1025 if ( maxrev < inR->revision() ) 1025 if ( maxrev < inR->revision() )
1026 maxrev = inR->revision(); 1026 maxrev = inR->revision();
1027 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1027 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1028 //qDebug("take %d %s ", take, inL->summary().latin1()); 1028 //qDebug("take %d %s ", take, inL->summary().latin1());
1029 if ( take == 3 ) 1029 if ( take == 3 )
1030 return false; 1030 return false;
1031 if ( take == 1 ) {// take local 1031 if ( take == 1 ) {// take local
1032 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1032 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1033 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1033 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1034 else 1034 else
1035 idS = inR->IDStr(); 1035 idS = inR->IDStr();
1036 remote->deleteIncidence( inR ); 1036 remote->deleteIncidence( inR );
1037 if ( inL->revision() < maxrev ) 1037 if ( inL->revision() < maxrev )
1038 inL->setRevision( maxrev ); 1038 inL->setRevision( maxrev );
1039 inR = inL->clone(); 1039 inR = inL->clone();
1040 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1040 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1041 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1041 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1042 inR->setIDStr( idS ); 1042 inR->setIDStr( idS );
1043 remote->addIncidence( inR ); 1043 remote->addIncidence( inR );
1044 ++changedRemote; 1044 ++changedRemote;
1045 } else { 1045 } else {
1046 if ( inR->revision() < maxrev ) 1046 if ( inR->revision() < maxrev )
1047 inR->setRevision( maxrev ); 1047 inR->setRevision( maxrev );
1048 idS = inL->IDStr(); 1048 idS = inL->IDStr();
1049 local->deleteIncidence( inL ); 1049 local->deleteIncidence( inL );
1050 inL = inR->clone(); 1050 inL = inR->clone();
1051 inL->setIDStr( idS ); 1051 inL->setIDStr( idS );
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1055 }
1052 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1053 ++changedLocal; 1057 ++changedLocal;
1054 } 1058 }
1055 } 1059 }
1056 } else { // no conflict 1060 } else { // no conflict
1057 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1058 QString des = eventLSync->description(); 1062 QString des = eventLSync->description();
1059 QString pref = "e"; 1063 QString pref = "e";
1060 if ( inR->type() == "Todo" ) 1064 if ( inR->type() == "Todo" )
1061 pref = "t"; 1065 pref = "t";
1062 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1066 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1063 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1067 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1064 //remote->deleteIncidence( inR ); 1068 //remote->deleteIncidence( inR );
1065 ++deletedEventR; 1069 ++deletedEventR;
1066 } else { 1070 } else {
1067 inR->setLastModified( modifiedCalendar ); 1071 inR->setLastModified( modifiedCalendar );
1068 inL = inR->clone(); 1072 inL = inR->clone();
1069 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1070 ++addedEvent; 1074 ++addedEvent;
1071 } 1075 }
1072 } else { 1076 } else {
1073 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1077 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1074 inR->setLastModified( modifiedCalendar ); 1078 inR->setLastModified( modifiedCalendar );
1075 local->addIncidence( inR->clone() ); 1079 local->addIncidence( inR->clone() );
1076 ++addedEvent; 1080 ++addedEvent;
1077 } else { 1081 } else {
1078 checkExternSyncEvent(eventRSyncSharp, inR); 1082 checkExternSyncEvent(eventRSyncSharp, inR);
1079 remote->deleteIncidence( inR ); 1083 remote->deleteIncidence( inR );
1080 ++deletedEventR; 1084 ++deletedEventR;
1081 } 1085 }
1082 } 1086 }
1083 } 1087 }
1084 } 1088 }
1085 inR = er.next(); 1089 inR = er.next();
1086 } 1090 }
1087 QPtrList<Incidence> el = local->rawIncidences(); 1091 QPtrList<Incidence> el = local->rawIncidences();
1088 inL = el.first(); 1092 inL = el.first();
1089 modulo = (el.count()/10)+1; 1093 modulo = (el.count()/10)+1;
1090 bar.setCaption (i18n("Add / remove events") ); 1094 bar.setCaption (i18n("Add / remove events") );
1091 bar.setTotalSteps ( el.count() ) ; 1095 bar.setTotalSteps ( el.count() ) ;
1092 bar.show(); 1096 bar.show();
1093 incCounter = 0; 1097 incCounter = 0;
1094 1098
1095 while ( inL ) { 1099 while ( inL ) {
1096 1100
1097 qApp->processEvents(); 1101 qApp->processEvents();
1098 if ( ! bar.isVisible() ) 1102 if ( ! bar.isVisible() )
1099 return false; 1103 return false;
1100 if ( incCounter % modulo == 0 ) 1104 if ( incCounter % modulo == 0 )
1101 bar.setProgress( incCounter ); 1105 bar.setProgress( incCounter );
1102 ++incCounter; 1106 ++incCounter;
1103 uid = inL->uid(); 1107 uid = inL->uid();
1104 bool skipIncidence = false; 1108 bool skipIncidence = false;
1105 if ( uid.left(15) == QString("last-syncEvent-") ) 1109 if ( uid.left(15) == QString("last-syncEvent-") )
1106 skipIncidence = true; 1110 skipIncidence = true;
1107 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1111 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1108 skipIncidence = true; 1112 skipIncidence = true;
1109 if ( !skipIncidence ) { 1113 if ( !skipIncidence ) {
1110 inR = remote->incidence( uid ); 1114 inR = remote->incidence( uid );
1111 if ( ! inR ) { 1115 if ( ! inR ) {
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1116 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1113 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1117 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1114 checkExternSyncEvent(eventLSyncSharp, inL); 1118 checkExternSyncEvent(eventLSyncSharp, inL);
1115 local->deleteIncidence( inL ); 1119 local->deleteIncidence( inL );