-rw-r--r-- | korganizer/calendarview.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfd9290..d5d31e2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1103,82 +1103,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1104 | inL->removeID(mCurrentSyncDevice ); | 1104 | inL->removeID(mCurrentSyncDevice ); |
1105 | ++addedEventR; | 1105 | ++addedEventR; |
1106 | inL->setLastModified( modifiedCalendar ); | 1106 | inL->setLastModified( modifiedCalendar ); |
1107 | remote->addIncidence( inL->clone() ); | 1107 | remote->addIncidence( inL->clone() ); |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | } else { | 1110 | } else { |
1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1114 | ++deletedEventL; |
1115 | } else { | 1115 | } else { |
1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1117 | ++addedEventR; | 1117 | ++addedEventR; |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | remote->addIncidence( inL->clone() ); | 1119 | remote->addIncidence( inL->clone() ); |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | inL = el.next(); | 1125 | inL = el.next(); |
1126 | } | 1126 | } |
1127 | int delFut = 0; | ||
1127 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1128 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1128 | er = remote->rawIncidences(); | 1129 | er = remote->rawIncidences(); |
1129 | inR = er.first(); | 1130 | inR = er.first(); |
1130 | QDateTime dt; | 1131 | QDateTime dt; |
1131 | QDateTime cur = QDateTime::currentDateTime(); | 1132 | QDateTime cur = QDateTime::currentDateTime(); |
1132 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1133 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1133 | while ( inR ) { | 1134 | while ( inR ) { |
1134 | if ( inR->type() == "Todo" ) { | 1135 | if ( inR->type() == "Todo" ) { |
1135 | Todo * t = (Todo*)inR; | 1136 | Todo * t = (Todo*)inR; |
1136 | if ( t->hasDueDate() ) | 1137 | if ( t->hasDueDate() ) |
1137 | dt = t->dtDue(); | 1138 | dt = t->dtDue(); |
1138 | else | 1139 | else |
1139 | dt = cur.addSecs( 62 ); | 1140 | dt = cur.addSecs( 62 ); |
1140 | } | 1141 | } |
1141 | else dt = inR->dtStart(); | 1142 | else if (inR->type() == "Event" ) { |
1142 | if ( dt < cur || dt > end ) | 1143 | bool ok; |
1144 | dt = inR->getNextOccurence( cur, &ok ); | ||
1145 | if ( !ok ) | ||
1146 | dt = cur.addSecs( -62 ); | ||
1147 | } | ||
1148 | else | ||
1149 | dt = inR->dtStart(); | ||
1150 | if ( dt < cur || dt > end ) { | ||
1143 | remote->deleteIncidence( inR ); | 1151 | remote->deleteIncidence( inR ); |
1152 | ++delFut; | ||
1153 | } | ||
1144 | inR = er.next(); | 1154 | inR = er.next(); |
1145 | } | 1155 | } |
1146 | } | 1156 | } |
1147 | bar.hide(); | 1157 | bar.hide(); |
1148 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1158 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1149 | eventLSync->setReadOnly( false ); | 1159 | eventLSync->setReadOnly( false ); |
1150 | eventLSync->setDtStart( mLastCalendarSync ); | 1160 | eventLSync->setDtStart( mLastCalendarSync ); |
1151 | eventRSync->setDtStart( mLastCalendarSync ); | 1161 | eventRSync->setDtStart( mLastCalendarSync ); |
1152 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1162 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1153 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1154 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1164 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1155 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1165 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1156 | eventLSync->setReadOnly( true ); | 1166 | eventLSync->setReadOnly( true ); |
1157 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1167 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1158 | remote->addEvent( eventRSync ); | 1168 | remote->addEvent( eventRSync ); |
1159 | QString mes; | 1169 | QString mes; |
1160 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1170 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1171 | QString delmess; | ||
1172 | if ( delFut ) { | ||
1173 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | ||
1174 | mes += delmess; | ||
1175 | } | ||
1161 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1176 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1162 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1177 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1163 | } | 1178 | } |
1164 | qDebug( mes ); | 1179 | qDebug( mes ); |
1165 | mCalendar->checkAlarmForIncidence( 0, true ); | 1180 | mCalendar->checkAlarmForIncidence( 0, true ); |
1166 | return syncOK; | 1181 | return syncOK; |
1167 | } | 1182 | } |
1168 | 1183 | ||
1169 | void CalendarView::setSyncDevice( QString s ) | 1184 | void CalendarView::setSyncDevice( QString s ) |
1170 | { | 1185 | { |
1171 | mCurrentSyncDevice= s; | 1186 | mCurrentSyncDevice= s; |
1172 | } | 1187 | } |
1173 | void CalendarView::setSyncName( QString s ) | 1188 | void CalendarView::setSyncName( QString s ) |
1174 | { | 1189 | { |
1175 | mCurrentSyncName= s; | 1190 | mCurrentSyncName= s; |
1176 | } | 1191 | } |
1177 | bool CalendarView::syncCalendar(QString filename, int mode) | 1192 | bool CalendarView::syncCalendar(QString filename, int mode) |
1178 | { | 1193 | { |
1179 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1194 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1180 | CalendarLocal* calendar = new CalendarLocal(); | 1195 | CalendarLocal* calendar = new CalendarLocal(); |
1181 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1196 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1182 | FileStorage* storage = new FileStorage( calendar ); | 1197 | FileStorage* storage = new FileStorage( calendar ); |
1183 | bool syncOK = false; | 1198 | bool syncOK = false; |
1184 | storage->setFileName( filename ); | 1199 | storage->setFileName( filename ); |
@@ -1224,54 +1239,52 @@ void CalendarView::syncExternal( int mode ) | |||
1224 | sharpFormat = new SharpFormat () ; | 1239 | sharpFormat = new SharpFormat () ; |
1225 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1240 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1226 | 1241 | ||
1227 | } else | 1242 | } else |
1228 | #endif | 1243 | #endif |
1229 | if ( mode == 1 ) { // phone | 1244 | if ( mode == 1 ) { // phone |
1230 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1245 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1231 | KOPrefs::instance()->mPhoneDevice, | 1246 | KOPrefs::instance()->mPhoneDevice, |
1232 | KOPrefs::instance()->mPhoneConnection, | 1247 | KOPrefs::instance()->mPhoneConnection, |
1233 | KOPrefs::instance()->mPhoneModel); | 1248 | KOPrefs::instance()->mPhoneModel); |
1234 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1249 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1235 | 1250 | ||
1236 | } else | 1251 | } else |
1237 | return; | 1252 | return; |
1238 | if ( loadSuccess ) { | 1253 | if ( loadSuccess ) { |
1239 | getEventViewerDialog()->setSyncMode( true ); | 1254 | getEventViewerDialog()->setSyncMode( true ); |
1240 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1255 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1241 | getEventViewerDialog()->setSyncMode( false ); | 1256 | getEventViewerDialog()->setSyncMode( false ); |
1242 | qApp->processEvents(); | 1257 | qApp->processEvents(); |
1243 | if ( syncOK ) { | 1258 | if ( syncOK ) { |
1244 | if ( KOPrefs::instance()->mWriteBackFile ) | 1259 | if ( KOPrefs::instance()->mWriteBackFile ) |
1245 | { | 1260 | { |
1246 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1261 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1247 | Incidence* inc = iL.first(); | 1262 | Incidence* inc = iL.first(); |
1248 | /* obsolete | ||
1249 | while ( inc ) { | 1263 | while ( inc ) { |
1250 | inc->setZaurusStat( inc->revision () ); | 1264 | inc->removeID(mCurrentSyncDevice); |
1251 | inc = iL.next(); | 1265 | inc = iL.next(); |
1252 | } | 1266 | } |
1253 | */ | ||
1254 | #ifndef DESKTOP_VERSION | 1267 | #ifndef DESKTOP_VERSION |
1255 | if ( sharpFormat ) | 1268 | if ( sharpFormat ) |
1256 | sharpFormat->save(calendar); | 1269 | sharpFormat->save(calendar); |
1257 | #endif | 1270 | #endif |
1258 | if ( phoneFormat ) | 1271 | if ( phoneFormat ) |
1259 | phoneFormat->save(calendar); | 1272 | phoneFormat->save(calendar); |
1260 | iL = calendar->rawIncidences(); | 1273 | iL = calendar->rawIncidences(); |
1261 | inc = iL.first(); | 1274 | inc = iL.first(); |
1262 | Incidence* loc; | 1275 | Incidence* loc; |
1263 | while ( inc ) { | 1276 | while ( inc ) { |
1264 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1277 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1265 | loc = mCalendar->incidence(inc->uid() ); | 1278 | loc = mCalendar->incidence(inc->uid() ); |
1266 | if ( loc ) { | 1279 | if ( loc ) { |
1267 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1280 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1268 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1281 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1269 | } | 1282 | } |
1270 | } | 1283 | } |
1271 | inc = iL.next(); | 1284 | inc = iL.next(); |
1272 | } | 1285 | } |
1273 | Incidence* lse = getLastSyncEvent(); | 1286 | Incidence* lse = getLastSyncEvent(); |
1274 | if ( lse ) { | 1287 | if ( lse ) { |
1275 | lse->setReadOnly( false ); | 1288 | lse->setReadOnly( false ); |
1276 | lse->setDescription( "" ); | 1289 | lse->setDescription( "" ); |
1277 | lse->setReadOnly( true ); | 1290 | lse->setReadOnly( true ); |