author | zautrix <zautrix> | 2004-09-22 01:13:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-22 01:13:09 (UTC) |
commit | ed2feaa9f7e2064e5b26ff678a25eb79ceae599b (patch) (unidiff) | |
tree | bd698d689aa16ce8c52c5060402d9560f95a713e /korganizer | |
parent | 01572248367c63119514d15d7401a5b2b83349a0 (diff) | |
download | kdepimpi-ed2feaa9f7e2064e5b26ff678a25eb79ceae599b.zip kdepimpi-ed2feaa9f7e2064e5b26ff678a25eb79ceae599b.tar.gz kdepimpi-ed2feaa9f7e2064e5b26ff678a25eb79ceae599b.tar.bz2 |
Sync dialog fixes
-rw-r--r-- | korganizer/calendarview.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7fae4a9..bc8625d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1058,194 +1058,194 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } else { // no conflict | 1060 | } else { // no conflict |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | QString des = eventLSync->description(); | 1062 | QString des = eventLSync->description(); |
1063 | QString pref = "e"; | 1063 | QString pref = "e"; |
1064 | if ( inR->type() == "Todo" ) | 1064 | if ( inR->type() == "Todo" ) |
1065 | pref = "t"; | 1065 | pref = "t"; |
1066 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1066 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1067 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1067 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1068 | //remote->deleteIncidence( inR ); | 1068 | //remote->deleteIncidence( inR ); |
1069 | ++deletedEventR; | 1069 | ++deletedEventR; |
1070 | } else { | 1070 | } else { |
1071 | inR->setLastModified( modifiedCalendar ); | 1071 | inR->setLastModified( modifiedCalendar ); |
1072 | inL = inR->clone(); | 1072 | inL = inR->clone(); |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++addedEvent; | 1074 | ++addedEvent; |
1075 | } | 1075 | } |
1076 | } else { | 1076 | } else { |
1077 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1077 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1078 | inR->setLastModified( modifiedCalendar ); | 1078 | inR->setLastModified( modifiedCalendar ); |
1079 | local->addIncidence( inR->clone() ); | 1079 | local->addIncidence( inR->clone() ); |
1080 | ++addedEvent; | 1080 | ++addedEvent; |
1081 | } else { | 1081 | } else { |
1082 | checkExternSyncEvent(eventRSyncSharp, inR); | 1082 | checkExternSyncEvent(eventRSyncSharp, inR); |
1083 | remote->deleteIncidence( inR ); | 1083 | remote->deleteIncidence( inR ); |
1084 | ++deletedEventR; | 1084 | ++deletedEventR; |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | inR = er.next(); | 1089 | inR = er.next(); |
1090 | } | 1090 | } |
1091 | QPtrList<Incidence> el = local->rawIncidences(); | 1091 | QPtrList<Incidence> el = local->rawIncidences(); |
1092 | inL = el.first(); | 1092 | inL = el.first(); |
1093 | modulo = (el.count()/10)+1; | 1093 | modulo = (el.count()/10)+1; |
1094 | bar.setCaption (i18n("Add / remove events") ); | 1094 | bar.setCaption (i18n("Add / remove events") ); |
1095 | bar.setTotalSteps ( el.count() ) ; | 1095 | bar.setTotalSteps ( el.count() ) ; |
1096 | bar.show(); | 1096 | bar.show(); |
1097 | incCounter = 0; | 1097 | incCounter = 0; |
1098 | 1098 | ||
1099 | while ( inL ) { | 1099 | while ( inL ) { |
1100 | 1100 | ||
1101 | qApp->processEvents(); | 1101 | qApp->processEvents(); |
1102 | if ( ! bar.isVisible() ) | 1102 | if ( ! bar.isVisible() ) |
1103 | return false; | 1103 | return false; |
1104 | if ( incCounter % modulo == 0 ) | 1104 | if ( incCounter % modulo == 0 ) |
1105 | bar.setProgress( incCounter ); | 1105 | bar.setProgress( incCounter ); |
1106 | ++incCounter; | 1106 | ++incCounter; |
1107 | uid = inL->uid(); | 1107 | uid = inL->uid(); |
1108 | bool skipIncidence = false; | 1108 | bool skipIncidence = false; |
1109 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1109 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1110 | skipIncidence = true; | 1110 | skipIncidence = true; |
1111 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1111 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1112 | skipIncidence = true; | 1112 | skipIncidence = true; |
1113 | if ( !skipIncidence ) { | 1113 | if ( !skipIncidence ) { |
1114 | inR = remote->incidence( uid ); | 1114 | inR = remote->incidence( uid ); |
1115 | if ( ! inR ) { | 1115 | if ( ! inR ) { |
1116 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1116 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1117 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1117 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1118 | checkExternSyncEvent(eventLSyncSharp, inL); | 1118 | checkExternSyncEvent(eventLSyncSharp, inL); |
1119 | local->deleteIncidence( inL ); | 1119 | local->deleteIncidence( inL ); |
1120 | ++deletedEventL; | 1120 | ++deletedEventL; |
1121 | } else { | 1121 | } else { |
1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1123 | inL->removeID(mCurrentSyncDevice ); | 1123 | inL->removeID(mCurrentSyncDevice ); |
1124 | ++addedEventR; | 1124 | ++addedEventR; |
1125 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1125 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1126 | inL->setLastModified( modifiedCalendar ); | 1126 | inL->setLastModified( modifiedCalendar ); |
1127 | inR = inL->clone(); | 1127 | inR = inL->clone(); |
1128 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1128 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1129 | remote->addIncidence( inR ); | 1129 | remote->addIncidence( inR ); |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | } else { | 1132 | } else { |
1133 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1133 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1134 | checkExternSyncEvent(eventLSyncSharp, inL); | 1134 | checkExternSyncEvent(eventLSyncSharp, inL); |
1135 | local->deleteIncidence( inL ); | 1135 | local->deleteIncidence( inL ); |
1136 | ++deletedEventL; | 1136 | ++deletedEventL; |
1137 | } else { | 1137 | } else { |
1138 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1138 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1139 | ++addedEventR; | 1139 | ++addedEventR; |
1140 | inL->setLastModified( modifiedCalendar ); | 1140 | inL->setLastModified( modifiedCalendar ); |
1141 | remote->addIncidence( inL->clone() ); | 1141 | remote->addIncidence( inL->clone() ); |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | inL = el.next(); | 1147 | inL = el.next(); |
1148 | } | 1148 | } |
1149 | int delFut = 0; | 1149 | int delFut = 0; |
1150 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1150 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1151 | er = remote->rawIncidences(); | 1151 | er = remote->rawIncidences(); |
1152 | inR = er.first(); | 1152 | inR = er.first(); |
1153 | QDateTime dt; | 1153 | QDateTime dt; |
1154 | QDateTime cur = QDateTime::currentDateTime(); | 1154 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1155 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1155 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); |
1156 | while ( inR ) { | 1156 | while ( inR ) { |
1157 | if ( inR->type() == "Todo" ) { | 1157 | if ( inR->type() == "Todo" ) { |
1158 | Todo * t = (Todo*)inR; | 1158 | Todo * t = (Todo*)inR; |
1159 | if ( t->hasDueDate() ) | 1159 | if ( t->hasDueDate() ) |
1160 | dt = t->dtDue(); | 1160 | dt = t->dtDue(); |
1161 | else | 1161 | else |
1162 | dt = cur.addSecs( 62 ); | 1162 | dt = cur.addSecs( 62 ); |
1163 | } | 1163 | } |
1164 | else if (inR->type() == "Event" ) { | 1164 | else if (inR->type() == "Event" ) { |
1165 | bool ok; | 1165 | bool ok; |
1166 | dt = inR->getNextOccurence( cur, &ok ); | 1166 | dt = inR->getNextOccurence( cur, &ok ); |
1167 | if ( !ok ) | 1167 | if ( !ok ) |
1168 | dt = cur.addSecs( -62 ); | 1168 | dt = cur.addSecs( -62 ); |
1169 | } | 1169 | } |
1170 | else | 1170 | else |
1171 | dt = inR->dtStart(); | 1171 | dt = inR->dtStart(); |
1172 | if ( dt < cur || dt > end ) { | 1172 | if ( dt < cur || dt > end ) { |
1173 | remote->deleteIncidence( inR ); | 1173 | remote->deleteIncidence( inR ); |
1174 | ++delFut; | 1174 | ++delFut; |
1175 | } | 1175 | } |
1176 | inR = er.next(); | 1176 | inR = er.next(); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | bar.hide(); | 1179 | bar.hide(); |
1180 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1180 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1181 | eventLSync->setReadOnly( false ); | 1181 | eventLSync->setReadOnly( false ); |
1182 | eventLSync->setDtStart( mLastCalendarSync ); | 1182 | eventLSync->setDtStart( mLastCalendarSync ); |
1183 | eventRSync->setDtStart( mLastCalendarSync ); | 1183 | eventRSync->setDtStart( mLastCalendarSync ); |
1184 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1184 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1185 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1185 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1186 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1186 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1187 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1187 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1188 | eventLSync->setReadOnly( true ); | 1188 | eventLSync->setReadOnly( true ); |
1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1190 | remote->addEvent( eventRSync ); | 1190 | remote->addEvent( eventRSync ); |
1191 | QString mes; | 1191 | QString mes; |
1192 | 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 ); | 1192 | 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 ); |
1193 | QString delmess; | 1193 | QString delmess; |
1194 | if ( delFut ) { | 1194 | if ( delFut ) { |
1195 | 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 ); | 1195 | 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 ); |
1196 | mes += delmess; | 1196 | mes += delmess; |
1197 | } | 1197 | } |
1198 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1198 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1199 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1199 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1200 | } | 1200 | } |
1201 | qDebug( mes ); | 1201 | qDebug( mes ); |
1202 | mCalendar->checkAlarmForIncidence( 0, true ); | 1202 | mCalendar->checkAlarmForIncidence( 0, true ); |
1203 | return syncOK; | 1203 | return syncOK; |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | void CalendarView::setSyncDevice( QString s ) | 1206 | void CalendarView::setSyncDevice( QString s ) |
1207 | { | 1207 | { |
1208 | mCurrentSyncDevice= s; | 1208 | mCurrentSyncDevice= s; |
1209 | } | 1209 | } |
1210 | void CalendarView::setSyncName( QString s ) | 1210 | void CalendarView::setSyncName( QString s ) |
1211 | { | 1211 | { |
1212 | mCurrentSyncName= s; | 1212 | mCurrentSyncName= s; |
1213 | } | 1213 | } |
1214 | bool CalendarView::syncCalendar(QString filename, int mode) | 1214 | bool CalendarView::syncCalendar(QString filename, int mode) |
1215 | { | 1215 | { |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1217 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1218 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1219 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1220 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1221 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1222 | // qDebug("loading ... "); |
1223 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1223 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1224 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1226 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1227 | if ( syncOK ) { |
1228 | if ( KOPrefs::instance()->mWriteBackFile ) | 1228 | if ( KOPrefs::instance()->mWriteBackFile ) |
1229 | { | 1229 | { |
1230 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1230 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1231 | storage->save(); | 1231 | storage->save(); |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | setModified( true ); | 1234 | setModified( true ); |
1235 | } | 1235 | } |
1236 | delete storage; | 1236 | delete storage; |
1237 | delete calendar; | 1237 | delete calendar; |
1238 | if ( syncOK ) | 1238 | if ( syncOK ) |
1239 | updateView(); | 1239 | updateView(); |
1240 | return syncOK; | 1240 | return syncOK; |
1241 | } | 1241 | } |
1242 | void CalendarView::syncPhone() | 1242 | void CalendarView::syncPhone() |
1243 | { | 1243 | { |
1244 | syncExternal( 1 ); | 1244 | syncExternal( 1 ); |
1245 | } | 1245 | } |
1246 | void CalendarView::syncExternal( int mode ) | 1246 | void CalendarView::syncExternal( int mode ) |
1247 | { | 1247 | { |
1248 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1248 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1249 | //mCurrentSyncDevice = "sharp-DTM"; | 1249 | //mCurrentSyncDevice = "sharp-DTM"; |
1250 | if ( KOPrefs::instance()->mAskForPreferences ) | 1250 | if ( KOPrefs::instance()->mAskForPreferences ) |
1251 | edit_sync_options(); | 1251 | edit_sync_options(); |