author | zautrix <zautrix> | 2005-03-20 10:57:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-20 10:57:02 (UTC) |
commit | 289dd44f4f23d92c45d8f28c867a14a980fd5dde (patch) (unidiff) | |
tree | 0c27baeb80e563e191da2a75ce3b79bfeaeec051 | |
parent | 1ebfa83d28d9eb3f48d8240e65212bbe22defb3c (diff) | |
download | kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.zip kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.tar.gz kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.tar.bz2 |
compile fix
-rw-r--r-- | korganizer/calendarview.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9acbbb1..3ce123c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1150,1559 +1150,1549 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1150 | checkExternSyncEvent(eventLSyncSharp, inL); | 1150 | checkExternSyncEvent(eventLSyncSharp, inL); |
1151 | local->deleteIncidence( inL ); | 1151 | local->deleteIncidence( inL ); |
1152 | ++deletedEventL; | 1152 | ++deletedEventL; |
1153 | } else { | 1153 | } else { |
1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1155 | inL->removeID(mCurrentSyncDevice ); | 1155 | inL->removeID(mCurrentSyncDevice ); |
1156 | ++addedEventR; | 1156 | ++addedEventR; |
1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1158 | inL->setLastModified( modifiedCalendar ); | 1158 | inL->setLastModified( modifiedCalendar ); |
1159 | inR = inL->clone(); | 1159 | inR = inL->clone(); |
1160 | inR->setIDStr( ":" ); | 1160 | inR->setIDStr( ":" ); |
1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1162 | remote->addIncidence( inR ); | 1162 | remote->addIncidence( inR ); |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } else { | 1165 | } else { |
1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1167 | checkExternSyncEvent(eventLSyncSharp, inL); | 1167 | checkExternSyncEvent(eventLSyncSharp, inL); |
1168 | local->deleteIncidence( inL ); | 1168 | local->deleteIncidence( inL ); |
1169 | ++deletedEventL; | 1169 | ++deletedEventL; |
1170 | } else { | 1170 | } else { |
1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1172 | ++addedEventR; | 1172 | ++addedEventR; |
1173 | inL->setLastModified( modifiedCalendar ); | 1173 | inL->setLastModified( modifiedCalendar ); |
1174 | inR = inL->clone(); | 1174 | inR = inL->clone(); |
1175 | inR->setIDStr( ":" ); | 1175 | inR->setIDStr( ":" ); |
1176 | remote->addIncidence( inR ); | 1176 | remote->addIncidence( inR ); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | } else { | 1180 | } else { |
1181 | ++filteredOUT; | 1181 | ++filteredOUT; |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | inL = el.next(); | 1185 | inL = el.next(); |
1186 | } | 1186 | } |
1187 | int delFut = 0; | 1187 | int delFut = 0; |
1188 | int remRem = 0; | 1188 | int remRem = 0; |
1189 | if ( mSyncManager->mWriteBackInFuture ) { | 1189 | if ( mSyncManager->mWriteBackInFuture ) { |
1190 | er = remote->rawIncidences(); | 1190 | er = remote->rawIncidences(); |
1191 | remRem = er.count(); | 1191 | remRem = er.count(); |
1192 | inR = er.first(); | 1192 | inR = er.first(); |
1193 | QDateTime dt; | 1193 | QDateTime dt; |
1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1196 | while ( inR ) { | 1196 | while ( inR ) { |
1197 | if ( inR->type() == "Todo" ) { | 1197 | if ( inR->type() == "Todo" ) { |
1198 | Todo * t = (Todo*)inR; | 1198 | Todo * t = (Todo*)inR; |
1199 | if ( t->hasDueDate() ) | 1199 | if ( t->hasDueDate() ) |
1200 | dt = t->dtDue(); | 1200 | dt = t->dtDue(); |
1201 | else | 1201 | else |
1202 | dt = cur.addSecs( 62 ); | 1202 | dt = cur.addSecs( 62 ); |
1203 | } | 1203 | } |
1204 | else if (inR->type() == "Event" ) { | 1204 | else if (inR->type() == "Event" ) { |
1205 | bool ok; | 1205 | bool ok; |
1206 | dt = inR->getNextOccurence( cur, &ok ); | 1206 | dt = inR->getNextOccurence( cur, &ok ); |
1207 | if ( !ok ) | 1207 | if ( !ok ) |
1208 | dt = cur.addSecs( -62 ); | 1208 | dt = cur.addSecs( -62 ); |
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | dt = inR->dtStart(); | 1211 | dt = inR->dtStart(); |
1212 | if ( dt < cur || dt > end ) { | 1212 | if ( dt < cur || dt > end ) { |
1213 | remote->deleteIncidence( inR ); | 1213 | remote->deleteIncidence( inR ); |
1214 | ++delFut; | 1214 | ++delFut; |
1215 | } | 1215 | } |
1216 | inR = er.next(); | 1216 | inR = er.next(); |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | bar.hide(); | 1219 | bar.hide(); |
1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1221 | eventLSync->setReadOnly( false ); | 1221 | eventLSync->setReadOnly( false ); |
1222 | eventLSync->setDtStart( mLastCalendarSync ); | 1222 | eventLSync->setDtStart( mLastCalendarSync ); |
1223 | eventRSync->setDtStart( mLastCalendarSync ); | 1223 | eventRSync->setDtStart( mLastCalendarSync ); |
1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1228 | eventLSync->setReadOnly( true ); | 1228 | eventLSync->setReadOnly( true ); |
1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1231 | remote->addEvent( eventRSync ); | 1231 | remote->addEvent( eventRSync ); |
1232 | else | 1232 | else |
1233 | delete eventRSync; | 1233 | delete eventRSync; |
1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1235 | QString mes; | 1235 | QString mes; |
1236 | 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 ); | 1236 | 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 ); |
1237 | QString delmess; | 1237 | QString delmess; |
1238 | if ( delFut ) { | 1238 | if ( delFut ) { |
1239 | 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); | 1239 | 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); |
1240 | mes += delmess; | 1240 | mes += delmess; |
1241 | } | 1241 | } |
1242 | mes = i18n("Local calendar changed!\n") +mes; | 1242 | mes = i18n("Local calendar changed!\n") +mes; |
1243 | mCalendar->checkAlarmForIncidence( 0, true ); | 1243 | mCalendar->checkAlarmForIncidence( 0, true ); |
1244 | qDebug( mes ); | 1244 | qDebug( mes ); |
1245 | if ( mSyncManager->mShowSyncSummary ) { | 1245 | if ( mSyncManager->mShowSyncSummary ) { |
1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1248 | qDebug("KO: WB cancelled "); | 1248 | qDebug("KO: WB cancelled "); |
1249 | mSyncManager->mWriteBackFile = false; | 1249 | mSyncManager->mWriteBackFile = false; |
1250 | return syncOK; | 1250 | return syncOK; |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | return syncOK; | 1253 | return syncOK; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void CalendarView::setSyncDevice( QString s ) | 1256 | void CalendarView::setSyncDevice( QString s ) |
1257 | { | 1257 | { |
1258 | mCurrentSyncDevice= s; | 1258 | mCurrentSyncDevice= s; |
1259 | } | 1259 | } |
1260 | void CalendarView::setSyncName( QString s ) | 1260 | void CalendarView::setSyncName( QString s ) |
1261 | { | 1261 | { |
1262 | mCurrentSyncName= s; | 1262 | mCurrentSyncName= s; |
1263 | } | 1263 | } |
1264 | bool CalendarView::syncCalendar(QString filename, int mode) | 1264 | bool CalendarView::syncCalendar(QString filename, int mode) |
1265 | { | 1265 | { |
1266 | //qDebug("syncCalendar %s ", filename.latin1()); | 1266 | //qDebug("syncCalendar %s ", filename.latin1()); |
1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1268 | CalendarLocal* calendar = new CalendarLocal(); | 1268 | CalendarLocal* calendar = new CalendarLocal(); |
1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1270 | FileStorage* storage = new FileStorage( calendar ); | 1270 | FileStorage* storage = new FileStorage( calendar ); |
1271 | bool syncOK = false; | 1271 | bool syncOK = false; |
1272 | storage->setFileName( filename ); | 1272 | storage->setFileName( filename ); |
1273 | // qDebug("loading ... "); | 1273 | // qDebug("loading ... "); |
1274 | if ( storage->load() ) { | 1274 | if ( storage->load() ) { |
1275 | getEventViewerDialog()->setSyncMode( true ); | 1275 | getEventViewerDialog()->setSyncMode( true ); |
1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1277 | getEventViewerDialog()->setSyncMode( false ); | 1277 | getEventViewerDialog()->setSyncMode( false ); |
1278 | if ( syncOK ) { | 1278 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1279 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1280 | { |
1281 | storage->setSaveFormat( new ICalFormat() ); | 1281 | storage->setSaveFormat( new ICalFormat() ); |
1282 | storage->save(); | 1282 | storage->save(); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | setModified( true ); | 1285 | setModified( true ); |
1286 | } | 1286 | } |
1287 | delete storage; | 1287 | delete storage; |
1288 | delete calendar; | 1288 | delete calendar; |
1289 | if ( syncOK ) | 1289 | if ( syncOK ) |
1290 | updateView(); | 1290 | updateView(); |
1291 | return syncOK; | 1291 | return syncOK; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void CalendarView::syncExternal( int mode ) | 1294 | void CalendarView::syncExternal( int mode ) |
1295 | { | 1295 | { |
1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1297 | 1297 | ||
1298 | qApp->processEvents(); | 1298 | qApp->processEvents(); |
1299 | CalendarLocal* calendar = new CalendarLocal(); | 1299 | CalendarLocal* calendar = new CalendarLocal(); |
1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1301 | bool syncOK = false; | 1301 | bool syncOK = false; |
1302 | bool loadSuccess = false; | 1302 | bool loadSuccess = false; |
1303 | PhoneFormat* phoneFormat = 0; | 1303 | PhoneFormat* phoneFormat = 0; |
1304 | emit tempDisableBR(true); | 1304 | emit tempDisableBR(true); |
1305 | #ifndef DESKTOP_VERSION | 1305 | #ifndef DESKTOP_VERSION |
1306 | SharpFormat* sharpFormat = 0; | 1306 | SharpFormat* sharpFormat = 0; |
1307 | if ( mode == 0 ) { // sharp | 1307 | if ( mode == 0 ) { // sharp |
1308 | sharpFormat = new SharpFormat () ; | 1308 | sharpFormat = new SharpFormat () ; |
1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1310 | 1310 | ||
1311 | } else | 1311 | } else |
1312 | #endif | 1312 | #endif |
1313 | if ( mode == 1 ) { // phone | 1313 | if ( mode == 1 ) { // phone |
1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1315 | mSyncManager->mPhoneDevice, | 1315 | mSyncManager->mPhoneDevice, |
1316 | mSyncManager->mPhoneConnection, | 1316 | mSyncManager->mPhoneConnection, |
1317 | mSyncManager->mPhoneModel); | 1317 | mSyncManager->mPhoneModel); |
1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1319 | 1319 | ||
1320 | } else { | 1320 | } else { |
1321 | emit tempDisableBR(false); | 1321 | emit tempDisableBR(false); |
1322 | return; | 1322 | return; |
1323 | } | 1323 | } |
1324 | if ( loadSuccess ) { | 1324 | if ( loadSuccess ) { |
1325 | getEventViewerDialog()->setSyncMode( true ); | 1325 | getEventViewerDialog()->setSyncMode( true ); |
1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1327 | getEventViewerDialog()->setSyncMode( false ); | 1327 | getEventViewerDialog()->setSyncMode( false ); |
1328 | qApp->processEvents(); | 1328 | qApp->processEvents(); |
1329 | if ( syncOK ) { | 1329 | if ( syncOK ) { |
1330 | if ( mSyncManager->mWriteBackFile ) | 1330 | if ( mSyncManager->mWriteBackFile ) |
1331 | { | 1331 | { |
1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1333 | Incidence* inc = iL.first(); | 1333 | Incidence* inc = iL.first(); |
1334 | if ( phoneFormat ) { | 1334 | if ( phoneFormat ) { |
1335 | while ( inc ) { | 1335 | while ( inc ) { |
1336 | inc->removeID(mCurrentSyncDevice); | 1336 | inc->removeID(mCurrentSyncDevice); |
1337 | inc = iL.next(); | 1337 | inc = iL.next(); |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1341 | if ( sharpFormat ) | 1341 | if ( sharpFormat ) |
1342 | sharpFormat->save(calendar); | 1342 | sharpFormat->save(calendar); |
1343 | #endif | 1343 | #endif |
1344 | if ( phoneFormat ) | 1344 | if ( phoneFormat ) |
1345 | phoneFormat->save(calendar); | 1345 | phoneFormat->save(calendar); |
1346 | iL = calendar->rawIncidences(); | 1346 | iL = calendar->rawIncidences(); |
1347 | inc = iL.first(); | 1347 | inc = iL.first(); |
1348 | Incidence* loc; | 1348 | Incidence* loc; |
1349 | while ( inc ) { | 1349 | while ( inc ) { |
1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1351 | loc = mCalendar->incidence(inc->uid() ); | 1351 | loc = mCalendar->incidence(inc->uid() ); |
1352 | if ( loc ) { | 1352 | if ( loc ) { |
1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1355 | } | 1355 | } |
1356 | } | 1356 | } |
1357 | inc = iL.next(); | 1357 | inc = iL.next(); |
1358 | } | 1358 | } |
1359 | Incidence* lse = getLastSyncEvent(); | 1359 | Incidence* lse = getLastSyncEvent(); |
1360 | if ( lse ) { | 1360 | if ( lse ) { |
1361 | lse->setReadOnly( false ); | 1361 | lse->setReadOnly( false ); |
1362 | lse->setDescription( "" ); | 1362 | lse->setDescription( "" ); |
1363 | lse->setReadOnly( true ); | 1363 | lse->setReadOnly( true ); |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | } else { | 1366 | } else { |
1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1368 | } | 1368 | } |
1369 | setModified( true ); | 1369 | setModified( true ); |
1370 | } else { | 1370 | } else { |
1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1373 | question, i18n("Ok")) ; | 1373 | question, i18n("Ok")) ; |
1374 | 1374 | ||
1375 | } | 1375 | } |
1376 | delete calendar; | 1376 | delete calendar; |
1377 | updateView(); | 1377 | updateView(); |
1378 | emit tempDisableBR(false); | 1378 | emit tempDisableBR(false); |
1379 | return ;//syncOK; | 1379 | return ;//syncOK; |
1380 | 1380 | ||
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool CalendarView::importBday() | 1383 | bool CalendarView::importBday() |
1384 | { | 1384 | { |
1385 | #ifndef KORG_NOKABC | 1385 | #ifndef KORG_NOKABC |
1386 | 1386 | ||
1387 | #ifdef DESKTOP_VERSION | 1387 | #ifdef DESKTOP_VERSION |
1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1389 | KABC::AddressBook::Iterator it; | 1389 | KABC::AddressBook::Iterator it; |
1390 | int count = 0; | 1390 | int count = 0; |
1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1392 | ++count; | 1392 | ++count; |
1393 | } | 1393 | } |
1394 | QProgressBar bar(count,0 ); | 1394 | QProgressBar bar(count,0 ); |
1395 | int w = 300; | 1395 | int w = 300; |
1396 | if ( QApplication::desktop()->width() < 320 ) | 1396 | if ( QApplication::desktop()->width() < 320 ) |
1397 | w = 220; | 1397 | w = 220; |
1398 | int h = bar.sizeHint().height() ; | 1398 | int h = bar.sizeHint().height() ; |
1399 | int dw = QApplication::desktop()->width(); | 1399 | int dw = QApplication::desktop()->width(); |
1400 | int dh = QApplication::desktop()->height(); | 1400 | int dh = QApplication::desktop()->height(); |
1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1402 | bar.show(); | 1402 | bar.show(); |
1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1404 | qApp->processEvents(); | 1404 | qApp->processEvents(); |
1405 | count = 0; | 1405 | count = 0; |
1406 | int addCount = 0; | 1406 | int addCount = 0; |
1407 | KCal::Attendee* a = 0; | 1407 | KCal::Attendee* a = 0; |
1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1409 | if ( ! bar.isVisible() ) | 1409 | if ( ! bar.isVisible() ) |
1410 | return false; | 1410 | return false; |
1411 | bar.setProgress( count++ ); | 1411 | bar.setProgress( count++ ); |
1412 | qApp->processEvents(); | 1412 | qApp->processEvents(); |
1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1414 | if ( (*it).birthday().date().isValid() ){ | 1414 | if ( (*it).birthday().date().isValid() ){ |
1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1417 | ++addCount; | 1417 | ++addCount; |
1418 | } | 1418 | } |
1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1420 | if ( anni.isValid() ){ | 1420 | if ( anni.isValid() ){ |
1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1423 | ++addCount; | 1423 | ++addCount; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | updateView(); | 1426 | updateView(); |
1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1428 | #else //DESKTOP_VERSION | 1428 | #else //DESKTOP_VERSION |
1429 | 1429 | ||
1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1431 | // the result should now arrive through method insertBirthdays | 1431 | // the result should now arrive through method insertBirthdays |
1432 | 1432 | ||
1433 | #endif //DESKTOP_VERSION | 1433 | #endif //DESKTOP_VERSION |
1434 | 1434 | ||
1435 | #endif //KORG_NOKABC | 1435 | #endif //KORG_NOKABC |
1436 | 1436 | ||
1437 | 1437 | ||
1438 | return true; | 1438 | return true; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1443 | const QStringList& anniversaryList, const QStringList& realNameList, | 1443 | const QStringList& anniversaryList, const QStringList& realNameList, |
1444 | const QStringList& emailList, const QStringList& assembledNameList, | 1444 | const QStringList& emailList, const QStringList& assembledNameList, |
1445 | const QStringList& uidList) | 1445 | const QStringList& uidList) |
1446 | { | 1446 | { |
1447 | //qDebug("KO::CalendarView::insertBirthdays"); | 1447 | //qDebug("KO::CalendarView::insertBirthdays"); |
1448 | if (uid == this->name()) | 1448 | if (uid == this->name()) |
1449 | { | 1449 | { |
1450 | int count = birthdayList.count(); | 1450 | int count = birthdayList.count(); |
1451 | int addCount = 0; | 1451 | int addCount = 0; |
1452 | KCal::Attendee* a = 0; | 1452 | KCal::Attendee* a = 0; |
1453 | 1453 | ||
1454 | //qDebug("CalView 1 %i", count); | 1454 | //qDebug("CalView 1 %i", count); |
1455 | 1455 | ||
1456 | QProgressBar bar(count,0 ); | 1456 | QProgressBar bar(count,0 ); |
1457 | int w = 300; | 1457 | int w = 300; |
1458 | if ( QApplication::desktop()->width() < 320 ) | 1458 | if ( QApplication::desktop()->width() < 320 ) |
1459 | w = 220; | 1459 | w = 220; |
1460 | int h = bar.sizeHint().height() ; | 1460 | int h = bar.sizeHint().height() ; |
1461 | int dw = QApplication::desktop()->width(); | 1461 | int dw = QApplication::desktop()->width(); |
1462 | int dh = QApplication::desktop()->height(); | 1462 | int dh = QApplication::desktop()->height(); |
1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1464 | bar.show(); | 1464 | bar.show(); |
1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1466 | qApp->processEvents(); | 1466 | qApp->processEvents(); |
1467 | 1467 | ||
1468 | QDate birthday; | 1468 | QDate birthday; |
1469 | QDate anniversary; | 1469 | QDate anniversary; |
1470 | QString realName; | 1470 | QString realName; |
1471 | QString email; | 1471 | QString email; |
1472 | QString assembledName; | 1472 | QString assembledName; |
1473 | QString uid; | 1473 | QString uid; |
1474 | bool ok = true; | 1474 | bool ok = true; |
1475 | for ( int i = 0; i < count; i++) | 1475 | for ( int i = 0; i < count; i++) |
1476 | { | 1476 | { |
1477 | if ( ! bar.isVisible() ) | 1477 | if ( ! bar.isVisible() ) |
1478 | return; | 1478 | return; |
1479 | bar.setProgress( i ); | 1479 | bar.setProgress( i ); |
1480 | qApp->processEvents(); | 1480 | qApp->processEvents(); |
1481 | 1481 | ||
1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1483 | if (!ok) { | 1483 | if (!ok) { |
1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1488 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1490 | } | 1490 | } |
1491 | realName = realNameList[i]; | 1491 | realName = realNameList[i]; |
1492 | email = emailList[i]; | 1492 | email = emailList[i]; |
1493 | assembledName = assembledNameList[i]; | 1493 | assembledName = assembledNameList[i]; |
1494 | uid = uidList[i]; | 1494 | uid = uidList[i]; |
1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1496 | 1496 | ||
1497 | if ( birthday.isValid() ){ | 1497 | if ( birthday.isValid() ){ |
1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1499 | KCal::Attendee::ReqParticipant,uid) ; | 1499 | KCal::Attendee::ReqParticipant,uid) ; |
1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1501 | ++addCount; | 1501 | ++addCount; |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | if ( anniversary.isValid() ){ | 1504 | if ( anniversary.isValid() ){ |
1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1506 | KCal::Attendee::ReqParticipant,uid) ; | 1506 | KCal::Attendee::ReqParticipant,uid) ; |
1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1508 | ++addCount; | 1508 | ++addCount; |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | updateView(); | 1512 | updateView(); |
1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | 1520 | ||
1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1522 | { | 1522 | { |
1523 | //qDebug("addAnni "); | 1523 | //qDebug("addAnni "); |
1524 | Event * ev = new Event(); | 1524 | Event * ev = new Event(); |
1525 | ev->setOrganizer(KOPrefs::instance()->email()); | 1525 | ev->setOrganizer(KOPrefs::instance()->email()); |
1526 | if ( a ) { | 1526 | if ( a ) { |
1527 | ev->addAttendee( a ); | 1527 | ev->addAttendee( a ); |
1528 | } | 1528 | } |
1529 | QString kind; | 1529 | QString kind; |
1530 | if ( birthday ) { | 1530 | if ( birthday ) { |
1531 | kind = i18n( "Birthday" ); | 1531 | kind = i18n( "Birthday" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1533 | } | 1533 | } |
1534 | else { | 1534 | else { |
1535 | kind = i18n( "Anniversary" ); | 1535 | kind = i18n( "Anniversary" ); |
1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1537 | } | 1537 | } |
1538 | ev->setCategories( kind ); | 1538 | ev->setCategories( kind ); |
1539 | ev->setDtStart( QDateTime(date) ); | 1539 | ev->setDtStart( QDateTime(date) ); |
1540 | ev->setDtEnd( QDateTime(date) ); | 1540 | ev->setDtEnd( QDateTime(date) ); |
1541 | ev->setFloats( true ); | 1541 | ev->setFloats( true ); |
1542 | Recurrence * rec = ev->recurrence(); | 1542 | Recurrence * rec = ev->recurrence(); |
1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1544 | rec->addYearlyNum( date.month() ); | 1544 | rec->addYearlyNum( date.month() ); |
1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1546 | delete ev; | 1546 | delete ev; |
1547 | return false; | 1547 | return false; |
1548 | } | 1548 | } |
1549 | return true; | 1549 | return true; |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | bool CalendarView::importQtopia( const QString &categories, | 1552 | bool CalendarView::importQtopia( const QString &categories, |
1553 | const QString &datebook, | 1553 | const QString &datebook, |
1554 | const QString &todolist ) | 1554 | const QString &todolist ) |
1555 | { | 1555 | { |
1556 | 1556 | ||
1557 | QtopiaFormat qtopiaFormat; | 1557 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1562 | 1562 | ||
1563 | updateView(); | 1563 | updateView(); |
1564 | return true; | 1564 | return true; |
1565 | 1565 | ||
1566 | #if 0 | 1566 | #if 0 |
1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1568 | mCurrentSyncDevice = "qtopia-XML"; | 1568 | mCurrentSyncDevice = "qtopia-XML"; |
1569 | if ( mSyncManager->mAskForPreferences ) | 1569 | if ( mSyncManager->mAskForPreferences ) |
1570 | edit_sync_options(); | 1570 | edit_sync_options(); |
1571 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1572 | CalendarLocal* calendar = new CalendarLocal(); | 1572 | CalendarLocal* calendar = new CalendarLocal(); |
1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1574 | bool syncOK = false; | 1574 | bool syncOK = false; |
1575 | QtopiaFormat qtopiaFormat; | 1575 | QtopiaFormat qtopiaFormat; |
1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1577 | bool loadOk = true; | 1577 | bool loadOk = true; |
1578 | if ( !categories.isEmpty() ) | 1578 | if ( !categories.isEmpty() ) |
1579 | loadOk = qtopiaFormat.load( calendar, categories ); | 1579 | loadOk = qtopiaFormat.load( calendar, categories ); |
1580 | if ( loadOk && !datebook.isEmpty() ) | 1580 | if ( loadOk && !datebook.isEmpty() ) |
1581 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1581 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1582 | if ( loadOk && !todolist.isEmpty() ) | 1582 | if ( loadOk && !todolist.isEmpty() ) |
1583 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1583 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1584 | 1584 | ||
1585 | if ( loadOk ) { | 1585 | if ( loadOk ) { |
1586 | getEventViewerDialog()->setSyncMode( true ); | 1586 | getEventViewerDialog()->setSyncMode( true ); |
1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1588 | getEventViewerDialog()->setSyncMode( false ); | 1588 | getEventViewerDialog()->setSyncMode( false ); |
1589 | qApp->processEvents(); | 1589 | qApp->processEvents(); |
1590 | if ( syncOK ) { | 1590 | if ( syncOK ) { |
1591 | if ( mSyncManager->mWriteBackFile ) | 1591 | if ( mSyncManager->mWriteBackFile ) |
1592 | { | 1592 | { |
1593 | // write back XML file | 1593 | // write back XML file |
1594 | 1594 | ||
1595 | } | 1595 | } |
1596 | setModified( true ); | 1596 | setModified( true ); |
1597 | } | 1597 | } |
1598 | } else { | 1598 | } else { |
1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1601 | question, i18n("Ok")) ; | 1601 | question, i18n("Ok")) ; |
1602 | } | 1602 | } |
1603 | delete calendar; | 1603 | delete calendar; |
1604 | updateView(); | 1604 | updateView(); |
1605 | return syncOK; | 1605 | return syncOK; |
1606 | 1606 | ||
1607 | 1607 | ||
1608 | #endif | 1608 | #endif |
1609 | 1609 | ||
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | void CalendarView::setSyncEventsReadOnly() | 1612 | void CalendarView::setSyncEventsReadOnly() |
1613 | { | 1613 | { |
1614 | Event * ev; | 1614 | Event * ev; |
1615 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1615 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1616 | ev = eL.first(); | 1616 | ev = eL.first(); |
1617 | while ( ev ) { | 1617 | while ( ev ) { |
1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1619 | ev->setReadOnly( true ); | 1619 | ev->setReadOnly( true ); |
1620 | ev = eL.next(); | 1620 | ev = eL.next(); |
1621 | } | 1621 | } |
1622 | } | 1622 | } |
1623 | bool CalendarView::openCalendar(QString filename, bool merge) | 1623 | bool CalendarView::openCalendar(QString filename, bool merge) |
1624 | { | 1624 | { |
1625 | 1625 | ||
1626 | if (filename.isEmpty()) { | 1626 | if (filename.isEmpty()) { |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | if (!QFile::exists(filename)) { | 1630 | if (!QFile::exists(filename)) { |
1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | globalFlagBlockAgenda = 1; | 1635 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1636 | if (!merge) mCalendar->close(); |
1637 | 1637 | ||
1638 | mStorage->setFileName( filename ); | 1638 | mStorage->setFileName( filename ); |
1639 | 1639 | ||
1640 | if ( mStorage->load() ) { | 1640 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1641 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1642 | else { |
1643 | //setModified( true ); | 1643 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1644 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1645 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1646 | mTodoList->setDocumentId( filename ); |
1647 | } | 1647 | } |
1648 | globalFlagBlockAgenda = 2; | 1648 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1649 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1650 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1651 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1652 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1653 | updateUnmanagedViews(); |
1654 | updateView(); | 1654 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1655 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1656 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1657 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1658 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1659 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1660 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | return true; | 1663 | return true; |
1664 | } else { | 1664 | } else { |
1665 | // while failing to load, the calendar object could | 1665 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1666 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1667 | if ( !merge ) { |
1668 | mCalendar->close(); | 1668 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1675 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1677 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1678 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1679 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1680 | updateUnmanagedViews(); |
1681 | updateView(); | 1681 | updateView(); |
1682 | } | 1682 | } |
1683 | return false; | 1683 | return false; |
1684 | } | 1684 | } |
1685 | void CalendarView::showOpenError() | 1685 | void CalendarView::showOpenError() |
1686 | { | 1686 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1688 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1690 | { |
1691 | loadedFileVersion = dt; | 1691 | loadedFileVersion = dt; |
1692 | } | 1692 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1693 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1694 | { |
1695 | QFileInfo finf ( fn ); | 1695 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1696 | if ( !finf.exists() ) |
1697 | return true; | 1697 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1698 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1699 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1700 | return false; |
1701 | return true; | 1701 | return true; |
1702 | 1702 | ||
1703 | } | 1703 | } |
1704 | void CalendarView::watchSavedFile() | 1704 | void CalendarView::watchSavedFile() |
1705 | { | 1705 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1706 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1708 | return; | 1708 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1710 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1713 | return; |
1714 | } | 1714 | } |
1715 | loadedFileVersion = dt; | 1715 | loadedFileVersion = dt; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1718 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1719 | { |
1720 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1722 | return true; | 1722 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1725 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1726 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1727 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1730 | i18n("Sync+save")); |
1731 | 1731 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1732 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1733 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1734 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1735 | return true; |
1736 | 1736 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1737 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1738 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1739 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1740 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1741 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1742 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1743 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1744 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1745 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1746 | updateView(); |
1747 | return true; | 1747 | return true; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1750 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1751 | { |
1752 | 1752 | ||
1753 | // Store back all unsaved data into calendar object | 1753 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1755 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1756 | mViewManager->currentView()->flushView(); |
1757 | 1757 | ||
1758 | 1758 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1760 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1761 | mStorage->setFileName( filename ); |
1762 | bool success; | 1762 | bool success; |
1763 | success = mStorage->save(); | 1763 | success = mStorage->save(); |
1764 | if ( !success ) { | 1764 | if ( !success ) { |
1765 | return false; | 1765 | return false; |
1766 | } | 1766 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1767 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1768 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1769 | watchSavedFile(); |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::closeCalendar() | 1774 | void CalendarView::closeCalendar() |
1775 | { | 1775 | { |
1776 | 1776 | ||
1777 | // child windows no longer valid | 1777 | // child windows no longer valid |
1778 | emit closingDown(); | 1778 | emit closingDown(); |
1779 | 1779 | ||
1780 | mCalendar->close(); | 1780 | mCalendar->close(); |
1781 | setModified(false); | 1781 | setModified(false); |
1782 | updateView(); | 1782 | updateView(); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void CalendarView::archiveCalendar() | 1785 | void CalendarView::archiveCalendar() |
1786 | { | 1786 | { |
1787 | mDialogManager->showArchiveDialog(); | 1787 | mDialogManager->showArchiveDialog(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | 1790 | ||
1791 | void CalendarView::readSettings() | 1791 | void CalendarView::readSettings() |
1792 | { | 1792 | { |
1793 | 1793 | ||
1794 | 1794 | ||
1795 | // mViewManager->showAgendaView(); | 1795 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1796 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1797 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1798 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1799 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1800 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1801 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1802 | config->setGroup("KOrganizer Geometry"); |
1803 | 1803 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1805 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1806 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1807 | sizes << 300; |
1808 | } | 1808 | } |
1809 | mPanner->setSizes(sizes); | 1809 | mPanner->setSizes(sizes); |
1810 | 1810 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1811 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1812 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1813 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1814 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1817 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1818 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1819 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1821 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1822 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1824 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1826 | ||
1827 | int resetval = 0; | 1827 | int resetval = 0; |
1828 | int maxVal = 0; | 1828 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1829 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1830 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1831 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1832 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1833 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1834 | } |
1835 | } | 1835 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1836 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1837 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1839 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1840 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1842 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | if ( resetval ) { | 1845 | if ( resetval ) { |
1846 | sizes.clear(); | 1846 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1847 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1848 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1849 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1850 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1851 | } |
1852 | sizes << resetval; | 1852 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1853 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1854 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1855 | sizes << resetval; |
1856 | sizes << 100; | 1856 | sizes << 100; |
1857 | } | 1857 | } |
1858 | mLeftFrame->setSizes(sizes); | 1858 | mLeftFrame->setSizes(sizes); |
1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1861 | else mNavigator->selectDates( dateCount ); | 1861 | else mNavigator->selectDates( dateCount ); |
1862 | // mViewManager->readSettings( config ); | 1862 | // mViewManager->readSettings( config ); |
1863 | updateConfig(); | 1863 | updateConfig(); |
1864 | globalFlagBlockAgenda = 2; | 1864 | globalFlagBlockAgenda = 2; |
1865 | mViewManager->readSettings( config ); | 1865 | mViewManager->readSettings( config ); |
1866 | #ifdef DESKTOP_VERSION | 1866 | #ifdef DESKTOP_VERSION |
1867 | config->setGroup("WidgetLayout"); | 1867 | config->setGroup("WidgetLayout"); |
1868 | QStringList list; | 1868 | QStringList list; |
1869 | list = config->readListEntry("MainLayout"); | 1869 | list = config->readListEntry("MainLayout"); |
1870 | int x,y,w,h; | 1870 | int x,y,w,h; |
1871 | if ( ! list.isEmpty() ) { | 1871 | if ( ! list.isEmpty() ) { |
1872 | x = list[0].toInt(); | 1872 | x = list[0].toInt(); |
1873 | y = list[1].toInt(); | 1873 | y = list[1].toInt(); |
1874 | w = list[2].toInt(); | 1874 | w = list[2].toInt(); |
1875 | h = list[3].toInt(); | 1875 | h = list[3].toInt(); |
1876 | topLevelWidget()->setGeometry(x,y,w,h); | 1876 | topLevelWidget()->setGeometry(x,y,w,h); |
1877 | 1877 | ||
1878 | } else { | 1878 | } else { |
1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1880 | } | 1880 | } |
1881 | list = config->readListEntry("EditEventLayout"); | 1881 | list = config->readListEntry("EditEventLayout"); |
1882 | if ( ! list.isEmpty() ) { | 1882 | if ( ! list.isEmpty() ) { |
1883 | x = list[0].toInt(); | 1883 | x = list[0].toInt(); |
1884 | y = list[1].toInt(); | 1884 | y = list[1].toInt(); |
1885 | w = list[2].toInt(); | 1885 | w = list[2].toInt(); |
1886 | h = list[3].toInt(); | 1886 | h = list[3].toInt(); |
1887 | mEventEditor->setGeometry(x,y,w,h); | 1887 | mEventEditor->setGeometry(x,y,w,h); |
1888 | 1888 | ||
1889 | } | 1889 | } |
1890 | list = config->readListEntry("EditTodoLayout"); | 1890 | list = config->readListEntry("EditTodoLayout"); |
1891 | if ( ! list.isEmpty() ) { | 1891 | if ( ! list.isEmpty() ) { |
1892 | x = list[0].toInt(); | 1892 | x = list[0].toInt(); |
1893 | y = list[1].toInt(); | 1893 | y = list[1].toInt(); |
1894 | w = list[2].toInt(); | 1894 | w = list[2].toInt(); |
1895 | h = list[3].toInt(); | 1895 | h = list[3].toInt(); |
1896 | mTodoEditor->setGeometry(x,y,w,h); | 1896 | mTodoEditor->setGeometry(x,y,w,h); |
1897 | 1897 | ||
1898 | } | 1898 | } |
1899 | list = config->readListEntry("ViewerLayout"); | 1899 | list = config->readListEntry("ViewerLayout"); |
1900 | if ( ! list.isEmpty() ) { | 1900 | if ( ! list.isEmpty() ) { |
1901 | x = list[0].toInt(); | 1901 | x = list[0].toInt(); |
1902 | y = list[1].toInt(); | 1902 | y = list[1].toInt(); |
1903 | w = list[2].toInt(); | 1903 | w = list[2].toInt(); |
1904 | h = list[3].toInt(); | 1904 | h = list[3].toInt(); |
1905 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1905 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1906 | } | 1906 | } |
1907 | #endif | 1907 | #endif |
1908 | 1908 | ||
1909 | } | 1909 | } |
1910 | 1910 | ||
1911 | 1911 | ||
1912 | void CalendarView::writeSettings() | 1912 | void CalendarView::writeSettings() |
1913 | { | 1913 | { |
1914 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1914 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1915 | 1915 | ||
1916 | KConfig *config = KOGlobals::config(); | 1916 | KConfig *config = KOGlobals::config(); |
1917 | 1917 | ||
1918 | #ifndef KORG_NOSPLITTER | ||
1919 | config->setGroup("KOrganizer Geometry"); | ||
1920 | |||
1921 | QValueList<int> list = mPanner->sizes(); | ||
1922 | config->writeEntry("Separator1",list); | ||
1923 | |||
1924 | list = mLeftSplitter->sizes(); | ||
1925 | config->writeEntry("Separator2",list); | ||
1926 | #endif | ||
1927 | |||
1928 | mViewManager->writeSettings( config ); | 1918 | mViewManager->writeSettings( config ); |
1929 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1919 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1930 | mDialogManager->writeSettings( config ); | 1920 | mDialogManager->writeSettings( config ); |
1931 | //KOPrefs::instance()->usrWriteConfig(); | 1921 | //KOPrefs::instance()->usrWriteConfig(); |
1932 | KOPrefs::instance()->writeConfig(); | 1922 | KOPrefs::instance()->writeConfig(); |
1933 | 1923 | ||
1934 | writeFilterSettings(config); | 1924 | writeFilterSettings(config); |
1935 | 1925 | ||
1936 | config->setGroup( "Views" ); | 1926 | config->setGroup( "Views" ); |
1937 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1927 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1938 | 1928 | ||
1939 | QValueList<int> list = mLeftFrame->sizes(); | 1929 | QValueList<int> listINT = mLeftFrame->sizes(); |
1940 | config->writeEntry("Left Splitter Frame",list); | 1930 | config->writeEntry("Left Splitter Frame",listINT); |
1941 | 1931 | ||
1942 | #ifdef DESKTOP_VERSION | 1932 | #ifdef DESKTOP_VERSION |
1943 | config->setGroup("WidgetLayout"); | 1933 | config->setGroup("WidgetLayout"); |
1944 | QStringList list ;//= config->readListEntry("MainLayout"); | 1934 | QStringList list ;//= config->readListEntry("MainLayout"); |
1945 | int x,y,w,h; | 1935 | int x,y,w,h; |
1946 | QWidget* wid; | 1936 | QWidget* wid; |
1947 | wid = topLevelWidget(); | 1937 | wid = topLevelWidget(); |
1948 | x = wid->geometry().x(); | 1938 | x = wid->geometry().x(); |
1949 | y = wid->geometry().y(); | 1939 | y = wid->geometry().y(); |
1950 | w = wid->width(); | 1940 | w = wid->width(); |
1951 | h = wid->height(); | 1941 | h = wid->height(); |
1952 | list.clear(); | 1942 | list.clear(); |
1953 | list << QString::number( x ); | 1943 | list << QString::number( x ); |
1954 | list << QString::number( y ); | 1944 | list << QString::number( y ); |
1955 | list << QString::number( w ); | 1945 | list << QString::number( w ); |
1956 | list << QString::number( h ); | 1946 | list << QString::number( h ); |
1957 | config->writeEntry("MainLayout",list ); | 1947 | config->writeEntry("MainLayout",list ); |
1958 | 1948 | ||
1959 | wid = mEventEditor; | 1949 | wid = mEventEditor; |
1960 | x = wid->geometry().x(); | 1950 | x = wid->geometry().x(); |
1961 | y = wid->geometry().y(); | 1951 | y = wid->geometry().y(); |
1962 | w = wid->width(); | 1952 | w = wid->width(); |
1963 | h = wid->height(); | 1953 | h = wid->height(); |
1964 | list.clear(); | 1954 | list.clear(); |
1965 | list << QString::number( x ); | 1955 | list << QString::number( x ); |
1966 | list << QString::number( y ); | 1956 | list << QString::number( y ); |
1967 | list << QString::number( w ); | 1957 | list << QString::number( w ); |
1968 | list << QString::number( h ); | 1958 | list << QString::number( h ); |
1969 | config->writeEntry("EditEventLayout",list ); | 1959 | config->writeEntry("EditEventLayout",list ); |
1970 | 1960 | ||
1971 | wid = mTodoEditor; | 1961 | wid = mTodoEditor; |
1972 | x = wid->geometry().x(); | 1962 | x = wid->geometry().x(); |
1973 | y = wid->geometry().y(); | 1963 | y = wid->geometry().y(); |
1974 | w = wid->width(); | 1964 | w = wid->width(); |
1975 | h = wid->height(); | 1965 | h = wid->height(); |
1976 | list.clear(); | 1966 | list.clear(); |
1977 | list << QString::number( x ); | 1967 | list << QString::number( x ); |
1978 | list << QString::number( y ); | 1968 | list << QString::number( y ); |
1979 | list << QString::number( w ); | 1969 | list << QString::number( w ); |
1980 | list << QString::number( h ); | 1970 | list << QString::number( h ); |
1981 | config->writeEntry("EditTodoLayout",list ); | 1971 | config->writeEntry("EditTodoLayout",list ); |
1982 | wid = getEventViewerDialog(); | 1972 | wid = getEventViewerDialog(); |
1983 | x = wid->geometry().x(); | 1973 | x = wid->geometry().x(); |
1984 | y = wid->geometry().y(); | 1974 | y = wid->geometry().y(); |
1985 | w = wid->width(); | 1975 | w = wid->width(); |
1986 | h = wid->height(); | 1976 | h = wid->height(); |
1987 | list.clear(); | 1977 | list.clear(); |
1988 | list << QString::number( x ); | 1978 | list << QString::number( x ); |
1989 | list << QString::number( y ); | 1979 | list << QString::number( y ); |
1990 | list << QString::number( w ); | 1980 | list << QString::number( w ); |
1991 | list << QString::number( h ); | 1981 | list << QString::number( h ); |
1992 | config->writeEntry("ViewerLayout",list ); | 1982 | config->writeEntry("ViewerLayout",list ); |
1993 | wid = mDialogManager->getSearchDialog(); | 1983 | wid = mDialogManager->getSearchDialog(); |
1994 | if ( wid ) { | 1984 | if ( wid ) { |
1995 | x = wid->geometry().x(); | 1985 | x = wid->geometry().x(); |
1996 | y = wid->geometry().y(); | 1986 | y = wid->geometry().y(); |
1997 | w = wid->width(); | 1987 | w = wid->width(); |
1998 | h = wid->height(); | 1988 | h = wid->height(); |
1999 | list.clear(); | 1989 | list.clear(); |
2000 | list << QString::number( x ); | 1990 | list << QString::number( x ); |
2001 | list << QString::number( y ); | 1991 | list << QString::number( y ); |
2002 | list << QString::number( w ); | 1992 | list << QString::number( w ); |
2003 | list << QString::number( h ); | 1993 | list << QString::number( h ); |
2004 | config->writeEntry("SearchLayout",list ); | 1994 | config->writeEntry("SearchLayout",list ); |
2005 | } | 1995 | } |
2006 | #endif | 1996 | #endif |
2007 | 1997 | ||
2008 | 1998 | ||
2009 | config->sync(); | 1999 | config->sync(); |
2010 | } | 2000 | } |
2011 | 2001 | ||
2012 | void CalendarView::readFilterSettings(KConfig *config) | 2002 | void CalendarView::readFilterSettings(KConfig *config) |
2013 | { | 2003 | { |
2014 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2004 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2015 | 2005 | ||
2016 | mFilters.clear(); | 2006 | mFilters.clear(); |
2017 | 2007 | ||
2018 | config->setGroup("General"); | 2008 | config->setGroup("General"); |
2019 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2009 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2020 | 2010 | ||
2021 | QStringList::ConstIterator it = filterList.begin(); | 2011 | QStringList::ConstIterator it = filterList.begin(); |
2022 | QStringList::ConstIterator end = filterList.end(); | 2012 | QStringList::ConstIterator end = filterList.end(); |
2023 | while(it != end) { | 2013 | while(it != end) { |
2024 | // kdDebug() << " filter: " << (*it) << endl; | 2014 | // kdDebug() << " filter: " << (*it) << endl; |
2025 | 2015 | ||
2026 | CalFilter *filter; | 2016 | CalFilter *filter; |
2027 | filter = new CalFilter(*it); | 2017 | filter = new CalFilter(*it); |
2028 | config->setGroup("Filter_" + (*it)); | 2018 | config->setGroup("Filter_" + (*it)); |
2029 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2019 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2030 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2020 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2031 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2021 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2032 | mFilters.append(filter); | 2022 | mFilters.append(filter); |
2033 | 2023 | ||
2034 | ++it; | 2024 | ++it; |
2035 | } | 2025 | } |
2036 | 2026 | ||
2037 | if (mFilters.count() == 0) { | 2027 | if (mFilters.count() == 0) { |
2038 | CalFilter *filter = new CalFilter(i18n("Default")); | 2028 | CalFilter *filter = new CalFilter(i18n("Default")); |
2039 | mFilters.append(filter); | 2029 | mFilters.append(filter); |
2040 | } | 2030 | } |
2041 | mFilterView->updateFilters(); | 2031 | mFilterView->updateFilters(); |
2042 | config->setGroup("FilterView"); | 2032 | config->setGroup("FilterView"); |
2043 | 2033 | ||
2044 | mFilterView->blockSignals(true); | 2034 | mFilterView->blockSignals(true); |
2045 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2035 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2046 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2036 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2047 | mFilterView->blockSignals(false); | 2037 | mFilterView->blockSignals(false); |
2048 | // We do it manually to avoid it being done twice by the above calls | 2038 | // We do it manually to avoid it being done twice by the above calls |
2049 | updateFilter(); | 2039 | updateFilter(); |
2050 | } | 2040 | } |
2051 | 2041 | ||
2052 | void CalendarView::writeFilterSettings(KConfig *config) | 2042 | void CalendarView::writeFilterSettings(KConfig *config) |
2053 | { | 2043 | { |
2054 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2044 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2055 | 2045 | ||
2056 | QStringList filterList; | 2046 | QStringList filterList; |
2057 | 2047 | ||
2058 | CalFilter *filter = mFilters.first(); | 2048 | CalFilter *filter = mFilters.first(); |
2059 | while(filter) { | 2049 | while(filter) { |
2060 | // kdDebug() << " fn: " << filter->name() << endl; | 2050 | // kdDebug() << " fn: " << filter->name() << endl; |
2061 | filterList << filter->name(); | 2051 | filterList << filter->name(); |
2062 | config->setGroup("Filter_" + filter->name()); | 2052 | config->setGroup("Filter_" + filter->name()); |
2063 | config->writeEntry("Criteria",filter->criteria()); | 2053 | config->writeEntry("Criteria",filter->criteria()); |
2064 | config->writeEntry("CategoryList",filter->categoryList()); | 2054 | config->writeEntry("CategoryList",filter->categoryList()); |
2065 | filter = mFilters.next(); | 2055 | filter = mFilters.next(); |
2066 | } | 2056 | } |
2067 | config->setGroup("General"); | 2057 | config->setGroup("General"); |
2068 | config->writeEntry("CalendarFilters",filterList); | 2058 | config->writeEntry("CalendarFilters",filterList); |
2069 | 2059 | ||
2070 | config->setGroup("FilterView"); | 2060 | config->setGroup("FilterView"); |
2071 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2061 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2072 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2062 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2073 | } | 2063 | } |
2074 | 2064 | ||
2075 | 2065 | ||
2076 | void CalendarView::goToday() | 2066 | void CalendarView::goToday() |
2077 | { | 2067 | { |
2078 | if ( mViewManager->currentView()->isMonthView() ) | 2068 | if ( mViewManager->currentView()->isMonthView() ) |
2079 | mNavigator->selectTodayMonth(); | 2069 | mNavigator->selectTodayMonth(); |
2080 | else | 2070 | else |
2081 | mNavigator->selectToday(); | 2071 | mNavigator->selectToday(); |
2082 | } | 2072 | } |
2083 | 2073 | ||
2084 | void CalendarView::goNext() | 2074 | void CalendarView::goNext() |
2085 | { | 2075 | { |
2086 | mNavigator->selectNext(); | 2076 | mNavigator->selectNext(); |
2087 | } | 2077 | } |
2088 | 2078 | ||
2089 | void CalendarView::goPrevious() | 2079 | void CalendarView::goPrevious() |
2090 | { | 2080 | { |
2091 | mNavigator->selectPrevious(); | 2081 | mNavigator->selectPrevious(); |
2092 | } | 2082 | } |
2093 | void CalendarView::goNextMonth() | 2083 | void CalendarView::goNextMonth() |
2094 | { | 2084 | { |
2095 | mNavigator->selectNextMonth(); | 2085 | mNavigator->selectNextMonth(); |
2096 | } | 2086 | } |
2097 | 2087 | ||
2098 | void CalendarView::goPreviousMonth() | 2088 | void CalendarView::goPreviousMonth() |
2099 | { | 2089 | { |
2100 | mNavigator->selectPreviousMonth(); | 2090 | mNavigator->selectPreviousMonth(); |
2101 | } | 2091 | } |
2102 | void CalendarView::writeLocale() | 2092 | void CalendarView::writeLocale() |
2103 | { | 2093 | { |
2104 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2094 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2105 | #if 0 | 2095 | #if 0 |
2106 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2096 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2107 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2097 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2108 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2098 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2109 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2099 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2110 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2100 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2111 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2101 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2112 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2102 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2113 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2103 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2114 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2104 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2115 | KOPrefs::instance()->mDaylightsavingStart, | 2105 | KOPrefs::instance()->mDaylightsavingStart, |
2116 | KOPrefs::instance()->mDaylightsavingEnd ); | 2106 | KOPrefs::instance()->mDaylightsavingEnd ); |
2117 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2107 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2118 | #endif | 2108 | #endif |
2119 | } | 2109 | } |
2120 | void CalendarView::updateConfig() | 2110 | void CalendarView::updateConfig() |
2121 | { | 2111 | { |
2122 | writeLocale(); | 2112 | writeLocale(); |
2123 | if ( KOPrefs::instance()->mUseAppColors ) | 2113 | if ( KOPrefs::instance()->mUseAppColors ) |
2124 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2125 | emit configChanged(); | 2115 | emit configChanged(); |
2126 | mTodoList->updateConfig(); | 2116 | mTodoList->updateConfig(); |
2127 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2117 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2128 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2118 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2129 | // To make the "fill window" configurations work | 2119 | // To make the "fill window" configurations work |
2130 | //mViewManager->raiseCurrentView(); | 2120 | //mViewManager->raiseCurrentView(); |
2131 | } | 2121 | } |
2132 | 2122 | ||
2133 | 2123 | ||
2134 | void CalendarView::eventChanged(Event *event) | 2124 | void CalendarView::eventChanged(Event *event) |
2135 | { | 2125 | { |
2136 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2126 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2137 | //updateUnmanagedViews(); | 2127 | //updateUnmanagedViews(); |
2138 | } | 2128 | } |
2139 | 2129 | ||
2140 | void CalendarView::eventAdded(Event *event) | 2130 | void CalendarView::eventAdded(Event *event) |
2141 | { | 2131 | { |
2142 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2132 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2143 | } | 2133 | } |
2144 | 2134 | ||
2145 | void CalendarView::eventToBeDeleted(Event *) | 2135 | void CalendarView::eventToBeDeleted(Event *) |
2146 | { | 2136 | { |
2147 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2137 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2148 | } | 2138 | } |
2149 | 2139 | ||
2150 | void CalendarView::eventDeleted() | 2140 | void CalendarView::eventDeleted() |
2151 | { | 2141 | { |
2152 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2142 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2153 | } | 2143 | } |
2154 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2144 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2155 | { | 2145 | { |
2156 | changeIncidenceDisplay((Incidence *)which, action); | 2146 | changeIncidenceDisplay((Incidence *)which, action); |
2157 | mDateNavigator->updateView(); //LR | 2147 | mDateNavigator->updateView(); //LR |
2158 | //mDialogManager->updateSearchDialog(); | 2148 | //mDialogManager->updateSearchDialog(); |
2159 | 2149 | ||
2160 | if (which) { | 2150 | if (which) { |
2161 | mViewManager->updateWNview(); | 2151 | mViewManager->updateWNview(); |
2162 | //mTodoList->updateView(); | 2152 | //mTodoList->updateView(); |
2163 | } | 2153 | } |
2164 | 2154 | ||
2165 | } | 2155 | } |
2166 | 2156 | ||
2167 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2157 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2168 | { | 2158 | { |
2169 | updateUnmanagedViews(); | 2159 | updateUnmanagedViews(); |
2170 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2160 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2171 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2161 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2172 | mCalendar->checkAlarmForIncidence( 0, true ); | 2162 | mCalendar->checkAlarmForIncidence( 0, true ); |
2173 | if ( mEventViewerDialog ) | 2163 | if ( mEventViewerDialog ) |
2174 | mEventViewerDialog->hide(); | 2164 | mEventViewerDialog->hide(); |
2175 | } | 2165 | } |
2176 | else | 2166 | else |
2177 | mCalendar->checkAlarmForIncidence( which , false ); | 2167 | mCalendar->checkAlarmForIncidence( which , false ); |
2178 | } | 2168 | } |
2179 | 2169 | ||
2180 | // most of the changeEventDisplays() right now just call the view's | 2170 | // most of the changeEventDisplays() right now just call the view's |
2181 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2171 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2182 | void CalendarView::changeEventDisplay(Event *which, int action) | 2172 | void CalendarView::changeEventDisplay(Event *which, int action) |
2183 | { | 2173 | { |
2184 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2174 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2185 | changeIncidenceDisplay((Incidence *)which, action); | 2175 | changeIncidenceDisplay((Incidence *)which, action); |
2186 | mDateNavigator->updateView(); | 2176 | mDateNavigator->updateView(); |
2187 | //mDialogManager->updateSearchDialog(); | 2177 | //mDialogManager->updateSearchDialog(); |
2188 | 2178 | ||
2189 | if (which) { | 2179 | if (which) { |
2190 | // If there is an event view visible update the display | 2180 | // If there is an event view visible update the display |
2191 | mViewManager->currentView()->changeEventDisplay(which,action); | 2181 | mViewManager->currentView()->changeEventDisplay(which,action); |
2192 | // TODO: check, if update needed | 2182 | // TODO: check, if update needed |
2193 | // if (which->getTodoStatus()) { | 2183 | // if (which->getTodoStatus()) { |
2194 | mTodoList->updateView(); | 2184 | mTodoList->updateView(); |
2195 | // } | 2185 | // } |
2196 | } else { | 2186 | } else { |
2197 | mViewManager->currentView()->updateView(); | 2187 | mViewManager->currentView()->updateView(); |
2198 | } | 2188 | } |
2199 | } | 2189 | } |
2200 | 2190 | ||
2201 | 2191 | ||
2202 | void CalendarView::updateTodoViews() | 2192 | void CalendarView::updateTodoViews() |
2203 | { | 2193 | { |
2204 | mTodoList->updateView(); | 2194 | mTodoList->updateView(); |
2205 | mViewManager->currentView()->updateView(); | 2195 | mViewManager->currentView()->updateView(); |
2206 | 2196 | ||
2207 | } | 2197 | } |
2208 | 2198 | ||
2209 | 2199 | ||
2210 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2200 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2211 | { | 2201 | { |
2212 | mTodoList->updateView(); | 2202 | mTodoList->updateView(); |
2213 | mViewManager->updateView(start, end); | 2203 | mViewManager->updateView(start, end); |
2214 | //mDateNavigator->updateView(); | 2204 | //mDateNavigator->updateView(); |
2215 | } | 2205 | } |
2216 | 2206 | ||
2217 | void CalendarView::updateView() | 2207 | void CalendarView::updateView() |
2218 | { | 2208 | { |
2219 | DateList tmpList = mNavigator->selectedDates(); | 2209 | DateList tmpList = mNavigator->selectedDates(); |
2220 | 2210 | ||
2221 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2211 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2222 | mTodoList->updateView(); | 2212 | mTodoList->updateView(); |
2223 | // We assume that the navigator only selects consecutive days. | 2213 | // We assume that the navigator only selects consecutive days. |
2224 | updateView( tmpList.first(), tmpList.last() ); | 2214 | updateView( tmpList.first(), tmpList.last() ); |
2225 | } | 2215 | } |
2226 | 2216 | ||
2227 | void CalendarView::updateUnmanagedViews() | 2217 | void CalendarView::updateUnmanagedViews() |
2228 | { | 2218 | { |
2229 | mDateNavigator->updateDayMatrix(); | 2219 | mDateNavigator->updateDayMatrix(); |
2230 | } | 2220 | } |
2231 | 2221 | ||
2232 | int CalendarView::msgItemDelete(const QString name) | 2222 | int CalendarView::msgItemDelete(const QString name) |
2233 | { | 2223 | { |
2234 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2224 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2235 | i18n("This item will be\npermanently deleted."), | 2225 | i18n("This item will be\npermanently deleted."), |
2236 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2226 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2237 | } | 2227 | } |
2238 | 2228 | ||
2239 | 2229 | ||
2240 | void CalendarView::edit_cut() | 2230 | void CalendarView::edit_cut() |
2241 | { | 2231 | { |
2242 | Event *anEvent=0; | 2232 | Event *anEvent=0; |
2243 | 2233 | ||
2244 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2234 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2245 | 2235 | ||
2246 | if (mViewManager->currentView()->isEventView()) { | 2236 | if (mViewManager->currentView()->isEventView()) { |
2247 | if ( incidence && incidence->type() == "Event" ) { | 2237 | if ( incidence && incidence->type() == "Event" ) { |
2248 | anEvent = static_cast<Event *>(incidence); | 2238 | anEvent = static_cast<Event *>(incidence); |
2249 | } | 2239 | } |
2250 | } | 2240 | } |
2251 | 2241 | ||
2252 | if (!anEvent) { | 2242 | if (!anEvent) { |
2253 | KNotifyClient::beep(); | 2243 | KNotifyClient::beep(); |
2254 | return; | 2244 | return; |
2255 | } | 2245 | } |
2256 | DndFactory factory( mCalendar ); | 2246 | DndFactory factory( mCalendar ); |
2257 | factory.cutIncidence(anEvent); | 2247 | factory.cutIncidence(anEvent); |
2258 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2248 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2259 | } | 2249 | } |
2260 | 2250 | ||
2261 | void CalendarView::edit_copy() | 2251 | void CalendarView::edit_copy() |
2262 | { | 2252 | { |
2263 | Event *anEvent=0; | 2253 | Event *anEvent=0; |
2264 | 2254 | ||
2265 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2255 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2266 | 2256 | ||
2267 | if (mViewManager->currentView()->isEventView()) { | 2257 | if (mViewManager->currentView()->isEventView()) { |
2268 | if ( incidence && incidence->type() == "Event" ) { | 2258 | if ( incidence && incidence->type() == "Event" ) { |
2269 | anEvent = static_cast<Event *>(incidence); | 2259 | anEvent = static_cast<Event *>(incidence); |
2270 | } | 2260 | } |
2271 | } | 2261 | } |
2272 | 2262 | ||
2273 | if (!anEvent) { | 2263 | if (!anEvent) { |
2274 | KNotifyClient::beep(); | 2264 | KNotifyClient::beep(); |
2275 | return; | 2265 | return; |
2276 | } | 2266 | } |
2277 | DndFactory factory( mCalendar ); | 2267 | DndFactory factory( mCalendar ); |
2278 | factory.copyIncidence(anEvent); | 2268 | factory.copyIncidence(anEvent); |
2279 | } | 2269 | } |
2280 | 2270 | ||
2281 | void CalendarView::edit_paste() | 2271 | void CalendarView::edit_paste() |
2282 | { | 2272 | { |
2283 | QDate date = mNavigator->selectedDates().first(); | 2273 | QDate date = mNavigator->selectedDates().first(); |
2284 | 2274 | ||
2285 | DndFactory factory( mCalendar ); | 2275 | DndFactory factory( mCalendar ); |
2286 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2276 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2287 | 2277 | ||
2288 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2278 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2289 | } | 2279 | } |
2290 | 2280 | ||
2291 | void CalendarView::edit_options() | 2281 | void CalendarView::edit_options() |
2292 | { | 2282 | { |
2293 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2283 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2294 | emit save(); | 2284 | emit save(); |
2295 | emit saveStopTimer(); | 2285 | emit saveStopTimer(); |
2296 | mDialogManager->showOptionsDialog(); | 2286 | mDialogManager->showOptionsDialog(); |
2297 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2287 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2298 | emit saveStopTimer(); | 2288 | emit saveStopTimer(); |
2299 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2289 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2300 | i18n("Timezone settings"),i18n("Reload"))) { | 2290 | i18n("Timezone settings"),i18n("Reload"))) { |
2301 | qDebug("KO: TZ reload cancelled "); | 2291 | qDebug("KO: TZ reload cancelled "); |
2302 | return; | 2292 | return; |
2303 | } | 2293 | } |
2304 | qDebug("KO: Timezone change "); | 2294 | qDebug("KO: Timezone change "); |
2305 | openCalendar( MainWindow::defaultFileName() ); | 2295 | openCalendar( MainWindow::defaultFileName() ); |
2306 | setModified(true); | 2296 | setModified(true); |
2307 | } | 2297 | } |
2308 | else | 2298 | else |
2309 | qDebug("KO: No tz change "); | 2299 | qDebug("KO: No tz change "); |
2310 | 2300 | ||
2311 | } | 2301 | } |
2312 | 2302 | ||
2313 | 2303 | ||
2314 | void CalendarView::slotSelectPickerDate( QDate d) | 2304 | void CalendarView::slotSelectPickerDate( QDate d) |
2315 | { | 2305 | { |
2316 | mDateFrame->hide(); | 2306 | mDateFrame->hide(); |
2317 | if ( mDatePickerMode == 1 ) { | 2307 | if ( mDatePickerMode == 1 ) { |
2318 | mNavigator->slotDaySelect( d ); | 2308 | mNavigator->slotDaySelect( d ); |
2319 | } else if ( mDatePickerMode == 2 ) { | 2309 | } else if ( mDatePickerMode == 2 ) { |
2320 | if ( mMoveIncidence->type() == "Todo" ) { | 2310 | if ( mMoveIncidence->type() == "Todo" ) { |
2321 | Todo * to = (Todo *) mMoveIncidence; | 2311 | Todo * to = (Todo *) mMoveIncidence; |
2322 | QTime tim; | 2312 | QTime tim; |
2323 | int len = 0; | 2313 | int len = 0; |
2324 | if ( to->hasStartDate() && to->hasDueDate() ) | 2314 | if ( to->hasStartDate() && to->hasDueDate() ) |
2325 | len = to->dtStart().secsTo( to->dtDue()); | 2315 | len = to->dtStart().secsTo( to->dtDue()); |
2326 | if ( to->hasDueDate() ) | 2316 | if ( to->hasDueDate() ) |
2327 | tim = to->dtDue().time(); | 2317 | tim = to->dtDue().time(); |
2328 | else { | 2318 | else { |
2329 | tim = QTime ( 0,0,0 ); | 2319 | tim = QTime ( 0,0,0 ); |
2330 | to->setFloats( true ); | 2320 | to->setFloats( true ); |
2331 | to->setHasDueDate( true ); | 2321 | to->setHasDueDate( true ); |
2332 | } | 2322 | } |
2333 | QDateTime dt ( d,tim ); | 2323 | QDateTime dt ( d,tim ); |
2334 | to->setDtDue( dt ); | 2324 | to->setDtDue( dt ); |
2335 | 2325 | ||
2336 | if ( to->hasStartDate() ) { | 2326 | if ( to->hasStartDate() ) { |
2337 | if ( len>0 ) | 2327 | if ( len>0 ) |
2338 | to->setDtStart(to->dtDue().addSecs( -len )); | 2328 | to->setDtStart(to->dtDue().addSecs( -len )); |
2339 | else | 2329 | else |
2340 | if (to->dtStart() > to->dtDue() ) | 2330 | if (to->dtStart() > to->dtDue() ) |
2341 | to->setDtStart(to->dtDue().addDays( -3 )); | 2331 | to->setDtStart(to->dtDue().addDays( -3 )); |
2342 | } | 2332 | } |
2343 | 2333 | ||
2344 | todoChanged( to ); | 2334 | todoChanged( to ); |
2345 | } else { | 2335 | } else { |
2346 | if ( mMoveIncidence->doesRecur() ) { | 2336 | if ( mMoveIncidence->doesRecur() ) { |
2347 | #if 0 | 2337 | #if 0 |
2348 | // PENDING implement this | 2338 | // PENDING implement this |
2349 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2339 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2350 | mCalendar()->addIncidence( newInc ); | 2340 | mCalendar()->addIncidence( newInc ); |
2351 | if ( mMoveIncidence->type() == "Todo" ) | 2341 | if ( mMoveIncidence->type() == "Todo" ) |
2352 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2342 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2353 | else | 2343 | else |
2354 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2344 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2355 | mMoveIncidence = newInc; | 2345 | mMoveIncidence = newInc; |
2356 | 2346 | ||
2357 | #endif | 2347 | #endif |
2358 | } | 2348 | } |
2359 | QTime tim = mMoveIncidence->dtStart().time(); | 2349 | QTime tim = mMoveIncidence->dtStart().time(); |
2360 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2350 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2361 | QDateTime dt ( d,tim ); | 2351 | QDateTime dt ( d,tim ); |
2362 | mMoveIncidence->setDtStart( dt ); | 2352 | mMoveIncidence->setDtStart( dt ); |
2363 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2353 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2364 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2354 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2365 | } | 2355 | } |
2366 | 2356 | ||
2367 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2357 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2368 | } | 2358 | } |
2369 | } | 2359 | } |
2370 | 2360 | ||
2371 | void CalendarView::removeCategories() | 2361 | void CalendarView::removeCategories() |
2372 | { | 2362 | { |
2373 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2363 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2374 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2364 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2375 | QStringList catIncList; | 2365 | QStringList catIncList; |
2376 | QStringList newCatList; | 2366 | QStringList newCatList; |
2377 | Incidence* inc = incList.first(); | 2367 | Incidence* inc = incList.first(); |
2378 | int i; | 2368 | int i; |
2379 | int count = 0; | 2369 | int count = 0; |
2380 | while ( inc ) { | 2370 | while ( inc ) { |
2381 | newCatList.clear(); | 2371 | newCatList.clear(); |
2382 | catIncList = inc->categories() ; | 2372 | catIncList = inc->categories() ; |
2383 | for( i = 0; i< catIncList.count(); ++i ) { | 2373 | for( i = 0; i< catIncList.count(); ++i ) { |
2384 | if ( catList.contains (catIncList[i])) | 2374 | if ( catList.contains (catIncList[i])) |
2385 | newCatList.append( catIncList[i] ); | 2375 | newCatList.append( catIncList[i] ); |
2386 | } | 2376 | } |
2387 | newCatList.sort(); | 2377 | newCatList.sort(); |
2388 | inc->setCategories( newCatList.join(",") ); | 2378 | inc->setCategories( newCatList.join(",") ); |
2389 | inc = incList.next(); | 2379 | inc = incList.next(); |
2390 | } | 2380 | } |
2391 | } | 2381 | } |
2392 | 2382 | ||
2393 | int CalendarView::addCategories() | 2383 | int CalendarView::addCategories() |
2394 | { | 2384 | { |
2395 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2385 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2396 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2386 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2397 | QStringList catIncList; | 2387 | QStringList catIncList; |
2398 | Incidence* inc = incList.first(); | 2388 | Incidence* inc = incList.first(); |
2399 | int i; | 2389 | int i; |
2400 | int count = 0; | 2390 | int count = 0; |
2401 | while ( inc ) { | 2391 | while ( inc ) { |
2402 | catIncList = inc->categories() ; | 2392 | catIncList = inc->categories() ; |
2403 | for( i = 0; i< catIncList.count(); ++i ) { | 2393 | for( i = 0; i< catIncList.count(); ++i ) { |
2404 | if ( !catList.contains (catIncList[i])) { | 2394 | if ( !catList.contains (catIncList[i])) { |
2405 | catList.append( catIncList[i] ); | 2395 | catList.append( catIncList[i] ); |
2406 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2396 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2407 | ++count; | 2397 | ++count; |
2408 | } | 2398 | } |
2409 | } | 2399 | } |
2410 | inc = incList.next(); | 2400 | inc = incList.next(); |
2411 | } | 2401 | } |
2412 | catList.sort(); | 2402 | catList.sort(); |
2413 | KOPrefs::instance()->mCustomCategories = catList; | 2403 | KOPrefs::instance()->mCustomCategories = catList; |
2414 | return count; | 2404 | return count; |
2415 | } | 2405 | } |
2416 | 2406 | ||
2417 | void CalendarView::manageCategories() | 2407 | void CalendarView::manageCategories() |
2418 | { | 2408 | { |
2419 | KOCatPrefs* cp = new KOCatPrefs(); | 2409 | KOCatPrefs* cp = new KOCatPrefs(); |
2420 | cp->show(); | 2410 | cp->show(); |
2421 | int w =cp->sizeHint().width() ; | 2411 | int w =cp->sizeHint().width() ; |
2422 | int h = cp->sizeHint().height() ; | 2412 | int h = cp->sizeHint().height() ; |
2423 | int dw = QApplication::desktop()->width(); | 2413 | int dw = QApplication::desktop()->width(); |
2424 | int dh = QApplication::desktop()->height(); | 2414 | int dh = QApplication::desktop()->height(); |
2425 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2415 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2426 | if ( !cp->exec() ) { | 2416 | if ( !cp->exec() ) { |
2427 | delete cp; | 2417 | delete cp; |
2428 | return; | 2418 | return; |
2429 | } | 2419 | } |
2430 | int count = 0; | 2420 | int count = 0; |
2431 | if ( cp->addCat() ) { | 2421 | if ( cp->addCat() ) { |
2432 | count = addCategories(); | 2422 | count = addCategories(); |
2433 | if ( count ) { | 2423 | if ( count ) { |
2434 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2424 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2435 | writeSettings(); | 2425 | writeSettings(); |
2436 | } else | 2426 | } else |
2437 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2427 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2438 | } else { | 2428 | } else { |
2439 | removeCategories(); | 2429 | removeCategories(); |
2440 | updateView(); | 2430 | updateView(); |
2441 | } | 2431 | } |
2442 | delete cp; | 2432 | delete cp; |
2443 | } | 2433 | } |
2444 | 2434 | ||
2445 | void CalendarView::beamIncidence(Incidence * Inc) | 2435 | void CalendarView::beamIncidence(Incidence * Inc) |
2446 | { | 2436 | { |
2447 | QPtrList<Incidence> delSel ; | 2437 | QPtrList<Incidence> delSel ; |
2448 | delSel.append(Inc); | 2438 | delSel.append(Inc); |
2449 | beamIncidenceList( delSel ); | 2439 | beamIncidenceList( delSel ); |
2450 | } | 2440 | } |
2451 | void CalendarView::beamCalendar() | 2441 | void CalendarView::beamCalendar() |
2452 | { | 2442 | { |
2453 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2443 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2454 | //qDebug("beamCalendar() "); | 2444 | //qDebug("beamCalendar() "); |
2455 | beamIncidenceList( delSel ); | 2445 | beamIncidenceList( delSel ); |
2456 | } | 2446 | } |
2457 | void CalendarView::beamFilteredCalendar() | 2447 | void CalendarView::beamFilteredCalendar() |
2458 | { | 2448 | { |
2459 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2449 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2460 | //qDebug("beamFilteredCalendar() "); | 2450 | //qDebug("beamFilteredCalendar() "); |
2461 | beamIncidenceList( delSel ); | 2451 | beamIncidenceList( delSel ); |
2462 | } | 2452 | } |
2463 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2453 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2464 | { | 2454 | { |
2465 | if ( beamDialog->exec () == QDialog::Rejected ) | 2455 | if ( beamDialog->exec () == QDialog::Rejected ) |
2466 | return; | 2456 | return; |
2467 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2468 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2458 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2469 | #else | 2459 | #else |
2470 | QString fn = "/tmp/kopibeamfile"; | 2460 | QString fn = "/tmp/kopibeamfile"; |
2471 | #endif | 2461 | #endif |
2472 | QString mes; | 2462 | QString mes; |
2473 | bool createbup = true; | 2463 | bool createbup = true; |
2474 | if ( createbup ) { | 2464 | if ( createbup ) { |
2475 | QString description = "\n"; | 2465 | QString description = "\n"; |
2476 | CalendarLocal* cal = new CalendarLocal(); | 2466 | CalendarLocal* cal = new CalendarLocal(); |
2477 | if ( beamDialog->beamLocal() ) | 2467 | if ( beamDialog->beamLocal() ) |
2478 | cal->setLocalTime(); | 2468 | cal->setLocalTime(); |
2479 | else | 2469 | else |
2480 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2470 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2481 | Incidence *incidence = delSel.first(); | 2471 | Incidence *incidence = delSel.first(); |
2482 | bool addText = false; | 2472 | bool addText = false; |
2483 | if ( delSel.count() < 10 ) | 2473 | if ( delSel.count() < 10 ) |
2484 | addText = true; | 2474 | addText = true; |
2485 | else { | 2475 | else { |
2486 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2476 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2487 | } | 2477 | } |
2488 | while ( incidence ) { | 2478 | while ( incidence ) { |
2489 | Incidence *in = incidence->clone(); | 2479 | Incidence *in = incidence->clone(); |
2490 | if ( ! in->summary().isEmpty() ) { | 2480 | if ( ! in->summary().isEmpty() ) { |
2491 | in->setDescription(""); | 2481 | in->setDescription(""); |
2492 | } else { | 2482 | } else { |
2493 | in->setSummary( in->description().left(20)); | 2483 | in->setSummary( in->description().left(20)); |
2494 | in->setDescription(""); | 2484 | in->setDescription(""); |
2495 | } | 2485 | } |
2496 | if ( addText ) | 2486 | if ( addText ) |
2497 | description += in->summary() + "\n"; | 2487 | description += in->summary() + "\n"; |
2498 | cal->addIncidence( in ); | 2488 | cal->addIncidence( in ); |
2499 | incidence = delSel.next(); | 2489 | incidence = delSel.next(); |
2500 | } | 2490 | } |
2501 | if ( beamDialog->beamVcal() ) { | 2491 | if ( beamDialog->beamVcal() ) { |
2502 | fn += ".vcs"; | 2492 | fn += ".vcs"; |
2503 | FileStorage storage( cal, fn, new VCalFormat ); | 2493 | FileStorage storage( cal, fn, new VCalFormat ); |
2504 | storage.save(); | 2494 | storage.save(); |
2505 | } else { | 2495 | } else { |
2506 | fn += ".ics"; | 2496 | fn += ".ics"; |
2507 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2497 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2508 | storage.save(); | 2498 | storage.save(); |
2509 | } | 2499 | } |
2510 | delete cal; | 2500 | delete cal; |
2511 | mes = i18n("KO/Pi: Ready for beaming"); | 2501 | mes = i18n("KO/Pi: Ready for beaming"); |
2512 | topLevelWidget()->setCaption(mes); | 2502 | topLevelWidget()->setCaption(mes); |
2513 | KApplication::convert2latin1( fn ); | 2503 | KApplication::convert2latin1( fn ); |
2514 | #ifndef DESKTOP_VERSION | 2504 | #ifndef DESKTOP_VERSION |
2515 | Ir *ir = new Ir( this ); | 2505 | Ir *ir = new Ir( this ); |
2516 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2506 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2517 | ir->send( fn, description, "text/x-vCalendar" ); | 2507 | ir->send( fn, description, "text/x-vCalendar" ); |
2518 | #endif | 2508 | #endif |
2519 | } | 2509 | } |
2520 | } | 2510 | } |
2521 | void CalendarView::beamDone( Ir *ir ) | 2511 | void CalendarView::beamDone( Ir *ir ) |
2522 | { | 2512 | { |
2523 | #ifndef DESKTOP_VERSION | 2513 | #ifndef DESKTOP_VERSION |
2524 | delete ir; | 2514 | delete ir; |
2525 | #endif | 2515 | #endif |
2526 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2516 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2527 | topLevelWidget()->raise(); | 2517 | topLevelWidget()->raise(); |
2528 | } | 2518 | } |
2529 | 2519 | ||
2530 | void CalendarView::moveIncidence(Incidence * inc ) | 2520 | void CalendarView::moveIncidence(Incidence * inc ) |
2531 | { | 2521 | { |
2532 | if ( !inc ) return; | 2522 | if ( !inc ) return; |
2533 | showDatePickerPopup(); | 2523 | showDatePickerPopup(); |
2534 | mDatePickerMode = 2; | 2524 | mDatePickerMode = 2; |
2535 | mMoveIncidence = inc ; | 2525 | mMoveIncidence = inc ; |
2536 | QDate da; | 2526 | QDate da; |
2537 | if ( mMoveIncidence->type() == "Todo" ) { | 2527 | if ( mMoveIncidence->type() == "Todo" ) { |
2538 | Todo * to = (Todo *) mMoveIncidence; | 2528 | Todo * to = (Todo *) mMoveIncidence; |
2539 | if ( to->hasDueDate() ) | 2529 | if ( to->hasDueDate() ) |
2540 | da = to->dtDue().date(); | 2530 | da = to->dtDue().date(); |
2541 | else | 2531 | else |
2542 | da = QDate::currentDate(); | 2532 | da = QDate::currentDate(); |
2543 | } else { | 2533 | } else { |
2544 | da = mMoveIncidence->dtStart().date(); | 2534 | da = mMoveIncidence->dtStart().date(); |
2545 | } | 2535 | } |
2546 | //PENDING set date for recurring incidence to date of recurrence | 2536 | //PENDING set date for recurring incidence to date of recurrence |
2547 | //mMoveIncidenceOldDate; | 2537 | //mMoveIncidenceOldDate; |
2548 | mDatePicker->setDate( da ); | 2538 | mDatePicker->setDate( da ); |
2549 | } | 2539 | } |
2550 | void CalendarView::showDatePickerPopup() | 2540 | void CalendarView::showDatePickerPopup() |
2551 | { | 2541 | { |
2552 | if ( mDateFrame->isVisible() ) | 2542 | if ( mDateFrame->isVisible() ) |
2553 | mDateFrame->hide(); | 2543 | mDateFrame->hide(); |
2554 | else { | 2544 | else { |
2555 | int offX = 0, offY = 0; | 2545 | int offX = 0, offY = 0; |
2556 | #ifdef DESKTOP_VERSION | 2546 | #ifdef DESKTOP_VERSION |
2557 | int w =mDatePicker->sizeHint().width() ; | 2547 | int w =mDatePicker->sizeHint().width() ; |
2558 | int h = mDatePicker->sizeHint().height() ; | 2548 | int h = mDatePicker->sizeHint().height() ; |
2559 | int dw = topLevelWidget()->width(); | 2549 | int dw = topLevelWidget()->width(); |
2560 | int dh = topLevelWidget()->height(); | 2550 | int dh = topLevelWidget()->height(); |
2561 | offX = topLevelWidget()->x(); | 2551 | offX = topLevelWidget()->x(); |
2562 | offY = topLevelWidget()->y(); | 2552 | offY = topLevelWidget()->y(); |
2563 | #else | 2553 | #else |
2564 | int w =mDatePicker->sizeHint().width() ; | 2554 | int w =mDatePicker->sizeHint().width() ; |
2565 | int h = mDatePicker->sizeHint().height() ; | 2555 | int h = mDatePicker->sizeHint().height() ; |
2566 | int dw = QApplication::desktop()->width(); | 2556 | int dw = QApplication::desktop()->width(); |
2567 | int dh = QApplication::desktop()->height(); | 2557 | int dh = QApplication::desktop()->height(); |
2568 | #endif | 2558 | #endif |
2569 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2559 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2570 | mDateFrame->show(); | 2560 | mDateFrame->show(); |
2571 | } | 2561 | } |
2572 | } | 2562 | } |
2573 | void CalendarView::showDatePicker( ) | 2563 | void CalendarView::showDatePicker( ) |
2574 | { | 2564 | { |
2575 | showDatePickerPopup(); | 2565 | showDatePickerPopup(); |
2576 | mDatePickerMode = 1; | 2566 | mDatePickerMode = 1; |
2577 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2567 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2578 | } | 2568 | } |
2579 | 2569 | ||
2580 | void CalendarView::showEventEditor() | 2570 | void CalendarView::showEventEditor() |
2581 | { | 2571 | { |
2582 | #ifdef DESKTOP_VERSION | 2572 | #ifdef DESKTOP_VERSION |
2583 | int x,y,w,h; | 2573 | int x,y,w,h; |
2584 | x = mEventEditor->geometry().x(); | 2574 | x = mEventEditor->geometry().x(); |
2585 | y = mEventEditor->geometry().y(); | 2575 | y = mEventEditor->geometry().y(); |
2586 | w = mEventEditor->width(); | 2576 | w = mEventEditor->width(); |
2587 | h = mEventEditor->height(); | 2577 | h = mEventEditor->height(); |
2588 | mEventEditor->show(); | 2578 | mEventEditor->show(); |
2589 | mEventEditor->setGeometry(x,y,w,h); | 2579 | mEventEditor->setGeometry(x,y,w,h); |
2590 | #else | 2580 | #else |
2591 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2581 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2592 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2582 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2593 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2583 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2594 | qApp->processEvents(); | 2584 | qApp->processEvents(); |
2595 | delete mEventEditor; | 2585 | delete mEventEditor; |
2596 | mEventEditor = mDialogManager->getEventEditor(); | 2586 | mEventEditor = mDialogManager->getEventEditor(); |
2597 | topLevelWidget()->setCaption( i18n("") ); | 2587 | topLevelWidget()->setCaption( i18n("") ); |
2598 | } | 2588 | } |
2599 | mEventEditor->showMaximized(); | 2589 | mEventEditor->showMaximized(); |
2600 | #endif | 2590 | #endif |
2601 | } | 2591 | } |
2602 | void CalendarView::showTodoEditor() | 2592 | void CalendarView::showTodoEditor() |
2603 | { | 2593 | { |
2604 | #ifdef DESKTOP_VERSION | 2594 | #ifdef DESKTOP_VERSION |
2605 | int x,y,w,h; | 2595 | int x,y,w,h; |
2606 | x = mTodoEditor->geometry().x(); | 2596 | x = mTodoEditor->geometry().x(); |
2607 | y = mTodoEditor->geometry().y(); | 2597 | y = mTodoEditor->geometry().y(); |
2608 | w = mTodoEditor->width(); | 2598 | w = mTodoEditor->width(); |
2609 | h = mTodoEditor->height(); | 2599 | h = mTodoEditor->height(); |
2610 | mTodoEditor->show(); | 2600 | mTodoEditor->show(); |
2611 | mTodoEditor->setGeometry(x,y,w,h); | 2601 | mTodoEditor->setGeometry(x,y,w,h); |
2612 | #else | 2602 | #else |
2613 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2603 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2614 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2604 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2615 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2605 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2616 | qApp->processEvents(); | 2606 | qApp->processEvents(); |
2617 | delete mTodoEditor; | 2607 | delete mTodoEditor; |
2618 | mTodoEditor = mDialogManager->getTodoEditor(); | 2608 | mTodoEditor = mDialogManager->getTodoEditor(); |
2619 | topLevelWidget()->setCaption( i18n("") ); | 2609 | topLevelWidget()->setCaption( i18n("") ); |
2620 | } | 2610 | } |
2621 | mTodoEditor->showMaximized(); | 2611 | mTodoEditor->showMaximized(); |
2622 | #endif | 2612 | #endif |
2623 | } | 2613 | } |
2624 | 2614 | ||
2625 | void CalendarView::cloneIncidence() | 2615 | void CalendarView::cloneIncidence() |
2626 | { | 2616 | { |
2627 | Incidence *incidence = currentSelection(); | 2617 | Incidence *incidence = currentSelection(); |
2628 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2618 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2629 | if ( incidence ) { | 2619 | if ( incidence ) { |
2630 | cloneIncidence(incidence); | 2620 | cloneIncidence(incidence); |
2631 | } | 2621 | } |
2632 | } | 2622 | } |
2633 | void CalendarView::moveIncidence() | 2623 | void CalendarView::moveIncidence() |
2634 | { | 2624 | { |
2635 | Incidence *incidence = currentSelection(); | 2625 | Incidence *incidence = currentSelection(); |
2636 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2626 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2637 | if ( incidence ) { | 2627 | if ( incidence ) { |
2638 | moveIncidence(incidence); | 2628 | moveIncidence(incidence); |
2639 | } | 2629 | } |
2640 | } | 2630 | } |
2641 | void CalendarView::beamIncidence() | 2631 | void CalendarView::beamIncidence() |
2642 | { | 2632 | { |
2643 | Incidence *incidence = currentSelection(); | 2633 | Incidence *incidence = currentSelection(); |
2644 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2634 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2645 | if ( incidence ) { | 2635 | if ( incidence ) { |
2646 | beamIncidence(incidence); | 2636 | beamIncidence(incidence); |
2647 | } | 2637 | } |
2648 | } | 2638 | } |
2649 | void CalendarView::toggleCancelIncidence() | 2639 | void CalendarView::toggleCancelIncidence() |
2650 | { | 2640 | { |
2651 | Incidence *incidence = currentSelection(); | 2641 | Incidence *incidence = currentSelection(); |
2652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2642 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2653 | if ( incidence ) { | 2643 | if ( incidence ) { |
2654 | cancelIncidence(incidence); | 2644 | cancelIncidence(incidence); |
2655 | } | 2645 | } |
2656 | } | 2646 | } |
2657 | 2647 | ||
2658 | 2648 | ||
2659 | void CalendarView::cancelIncidence(Incidence * inc ) | 2649 | void CalendarView::cancelIncidence(Incidence * inc ) |
2660 | { | 2650 | { |
2661 | inc->setCancelled( ! inc->cancelled() ); | 2651 | inc->setCancelled( ! inc->cancelled() ); |
2662 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2652 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2663 | updateView(); | 2653 | updateView(); |
2664 | } | 2654 | } |
2665 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2655 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2666 | { | 2656 | { |
2667 | Incidence * newInc = orgInc->clone(); | 2657 | Incidence * newInc = orgInc->clone(); |
2668 | newInc->recreate(); | 2658 | newInc->recreate(); |
2669 | 2659 | ||
2670 | if ( newInc->type() == "Todo" ) { | 2660 | if ( newInc->type() == "Todo" ) { |
2671 | Todo* t = (Todo*) newInc; | 2661 | Todo* t = (Todo*) newInc; |
2672 | showTodoEditor(); | 2662 | showTodoEditor(); |
2673 | mTodoEditor->editTodo( t ); | 2663 | mTodoEditor->editTodo( t ); |
2674 | if ( mTodoEditor->exec() ) { | 2664 | if ( mTodoEditor->exec() ) { |
2675 | mCalendar->addTodo( t ); | 2665 | mCalendar->addTodo( t ); |
2676 | updateView(); | 2666 | updateView(); |
2677 | } else { | 2667 | } else { |
2678 | delete t; | 2668 | delete t; |
2679 | } | 2669 | } |
2680 | } | 2670 | } |
2681 | else { | 2671 | else { |
2682 | Event* e = (Event*) newInc; | 2672 | Event* e = (Event*) newInc; |
2683 | showEventEditor(); | 2673 | showEventEditor(); |
2684 | mEventEditor->editEvent( e ); | 2674 | mEventEditor->editEvent( e ); |
2685 | if ( mEventEditor->exec() ) { | 2675 | if ( mEventEditor->exec() ) { |
2686 | mCalendar->addEvent( e ); | 2676 | mCalendar->addEvent( e ); |
2687 | updateView(); | 2677 | updateView(); |
2688 | } else { | 2678 | } else { |
2689 | delete e; | 2679 | delete e; |
2690 | } | 2680 | } |
2691 | } | 2681 | } |
2692 | setActiveWindow(); | 2682 | setActiveWindow(); |
2693 | } | 2683 | } |
2694 | 2684 | ||
2695 | void CalendarView::newEvent() | 2685 | void CalendarView::newEvent() |
2696 | { | 2686 | { |
2697 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2687 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2698 | KOAgendaView *aView = mViewManager->agendaView(); | 2688 | KOAgendaView *aView = mViewManager->agendaView(); |
2699 | if (aView) { | 2689 | if (aView) { |
2700 | if (aView->selectionStart().isValid()) { | 2690 | if (aView->selectionStart().isValid()) { |
2701 | if (aView->selectedIsAllDay()) { | 2691 | if (aView->selectedIsAllDay()) { |
2702 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2692 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2703 | } else { | 2693 | } else { |
2704 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2694 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2705 | } | 2695 | } |
2706 | return; | 2696 | return; |
2707 | } | 2697 | } |
2708 | } | 2698 | } |