summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp58
1 files changed, 33 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8258c74..02c5e45 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1056,127 +1056,135 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1056 local->deleteIncidence( inL ); 1056 local->deleteIncidence( inL );
1057 inL = inR->clone(); 1057 inL = inR->clone();
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inL->setPilotId( pid ); 1059 inL->setPilotId( pid );
1060 inL->setIDStr( idS ); 1060 inL->setIDStr( idS );
1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1064 } 1064 }
1065 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1066 ++changedLocal; 1066 ++changedLocal;
1067 } 1067 }
1068 } 1068 }
1069 } else { // no conflict ********** add or delete remote 1069 } else { // no conflict ********** add or delete remote
1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1071 QString des = eventLSync->description(); 1071 QString des = eventLSync->description();
1072 QString pref = "e"; 1072 QString pref = "e";
1073 if ( inR->type() == "Todo" ) 1073 if ( inR->type() == "Todo" )
1074 pref = "t"; 1074 pref = "t";
1075 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
1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1077 //remote->deleteIncidence( inR ); 1077 //remote->deleteIncidence( inR );
1078 ++deletedEventR; 1078 ++deletedEventR;
1079 } else { 1079 } else {
1080 inR->setLastModified( modifiedCalendar ); 1080 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1081 inL = inR->clone(); 1081 inR->setLastModified( modifiedCalendar );
1082 inL->setIDStr( ":" ); 1082 inL = inR->clone();
1083 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1083 inL->setIDStr( ":" );
1084 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1084 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1085 local->addIncidence( inL ); 1085 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1086 ++addedEvent; 1086 local->addIncidence( inL );
1087 ++addedEvent;
1088 }
1087 } 1089 }
1088 } else { 1090 } else {
1089 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1091 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1090 inR->setLastModified( modifiedCalendar ); 1092 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1091 inL = inR->clone(); 1093 inR->setLastModified( modifiedCalendar );
1092 inL->setIDStr( ":" ); 1094 inL = inR->clone();
1093 local->addIncidence( inL ); 1095 inL->setIDStr( ":" );
1094 ++addedEvent; 1096 local->addIncidence( inL );
1097 ++addedEvent;
1098 }
1095 } else { 1099 } else {
1096 checkExternSyncEvent(eventRSyncSharp, inR); 1100 checkExternSyncEvent(eventRSyncSharp, inR);
1097 remote->deleteIncidence( inR ); 1101 remote->deleteIncidence( inR );
1098 ++deletedEventR; 1102 ++deletedEventR;
1099 } 1103 }
1100 } 1104 }
1101 } 1105 }
1102 } 1106 }
1103 inR = er.next(); 1107 inR = er.next();
1104 } 1108 }
1105 QPtrList<Incidence> el = local->rawIncidences(); 1109 QPtrList<Incidence> el = local->rawIncidences();
1106 inL = el.first(); 1110 inL = el.first();
1107 modulo = (el.count()/10)+1; 1111 modulo = (el.count()/10)+1;
1108 bar.setCaption (i18n("Add / remove events") ); 1112 bar.setCaption (i18n("Add / remove events") );
1109 bar.setTotalSteps ( el.count() ) ; 1113 bar.setTotalSteps ( el.count() ) ;
1110 bar.show(); 1114 bar.show();
1111 incCounter = 0; 1115 incCounter = 0;
1112 1116
1113 while ( inL ) { 1117 while ( inL ) {
1114 1118
1115 qApp->processEvents(); 1119 qApp->processEvents();
1116 if ( ! bar.isVisible() ) 1120 if ( ! bar.isVisible() )
1117 return false; 1121 return false;
1118 if ( incCounter % modulo == 0 ) 1122 if ( incCounter % modulo == 0 )
1119 bar.setProgress( incCounter ); 1123 bar.setProgress( incCounter );
1120 ++incCounter; 1124 ++incCounter;
1121 uid = inL->uid(); 1125 uid = inL->uid();
1122 bool skipIncidence = false; 1126 bool skipIncidence = false;
1123 if ( uid.left(15) == QString("last-syncEvent-") ) 1127 if ( uid.left(15) == QString("last-syncEvent-") )
1124 skipIncidence = true; 1128 skipIncidence = true;
1125 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1126 skipIncidence = true; 1130 skipIncidence = true;
1127 if ( !skipIncidence ) { 1131 if ( !skipIncidence ) {
1128 inR = remote->incidence( uid ); 1132 inR = remote->incidence( uid );
1129 if ( ! inR ) { // no conflict ********** add or delete local 1133 if ( ! inR ) { // no conflict ********** add or delete local
1130 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1131 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1135 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1132 checkExternSyncEvent(eventLSyncSharp, inL); 1136 checkExternSyncEvent(eventLSyncSharp, inL);
1133 local->deleteIncidence( inL ); 1137 local->deleteIncidence( inL );
1134 ++deletedEventL; 1138 ++deletedEventL;
1135 } else { 1139 } else {
1136 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1140 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1137 inL->removeID(mCurrentSyncDevice ); 1141 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1138 ++addedEventR; 1142 inL->removeID(mCurrentSyncDevice );
1139 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1143 ++addedEventR;
1140 inL->setLastModified( modifiedCalendar ); 1144 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1141 inR = inL->clone(); 1145 inL->setLastModified( modifiedCalendar );
1142 inR->setIDStr( ":" ); 1146 inR = inL->clone();
1143 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1147 inR->setIDStr( ":" );
1144 remote->addIncidence( inR ); 1148 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1149 remote->addIncidence( inR );
1150 }
1145 } 1151 }
1146 } 1152 }
1147 } else { 1153 } else {
1148 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1154 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1149 checkExternSyncEvent(eventLSyncSharp, inL); 1155 checkExternSyncEvent(eventLSyncSharp, inL);
1150 local->deleteIncidence( inL ); 1156 local->deleteIncidence( inL );
1151 ++deletedEventL; 1157 ++deletedEventL;
1152 } else { 1158 } else {
1153 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1159 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1154 ++addedEventR; 1160 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1155 inL->setLastModified( modifiedCalendar ); 1161 ++addedEventR;
1156 inR = inL->clone(); 1162 inL->setLastModified( modifiedCalendar );
1157 inR->setIDStr( ":" ); 1163 inR = inL->clone();
1158 remote->addIncidence( inR ); 1164 inR->setIDStr( ":" );
1165 remote->addIncidence( inR );
1166 }
1159 } 1167 }
1160 } 1168 }
1161 } 1169 }
1162 } 1170 }
1163 } 1171 }
1164 inL = el.next(); 1172 inL = el.next();
1165 } 1173 }
1166 int delFut = 0; 1174 int delFut = 0;
1167 int remRem = 0; 1175 int remRem = 0;
1168 if ( mSyncManager->mWriteBackInFuture ) { 1176 if ( mSyncManager->mWriteBackInFuture ) {
1169 er = remote->rawIncidences(); 1177 er = remote->rawIncidences();
1170 remRem = er.count(); 1178 remRem = er.count();
1171 inR = er.first(); 1179 inR = er.first();
1172 QDateTime dt; 1180 QDateTime dt;
1173 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1181 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1174 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1182 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1175 while ( inR ) { 1183 while ( inR ) {
1176 if ( inR->type() == "Todo" ) { 1184 if ( inR->type() == "Todo" ) {
1177 Todo * t = (Todo*)inR; 1185 Todo * t = (Todo*)inR;
1178 if ( t->hasDueDate() ) 1186 if ( t->hasDueDate() )
1179 dt = t->dtDue(); 1187 dt = t->dtDue();
1180 else 1188 else
1181 dt = cur.addSecs( 62 ); 1189 dt = cur.addSecs( 62 );
1182 } 1190 }