author | zautrix <zautrix> | 2004-09-12 19:26:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 19:26:13 (UTC) |
commit | 5b434dd78f71bcea5e6067fc8ae0faaaea313f9d (patch) (unidiff) | |
tree | ed532e602a3b503b72a46ea18d40e3a5dc97aa3f /korganizer/calendarview.cpp | |
parent | bc4153a99e205f43d0144e2e910730dd1a14d402 (diff) | |
download | kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.zip kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.gz kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.bz2 |
phone fixes
-rw-r--r-- | korganizer/calendarview.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfd9290..d5d31e2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1031,319 +1031,332 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1031 | if ( inL->revision() < maxrev ) | 1031 | if ( inL->revision() < maxrev ) |
1032 | inL->setRevision( maxrev ); | 1032 | inL->setRevision( maxrev ); |
1033 | remote->addIncidence( inL->clone() ); | 1033 | remote->addIncidence( inL->clone() ); |
1034 | ++changedRemote; | 1034 | ++changedRemote; |
1035 | } else { | 1035 | } else { |
1036 | if ( inR->revision() < maxrev ) | 1036 | if ( inR->revision() < maxrev ) |
1037 | inR->setRevision( maxrev ); | 1037 | inR->setRevision( maxrev ); |
1038 | local->deleteIncidence( inL ); | 1038 | local->deleteIncidence( inL ); |
1039 | local->addIncidence( inR->clone() ); | 1039 | local->addIncidence( inR->clone() ); |
1040 | ++changedLocal; | 1040 | ++changedLocal; |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } else { // no conflict | 1043 | } else { // no conflict |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | QString des = eventLSync->description(); | 1045 | QString des = eventLSync->description(); |
1046 | QString pref = "e"; | 1046 | QString pref = "e"; |
1047 | if ( inR->type() == "Todo" ) | 1047 | if ( inR->type() == "Todo" ) |
1048 | pref = "t"; | 1048 | pref = "t"; |
1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1051 | //remote->deleteIncidence( inR ); | 1051 | //remote->deleteIncidence( inR ); |
1052 | ++deletedEventR; | 1052 | ++deletedEventR; |
1053 | } else { | 1053 | } else { |
1054 | inR->setLastModified( modifiedCalendar ); | 1054 | inR->setLastModified( modifiedCalendar ); |
1055 | local->addIncidence( inR->clone() ); | 1055 | local->addIncidence( inR->clone() ); |
1056 | ++addedEvent; | 1056 | ++addedEvent; |
1057 | } | 1057 | } |
1058 | } else { | 1058 | } else { |
1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | local->addIncidence( inR->clone() ); | 1061 | local->addIncidence( inR->clone() ); |
1062 | ++addedEvent; | 1062 | ++addedEvent; |
1063 | } else { | 1063 | } else { |
1064 | checkExternSyncEvent(eventRSyncSharp, inR); | 1064 | checkExternSyncEvent(eventRSyncSharp, inR); |
1065 | remote->deleteIncidence( inR ); | 1065 | remote->deleteIncidence( inR ); |
1066 | ++deletedEventR; | 1066 | ++deletedEventR; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | } | 1070 | } |
1071 | inR = er.next(); | 1071 | inR = er.next(); |
1072 | } | 1072 | } |
1073 | QPtrList<Incidence> el = local->rawIncidences(); | 1073 | QPtrList<Incidence> el = local->rawIncidences(); |
1074 | inL = el.first(); | 1074 | inL = el.first(); |
1075 | modulo = (el.count()/10)+1; | 1075 | modulo = (el.count()/10)+1; |
1076 | bar.setCaption (i18n("Add / remove events") ); | 1076 | bar.setCaption (i18n("Add / remove events") ); |
1077 | bar.setTotalSteps ( el.count() ) ; | 1077 | bar.setTotalSteps ( el.count() ) ; |
1078 | bar.show(); | 1078 | bar.show(); |
1079 | incCounter = 0; | 1079 | incCounter = 0; |
1080 | 1080 | ||
1081 | while ( inL ) { | 1081 | while ( inL ) { |
1082 | 1082 | ||
1083 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1084 | if ( ! bar.isVisible() ) | 1084 | if ( ! bar.isVisible() ) |
1085 | return false; | 1085 | return false; |
1086 | if ( incCounter % modulo == 0 ) | 1086 | if ( incCounter % modulo == 0 ) |
1087 | bar.setProgress( incCounter ); | 1087 | bar.setProgress( incCounter ); |
1088 | ++incCounter; | 1088 | ++incCounter; |
1089 | uid = inL->uid(); | 1089 | uid = inL->uid(); |
1090 | bool skipIncidence = false; | 1090 | bool skipIncidence = false; |
1091 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1091 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1092 | skipIncidence = true; | 1092 | skipIncidence = true; |
1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1094 | skipIncidence = true; | 1094 | skipIncidence = true; |
1095 | if ( !skipIncidence ) { | 1095 | if ( !skipIncidence ) { |
1096 | inR = remote->incidence( uid ); | 1096 | inR = remote->incidence( uid ); |
1097 | if ( ! inR ) { | 1097 | if ( ! inR ) { |
1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1100 | local->deleteIncidence( inL ); | 1100 | local->deleteIncidence( inL ); |
1101 | ++deletedEventL; | 1101 | ++deletedEventL; |
1102 | } else { | 1102 | } else { |
1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1104 | inL->removeID(mCurrentSyncDevice ); | 1104 | inL->removeID(mCurrentSyncDevice ); |
1105 | ++addedEventR; | 1105 | ++addedEventR; |
1106 | inL->setLastModified( modifiedCalendar ); | 1106 | inL->setLastModified( modifiedCalendar ); |
1107 | remote->addIncidence( inL->clone() ); | 1107 | remote->addIncidence( inL->clone() ); |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | } else { | 1110 | } else { |
1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1114 | ++deletedEventL; |
1115 | } else { | 1115 | } else { |
1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1117 | ++addedEventR; | 1117 | ++addedEventR; |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | remote->addIncidence( inL->clone() ); | 1119 | remote->addIncidence( inL->clone() ); |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | inL = el.next(); | 1125 | inL = el.next(); |
1126 | } | 1126 | } |
1127 | int delFut = 0; | ||
1127 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1128 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1128 | er = remote->rawIncidences(); | 1129 | er = remote->rawIncidences(); |
1129 | inR = er.first(); | 1130 | inR = er.first(); |
1130 | QDateTime dt; | 1131 | QDateTime dt; |
1131 | QDateTime cur = QDateTime::currentDateTime(); | 1132 | QDateTime cur = QDateTime::currentDateTime(); |
1132 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1133 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1133 | while ( inR ) { | 1134 | while ( inR ) { |
1134 | if ( inR->type() == "Todo" ) { | 1135 | if ( inR->type() == "Todo" ) { |
1135 | Todo * t = (Todo*)inR; | 1136 | Todo * t = (Todo*)inR; |
1136 | if ( t->hasDueDate() ) | 1137 | if ( t->hasDueDate() ) |
1137 | dt = t->dtDue(); | 1138 | dt = t->dtDue(); |
1138 | else | 1139 | else |
1139 | dt = cur.addSecs( 62 ); | 1140 | dt = cur.addSecs( 62 ); |
1140 | } | 1141 | } |
1141 | else dt = inR->dtStart(); | 1142 | else if (inR->type() == "Event" ) { |
1142 | if ( dt < cur || dt > end ) | 1143 | bool ok; |
1144 | dt = inR->getNextOccurence( cur, &ok ); | ||
1145 | if ( !ok ) | ||
1146 | dt = cur.addSecs( -62 ); | ||
1147 | } | ||
1148 | else | ||
1149 | dt = inR->dtStart(); | ||
1150 | if ( dt < cur || dt > end ) { | ||
1143 | remote->deleteIncidence( inR ); | 1151 | remote->deleteIncidence( inR ); |
1152 | ++delFut; | ||
1153 | } | ||
1144 | inR = er.next(); | 1154 | inR = er.next(); |
1145 | } | 1155 | } |
1146 | } | 1156 | } |
1147 | bar.hide(); | 1157 | bar.hide(); |
1148 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1158 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1149 | eventLSync->setReadOnly( false ); | 1159 | eventLSync->setReadOnly( false ); |
1150 | eventLSync->setDtStart( mLastCalendarSync ); | 1160 | eventLSync->setDtStart( mLastCalendarSync ); |
1151 | eventRSync->setDtStart( mLastCalendarSync ); | 1161 | eventRSync->setDtStart( mLastCalendarSync ); |
1152 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1162 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1153 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1154 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1164 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1155 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1165 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1156 | eventLSync->setReadOnly( true ); | 1166 | eventLSync->setReadOnly( true ); |
1157 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1167 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1158 | remote->addEvent( eventRSync ); | 1168 | remote->addEvent( eventRSync ); |
1159 | QString mes; | 1169 | QString mes; |
1160 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1170 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1171 | QString delmess; | ||
1172 | if ( delFut ) { | ||
1173 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | ||
1174 | mes += delmess; | ||
1175 | } | ||
1161 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1176 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1162 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1177 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1163 | } | 1178 | } |
1164 | qDebug( mes ); | 1179 | qDebug( mes ); |
1165 | mCalendar->checkAlarmForIncidence( 0, true ); | 1180 | mCalendar->checkAlarmForIncidence( 0, true ); |
1166 | return syncOK; | 1181 | return syncOK; |
1167 | } | 1182 | } |
1168 | 1183 | ||
1169 | void CalendarView::setSyncDevice( QString s ) | 1184 | void CalendarView::setSyncDevice( QString s ) |
1170 | { | 1185 | { |
1171 | mCurrentSyncDevice= s; | 1186 | mCurrentSyncDevice= s; |
1172 | } | 1187 | } |
1173 | void CalendarView::setSyncName( QString s ) | 1188 | void CalendarView::setSyncName( QString s ) |
1174 | { | 1189 | { |
1175 | mCurrentSyncName= s; | 1190 | mCurrentSyncName= s; |
1176 | } | 1191 | } |
1177 | bool CalendarView::syncCalendar(QString filename, int mode) | 1192 | bool CalendarView::syncCalendar(QString filename, int mode) |
1178 | { | 1193 | { |
1179 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1194 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1180 | CalendarLocal* calendar = new CalendarLocal(); | 1195 | CalendarLocal* calendar = new CalendarLocal(); |
1181 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1196 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1182 | FileStorage* storage = new FileStorage( calendar ); | 1197 | FileStorage* storage = new FileStorage( calendar ); |
1183 | bool syncOK = false; | 1198 | bool syncOK = false; |
1184 | storage->setFileName( filename ); | 1199 | storage->setFileName( filename ); |
1185 | // qDebug("loading ... "); | 1200 | // qDebug("loading ... "); |
1186 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1201 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1187 | getEventViewerDialog()->setSyncMode( true ); | 1202 | getEventViewerDialog()->setSyncMode( true ); |
1188 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1203 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1189 | getEventViewerDialog()->setSyncMode( false ); | 1204 | getEventViewerDialog()->setSyncMode( false ); |
1190 | if ( syncOK ) { | 1205 | if ( syncOK ) { |
1191 | if ( KOPrefs::instance()->mWriteBackFile ) | 1206 | if ( KOPrefs::instance()->mWriteBackFile ) |
1192 | { | 1207 | { |
1193 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1208 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1194 | storage->save(); | 1209 | storage->save(); |
1195 | } | 1210 | } |
1196 | } | 1211 | } |
1197 | setModified( true ); | 1212 | setModified( true ); |
1198 | } | 1213 | } |
1199 | delete storage; | 1214 | delete storage; |
1200 | delete calendar; | 1215 | delete calendar; |
1201 | if ( syncOK ) | 1216 | if ( syncOK ) |
1202 | updateView(); | 1217 | updateView(); |
1203 | return syncOK; | 1218 | return syncOK; |
1204 | } | 1219 | } |
1205 | void CalendarView::syncPhone() | 1220 | void CalendarView::syncPhone() |
1206 | { | 1221 | { |
1207 | syncExternal( 1 ); | 1222 | syncExternal( 1 ); |
1208 | } | 1223 | } |
1209 | void CalendarView::syncExternal( int mode ) | 1224 | void CalendarView::syncExternal( int mode ) |
1210 | { | 1225 | { |
1211 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1226 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1212 | //mCurrentSyncDevice = "sharp-DTM"; | 1227 | //mCurrentSyncDevice = "sharp-DTM"; |
1213 | if ( KOPrefs::instance()->mAskForPreferences ) | 1228 | if ( KOPrefs::instance()->mAskForPreferences ) |
1214 | edit_sync_options(); | 1229 | edit_sync_options(); |
1215 | qApp->processEvents(); | 1230 | qApp->processEvents(); |
1216 | CalendarLocal* calendar = new CalendarLocal(); | 1231 | CalendarLocal* calendar = new CalendarLocal(); |
1217 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1232 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1218 | bool syncOK = false; | 1233 | bool syncOK = false; |
1219 | bool loadSuccess = false; | 1234 | bool loadSuccess = false; |
1220 | PhoneFormat* phoneFormat = 0; | 1235 | PhoneFormat* phoneFormat = 0; |
1221 | #ifndef DESKTOP_VERSION | 1236 | #ifndef DESKTOP_VERSION |
1222 | SharpFormat* sharpFormat = 0; | 1237 | SharpFormat* sharpFormat = 0; |
1223 | if ( mode == 0 ) { // sharp | 1238 | if ( mode == 0 ) { // sharp |
1224 | sharpFormat = new SharpFormat () ; | 1239 | sharpFormat = new SharpFormat () ; |
1225 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1240 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1226 | 1241 | ||
1227 | } else | 1242 | } else |
1228 | #endif | 1243 | #endif |
1229 | if ( mode == 1 ) { // phone | 1244 | if ( mode == 1 ) { // phone |
1230 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1245 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1231 | KOPrefs::instance()->mPhoneDevice, | 1246 | KOPrefs::instance()->mPhoneDevice, |
1232 | KOPrefs::instance()->mPhoneConnection, | 1247 | KOPrefs::instance()->mPhoneConnection, |
1233 | KOPrefs::instance()->mPhoneModel); | 1248 | KOPrefs::instance()->mPhoneModel); |
1234 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1249 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1235 | 1250 | ||
1236 | } else | 1251 | } else |
1237 | return; | 1252 | return; |
1238 | if ( loadSuccess ) { | 1253 | if ( loadSuccess ) { |
1239 | getEventViewerDialog()->setSyncMode( true ); | 1254 | getEventViewerDialog()->setSyncMode( true ); |
1240 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1255 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1241 | getEventViewerDialog()->setSyncMode( false ); | 1256 | getEventViewerDialog()->setSyncMode( false ); |
1242 | qApp->processEvents(); | 1257 | qApp->processEvents(); |
1243 | if ( syncOK ) { | 1258 | if ( syncOK ) { |
1244 | if ( KOPrefs::instance()->mWriteBackFile ) | 1259 | if ( KOPrefs::instance()->mWriteBackFile ) |
1245 | { | 1260 | { |
1246 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1261 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1247 | Incidence* inc = iL.first(); | 1262 | Incidence* inc = iL.first(); |
1248 | /* obsolete | ||
1249 | while ( inc ) { | 1263 | while ( inc ) { |
1250 | inc->setZaurusStat( inc->revision () ); | 1264 | inc->removeID(mCurrentSyncDevice); |
1251 | inc = iL.next(); | 1265 | inc = iL.next(); |
1252 | } | 1266 | } |
1253 | */ | ||
1254 | #ifndef DESKTOP_VERSION | 1267 | #ifndef DESKTOP_VERSION |
1255 | if ( sharpFormat ) | 1268 | if ( sharpFormat ) |
1256 | sharpFormat->save(calendar); | 1269 | sharpFormat->save(calendar); |
1257 | #endif | 1270 | #endif |
1258 | if ( phoneFormat ) | 1271 | if ( phoneFormat ) |
1259 | phoneFormat->save(calendar); | 1272 | phoneFormat->save(calendar); |
1260 | iL = calendar->rawIncidences(); | 1273 | iL = calendar->rawIncidences(); |
1261 | inc = iL.first(); | 1274 | inc = iL.first(); |
1262 | Incidence* loc; | 1275 | Incidence* loc; |
1263 | while ( inc ) { | 1276 | while ( inc ) { |
1264 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1277 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1265 | loc = mCalendar->incidence(inc->uid() ); | 1278 | loc = mCalendar->incidence(inc->uid() ); |
1266 | if ( loc ) { | 1279 | if ( loc ) { |
1267 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1280 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1268 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1281 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1269 | } | 1282 | } |
1270 | } | 1283 | } |
1271 | inc = iL.next(); | 1284 | inc = iL.next(); |
1272 | } | 1285 | } |
1273 | Incidence* lse = getLastSyncEvent(); | 1286 | Incidence* lse = getLastSyncEvent(); |
1274 | if ( lse ) { | 1287 | if ( lse ) { |
1275 | lse->setReadOnly( false ); | 1288 | lse->setReadOnly( false ); |
1276 | lse->setDescription( "" ); | 1289 | lse->setDescription( "" ); |
1277 | lse->setReadOnly( true ); | 1290 | lse->setReadOnly( true ); |
1278 | } | 1291 | } |
1279 | } | 1292 | } |
1280 | } | 1293 | } |
1281 | setModified( true ); | 1294 | setModified( true ); |
1282 | } else { | 1295 | } else { |
1283 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1296 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1284 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1297 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1285 | question, i18n("Ok")) ; | 1298 | question, i18n("Ok")) ; |
1286 | 1299 | ||
1287 | } | 1300 | } |
1288 | delete calendar; | 1301 | delete calendar; |
1289 | updateView(); | 1302 | updateView(); |
1290 | return ;//syncOK; | 1303 | return ;//syncOK; |
1291 | 1304 | ||
1292 | } | 1305 | } |
1293 | void CalendarView::syncSharp() | 1306 | void CalendarView::syncSharp() |
1294 | { | 1307 | { |
1295 | syncExternal( 0 ); | 1308 | syncExternal( 0 ); |
1296 | 1309 | ||
1297 | } | 1310 | } |
1298 | 1311 | ||
1299 | 1312 | ||
1300 | #include <kabc/stdaddressbook.h> | 1313 | #include <kabc/stdaddressbook.h> |
1301 | bool CalendarView::importBday() | 1314 | bool CalendarView::importBday() |
1302 | { | 1315 | { |
1303 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1316 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1304 | KABC::AddressBook::Iterator it; | 1317 | KABC::AddressBook::Iterator it; |
1305 | int count = 0; | 1318 | int count = 0; |
1306 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1319 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1307 | ++count; | 1320 | ++count; |
1308 | } | 1321 | } |
1309 | QProgressBar bar(count,0 ); | 1322 | QProgressBar bar(count,0 ); |
1310 | int w = 300; | 1323 | int w = 300; |
1311 | if ( QApplication::desktop()->width() < 320 ) | 1324 | if ( QApplication::desktop()->width() < 320 ) |
1312 | w = 220; | 1325 | w = 220; |
1313 | int h = bar.sizeHint().height() ; | 1326 | int h = bar.sizeHint().height() ; |
1314 | int dw = QApplication::desktop()->width(); | 1327 | int dw = QApplication::desktop()->width(); |
1315 | int dh = QApplication::desktop()->height(); | 1328 | int dh = QApplication::desktop()->height(); |
1316 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1329 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1317 | bar.show(); | 1330 | bar.show(); |
1318 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1331 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1319 | qApp->processEvents(); | 1332 | qApp->processEvents(); |
1320 | count = 0; | 1333 | count = 0; |
1321 | int addCount = 0; | 1334 | int addCount = 0; |
1322 | KCal::Attendee* a = 0; | 1335 | KCal::Attendee* a = 0; |
1323 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1336 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1324 | if ( ! bar.isVisible() ) | 1337 | if ( ! bar.isVisible() ) |
1325 | return false; | 1338 | return false; |
1326 | bar.setProgress( count++ ); | 1339 | bar.setProgress( count++ ); |
1327 | qApp->processEvents(); | 1340 | qApp->processEvents(); |
1328 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1341 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1329 | if ( (*it).birthday().date().isValid() ){ | 1342 | if ( (*it).birthday().date().isValid() ){ |
1330 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1343 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1331 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1344 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1332 | ++addCount; | 1345 | ++addCount; |
1333 | } | 1346 | } |
1334 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1347 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1335 | if ( anni.isValid() ){ | 1348 | if ( anni.isValid() ){ |
1336 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1349 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1337 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1350 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1338 | ++addCount; | 1351 | ++addCount; |
1339 | } | 1352 | } |
1340 | } | 1353 | } |
1341 | updateView(); | 1354 | updateView(); |
1342 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1355 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1343 | return true; | 1356 | return true; |
1344 | } | 1357 | } |
1345 | 1358 | ||
1346 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1359 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1347 | { | 1360 | { |
1348 | //qDebug("addAnni "); | 1361 | //qDebug("addAnni "); |
1349 | Event * ev = new Event(); | 1362 | Event * ev = new Event(); |