author | zautrix <zautrix> | 2005-11-25 20:49:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 20:49:16 (UTC) |
commit | 2468bddcb380d8621d5bb49b69b3492d90562d93 (patch) (unidiff) | |
tree | c310f4fff5e476087e8406614e57a7f258f1b14f /korganizer | |
parent | 7a439999b9fa2bd7ad76e195cdf95bf5211952cb (diff) | |
download | kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.zip kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.tar.gz kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.tar.bz2 |
sync
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 307027a..e45240a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1147,1025 +1147,1025 @@ void CalendarView::startAlarm( QString mess , QString filename) | |||
1147 | 1147 | ||
1148 | topLevelWidget()->showNormal(); | 1148 | topLevelWidget()->showNormal(); |
1149 | topLevelWidget()->setActiveWindow(); | 1149 | topLevelWidget()->setActiveWindow(); |
1150 | topLevelWidget()->raise(); | 1150 | topLevelWidget()->raise(); |
1151 | 1151 | ||
1152 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1152 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1153 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1153 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1154 | 1154 | ||
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void CalendarView::checkNextTimerAlarm() | 1157 | void CalendarView::checkNextTimerAlarm() |
1158 | { | 1158 | { |
1159 | mCalendar->checkAlarmForIncidence( 0, true ); | 1159 | mCalendar->checkAlarmForIncidence( 0, true ); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | void CalendarView::computeAlarm( QString msg ) | 1162 | void CalendarView::computeAlarm( QString msg ) |
1163 | { | 1163 | { |
1164 | 1164 | ||
1165 | QString mess = msg; | 1165 | QString mess = msg; |
1166 | QString mAlarmMessage = mess.mid( 9 ); | 1166 | QString mAlarmMessage = mess.mid( 9 ); |
1167 | QString filename = MainWindow::resourcePath(); | 1167 | QString filename = MainWindow::resourcePath(); |
1168 | filename += "koalarm.wav"; | 1168 | filename += "koalarm.wav"; |
1169 | QString tempfilename; | 1169 | QString tempfilename; |
1170 | if ( mess.left( 13 ) == "suspend_alarm") { | 1170 | if ( mess.left( 13 ) == "suspend_alarm") { |
1171 | bool error = false; | 1171 | bool error = false; |
1172 | int len = mess.mid( 13 ).find("+++"); | 1172 | int len = mess.mid( 13 ).find("+++"); |
1173 | if ( len < 2 ) | 1173 | if ( len < 2 ) |
1174 | error = true; | 1174 | error = true; |
1175 | else { | 1175 | else { |
1176 | tempfilename = mess.mid( 13, len ); | 1176 | tempfilename = mess.mid( 13, len ); |
1177 | if ( !QFile::exists( tempfilename ) ) | 1177 | if ( !QFile::exists( tempfilename ) ) |
1178 | error = true; | 1178 | error = true; |
1179 | } | 1179 | } |
1180 | if ( ! error ) { | 1180 | if ( ! error ) { |
1181 | filename = tempfilename; | 1181 | filename = tempfilename; |
1182 | } | 1182 | } |
1183 | mAlarmMessage = mess.mid( 13+len+3 ); | 1183 | mAlarmMessage = mess.mid( 13+len+3 ); |
1184 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1184 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1185 | startAlarm( mAlarmMessage, filename); | 1185 | startAlarm( mAlarmMessage, filename); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( mess.left( 11 ) == "timer_alarm") { | 1188 | if ( mess.left( 11 ) == "timer_alarm") { |
1189 | //mTimerTime = 0; | 1189 | //mTimerTime = 0; |
1190 | startAlarm( mess.mid( 11 ), filename ); | 1190 | startAlarm( mess.mid( 11 ), filename ); |
1191 | return; | 1191 | return; |
1192 | } | 1192 | } |
1193 | if ( mess.left( 10 ) == "proc_alarm") { | 1193 | if ( mess.left( 10 ) == "proc_alarm") { |
1194 | bool error = false; | 1194 | bool error = false; |
1195 | int len = mess.mid( 10 ).find("+++"); | 1195 | int len = mess.mid( 10 ).find("+++"); |
1196 | if ( len < 2 ) | 1196 | if ( len < 2 ) |
1197 | error = true; | 1197 | error = true; |
1198 | else { | 1198 | else { |
1199 | tempfilename = mess.mid( 10, len ); | 1199 | tempfilename = mess.mid( 10, len ); |
1200 | if ( !QFile::exists( tempfilename ) ) | 1200 | if ( !QFile::exists( tempfilename ) ) |
1201 | error = true; | 1201 | error = true; |
1202 | } | 1202 | } |
1203 | if ( error ) { | 1203 | if ( error ) { |
1204 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1204 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1205 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1205 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1206 | } else { | 1206 | } else { |
1207 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1207 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1208 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1208 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1209 | #ifndef _WIN32_ | 1209 | #ifndef _WIN32_ |
1210 | if ( vfork () == 0 ) { | 1210 | if ( vfork () == 0 ) { |
1211 | execl ( tempfilename.latin1(), 0 ); | 1211 | execl ( tempfilename.latin1(), 0 ); |
1212 | return; | 1212 | return; |
1213 | } | 1213 | } |
1214 | #else | 1214 | #else |
1215 | QProcess* p = new QProcess(); | 1215 | QProcess* p = new QProcess(); |
1216 | p->addArgument( tempfilename.latin1() ); | 1216 | p->addArgument( tempfilename.latin1() ); |
1217 | p->start(); | 1217 | p->start(); |
1218 | return; | 1218 | return; |
1219 | #endif | 1219 | #endif |
1220 | 1220 | ||
1221 | return; | 1221 | return; |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1224 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1225 | } | 1225 | } |
1226 | if ( mess.left( 11 ) == "audio_alarm") { | 1226 | if ( mess.left( 11 ) == "audio_alarm") { |
1227 | bool error = false; | 1227 | bool error = false; |
1228 | int len = mess.mid( 11 ).find("+++"); | 1228 | int len = mess.mid( 11 ).find("+++"); |
1229 | if ( len < 2 ) | 1229 | if ( len < 2 ) |
1230 | error = true; | 1230 | error = true; |
1231 | else { | 1231 | else { |
1232 | tempfilename = mess.mid( 11, len ); | 1232 | tempfilename = mess.mid( 11, len ); |
1233 | if ( !QFile::exists( tempfilename ) ) | 1233 | if ( !QFile::exists( tempfilename ) ) |
1234 | error = true; | 1234 | error = true; |
1235 | } | 1235 | } |
1236 | if ( ! error ) { | 1236 | if ( ! error ) { |
1237 | filename = tempfilename; | 1237 | filename = tempfilename; |
1238 | } | 1238 | } |
1239 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1239 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1240 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1240 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1241 | } | 1241 | } |
1242 | if ( mess.left( 9 ) == "cal_alarm") { | 1242 | if ( mess.left( 9 ) == "cal_alarm") { |
1243 | mAlarmMessage = mess.mid( 9 ) ; | 1243 | mAlarmMessage = mess.mid( 9 ) ; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | startAlarm( mAlarmMessage, filename ); | 1246 | startAlarm( mAlarmMessage, filename ); |
1247 | 1247 | ||
1248 | 1248 | ||
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1251 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1252 | { | 1252 | { |
1253 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1253 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1254 | 1254 | ||
1255 | mSuspendAlarmNotification = noti; | 1255 | mSuspendAlarmNotification = noti; |
1256 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1256 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1257 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1257 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1258 | mSuspendTimer->start( ms , true ); | 1258 | mSuspendTimer->start( ms , true ); |
1259 | #ifdef DESKTOP_VERSION | 1259 | #ifdef DESKTOP_VERSION |
1260 | if ( QApplication::desktop()->width() < 1024 ) { | 1260 | if ( QApplication::desktop()->width() < 1024 ) { |
1261 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1261 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1262 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1262 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1263 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1263 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1264 | QFile file( fn ); | 1264 | QFile file( fn ); |
1265 | if (!file.open( IO_WriteOnly ) ) { | 1265 | if (!file.open( IO_WriteOnly ) ) { |
1266 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1266 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1267 | } else { | 1267 | } else { |
1268 | QTextStream ts( &file ); | 1268 | QTextStream ts( &file ); |
1269 | ts << mess; | 1269 | ts << mess; |
1270 | file.close(); | 1270 | file.close(); |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | #endif | 1273 | #endif |
1274 | 1274 | ||
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1277 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1278 | { | 1278 | { |
1279 | mNextAlarmDateTime = qdt; | 1279 | mNextAlarmDateTime = qdt; |
1280 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1280 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1281 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1281 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1282 | #ifndef DESKTOP_VERSION | 1282 | #ifndef DESKTOP_VERSION |
1283 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1283 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1284 | #endif | 1284 | #endif |
1285 | return; | 1285 | return; |
1286 | } | 1286 | } |
1287 | #ifdef DESKTOP_VERSION | 1287 | #ifdef DESKTOP_VERSION |
1288 | if ( QApplication::desktop()->width() < 1024 ) { | 1288 | if ( QApplication::desktop()->width() < 1024 ) { |
1289 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1289 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1290 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1290 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1291 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1291 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1292 | QFile file( fn ); | 1292 | QFile file( fn ); |
1293 | if (!file.open( IO_WriteOnly ) ) { | 1293 | if (!file.open( IO_WriteOnly ) ) { |
1294 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1294 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1295 | } else { | 1295 | } else { |
1296 | QTextStream ts( &file ); | 1296 | QTextStream ts( &file ); |
1297 | ts << mess; | 1297 | ts << mess; |
1298 | file.close(); | 1298 | file.close(); |
1299 | } | 1299 | } |
1300 | } | 1300 | } |
1301 | #endif | 1301 | #endif |
1302 | int maxSec; | 1302 | int maxSec; |
1303 | //maxSec = 5; //testing only | 1303 | //maxSec = 5; //testing only |
1304 | maxSec = 86400+3600; // one day+1hour | 1304 | maxSec = 86400+3600; // one day+1hour |
1305 | mAlarmNotification = noti; | 1305 | mAlarmNotification = noti; |
1306 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1306 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1307 | if ( sec > maxSec ) { | 1307 | if ( sec > maxSec ) { |
1308 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1308 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1309 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1309 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1310 | return; | 1310 | return; |
1311 | } else { | 1311 | } else { |
1312 | mRecheckAlarmTimer->stop(); | 1312 | mRecheckAlarmTimer->stop(); |
1313 | } | 1313 | } |
1314 | //qDebug("Alarm timer started with secs: %d ", sec); | 1314 | //qDebug("Alarm timer started with secs: %d ", sec); |
1315 | mAlarmTimer->start( sec * 1000 , true ); | 1315 | mAlarmTimer->start( sec * 1000 , true ); |
1316 | 1316 | ||
1317 | } | 1317 | } |
1318 | // called by mRecheckAlarmTimer to get next alarm | 1318 | // called by mRecheckAlarmTimer to get next alarm |
1319 | // we need this, because a QTimer has only a max range of 25 days | 1319 | // we need this, because a QTimer has only a max range of 25 days |
1320 | void CalendarView::recheckTimerAlarm() | 1320 | void CalendarView::recheckTimerAlarm() |
1321 | { | 1321 | { |
1322 | mAlarmTimer->stop(); | 1322 | mAlarmTimer->stop(); |
1323 | mRecheckAlarmTimer->stop(); | 1323 | mRecheckAlarmTimer->stop(); |
1324 | mCalendar->checkAlarmForIncidence( 0, true ); | 1324 | mCalendar->checkAlarmForIncidence( 0, true ); |
1325 | } | 1325 | } |
1326 | #ifndef DESKTOP_VERSION | 1326 | #ifndef DESKTOP_VERSION |
1327 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1327 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1328 | #else | 1328 | #else |
1329 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1329 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1330 | #endif | 1330 | #endif |
1331 | { | 1331 | { |
1332 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1332 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1333 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1333 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1334 | #ifndef DESKTOP_VERSION | 1334 | #ifndef DESKTOP_VERSION |
1335 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1335 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1336 | #endif | 1336 | #endif |
1337 | return; | 1337 | return; |
1338 | } | 1338 | } |
1339 | mAlarmTimer->stop(); | 1339 | mAlarmTimer->stop(); |
1340 | } | 1340 | } |
1341 | void CalendarView::selectWeekNum ( int num ) | 1341 | void CalendarView::selectWeekNum ( int num ) |
1342 | { | 1342 | { |
1343 | dateNavigator()->blockSignals( true ); | 1343 | dateNavigator()->blockSignals( true ); |
1344 | dateNavigator()->selectWeek( num ); | 1344 | dateNavigator()->selectWeek( num ); |
1345 | dateNavigator()->blockSignals( false ); | 1345 | dateNavigator()->blockSignals( false ); |
1346 | mViewManager->showWeekView(); | 1346 | mViewManager->showWeekView(); |
1347 | } | 1347 | } |
1348 | KOViewManager *CalendarView::viewManager() | 1348 | KOViewManager *CalendarView::viewManager() |
1349 | { | 1349 | { |
1350 | return mViewManager; | 1350 | return mViewManager; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | KODialogManager *CalendarView::dialogManager() | 1353 | KODialogManager *CalendarView::dialogManager() |
1354 | { | 1354 | { |
1355 | return mDialogManager; | 1355 | return mDialogManager; |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | QDate CalendarView::startDate() | 1358 | QDate CalendarView::startDate() |
1359 | { | 1359 | { |
1360 | DateList dates = mNavigator->selectedDates(); | 1360 | DateList dates = mNavigator->selectedDates(); |
1361 | 1361 | ||
1362 | return dates.first(); | 1362 | return dates.first(); |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | QDate CalendarView::endDate() | 1365 | QDate CalendarView::endDate() |
1366 | { | 1366 | { |
1367 | DateList dates = mNavigator->selectedDates(); | 1367 | DateList dates = mNavigator->selectedDates(); |
1368 | 1368 | ||
1369 | return dates.last(); | 1369 | return dates.last(); |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | 1372 | ||
1373 | void CalendarView::createPrinter() | 1373 | void CalendarView::createPrinter() |
1374 | { | 1374 | { |
1375 | #ifndef KORG_NOPRINTER | 1375 | #ifndef KORG_NOPRINTER |
1376 | if (!mCalPrinter) { | 1376 | if (!mCalPrinter) { |
1377 | mCalPrinter = new CalPrinter(this, mCalendar); | 1377 | mCalPrinter = new CalPrinter(this, mCalendar); |
1378 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1378 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1379 | } | 1379 | } |
1380 | #endif | 1380 | #endif |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | 1383 | ||
1384 | //KOPrefs::instance()->mWriteBackFile | 1384 | //KOPrefs::instance()->mWriteBackFile |
1385 | //KOPrefs::instance()->mWriteBackExistingOnly | 1385 | //KOPrefs::instance()->mWriteBackExistingOnly |
1386 | 1386 | ||
1387 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1387 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1388 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1388 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1389 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1389 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1390 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1390 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1391 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1391 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1392 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1392 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1393 | 1393 | ||
1394 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1394 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1395 | { | 1395 | { |
1396 | 1396 | ||
1397 | // 0 equal | 1397 | // 0 equal |
1398 | // 1 take local | 1398 | // 1 take local |
1399 | // 2 take remote | 1399 | // 2 take remote |
1400 | // 3 cancel | 1400 | // 3 cancel |
1401 | QDateTime lastSync = mLastCalendarSync; | 1401 | QDateTime lastSync = mLastCalendarSync; |
1402 | QDateTime localMod = local->lastModified(); | 1402 | QDateTime localMod = local->lastModified(); |
1403 | QDateTime remoteMod = remote->lastModified(); | 1403 | QDateTime remoteMod = remote->lastModified(); |
1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1405 | bool remCh, locCh; | 1405 | bool remCh, locCh; |
1406 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1406 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1407 | //if ( remCh ) | 1407 | //if ( remCh ) |
1408 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1408 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1409 | locCh = ( localMod > mLastCalendarSync ); | 1409 | locCh = ( localMod > mLastCalendarSync ); |
1410 | if ( !remCh && ! locCh ) { | 1410 | if ( !remCh && ! locCh ) { |
1411 | //qDebug("both not changed "); | 1411 | //qDebug("both not changed "); |
1412 | lastSync = localMod.addDays(1); | 1412 | lastSync = localMod.addDays(1); |
1413 | if ( mode <= SYNC_PREF_ASK ) | 1413 | if ( mode <= SYNC_PREF_ASK ) |
1414 | return 0; | 1414 | return 0; |
1415 | } else { | 1415 | } else { |
1416 | if ( locCh ) { | 1416 | if ( locCh ) { |
1417 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1417 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1418 | lastSync = localMod.addDays( -1 ); | 1418 | lastSync = localMod.addDays( -1 ); |
1419 | if ( !remCh ) | 1419 | if ( !remCh ) |
1420 | remoteMod = ( lastSync.addDays( -1 ) ); | 1420 | remoteMod = ( lastSync.addDays( -1 ) ); |
1421 | } else { | 1421 | } else { |
1422 | //qDebug(" not loc changed "); | 1422 | //qDebug(" not loc changed "); |
1423 | lastSync = localMod.addDays( 1 ); | 1423 | lastSync = localMod.addDays( 1 ); |
1424 | if ( remCh ) | 1424 | if ( remCh ) |
1425 | remoteMod =( lastSync.addDays( 1 ) ); | 1425 | remoteMod =( lastSync.addDays( 1 ) ); |
1426 | 1426 | ||
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | full = true; | 1429 | full = true; |
1430 | if ( mode < SYNC_PREF_ASK ) | 1430 | if ( mode < SYNC_PREF_ASK ) |
1431 | mode = SYNC_PREF_ASK; | 1431 | mode = SYNC_PREF_ASK; |
1432 | } else { | 1432 | } else { |
1433 | if ( localMod == remoteMod ) | 1433 | if ( localMod == remoteMod ) |
1434 | // if ( local->revision() == remote->revision() ) | 1434 | // if ( local->revision() == remote->revision() ) |
1435 | return 0; | 1435 | return 0; |
1436 | 1436 | ||
1437 | } | 1437 | } |
1438 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1438 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1439 | 1439 | ||
1440 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1440 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1441 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1441 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1442 | //full = true; //debug only | 1442 | //full = true; //debug only |
1443 | if ( full ) { | 1443 | if ( full ) { |
1444 | bool equ = false; | 1444 | bool equ = false; |
1445 | if ( local->typeID() == eventID ) { | 1445 | if ( local->typeID() == eventID ) { |
1446 | equ = (*((Event*) local) == *((Event*) remote)); | 1446 | equ = (*((Event*) local) == *((Event*) remote)); |
1447 | } | 1447 | } |
1448 | else if ( local->typeID() == todoID ) | 1448 | else if ( local->typeID() == todoID ) |
1449 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1449 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1450 | else if ( local->typeID() == journalID ) | 1450 | else if ( local->typeID() == journalID ) |
1451 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1451 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1452 | if ( equ ) { | 1452 | if ( equ ) { |
1453 | //qDebug("equal "); | 1453 | //qDebug("equal "); |
1454 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1454 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1455 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1455 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1456 | } | 1456 | } |
1457 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1457 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1458 | return 0; | 1458 | return 0; |
1459 | 1459 | ||
1460 | }//else //debug only | 1460 | }//else //debug only |
1461 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1461 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1462 | } | 1462 | } |
1463 | int result; | 1463 | int result; |
1464 | bool localIsNew; | 1464 | bool localIsNew; |
1465 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1465 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1466 | 1466 | ||
1467 | 1467 | ||
1468 | // ************************************************ | 1468 | // ************************************************ |
1469 | // ************************************************ | 1469 | // ************************************************ |
1470 | // ************************************************ | 1470 | // ************************************************ |
1471 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1471 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1472 | // BUT remoteMod != localMod | 1472 | // BUT remoteMod != localMod |
1473 | 1473 | ||
1474 | 1474 | ||
1475 | if ( full && mode < SYNC_PREF_NEWEST ) | 1475 | if ( full && mode < SYNC_PREF_NEWEST ) |
1476 | mode = SYNC_PREF_ASK; | 1476 | mode = SYNC_PREF_ASK; |
1477 | 1477 | ||
1478 | switch( mode ) { | 1478 | switch( mode ) { |
1479 | case SYNC_PREF_LOCAL: | 1479 | case SYNC_PREF_LOCAL: |
1480 | if ( lastSync > remoteMod ) | 1480 | if ( lastSync > remoteMod ) |
1481 | return 1; | 1481 | return 1; |
1482 | if ( lastSync > localMod ) | 1482 | if ( lastSync > localMod ) |
1483 | return 2; | 1483 | return 2; |
1484 | return 1; | 1484 | return 1; |
1485 | break; | 1485 | break; |
1486 | case SYNC_PREF_REMOTE: | 1486 | case SYNC_PREF_REMOTE: |
1487 | if ( lastSync > localMod ) | 1487 | if ( lastSync > localMod ) |
1488 | return 2; | 1488 | return 2; |
1489 | if ( lastSync > remoteMod ) | 1489 | if ( lastSync > remoteMod ) |
1490 | return 1; | 1490 | return 1; |
1491 | return 2; | 1491 | return 2; |
1492 | break; | 1492 | break; |
1493 | case SYNC_PREF_NEWEST: | 1493 | case SYNC_PREF_NEWEST: |
1494 | if ( localMod >= remoteMod ) | 1494 | if ( localMod >= remoteMod ) |
1495 | return 1; | 1495 | return 1; |
1496 | else | 1496 | else |
1497 | return 2; | 1497 | return 2; |
1498 | break; | 1498 | break; |
1499 | case SYNC_PREF_ASK: | 1499 | case SYNC_PREF_ASK: |
1500 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1500 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1501 | if ( lastSync > remoteMod && lastSync > localMod) | 1501 | if ( lastSync > remoteMod && lastSync > localMod) |
1502 | return 0; | 1502 | return 0; |
1503 | if ( lastSync > remoteMod ) | 1503 | if ( lastSync > remoteMod ) |
1504 | return 1; | 1504 | return 1; |
1505 | if ( lastSync > localMod ) | 1505 | if ( lastSync > localMod ) |
1506 | return 2; | 1506 | return 2; |
1507 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1507 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1508 | localIsNew = localMod >= remoteMod; | 1508 | localIsNew = localMod >= remoteMod; |
1509 | if ( localIsNew ) | 1509 | if ( localIsNew ) |
1510 | getEventViewerDialog()->setColorMode( 1 ); | 1510 | getEventViewerDialog()->setColorMode( 1 ); |
1511 | else | 1511 | else |
1512 | getEventViewerDialog()->setColorMode( 2 ); | 1512 | getEventViewerDialog()->setColorMode( 2 ); |
1513 | getEventViewerDialog()->setIncidence(local); | 1513 | getEventViewerDialog()->setIncidence(local); |
1514 | if ( localIsNew ) | 1514 | if ( localIsNew ) |
1515 | getEventViewerDialog()->setColorMode( 2 ); | 1515 | getEventViewerDialog()->setColorMode( 2 ); |
1516 | else | 1516 | else |
1517 | getEventViewerDialog()->setColorMode( 1 ); | 1517 | getEventViewerDialog()->setColorMode( 1 ); |
1518 | getEventViewerDialog()->addIncidence(remote); | 1518 | getEventViewerDialog()->addIncidence(remote); |
1519 | getEventViewerDialog()->setColorMode( 0 ); | 1519 | getEventViewerDialog()->setColorMode( 0 ); |
1520 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1520 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1521 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1521 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1522 | getEventViewerDialog()->showMe(); | 1522 | getEventViewerDialog()->showMe(); |
1523 | result = getEventViewerDialog()->executeS( localIsNew ); | 1523 | result = getEventViewerDialog()->executeS( localIsNew ); |
1524 | return result; | 1524 | return result; |
1525 | 1525 | ||
1526 | break; | 1526 | break; |
1527 | case SYNC_PREF_FORCE_LOCAL: | 1527 | case SYNC_PREF_FORCE_LOCAL: |
1528 | return 1; | 1528 | return 1; |
1529 | break; | 1529 | break; |
1530 | case SYNC_PREF_FORCE_REMOTE: | 1530 | case SYNC_PREF_FORCE_REMOTE: |
1531 | return 2; | 1531 | return 2; |
1532 | break; | 1532 | break; |
1533 | 1533 | ||
1534 | default: | 1534 | default: |
1535 | // SYNC_PREF_TAKE_BOTH not implemented | 1535 | // SYNC_PREF_TAKE_BOTH not implemented |
1536 | break; | 1536 | break; |
1537 | } | 1537 | } |
1538 | return 0; | 1538 | return 0; |
1539 | } | 1539 | } |
1540 | Event* CalendarView::getLastSyncEvent() | 1540 | Event* CalendarView::getLastSyncEvent() |
1541 | { | 1541 | { |
1542 | Event* lse; | 1542 | Event* lse; |
1543 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1543 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1544 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1544 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1545 | if (!lse) { | 1545 | if (!lse) { |
1546 | lse = new Event(); | 1546 | lse = new Event(); |
1547 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1547 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1548 | QString sum = ""; | 1548 | QString sum = ""; |
1549 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1549 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1550 | sum = "E: "; | 1550 | sum = "E: "; |
1551 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1551 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1552 | lse->setDtStart( mLastCalendarSync ); | 1552 | lse->setDtStart( mLastCalendarSync ); |
1553 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1553 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1554 | lse->setCategories( i18n("SyncEvent") ); | 1554 | lse->setCategories( i18n("SyncEvent") ); |
1555 | lse->setReadOnly( true ); | 1555 | lse->setReadOnly( true ); |
1556 | lse->setCalID( 1 ); | 1556 | lse->setCalID( 1 ); |
1557 | mCalendar->addEvent( lse ); | 1557 | mCalendar->addEvent( lse ); |
1558 | } | 1558 | } |
1559 | 1559 | ||
1560 | return lse; | 1560 | return lse; |
1561 | 1561 | ||
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | // we check, if the to delete event has a id for a profile | 1564 | // we check, if the to delete event has a id for a profile |
1565 | // if yes, we set this id in the profile to delete | 1565 | // if yes, we set this id in the profile to delete |
1566 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1566 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1567 | { | 1567 | { |
1568 | if ( lastSync.count() == 0 ) { | 1568 | if ( lastSync.count() == 0 ) { |
1569 | //qDebug(" lastSync.count() == 0"); | 1569 | //qDebug(" lastSync.count() == 0"); |
1570 | return; | 1570 | return; |
1571 | } | 1571 | } |
1572 | if ( toDelete->typeID() == journalID ) | 1572 | if ( toDelete->typeID() == journalID ) |
1573 | return; | 1573 | return; |
1574 | 1574 | ||
1575 | Event* eve = lastSync.first(); | 1575 | Event* eve = lastSync.first(); |
1576 | 1576 | ||
1577 | while ( eve ) { | 1577 | while ( eve ) { |
1578 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1578 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1579 | if ( !id.isEmpty() ) { | 1579 | if ( !id.isEmpty() ) { |
1580 | QString des = eve->description(); | 1580 | QString des = eve->description(); |
1581 | QString pref = "e"; | 1581 | QString pref = "e"; |
1582 | if ( toDelete->typeID() == todoID ) | 1582 | if ( toDelete->typeID() == todoID ) |
1583 | pref = "t"; | 1583 | pref = "t"; |
1584 | des += pref+ id + ","; | 1584 | des += pref+ id + ","; |
1585 | eve->setReadOnly( false ); | 1585 | eve->setReadOnly( false ); |
1586 | eve->setDescription( des ); | 1586 | eve->setDescription( des ); |
1587 | //qDebug("setdes %s ", des.latin1()); | 1587 | //qDebug("setdes %s ", des.latin1()); |
1588 | eve->setReadOnly( true ); | 1588 | eve->setReadOnly( true ); |
1589 | } | 1589 | } |
1590 | eve = lastSync.next(); | 1590 | eve = lastSync.next(); |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | } | 1593 | } |
1594 | void CalendarView::checkExternalId( Incidence * inc ) | 1594 | void CalendarView::checkExternalId( Incidence * inc ) |
1595 | { | 1595 | { |
1596 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1596 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1597 | checkExternSyncEvent( lastSync, inc ); | 1597 | checkExternSyncEvent( lastSync, inc ); |
1598 | 1598 | ||
1599 | } | 1599 | } |
1600 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1600 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1601 | { | 1601 | { |
1602 | bool syncOK = true; | 1602 | bool syncOK = true; |
1603 | int addedEvent = 0; | 1603 | int addedEvent = 0; |
1604 | int addedEventR = 0; | 1604 | int addedEventR = 0; |
1605 | int deletedEventR = 0; | 1605 | int deletedEventR = 0; |
1606 | int deletedEventL = 0; | 1606 | int deletedEventL = 0; |
1607 | int changedLocal = 0; | 1607 | int changedLocal = 0; |
1608 | int changedRemote = 0; | 1608 | int changedRemote = 0; |
1609 | int filteredIN = 0; | 1609 | int filteredIN = 0; |
1610 | int filteredOUT = 0; | 1610 | int filteredOUT = 0; |
1611 | //QPtrList<Event> el = local->rawEvents(); | 1611 | //QPtrList<Event> el = local->rawEvents(); |
1612 | Event* eventR; | 1612 | Event* eventR; |
1613 | QString uid; | 1613 | QString uid; |
1614 | int take; | 1614 | int take; |
1615 | Event* eventRSync; | 1615 | Event* eventRSync; |
1616 | Event* eventLSync; | 1616 | Event* eventLSync; |
1617 | clearAllViews(); | 1617 | clearAllViews(); |
1618 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1618 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1619 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1619 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1620 | bool fullDateRange = false; | 1620 | bool fullDateRange = false; |
1621 | local->resetTempSyncStat(); | 1621 | local->resetTempSyncStat(); |
1622 | mLastCalendarSync = QDateTime::currentDateTime(); | 1622 | mLastCalendarSync = QDateTime::currentDateTime(); |
1623 | if ( mSyncManager->syncWithDesktop() ) { | 1623 | if ( mSyncManager->syncWithDesktop() ) { |
1624 | remote->resetPilotStat(1); | 1624 | remote->resetPilotStat(1); |
1625 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1625 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1626 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1626 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1627 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1627 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1628 | } else { | 1628 | } else { |
1629 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1629 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | QDateTime modifiedCalendar = mLastCalendarSync; | 1632 | QDateTime modifiedCalendar = mLastCalendarSync; |
1633 | eventLSync = getLastSyncEvent(); | 1633 | eventLSync = getLastSyncEvent(); |
1634 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1634 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1635 | if ( eventR ) { | 1635 | if ( eventR ) { |
1636 | qDebug("last-syncEvent on remote found "); | 1636 | qDebug("last-syncEvent on remote found "); |
1637 | eventRSync = (Event*) eventR->clone(); | 1637 | eventRSync = (Event*) eventR->clone(); |
1638 | remote->deleteEvent(eventR ); | 1638 | remote->deleteEvent(eventR ); |
1639 | 1639 | ||
1640 | } else { | 1640 | } else { |
1641 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1641 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1642 | eventRSync = (Event*)eventLSync->clone(); | 1642 | eventRSync = (Event*)eventLSync->clone(); |
1643 | } else { | 1643 | } else { |
1644 | fullDateRange = true; | 1644 | fullDateRange = true; |
1645 | eventRSync = new Event(); | 1645 | eventRSync = new Event(); |
1646 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1646 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1647 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1647 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1648 | eventRSync->setDtStart( mLastCalendarSync ); | 1648 | eventRSync->setDtStart( mLastCalendarSync ); |
1649 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1649 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1650 | eventRSync->setCategories( i18n("SyncEvent") ); | 1650 | eventRSync->setCategories( i18n("SyncEvent") ); |
1651 | } | 1651 | } |
1652 | } | 1652 | } |
1653 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1653 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1654 | fullDateRange = true; | 1654 | fullDateRange = true; |
1655 | 1655 | ||
1656 | if ( ! fullDateRange ) { | 1656 | if ( ! fullDateRange ) { |
1657 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1657 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1658 | 1658 | ||
1659 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1659 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1660 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1660 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1661 | fullDateRange = true; | 1661 | fullDateRange = true; |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | if ( mSyncManager->syncWithDesktop() ) { | 1664 | if ( mSyncManager->syncWithDesktop() ) { |
1665 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1665 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1666 | } | 1666 | } |
1667 | if ( fullDateRange ) | 1667 | if ( fullDateRange ) |
1668 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1668 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1669 | else | 1669 | else |
1670 | mLastCalendarSync = eventLSync->dtStart(); | 1670 | mLastCalendarSync = eventLSync->dtStart(); |
1671 | // for resyncing if own file has changed | 1671 | // for resyncing if own file has changed |
1672 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1672 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1673 | mLastCalendarSync = loadedFileVersion; | 1673 | mLastCalendarSync = loadedFileVersion; |
1674 | //qDebug("setting mLastCalendarSync "); | 1674 | //qDebug("setting mLastCalendarSync "); |
1675 | } | 1675 | } |
1676 | //qDebug("*************************** "); | 1676 | //qDebug("*************************** "); |
1677 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1677 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1678 | QPtrList<Incidence> er = remote->rawIncidences(); | 1678 | QPtrList<Incidence> er = remote->rawIncidences(); |
1679 | Incidence* inR = er.first(); | 1679 | Incidence* inR = er.first(); |
1680 | Incidence* inL; | 1680 | Incidence* inL; |
1681 | QProgressBar bar( er.count(),0 ); | 1681 | QProgressBar bar( er.count(),0 ); |
1682 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1682 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1683 | 1683 | ||
1684 | // ************** setting up filter ************* | 1684 | // ************** setting up filter ************* |
1685 | CalFilter *filterIN = 0; | 1685 | CalFilter *filterIN = 0; |
1686 | CalFilter *filterOUT = 0; | 1686 | CalFilter *filterOUT = 0; |
1687 | CalFilter *filter = mFilters.first(); | 1687 | CalFilter *filter = mFilters.first(); |
1688 | while(filter) { | 1688 | while(filter) { |
1689 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1689 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1690 | filterIN = filter; | 1690 | filterIN = filter; |
1691 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1691 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1692 | filterOUT = filter; | 1692 | filterOUT = filter; |
1693 | filter = mFilters.next(); | 1693 | filter = mFilters.next(); |
1694 | } | 1694 | } |
1695 | int w = 300; | 1695 | int w = 300; |
1696 | if ( QApplication::desktop()->width() < 320 ) | 1696 | if ( QApplication::desktop()->width() < 320 ) |
1697 | w = 220; | 1697 | w = 220; |
1698 | int h = bar.sizeHint().height() ; | 1698 | int h = bar.sizeHint().height() ; |
1699 | int dw = QApplication::desktop()->width(); | 1699 | int dw = QApplication::desktop()->width(); |
1700 | int dh = QApplication::desktop()->height(); | 1700 | int dh = QApplication::desktop()->height(); |
1701 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1701 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1702 | bar.show(); | 1702 | bar.show(); |
1703 | int modulo = (er.count()/10)+1; | 1703 | int modulo = (er.count()/10)+1; |
1704 | int incCounter = 0; | 1704 | int incCounter = 0; |
1705 | while ( inR ) { | 1705 | while ( inR ) { |
1706 | if ( ! bar.isVisible() ) | 1706 | if ( ! bar.isVisible() ) |
1707 | return false; | 1707 | return false; |
1708 | if ( incCounter % modulo == 0 ) | 1708 | if ( incCounter % modulo == 0 ) |
1709 | bar.setProgress( incCounter ); | 1709 | bar.setProgress( incCounter ); |
1710 | ++incCounter; | 1710 | ++incCounter; |
1711 | uid = inR->uid(); | 1711 | uid = inR->uid(); |
1712 | bool skipIncidence = false; | 1712 | bool skipIncidence = false; |
1713 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1713 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1714 | skipIncidence = true; | 1714 | skipIncidence = true; |
1715 | QString idS; | 1715 | QString idS; |
1716 | qApp->processEvents(); | 1716 | qApp->processEvents(); |
1717 | if ( !skipIncidence ) { | 1717 | if ( !skipIncidence ) { |
1718 | inL = local->incidenceForUid( uid , false ); | 1718 | inL = local->incidenceForUid( uid , false ); |
1719 | if ( inL ) { // maybe conflict - same uid in both calendars | 1719 | if ( inL ) { // maybe conflict - same uid in both calendars |
1720 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1720 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1721 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1721 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1722 | if ( take == 3 ) | 1722 | if ( take == 3 ) |
1723 | return false; | 1723 | return false; |
1724 | if ( take == 1 ) {// take local ********************** | 1724 | if ( take == 1 ) {// take local ********************** |
1725 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1725 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1726 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1726 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1727 | else | 1727 | else |
1728 | idS = inR->IDStr(); | 1728 | idS = inR->IDStr(); |
1729 | int calID = inR->calID(); | 1729 | int calID = inR->calID(); |
1730 | remote->deleteIncidence( inR ); | 1730 | remote->deleteIncidence( inR ); |
1731 | inR = inL->clone(); | 1731 | inR = inL->clone(); |
1732 | inR->setCalID( calID ); | 1732 | inR->setCalID( calID ); |
1733 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1733 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1734 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1734 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1735 | inR->setIDStr( idS ); | 1735 | inR->setIDStr( idS ); |
1736 | remote->addIncidence( inR ); | 1736 | remote->addIncidence( inR ); |
1737 | if ( mSyncManager->syncWithDesktop() ) | 1737 | if ( mSyncManager->syncWithDesktop() ) |
1738 | inR->setPilotId( 2 ); | 1738 | inR->setPilotId( 2 ); |
1739 | ++changedRemote; | 1739 | ++changedRemote; |
1740 | } else {// take remote ********************** | 1740 | } else {// take remote ********************** |
1741 | if ( !inL->isReadOnly() ) { | 1741 | if ( !inL->isReadOnly() ) { |
1742 | idS = inL->IDStr(); | 1742 | idS = inL->IDStr(); |
1743 | int pid = inL->pilotId(); | 1743 | int pid = inL->pilotId(); |
1744 | int calID = inL->calID(); | 1744 | int calID = inL->calID(); |
1745 | local->deleteIncidence( inL ); | 1745 | local->deleteIncidence( inL ); |
1746 | inL = inR->clone(); | 1746 | inL = inR->clone(); |
1747 | inL->setCalID( calID ); | 1747 | inL->setCalID( calID ); |
1748 | if ( mSyncManager->syncWithDesktop() ) | 1748 | if ( mSyncManager->syncWithDesktop() ) |
1749 | inL->setPilotId( pid ); | 1749 | inL->setPilotId( pid ); |
1750 | inL->setIDStr( idS ); | 1750 | inL->setIDStr( idS ); |
1751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1752 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1752 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1753 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1753 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1754 | } | 1754 | } |
1755 | local->addIncidence( inL ); | 1755 | local->addIncidence( inL ); |
1756 | ++changedLocal; | 1756 | ++changedLocal; |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | } | 1759 | } |
1760 | } else { // no conflict ********** add or delete remote | 1760 | } else { // no conflict ********** add or delete remote |
1761 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1761 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1762 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1762 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1763 | QString des = eventLSync->description(); | 1763 | QString des = eventLSync->description(); |
1764 | QString pref = "e"; | 1764 | QString pref = "e"; |
1765 | if ( inR->typeID() == todoID ) | 1765 | if ( inR->typeID() == todoID ) |
1766 | pref = "t"; | 1766 | pref = "t"; |
1767 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1767 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1768 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1768 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1769 | //remote->deleteIncidence( inR ); | 1769 | //remote->deleteIncidence( inR ); |
1770 | ++deletedEventR; | 1770 | ++deletedEventR; |
1771 | } else { | 1771 | } else { |
1772 | inR->setLastModified( modifiedCalendar ); | 1772 | inR->setLastModified( modifiedCalendar ); |
1773 | inL = inR->clone(); | 1773 | inL = inR->clone(); |
1774 | inL->setIDStr( ":" ); | 1774 | inL->setIDStr( ":" ); |
1775 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1775 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1776 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1776 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1777 | 1777 | ||
1778 | inL->setCalID( 0 );// add to default cal | 1778 | inL->setCalID( 0 );// add to default cal |
1779 | local->addIncidence( inL ); | 1779 | local->addIncidence( inL ); |
1780 | ++addedEvent; | 1780 | ++addedEvent; |
1781 | 1781 | ||
1782 | } | 1782 | } |
1783 | } else { | 1783 | } else { |
1784 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1784 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1785 | inR->setLastModified( modifiedCalendar ); | 1785 | inR->setLastModified( modifiedCalendar ); |
1786 | inL = inR->clone(); | 1786 | inL = inR->clone(); |
1787 | inL->setIDStr( ":" ); | 1787 | inL->setIDStr( ":" ); |
1788 | inL->setCalID( 0 );// add to default cal | 1788 | inL->setCalID( 0 );// add to default cal |
1789 | local->addIncidence( inL ); | 1789 | local->addIncidence( inL ); |
1790 | ++addedEvent; | 1790 | ++addedEvent; |
1791 | 1791 | ||
1792 | } else { | 1792 | } else { |
1793 | checkExternSyncEvent(eventRSyncSharp, inR); | 1793 | checkExternSyncEvent(eventRSyncSharp, inR); |
1794 | remote->deleteIncidence( inR ); | 1794 | remote->deleteIncidence( inR ); |
1795 | ++deletedEventR; | 1795 | ++deletedEventR; |
1796 | } | 1796 | } |
1797 | } | 1797 | } |
1798 | } else { | 1798 | } else { |
1799 | ++filteredIN; | 1799 | ++filteredIN; |
1800 | } | 1800 | } |
1801 | } | 1801 | } |
1802 | } | 1802 | } |
1803 | inR = er.next(); | 1803 | inR = er.next(); |
1804 | } | 1804 | } |
1805 | QPtrList<Incidence> el = local->rawIncidences(); | 1805 | QPtrList<Incidence> el = local->rawIncidences(); |
1806 | inL = el.first(); | 1806 | inL = el.first(); |
1807 | modulo = (el.count()/10)+1; | 1807 | modulo = (el.count()/10)+1; |
1808 | bar.setCaption (i18n("Add / remove events") ); | 1808 | bar.setCaption (i18n("Add / remove events") ); |
1809 | bar.setTotalSteps ( el.count() ) ; | 1809 | bar.setTotalSteps ( el.count() ) ; |
1810 | bar.show(); | 1810 | bar.show(); |
1811 | incCounter = 0; | 1811 | incCounter = 0; |
1812 | 1812 | ||
1813 | while ( inL ) { | 1813 | while ( inL ) { |
1814 | 1814 | ||
1815 | qApp->processEvents(); | 1815 | qApp->processEvents(); |
1816 | if ( ! bar.isVisible() ) | 1816 | if ( ! bar.isVisible() ) |
1817 | return false; | 1817 | return false; |
1818 | if ( incCounter % modulo == 0 ) | 1818 | if ( incCounter % modulo == 0 ) |
1819 | bar.setProgress( incCounter ); | 1819 | bar.setProgress( incCounter ); |
1820 | ++incCounter; | 1820 | ++incCounter; |
1821 | uid = inL->uid(); | 1821 | uid = inL->uid(); |
1822 | bool skipIncidence = false; | 1822 | bool skipIncidence = false; |
1823 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1823 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1824 | skipIncidence = true; | 1824 | skipIncidence = true; |
1825 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1825 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1826 | skipIncidence = true; | 1826 | skipIncidence = true; |
1827 | if ( !skipIncidence ) { | 1827 | if ( !skipIncidence ) { |
1828 | inR = remote->incidenceForUid( uid , true ); | 1828 | inR = remote->incidenceForUid( uid , true ); |
1829 | if ( ! inR ) { | 1829 | if ( ! inR ) { |
1830 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1830 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1831 | // no conflict ********** add or delete local | 1831 | // no conflict ********** add or delete local |
1832 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1832 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1833 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1833 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1834 | checkExternSyncEvent(eventLSyncSharp, inL); | 1834 | checkExternSyncEvent(eventLSyncSharp, inL); |
1835 | local->deleteIncidence( inL ); | 1835 | local->deleteIncidence( inL ); |
1836 | ++deletedEventL; | 1836 | ++deletedEventL; |
1837 | } else { | 1837 | } else { |
1838 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1838 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1839 | inL->removeID(mCurrentSyncDevice ); | 1839 | inL->removeID(mCurrentSyncDevice ); |
1840 | ++addedEventR; | 1840 | ++addedEventR; |
1841 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1841 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1842 | inL->setLastModified( modifiedCalendar ); | 1842 | inL->setLastModified( modifiedCalendar ); |
1843 | inR = inL->clone(); | 1843 | inR = inL->clone(); |
1844 | inR->setIDStr( ":" ); | 1844 | inR->setIDStr( ":" ); |
1845 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1845 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1846 | inR->setCalID( 0 );// add to default cal | 1846 | inR->setCalID( 0 );// add to default cal |
1847 | remote->addIncidence( inR ); | 1847 | remote->addIncidence( inR ); |
1848 | } | 1848 | } |
1849 | } | 1849 | } |
1850 | } else { | 1850 | } else { |
1851 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1851 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1852 | checkExternSyncEvent(eventLSyncSharp, inL); | 1852 | checkExternSyncEvent(eventLSyncSharp, inL); |
1853 | local->deleteIncidence( inL ); | 1853 | local->deleteIncidence( inL ); |
1854 | ++deletedEventL; | 1854 | ++deletedEventL; |
1855 | } else { | 1855 | } else { |
1856 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1856 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1857 | ++addedEventR; | 1857 | ++addedEventR; |
1858 | inL->setLastModified( modifiedCalendar ); | 1858 | inL->setLastModified( modifiedCalendar ); |
1859 | inR = inL->clone(); | 1859 | inR = inL->clone(); |
1860 | inR->setIDStr( ":" ); | 1860 | inR->setIDStr( ":" ); |
1861 | inR->setCalID( 0 );// add to default cal | 1861 | inR->setCalID( 0 );// add to default cal |
1862 | remote->addIncidence( inR ); | 1862 | remote->addIncidence( inR ); |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | } | 1865 | } |
1866 | } else { | 1866 | } else { |
1867 | ++filteredOUT; | 1867 | ++filteredOUT; |
1868 | } | 1868 | } |
1869 | } | 1869 | } |
1870 | } | 1870 | } |
1871 | inL = el.next(); | 1871 | inL = el.next(); |
1872 | } | 1872 | } |
1873 | int delFut = 0; | 1873 | int delFut = 0; |
1874 | int remRem = 0; | 1874 | int remRem = 0; |
1875 | if ( mSyncManager->mWriteBackInFuture ) { | 1875 | if ( mSyncManager->mWriteBackInFuture ) { |
1876 | er = remote->rawIncidences(); | 1876 | er = remote->rawIncidences(); |
1877 | remRem = er.count(); | 1877 | remRem = er.count(); |
1878 | inR = er.first(); | 1878 | inR = er.first(); |
1879 | QDateTime dt; | 1879 | QDateTime dt; |
1880 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1880 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1881 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1881 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1882 | while ( inR ) { | 1882 | while ( inR ) { |
1883 | if ( inR->typeID() == todoID ) { | 1883 | if ( inR->typeID() == todoID ) { |
1884 | Todo * t = (Todo*)inR; | 1884 | Todo * t = (Todo*)inR; |
1885 | if ( t->hasDueDate() ) | 1885 | if ( t->hasDueDate() ) |
1886 | dt = t->dtDue(); | 1886 | dt = t->dtDue(); |
1887 | else | 1887 | else |
1888 | dt = cur.addSecs( 62 ); | 1888 | dt = cur.addSecs( 62 ); |
1889 | } | 1889 | } |
1890 | else if (inR->typeID() == eventID ) { | 1890 | else if (inR->typeID() == eventID ) { |
1891 | bool ok; | 1891 | bool ok; |
1892 | dt = inR->getNextOccurence( cur, &ok ); | 1892 | dt = inR->getNextOccurence( cur, &ok ); |
1893 | if ( !ok ) | 1893 | if ( !ok ) |
1894 | dt = cur.addSecs( -62 ); | 1894 | dt = cur.addSecs( -62 ); |
1895 | } | 1895 | } |
1896 | else | 1896 | else |
1897 | dt = inR->dtStart(); | 1897 | dt = inR->dtStart(); |
1898 | if ( dt < cur || dt > end ) { | 1898 | if ( dt < cur || dt > end ) { |
1899 | remote->deleteIncidence( inR ); | 1899 | remote->deleteIncidence( inR ); |
1900 | ++delFut; | 1900 | ++delFut; |
1901 | } | 1901 | } |
1902 | inR = er.next(); | 1902 | inR = er.next(); |
1903 | } | 1903 | } |
1904 | } | 1904 | } |
1905 | bar.hide(); | 1905 | bar.hide(); |
1906 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1906 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1907 | if ( mMultiResourceSync ) { | 1907 | if ( mMultiResourceSync ) { |
1908 | remote->removeSyncInfo( "" ); //all | 1908 | remote->removeSyncInfo( "" ); //all |
1909 | 1909 | ||
1910 | } else { | 1910 | } else { |
1911 | eventLSync->setReadOnly( false ); | 1911 | eventLSync->setReadOnly( false ); |
1912 | eventLSync->setDtStart( mLastCalendarSync ); | 1912 | eventLSync->setDtStart( mLastCalendarSync ); |
1913 | eventRSync->setDtStart( mLastCalendarSync ); | 1913 | eventRSync->setDtStart( mLastCalendarSync ); |
1914 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1914 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1915 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1915 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1916 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1916 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1917 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1917 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1918 | eventLSync->setReadOnly( true ); | 1918 | eventLSync->setReadOnly( true ); |
1919 | } | 1919 | } |
1920 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1920 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1921 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... | 1921 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1922 | remote->addEvent( eventRSync ); | 1922 | remote->addEvent( eventRSync ); |
1923 | else | 1923 | else |
1924 | delete eventRSync; | 1924 | delete eventRSync; |
1925 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1925 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1926 | QString mes; | 1926 | QString mes; |
1927 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1927 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1928 | QString delmess; | 1928 | QString delmess; |
1929 | if ( delFut ) { | 1929 | if ( delFut ) { |
1930 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1930 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1931 | mes += delmess; | 1931 | mes += delmess; |
1932 | } | 1932 | } |
1933 | mes = i18n("Local calendar changed!\n") +mes; | 1933 | mes = i18n("Local calendar changed!\n") +mes; |
1934 | mCalendar->checkAlarmForIncidence( 0, true ); | 1934 | mCalendar->checkAlarmForIncidence( 0, true ); |
1935 | qDebug( mes ); | 1935 | qDebug( mes ); |
1936 | if ( mSyncManager->mShowSyncSummary ) { | 1936 | if ( mSyncManager->mShowSyncSummary ) { |
1937 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1937 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1938 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1938 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1939 | qDebug("KO: WB cancelled "); | 1939 | qDebug("KO: WB cancelled "); |
1940 | mSyncManager->mWriteBackFile = false; | 1940 | mSyncManager->mWriteBackFile = false; |
1941 | return syncOK; | 1941 | return syncOK; |
1942 | } | 1942 | } |
1943 | } | 1943 | } |
1944 | return syncOK; | 1944 | return syncOK; |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | void CalendarView::setSyncDevice( QString s ) | 1947 | void CalendarView::setSyncDevice( QString s ) |
1948 | { | 1948 | { |
1949 | mCurrentSyncDevice= s; | 1949 | mCurrentSyncDevice= s; |
1950 | } | 1950 | } |
1951 | void CalendarView::setSyncName( QString s ) | 1951 | void CalendarView::setSyncName( QString s ) |
1952 | { | 1952 | { |
1953 | mCurrentSyncName= s; | 1953 | mCurrentSyncName= s; |
1954 | } | 1954 | } |
1955 | bool CalendarView::syncCalendar(QString filename, int mode) | 1955 | bool CalendarView::syncCalendar(QString filename, int mode) |
1956 | { | 1956 | { |
1957 | //qDebug("syncCalendar %s ", filename.latin1()); | 1957 | //qDebug("syncCalendar %s ", filename.latin1()); |
1958 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1958 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1959 | CalendarLocal* calendar = new CalendarLocal(); | 1959 | CalendarLocal* calendar = new CalendarLocal(); |
1960 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1960 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1961 | FileStorage* storage = new FileStorage( calendar ); | 1961 | FileStorage* storage = new FileStorage( calendar ); |
1962 | bool syncOK = false; | 1962 | bool syncOK = false; |
1963 | storage->setFileName( filename ); | 1963 | storage->setFileName( filename ); |
1964 | // qDebug("loading ... "); | 1964 | // qDebug("loading ... "); |
1965 | if ( storage->load() ) { | 1965 | if ( storage->load() ) { |
1966 | getEventViewerDialog()->setSyncMode( true ); | 1966 | getEventViewerDialog()->setSyncMode( true ); |
1967 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1967 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1968 | getEventViewerDialog()->setSyncMode( false ); | 1968 | getEventViewerDialog()->setSyncMode( false ); |
1969 | if ( syncOK ) { | 1969 | if ( syncOK ) { |
1970 | if ( mSyncManager->mWriteBackFile ) | 1970 | if ( mSyncManager->mWriteBackFile ) |
1971 | { | 1971 | { |
1972 | storage->setSaveFormat( new ICalFormat() ); | 1972 | storage->setSaveFormat( new ICalFormat() ); |
1973 | storage->save(); | 1973 | storage->save(); |
1974 | } | 1974 | } |
1975 | } | 1975 | } |
1976 | setModified( true ); | 1976 | setModified( true ); |
1977 | } | 1977 | } |
1978 | delete storage; | 1978 | delete storage; |
1979 | delete calendar; | 1979 | delete calendar; |
1980 | if ( syncOK ) | 1980 | if ( syncOK ) |
1981 | updateView(); | 1981 | updateView(); |
1982 | return syncOK; | 1982 | return syncOK; |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | void CalendarView::syncExternal( int mode ) | 1985 | void CalendarView::syncExternal( int mode ) |
1986 | { | 1986 | { |
1987 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1987 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1988 | qApp->processEvents(); | 1988 | qApp->processEvents(); |
1989 | CalendarLocal* calendar = new CalendarLocal(); | 1989 | CalendarLocal* calendar = new CalendarLocal(); |
1990 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1990 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1991 | bool syncOK = false; | 1991 | bool syncOK = false; |
1992 | bool loadSuccess = false; | 1992 | bool loadSuccess = false; |
1993 | PhoneFormat* phoneFormat = 0; | 1993 | PhoneFormat* phoneFormat = 0; |
1994 | emit tempDisableBR(true); | 1994 | emit tempDisableBR(true); |
1995 | #ifndef DESKTOP_VERSION | 1995 | #ifndef DESKTOP_VERSION |
1996 | SharpFormat* sharpFormat = 0; | 1996 | SharpFormat* sharpFormat = 0; |
1997 | if ( mode == 0 ) { // sharp | 1997 | if ( mode == 0 ) { // sharp |
1998 | sharpFormat = new SharpFormat () ; | 1998 | sharpFormat = new SharpFormat () ; |
1999 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1999 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
2000 | 2000 | ||
2001 | } else | 2001 | } else |
2002 | #endif | 2002 | #endif |
2003 | if ( mode == 1 ) { // phone | 2003 | if ( mode == 1 ) { // phone |
2004 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 2004 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
2005 | mSyncManager->mPhoneDevice, | 2005 | mSyncManager->mPhoneDevice, |
2006 | mSyncManager->mPhoneConnection, | 2006 | mSyncManager->mPhoneConnection, |
2007 | mSyncManager->mPhoneModel); | 2007 | mSyncManager->mPhoneModel); |
2008 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2008 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2009 | 2009 | ||
2010 | } else { | 2010 | } else { |
2011 | emit tempDisableBR(false); | 2011 | emit tempDisableBR(false); |
2012 | return; | 2012 | return; |
2013 | } | 2013 | } |
2014 | if ( loadSuccess ) { | 2014 | if ( loadSuccess ) { |
2015 | getEventViewerDialog()->setSyncMode( true ); | 2015 | getEventViewerDialog()->setSyncMode( true ); |
2016 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2016 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2017 | getEventViewerDialog()->setSyncMode( false ); | 2017 | getEventViewerDialog()->setSyncMode( false ); |
2018 | qApp->processEvents(); | 2018 | qApp->processEvents(); |
2019 | if ( syncOK ) { | 2019 | if ( syncOK ) { |
2020 | if ( mSyncManager->mWriteBackFile ) | 2020 | if ( mSyncManager->mWriteBackFile ) |
2021 | { | 2021 | { |
2022 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2022 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2023 | Incidence* inc = iL.first(); | 2023 | Incidence* inc = iL.first(); |
2024 | if ( phoneFormat ) { | 2024 | if ( phoneFormat ) { |
2025 | while ( inc ) { | 2025 | while ( inc ) { |
2026 | inc->removeID(mCurrentSyncDevice); | 2026 | inc->removeID(mCurrentSyncDevice); |
2027 | inc = iL.next(); | 2027 | inc = iL.next(); |
2028 | } | 2028 | } |
2029 | } | 2029 | } |
2030 | #ifndef DESKTOP_VERSION | 2030 | #ifndef DESKTOP_VERSION |
2031 | if ( sharpFormat ) | 2031 | if ( sharpFormat ) |
2032 | sharpFormat->save(calendar); | 2032 | sharpFormat->save(calendar); |
2033 | #endif | 2033 | #endif |
2034 | if ( phoneFormat ) | 2034 | if ( phoneFormat ) |
2035 | phoneFormat->save(calendar); | 2035 | phoneFormat->save(calendar); |
2036 | iL = calendar->rawIncidences(); | 2036 | iL = calendar->rawIncidences(); |
2037 | inc = iL.first(); | 2037 | inc = iL.first(); |
2038 | Incidence* loc; | 2038 | Incidence* loc; |
2039 | while ( inc ) { | 2039 | while ( inc ) { |
2040 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2040 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2041 | loc = mCalendar->incidence(inc->uid() ); | 2041 | loc = mCalendar->incidence(inc->uid() ); |
2042 | if ( loc ) { | 2042 | if ( loc ) { |
2043 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2043 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2044 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2044 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2045 | } | 2045 | } |
2046 | } | 2046 | } |
2047 | inc = iL.next(); | 2047 | inc = iL.next(); |
2048 | } | 2048 | } |
2049 | Incidence* lse = getLastSyncEvent(); | 2049 | Incidence* lse = getLastSyncEvent(); |
2050 | if ( lse ) { | 2050 | if ( lse ) { |
2051 | lse->setReadOnly( false ); | 2051 | lse->setReadOnly( false ); |
2052 | lse->setDescription( "" ); | 2052 | lse->setDescription( "" ); |
2053 | lse->setReadOnly( true ); | 2053 | lse->setReadOnly( true ); |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | } else { | 2056 | } else { |
2057 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2057 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2058 | } | 2058 | } |
2059 | setModified( true ); | 2059 | setModified( true ); |
2060 | } else { | 2060 | } else { |
2061 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2061 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2062 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2062 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2063 | question, i18n("Ok")) ; | 2063 | question, i18n("Ok")) ; |
2064 | 2064 | ||
2065 | } | 2065 | } |
2066 | delete calendar; | 2066 | delete calendar; |
2067 | updateView(); | 2067 | updateView(); |
2068 | emit tempDisableBR(false); | 2068 | emit tempDisableBR(false); |
2069 | return ;//syncOK; | 2069 | return ;//syncOK; |
2070 | 2070 | ||
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | bool CalendarView::importBday() | 2073 | bool CalendarView::importBday() |
2074 | { | 2074 | { |
2075 | #ifndef KORG_NOKABC | 2075 | #ifndef KORG_NOKABC |
2076 | 2076 | ||
2077 | #ifdef DESKTOP_VERSION | 2077 | #ifdef DESKTOP_VERSION |
2078 | int curCal = mCalendar->defaultCalendar(); | 2078 | int curCal = mCalendar->defaultCalendar(); |
2079 | int bd = mCalEditView->getBirtdayID(); | 2079 | int bd = mCalEditView->getBirtdayID(); |
2080 | if ( bd == 0 ) | 2080 | if ( bd == 0 ) |
2081 | return false; | 2081 | return false; |
2082 | mCalendar->setDefaultCalendar( bd ); | 2082 | mCalendar->setDefaultCalendar( bd ); |
2083 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2083 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2084 | KABC::AddressBook::Iterator it; | 2084 | KABC::AddressBook::Iterator it; |
2085 | int count = 0; | 2085 | int count = 0; |
2086 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2086 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2087 | ++count; | 2087 | ++count; |
2088 | } | 2088 | } |
2089 | QProgressBar bar(count,0 ); | 2089 | QProgressBar bar(count,0 ); |
2090 | int w = 300; | 2090 | int w = 300; |
2091 | if ( QApplication::desktop()->width() < 320 ) | 2091 | if ( QApplication::desktop()->width() < 320 ) |
2092 | w = 220; | 2092 | w = 220; |
2093 | int h = bar.sizeHint().height() ; | 2093 | int h = bar.sizeHint().height() ; |
2094 | int dw = QApplication::desktop()->width(); | 2094 | int dw = QApplication::desktop()->width(); |
2095 | int dh = QApplication::desktop()->height(); | 2095 | int dh = QApplication::desktop()->height(); |
2096 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2096 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2097 | bar.show(); | 2097 | bar.show(); |
2098 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2098 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2099 | qApp->processEvents(); | 2099 | qApp->processEvents(); |
2100 | count = 0; | 2100 | count = 0; |
2101 | int addCount = 0; | 2101 | int addCount = 0; |
2102 | KCal::Attendee* a = 0; | 2102 | KCal::Attendee* a = 0; |
2103 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2103 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2104 | if ( ! bar.isVisible() ) | 2104 | if ( ! bar.isVisible() ) |
2105 | return false; | 2105 | return false; |
2106 | bar.setProgress( count++ ); | 2106 | bar.setProgress( count++ ); |
2107 | qApp->processEvents(); | 2107 | qApp->processEvents(); |
2108 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2108 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2109 | if ( (*it).birthday().date().isValid() ){ | 2109 | if ( (*it).birthday().date().isValid() ){ |
2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2111 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2111 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2112 | ++addCount; | 2112 | ++addCount; |
2113 | } | 2113 | } |
2114 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2114 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2115 | if ( anni.isValid() ){ | 2115 | if ( anni.isValid() ){ |
2116 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2116 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2117 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2117 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2118 | ++addCount; | 2118 | ++addCount; |
2119 | } | 2119 | } |
2120 | } | 2120 | } |
2121 | mCalendar->setDefaultCalendar( curCal ); | 2121 | mCalendar->setDefaultCalendar( curCal ); |
2122 | updateView(); | 2122 | updateView(); |
2123 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2123 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2124 | #else //DESKTOP_VERSION | 2124 | #else //DESKTOP_VERSION |
2125 | 2125 | ||
2126 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2126 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2127 | // the result should now arrive through method insertBirthdays | 2127 | // the result should now arrive through method insertBirthdays |
2128 | 2128 | ||
2129 | #endif //DESKTOP_VERSION | 2129 | #endif //DESKTOP_VERSION |
2130 | 2130 | ||
2131 | #endif //KORG_NOKABC | 2131 | #endif //KORG_NOKABC |
2132 | 2132 | ||
2133 | 2133 | ||
2134 | return true; | 2134 | return true; |
2135 | } | 2135 | } |
2136 | 2136 | ||
2137 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2137 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2138 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2138 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2139 | const QStringList& anniversaryList, const QStringList& realNameList, | 2139 | const QStringList& anniversaryList, const QStringList& realNameList, |
2140 | const QStringList& emailList, const QStringList& assembledNameList, | 2140 | const QStringList& emailList, const QStringList& assembledNameList, |
2141 | const QStringList& uidList) | 2141 | const QStringList& uidList) |
2142 | { | 2142 | { |
2143 | 2143 | ||
2144 | //qDebug("KO::CalendarView::insertBirthdays"); | 2144 | //qDebug("KO::CalendarView::insertBirthdays"); |
2145 | if (uid == this->name()) | 2145 | if (uid == this->name()) |
2146 | { | 2146 | { |
2147 | int curCal = mCalendar->defaultCalendar(); | 2147 | int curCal = mCalendar->defaultCalendar(); |
2148 | int bd = mCalEditView->getBirtdayID(); | 2148 | int bd = mCalEditView->getBirtdayID(); |
2149 | if ( bd == 0 ) | 2149 | if ( bd == 0 ) |
2150 | return; | 2150 | return; |
2151 | mCalendar->setDefaultCalendar( bd ); | 2151 | mCalendar->setDefaultCalendar( bd ); |
2152 | 2152 | ||
2153 | 2153 | ||
2154 | int count = birthdayList.count(); | 2154 | int count = birthdayList.count(); |
2155 | int addCount = 0; | 2155 | int addCount = 0; |
2156 | KCal::Attendee* a = 0; | 2156 | KCal::Attendee* a = 0; |
2157 | 2157 | ||
2158 | //qDebug("CalView 1 %i", count); | 2158 | //qDebug("CalView 1 %i", count); |
2159 | 2159 | ||
2160 | QProgressBar bar(count,0 ); | 2160 | QProgressBar bar(count,0 ); |
2161 | int w = 300; | 2161 | int w = 300; |
2162 | if ( QApplication::desktop()->width() < 320 ) | 2162 | if ( QApplication::desktop()->width() < 320 ) |
2163 | w = 220; | 2163 | w = 220; |
2164 | int h = bar.sizeHint().height() ; | 2164 | int h = bar.sizeHint().height() ; |
2165 | int dw = QApplication::desktop()->width(); | 2165 | int dw = QApplication::desktop()->width(); |
2166 | int dh = QApplication::desktop()->height(); | 2166 | int dh = QApplication::desktop()->height(); |
2167 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2167 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2168 | bar.show(); | 2168 | bar.show(); |
2169 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2169 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2170 | qApp->processEvents(); | 2170 | qApp->processEvents(); |
2171 | 2171 | ||