summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp18
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/mainwindow.cpp19
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 36 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e0380fa..77de94f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1230,2050 +1230,2066 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 return false; 1249 return false;
1250 } 1250 }
1251 } 1251 }
1252 return syncOK; 1252 return syncOK;
1253} 1253}
1254 1254
1255void CalendarView::setSyncDevice( QString s ) 1255void CalendarView::setSyncDevice( QString s )
1256{ 1256{
1257 mCurrentSyncDevice= s; 1257 mCurrentSyncDevice= s;
1258} 1258}
1259void CalendarView::setSyncName( QString s ) 1259void CalendarView::setSyncName( QString s )
1260{ 1260{
1261 mCurrentSyncName= s; 1261 mCurrentSyncName= s;
1262} 1262}
1263bool CalendarView::syncCalendar(QString filename, int mode) 1263bool CalendarView::syncCalendar(QString filename, int mode)
1264{ 1264{
1265 //qDebug("syncCalendar %s ", filename.latin1()); 1265 //qDebug("syncCalendar %s ", filename.latin1());
1266 mGlobalSyncMode = SYNC_MODE_NORMAL; 1266 mGlobalSyncMode = SYNC_MODE_NORMAL;
1267 CalendarLocal* calendar = new CalendarLocal(); 1267 CalendarLocal* calendar = new CalendarLocal();
1268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1269 FileStorage* storage = new FileStorage( calendar ); 1269 FileStorage* storage = new FileStorage( calendar );
1270 bool syncOK = false; 1270 bool syncOK = false;
1271 storage->setFileName( filename ); 1271 storage->setFileName( filename );
1272 // qDebug("loading ... "); 1272 // qDebug("loading ... ");
1273 if ( storage->load() ) { 1273 if ( storage->load() ) {
1274 getEventViewerDialog()->setSyncMode( true ); 1274 getEventViewerDialog()->setSyncMode( true );
1275 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1275 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1276 getEventViewerDialog()->setSyncMode( false ); 1276 getEventViewerDialog()->setSyncMode( false );
1277 if ( syncOK ) { 1277 if ( syncOK ) {
1278 if ( mSyncManager->mWriteBackFile ) 1278 if ( mSyncManager->mWriteBackFile )
1279 { 1279 {
1280 storage->setSaveFormat( new ICalFormat() ); 1280 storage->setSaveFormat( new ICalFormat() );
1281 storage->save(); 1281 storage->save();
1282 } 1282 }
1283 } 1283 }
1284 setModified( true ); 1284 setModified( true );
1285 } 1285 }
1286 delete storage; 1286 delete storage;
1287 delete calendar; 1287 delete calendar;
1288 if ( syncOK ) 1288 if ( syncOK )
1289 updateView(); 1289 updateView();
1290 return syncOK; 1290 return syncOK;
1291} 1291}
1292 1292
1293void CalendarView::syncExternal( int mode ) 1293void CalendarView::syncExternal( int mode )
1294{ 1294{
1295 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1295 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1296 1296
1297 qApp->processEvents(); 1297 qApp->processEvents();
1298 CalendarLocal* calendar = new CalendarLocal(); 1298 CalendarLocal* calendar = new CalendarLocal();
1299 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1299 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1300 bool syncOK = false; 1300 bool syncOK = false;
1301 bool loadSuccess = false; 1301 bool loadSuccess = false;
1302 PhoneFormat* phoneFormat = 0; 1302 PhoneFormat* phoneFormat = 0;
1303 emit tempDisableBR(true); 1303 emit tempDisableBR(true);
1304#ifndef DESKTOP_VERSION 1304#ifndef DESKTOP_VERSION
1305 SharpFormat* sharpFormat = 0; 1305 SharpFormat* sharpFormat = 0;
1306 if ( mode == 0 ) { // sharp 1306 if ( mode == 0 ) { // sharp
1307 sharpFormat = new SharpFormat () ; 1307 sharpFormat = new SharpFormat () ;
1308 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1308 loadSuccess = sharpFormat->load( calendar, mCalendar );
1309 1309
1310 } else 1310 } else
1311#endif 1311#endif
1312 if ( mode == 1 ) { // phone 1312 if ( mode == 1 ) { // phone
1313 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1313 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1314 mSyncManager->mPhoneDevice, 1314 mSyncManager->mPhoneDevice,
1315 mSyncManager->mPhoneConnection, 1315 mSyncManager->mPhoneConnection,
1316 mSyncManager->mPhoneModel); 1316 mSyncManager->mPhoneModel);
1317 loadSuccess = phoneFormat->load( calendar,mCalendar); 1317 loadSuccess = phoneFormat->load( calendar,mCalendar);
1318 1318
1319 } else { 1319 } else {
1320 emit tempDisableBR(false); 1320 emit tempDisableBR(false);
1321 return; 1321 return;
1322 } 1322 }
1323 if ( loadSuccess ) { 1323 if ( loadSuccess ) {
1324 getEventViewerDialog()->setSyncMode( true ); 1324 getEventViewerDialog()->setSyncMode( true );
1325 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1325 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1326 getEventViewerDialog()->setSyncMode( false ); 1326 getEventViewerDialog()->setSyncMode( false );
1327 qApp->processEvents(); 1327 qApp->processEvents();
1328 if ( syncOK ) { 1328 if ( syncOK ) {
1329 if ( mSyncManager->mWriteBackFile ) 1329 if ( mSyncManager->mWriteBackFile )
1330 { 1330 {
1331 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1331 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1332 Incidence* inc = iL.first(); 1332 Incidence* inc = iL.first();
1333 if ( phoneFormat ) { 1333 if ( phoneFormat ) {
1334 while ( inc ) { 1334 while ( inc ) {
1335 inc->removeID(mCurrentSyncDevice); 1335 inc->removeID(mCurrentSyncDevice);
1336 inc = iL.next(); 1336 inc = iL.next();
1337 } 1337 }
1338 } 1338 }
1339#ifndef DESKTOP_VERSION 1339#ifndef DESKTOP_VERSION
1340 if ( sharpFormat ) 1340 if ( sharpFormat )
1341 sharpFormat->save(calendar); 1341 sharpFormat->save(calendar);
1342#endif 1342#endif
1343 if ( phoneFormat ) 1343 if ( phoneFormat )
1344 phoneFormat->save(calendar); 1344 phoneFormat->save(calendar);
1345 iL = calendar->rawIncidences(); 1345 iL = calendar->rawIncidences();
1346 inc = iL.first(); 1346 inc = iL.first();
1347 Incidence* loc; 1347 Incidence* loc;
1348 while ( inc ) { 1348 while ( inc ) {
1349 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1349 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1350 loc = mCalendar->incidence(inc->uid() ); 1350 loc = mCalendar->incidence(inc->uid() );
1351 if ( loc ) { 1351 if ( loc ) {
1352 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1352 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1353 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1353 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1354 } 1354 }
1355 } 1355 }
1356 inc = iL.next(); 1356 inc = iL.next();
1357 } 1357 }
1358 Incidence* lse = getLastSyncEvent(); 1358 Incidence* lse = getLastSyncEvent();
1359 if ( lse ) { 1359 if ( lse ) {
1360 lse->setReadOnly( false ); 1360 lse->setReadOnly( false );
1361 lse->setDescription( "" ); 1361 lse->setDescription( "" );
1362 lse->setReadOnly( true ); 1362 lse->setReadOnly( true );
1363 } 1363 }
1364 } 1364 }
1365 } else { 1365 } else {
1366 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1366 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1367 } 1367 }
1368 setModified( true ); 1368 setModified( true );
1369 } else { 1369 } else {
1370 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1370 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1371 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1371 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1372 question, i18n("Ok")) ; 1372 question, i18n("Ok")) ;
1373 1373
1374 } 1374 }
1375 delete calendar; 1375 delete calendar;
1376 updateView(); 1376 updateView();
1377 emit tempDisableBR(false); 1377 emit tempDisableBR(false);
1378 return ;//syncOK; 1378 return ;//syncOK;
1379 1379
1380} 1380}
1381 1381
1382bool CalendarView::importBday() 1382bool CalendarView::importBday()
1383{ 1383{
1384#ifndef KORG_NOKABC 1384#ifndef KORG_NOKABC
1385 1385
1386#ifdef DESKTOP_VERSION 1386#ifdef DESKTOP_VERSION
1387 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1387 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1388 KABC::AddressBook::Iterator it; 1388 KABC::AddressBook::Iterator it;
1389 int count = 0; 1389 int count = 0;
1390 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1390 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1391 ++count; 1391 ++count;
1392 } 1392 }
1393 QProgressBar bar(count,0 ); 1393 QProgressBar bar(count,0 );
1394 int w = 300; 1394 int w = 300;
1395 if ( QApplication::desktop()->width() < 320 ) 1395 if ( QApplication::desktop()->width() < 320 )
1396 w = 220; 1396 w = 220;
1397 int h = bar.sizeHint().height() ; 1397 int h = bar.sizeHint().height() ;
1398 int dw = QApplication::desktop()->width(); 1398 int dw = QApplication::desktop()->width();
1399 int dh = QApplication::desktop()->height(); 1399 int dh = QApplication::desktop()->height();
1400 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1400 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1401 bar.show(); 1401 bar.show();
1402 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1402 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1403 qApp->processEvents(); 1403 qApp->processEvents();
1404 count = 0; 1404 count = 0;
1405 int addCount = 0; 1405 int addCount = 0;
1406 KCal::Attendee* a = 0; 1406 KCal::Attendee* a = 0;
1407 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1407 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1408 if ( ! bar.isVisible() ) 1408 if ( ! bar.isVisible() )
1409 return false; 1409 return false;
1410 bar.setProgress( count++ ); 1410 bar.setProgress( count++ );
1411 qApp->processEvents(); 1411 qApp->processEvents();
1412 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1412 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1413 if ( (*it).birthday().date().isValid() ){ 1413 if ( (*it).birthday().date().isValid() ){
1414 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1414 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1415 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1415 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1416 ++addCount; 1416 ++addCount;
1417 } 1417 }
1418 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1418 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1419 if ( anni.isValid() ){ 1419 if ( anni.isValid() ){
1420 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1420 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1421 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1421 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1422 ++addCount; 1422 ++addCount;
1423 } 1423 }
1424 } 1424 }
1425 updateView(); 1425 updateView();
1426 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1426 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1427#else //DESKTOP_VERSION 1427#else //DESKTOP_VERSION
1428 1428
1429 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1429 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1430 // the result should now arrive through method insertBirthdays 1430 // the result should now arrive through method insertBirthdays
1431 1431
1432#endif //DESKTOP_VERSION 1432#endif //DESKTOP_VERSION
1433 1433
1434#endif //KORG_NOKABC 1434#endif //KORG_NOKABC
1435 1435
1436 1436
1437 return true; 1437 return true;
1438} 1438}
1439 1439
1440// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1440// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1441void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1441void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1442 const QStringList& anniversaryList, const QStringList& realNameList, 1442 const QStringList& anniversaryList, const QStringList& realNameList,
1443 const QStringList& emailList, const QStringList& assembledNameList, 1443 const QStringList& emailList, const QStringList& assembledNameList,
1444 const QStringList& uidList) 1444 const QStringList& uidList)
1445{ 1445{
1446 //qDebug("KO::CalendarView::insertBirthdays"); 1446 //qDebug("KO::CalendarView::insertBirthdays");
1447 if (uid == this->name()) 1447 if (uid == this->name())
1448 { 1448 {
1449 int count = birthdayList.count(); 1449 int count = birthdayList.count();
1450 int addCount = 0; 1450 int addCount = 0;
1451 KCal::Attendee* a = 0; 1451 KCal::Attendee* a = 0;
1452 1452
1453 //qDebug("CalView 1 %i", count); 1453 //qDebug("CalView 1 %i", count);
1454 1454
1455 QProgressBar bar(count,0 ); 1455 QProgressBar bar(count,0 );
1456 int w = 300; 1456 int w = 300;
1457 if ( QApplication::desktop()->width() < 320 ) 1457 if ( QApplication::desktop()->width() < 320 )
1458 w = 220; 1458 w = 220;
1459 int h = bar.sizeHint().height() ; 1459 int h = bar.sizeHint().height() ;
1460 int dw = QApplication::desktop()->width(); 1460 int dw = QApplication::desktop()->width();
1461 int dh = QApplication::desktop()->height(); 1461 int dh = QApplication::desktop()->height();
1462 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1462 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1463 bar.show(); 1463 bar.show();
1464 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1464 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1465 qApp->processEvents(); 1465 qApp->processEvents();
1466 1466
1467 QDate birthday; 1467 QDate birthday;
1468 QDate anniversary; 1468 QDate anniversary;
1469 QString realName; 1469 QString realName;
1470 QString email; 1470 QString email;
1471 QString assembledName; 1471 QString assembledName;
1472 QString uid; 1472 QString uid;
1473 bool ok = true; 1473 bool ok = true;
1474 for ( int i = 0; i < count; i++) 1474 for ( int i = 0; i < count; i++)
1475 { 1475 {
1476 if ( ! bar.isVisible() ) 1476 if ( ! bar.isVisible() )
1477 return; 1477 return;
1478 bar.setProgress( i ); 1478 bar.setProgress( i );
1479 qApp->processEvents(); 1479 qApp->processEvents();
1480 1480
1481 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1481 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1482 if (!ok) { 1482 if (!ok) {
1483 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1483 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1484 } 1484 }
1485 1485
1486 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1486 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1487 if (!ok) { 1487 if (!ok) {
1488 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1488 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1489 } 1489 }
1490 realName = realNameList[i]; 1490 realName = realNameList[i];
1491 email = emailList[i]; 1491 email = emailList[i];
1492 assembledName = assembledNameList[i]; 1492 assembledName = assembledNameList[i];
1493 uid = uidList[i]; 1493 uid = uidList[i];
1494 //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() ); 1494 //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 1495
1496 if ( birthday.isValid() ){ 1496 if ( birthday.isValid() ){
1497 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1497 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1498 KCal::Attendee::ReqParticipant,uid) ; 1498 KCal::Attendee::ReqParticipant,uid) ;
1499 if ( addAnniversary( birthday, assembledName, a, true ) ) 1499 if ( addAnniversary( birthday, assembledName, a, true ) )
1500 ++addCount; 1500 ++addCount;
1501 } 1501 }
1502 1502
1503 if ( anniversary.isValid() ){ 1503 if ( anniversary.isValid() ){
1504 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1504 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1505 KCal::Attendee::ReqParticipant,uid) ; 1505 KCal::Attendee::ReqParticipant,uid) ;
1506 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1506 if ( addAnniversary( anniversary, assembledName, a, false ) )
1507 ++addCount; 1507 ++addCount;
1508 } 1508 }
1509 } 1509 }
1510 1510
1511 updateView(); 1511 updateView();
1512 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1512 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1513 1513
1514 } 1514 }
1515 1515
1516} 1516}
1517 1517
1518 1518
1519 1519
1520bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1520bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1521{ 1521{
1522 //qDebug("addAnni "); 1522 //qDebug("addAnni ");
1523 Event * ev = new Event(); 1523 Event * ev = new Event();
1524 ev->setOrganizer(KOPrefs::instance()->email()); 1524 ev->setOrganizer(KOPrefs::instance()->email());
1525 if ( a ) { 1525 if ( a ) {
1526 ev->addAttendee( a ); 1526 ev->addAttendee( a );
1527 } 1527 }
1528 QString kind; 1528 QString kind;
1529 if ( birthday ) { 1529 if ( birthday ) {
1530 kind = i18n( "Birthday" ); 1530 kind = i18n( "Birthday" );
1531 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1531 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1532 } 1532 }
1533 else { 1533 else {
1534 kind = i18n( "Anniversary" ); 1534 kind = i18n( "Anniversary" );
1535 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1535 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1536 } 1536 }
1537 ev->setCategories( kind ); 1537 ev->setCategories( kind );
1538 ev->setDtStart( QDateTime(date) ); 1538 ev->setDtStart( QDateTime(date) );
1539 ev->setDtEnd( QDateTime(date) ); 1539 ev->setDtEnd( QDateTime(date) );
1540 ev->setFloats( true ); 1540 ev->setFloats( true );
1541 Recurrence * rec = ev->recurrence(); 1541 Recurrence * rec = ev->recurrence();
1542 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1542 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1543 rec->addYearlyNum( date.month() ); 1543 rec->addYearlyNum( date.month() );
1544 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1544 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1545 delete ev; 1545 delete ev;
1546 return false; 1546 return false;
1547 } 1547 }
1548 return true; 1548 return true;
1549 1549
1550} 1550}
1551bool CalendarView::importQtopia( const QString &categories, 1551bool CalendarView::importQtopia( const QString &categories,
1552 const QString &datebook, 1552 const QString &datebook,
1553 const QString &todolist ) 1553 const QString &todolist )
1554{ 1554{
1555 1555
1556 QtopiaFormat qtopiaFormat; 1556 QtopiaFormat qtopiaFormat;
1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1558 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1558 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1559 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1559 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1560 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1560 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1561 1561
1562 updateView(); 1562 updateView();
1563 return true; 1563 return true;
1564 1564
1565#if 0 1565#if 0
1566 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1566 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1567 mCurrentSyncDevice = "qtopia-XML"; 1567 mCurrentSyncDevice = "qtopia-XML";
1568 if ( mSyncManager->mAskForPreferences ) 1568 if ( mSyncManager->mAskForPreferences )
1569 edit_sync_options(); 1569 edit_sync_options();
1570 qApp->processEvents(); 1570 qApp->processEvents();
1571 CalendarLocal* calendar = new CalendarLocal(); 1571 CalendarLocal* calendar = new CalendarLocal();
1572 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1572 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1573 bool syncOK = false; 1573 bool syncOK = false;
1574 QtopiaFormat qtopiaFormat; 1574 QtopiaFormat qtopiaFormat;
1575 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1575 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1576 bool loadOk = true; 1576 bool loadOk = true;
1577 if ( !categories.isEmpty() ) 1577 if ( !categories.isEmpty() )
1578 loadOk = qtopiaFormat.load( calendar, categories ); 1578 loadOk = qtopiaFormat.load( calendar, categories );
1579 if ( loadOk && !datebook.isEmpty() ) 1579 if ( loadOk && !datebook.isEmpty() )
1580 loadOk = qtopiaFormat.load( calendar, datebook ); 1580 loadOk = qtopiaFormat.load( calendar, datebook );
1581 if ( loadOk && !todolist.isEmpty() ) 1581 if ( loadOk && !todolist.isEmpty() )
1582 loadOk = qtopiaFormat.load( calendar, todolist ); 1582 loadOk = qtopiaFormat.load( calendar, todolist );
1583 1583
1584 if ( loadOk ) { 1584 if ( loadOk ) {
1585 getEventViewerDialog()->setSyncMode( true ); 1585 getEventViewerDialog()->setSyncMode( true );
1586 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1586 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1587 getEventViewerDialog()->setSyncMode( false ); 1587 getEventViewerDialog()->setSyncMode( false );
1588 qApp->processEvents(); 1588 qApp->processEvents();
1589 if ( syncOK ) { 1589 if ( syncOK ) {
1590 if ( mSyncManager->mWriteBackFile ) 1590 if ( mSyncManager->mWriteBackFile )
1591 { 1591 {
1592 // write back XML file 1592 // write back XML file
1593 1593
1594 } 1594 }
1595 setModified( true ); 1595 setModified( true );
1596 } 1596 }
1597 } else { 1597 } else {
1598 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1598 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1599 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1599 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1600 question, i18n("Ok")) ; 1600 question, i18n("Ok")) ;
1601 } 1601 }
1602 delete calendar; 1602 delete calendar;
1603 updateView(); 1603 updateView();
1604 return syncOK; 1604 return syncOK;
1605 1605
1606 1606
1607#endif 1607#endif
1608 1608
1609} 1609}
1610 1610
1611void CalendarView::setSyncEventsReadOnly() 1611void CalendarView::setSyncEventsReadOnly()
1612{ 1612{
1613 Event * ev; 1613 Event * ev;
1614 QPtrList<Event> eL = mCalendar->rawEvents(); 1614 QPtrList<Event> eL = mCalendar->rawEvents();
1615 ev = eL.first(); 1615 ev = eL.first();
1616 while ( ev ) { 1616 while ( ev ) {
1617 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1617 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1618 ev->setReadOnly( true ); 1618 ev->setReadOnly( true );
1619 ev = eL.next(); 1619 ev = eL.next();
1620 } 1620 }
1621} 1621}
1622bool CalendarView::openCalendar(QString filename, bool merge) 1622bool CalendarView::openCalendar(QString filename, bool merge)
1623{ 1623{
1624 1624
1625 if (filename.isEmpty()) { 1625 if (filename.isEmpty()) {
1626 return false; 1626 return false;
1627 } 1627 }
1628 1628
1629 if (!QFile::exists(filename)) { 1629 if (!QFile::exists(filename)) {
1630 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1630 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1631 return false; 1631 return false;
1632 } 1632 }
1633 1633
1634 globalFlagBlockAgenda = 1; 1634 globalFlagBlockAgenda = 1;
1635 if (!merge) mCalendar->close(); 1635 if (!merge) mCalendar->close();
1636 1636
1637 mStorage->setFileName( filename ); 1637 mStorage->setFileName( filename );
1638 1638
1639 if ( mStorage->load() ) { 1639 if ( mStorage->load() ) {
1640 if ( merge ) ;//setModified( true ); 1640 if ( merge ) ;//setModified( true );
1641 else { 1641 else {
1642 //setModified( true ); 1642 //setModified( true );
1643 mViewManager->setDocumentId( filename ); 1643 mViewManager->setDocumentId( filename );
1644 mDialogManager->setDocumentId( filename ); 1644 mDialogManager->setDocumentId( filename );
1645 mTodoList->setDocumentId( filename ); 1645 mTodoList->setDocumentId( filename );
1646 } 1646 }
1647 globalFlagBlockAgenda = 2; 1647 globalFlagBlockAgenda = 2;
1648 // if ( getLastSyncEvent() ) 1648 // if ( getLastSyncEvent() )
1649 // getLastSyncEvent()->setReadOnly( true ); 1649 // getLastSyncEvent()->setReadOnly( true );
1650 mCalendar->reInitAlarmSettings(); 1650 mCalendar->reInitAlarmSettings();
1651 setSyncEventsReadOnly(); 1651 setSyncEventsReadOnly();
1652 updateUnmanagedViews(); 1652 updateUnmanagedViews();
1653 updateView(); 1653 updateView();
1654 if ( filename != MainWindow::defaultFileName() ) { 1654 if ( filename != MainWindow::defaultFileName() ) {
1655 saveCalendar( MainWindow::defaultFileName() ); 1655 saveCalendar( MainWindow::defaultFileName() );
1656 } else { 1656 } else {
1657 QFileInfo finf ( MainWindow::defaultFileName()); 1657 QFileInfo finf ( MainWindow::defaultFileName());
1658 if ( finf.exists() ) { 1658 if ( finf.exists() ) {
1659 setLoadedFileVersion( finf.lastModified () ); 1659 setLoadedFileVersion( finf.lastModified () );
1660 } 1660 }
1661 } 1661 }
1662 return true; 1662 return true;
1663 } else { 1663 } else {
1664 // while failing to load, the calendar object could 1664 // while failing to load, the calendar object could
1665 // have become partially populated. Clear it out. 1665 // have become partially populated. Clear it out.
1666 if ( !merge ) { 1666 if ( !merge ) {
1667 mCalendar->close(); 1667 mCalendar->close();
1668 mViewManager->setDocumentId( filename ); 1668 mViewManager->setDocumentId( filename );
1669 mDialogManager->setDocumentId( filename ); 1669 mDialogManager->setDocumentId( filename );
1670 mTodoList->setDocumentId( filename ); 1670 mTodoList->setDocumentId( filename );
1671 } 1671 }
1672 1672
1673 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1673 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1674 1674
1675 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1675 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1676 globalFlagBlockAgenda = 2; 1676 globalFlagBlockAgenda = 2;
1677 mCalendar->reInitAlarmSettings(); 1677 mCalendar->reInitAlarmSettings();
1678 setSyncEventsReadOnly(); 1678 setSyncEventsReadOnly();
1679 updateUnmanagedViews(); 1679 updateUnmanagedViews();
1680 updateView(); 1680 updateView();
1681 } 1681 }
1682 return false; 1682 return false;
1683} 1683}
1684void CalendarView::showOpenError() 1684void CalendarView::showOpenError()
1685{ 1685{
1686 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1686 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1687} 1687}
1688void CalendarView::setLoadedFileVersion(QDateTime dt) 1688void CalendarView::setLoadedFileVersion(QDateTime dt)
1689{ 1689{
1690 loadedFileVersion = dt; 1690 loadedFileVersion = dt;
1691} 1691}
1692bool CalendarView::checkFileChanged(QString fn) 1692bool CalendarView::checkFileChanged(QString fn)
1693{ 1693{
1694 QFileInfo finf ( fn ); 1694 QFileInfo finf ( fn );
1695 if ( !finf.exists() ) 1695 if ( !finf.exists() )
1696 return true; 1696 return true;
1697 QDateTime dt = finf.lastModified (); 1697 QDateTime dt = finf.lastModified ();
1698 if ( dt <= loadedFileVersion ) 1698 if ( dt <= loadedFileVersion )
1699 return false; 1699 return false;
1700 return true; 1700 return true;
1701 1701
1702} 1702}
1703void CalendarView::watchSavedFile() 1703void CalendarView::watchSavedFile()
1704{ 1704{
1705 QFileInfo finf ( MainWindow::defaultFileName()); 1705 QFileInfo finf ( MainWindow::defaultFileName());
1706 if ( !finf.exists() ) 1706 if ( !finf.exists() )
1707 return; 1707 return;
1708 QDateTime dt = finf.lastModified (); 1708 QDateTime dt = finf.lastModified ();
1709 if ( dt < loadedFileVersion ) { 1709 if ( dt < loadedFileVersion ) {
1710 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1710 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1711 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1711 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1712 return; 1712 return;
1713 } 1713 }
1714 loadedFileVersion = dt; 1714 loadedFileVersion = dt;
1715} 1715}
1716 1716
1717bool CalendarView::checkFileVersion(QString fn) 1717bool CalendarView::checkFileVersion(QString fn)
1718{ 1718{
1719 QFileInfo finf ( fn ); 1719 QFileInfo finf ( fn );
1720 if ( !finf.exists() ) 1720 if ( !finf.exists() )
1721 return true; 1721 return true;
1722 QDateTime dt = finf.lastModified (); 1722 QDateTime dt = finf.lastModified ();
1723 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1723 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1724 //qDebug("file on disk version %s",dt.toString().latin1()); 1724 //qDebug("file on disk version %s",dt.toString().latin1());
1725 if ( dt <= loadedFileVersion ) 1725 if ( dt <= loadedFileVersion )
1726 return true; 1726 return true;
1727 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)) , 1727 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 i18n("KO/Pi Warning"),i18n("Overwrite"), 1728 i18n("KO/Pi Warning"),i18n("Overwrite"),
1729 i18n("Sync+save")); 1729 i18n("Sync+save"));
1730 1730
1731 if ( km == KMessageBox::Cancel ) 1731 if ( km == KMessageBox::Cancel )
1732 return false; 1732 return false;
1733 if ( km == KMessageBox::Yes ) 1733 if ( km == KMessageBox::Yes )
1734 return true; 1734 return true;
1735 1735
1736 setSyncDevice("deleteaftersync" ); 1736 setSyncDevice("deleteaftersync" );
1737 mSyncManager->mAskForPreferences = true; 1737 mSyncManager->mAskForPreferences = true;
1738 mSyncManager->mSyncAlgoPrefs = 3; 1738 mSyncManager->mSyncAlgoPrefs = 3;
1739 mSyncManager->mWriteBackFile = false; 1739 mSyncManager->mWriteBackFile = false;
1740 mSyncManager->mWriteBackExistingOnly = false; 1740 mSyncManager->mWriteBackExistingOnly = false;
1741 mSyncManager->mShowSyncSummary = false; 1741 mSyncManager->mShowSyncSummary = false;
1742 syncCalendar( fn, 3 ); 1742 syncCalendar( fn, 3 );
1743 Event * e = getLastSyncEvent(); 1743 Event * e = getLastSyncEvent();
1744 mCalendar->deleteEvent ( e ); 1744 mCalendar->deleteEvent ( e );
1745 updateView(); 1745 updateView();
1746 return true; 1746 return true;
1747} 1747}
1748 1748
1749bool CalendarView::saveCalendar( QString filename ) 1749bool CalendarView::saveCalendar( QString filename )
1750{ 1750{
1751 1751
1752 // Store back all unsaved data into calendar object 1752 // Store back all unsaved data into calendar object
1753 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1753 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1754 if ( mViewManager->currentView() ) 1754 if ( mViewManager->currentView() )
1755 mViewManager->currentView()->flushView(); 1755 mViewManager->currentView()->flushView();
1756 1756
1757 1757
1758 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1758 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1759 mStorage->setSaveFormat( new ICalFormat() ); 1759 mStorage->setSaveFormat( new ICalFormat() );
1760 mStorage->setFileName( filename ); 1760 mStorage->setFileName( filename );
1761 bool success; 1761 bool success;
1762 success = mStorage->save(); 1762 success = mStorage->save();
1763 if ( !success ) { 1763 if ( !success ) {
1764 return false; 1764 return false;
1765 } 1765 }
1766 if ( filename == MainWindow::defaultFileName() ) { 1766 if ( filename == MainWindow::defaultFileName() ) {
1767 setLoadedFileVersion( lfv ); 1767 setLoadedFileVersion( lfv );
1768 watchSavedFile(); 1768 watchSavedFile();
1769 } 1769 }
1770 return true; 1770 return true;
1771} 1771}
1772 1772
1773void CalendarView::closeCalendar() 1773void CalendarView::closeCalendar()
1774{ 1774{
1775 1775
1776 // child windows no longer valid 1776 // child windows no longer valid
1777 emit closingDown(); 1777 emit closingDown();
1778 1778
1779 mCalendar->close(); 1779 mCalendar->close();
1780 setModified(false); 1780 setModified(false);
1781 updateView(); 1781 updateView();
1782} 1782}
1783 1783
1784void CalendarView::archiveCalendar() 1784void CalendarView::archiveCalendar()
1785{ 1785{
1786 mDialogManager->showArchiveDialog(); 1786 mDialogManager->showArchiveDialog();
1787} 1787}
1788 1788
1789 1789
1790void CalendarView::readSettings() 1790void CalendarView::readSettings()
1791{ 1791{
1792 1792
1793 1793
1794 // mViewManager->showAgendaView(); 1794 // mViewManager->showAgendaView();
1795 QString str; 1795 QString str;
1796 //qDebug("CalendarView::readSettings() "); 1796 //qDebug("CalendarView::readSettings() ");
1797 // read settings from the KConfig, supplying reasonable 1797 // read settings from the KConfig, supplying reasonable
1798 // defaults where none are to be found 1798 // defaults where none are to be found
1799 KConfig *config = KOGlobals::config(); 1799 KConfig *config = KOGlobals::config();
1800#ifndef KORG_NOSPLITTER 1800#ifndef KORG_NOSPLITTER
1801 config->setGroup("KOrganizer Geometry"); 1801 config->setGroup("KOrganizer Geometry");
1802 1802
1803 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1803 QValueList<int> sizes = config->readIntListEntry("Separator1");
1804 if (sizes.count() != 2) { 1804 if (sizes.count() != 2) {
1805 sizes << mDateNavigator->minimumSizeHint().width(); 1805 sizes << mDateNavigator->minimumSizeHint().width();
1806 sizes << 300; 1806 sizes << 300;
1807 } 1807 }
1808 mPanner->setSizes(sizes); 1808 mPanner->setSizes(sizes);
1809 1809
1810 sizes = config->readIntListEntry("Separator2"); 1810 sizes = config->readIntListEntry("Separator2");
1811 if ( ( mResourceView && sizes.count() == 4 ) || 1811 if ( ( mResourceView && sizes.count() == 4 ) ||
1812 ( !mResourceView && sizes.count() == 3 ) ) { 1812 ( !mResourceView && sizes.count() == 3 ) ) {
1813 mLeftSplitter->setSizes(sizes); 1813 mLeftSplitter->setSizes(sizes);
1814 } 1814 }
1815#endif 1815#endif
1816 globalFlagBlockAgenda = 1; 1816 globalFlagBlockAgenda = 1;
1817 mViewManager->showAgendaView(); 1817 mViewManager->showAgendaView();
1818 //mViewManager->readSettings( config ); 1818 //mViewManager->readSettings( config );
1819 mTodoList->restoreLayout(config,QString("Todo Layout")); 1819 mTodoList->restoreLayout(config,QString("Todo Layout"));
1820 readFilterSettings(config); 1820 readFilterSettings(config);
1821 config->setGroup( "Views" ); 1821 config->setGroup( "Views" );
1822 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1822 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1823 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1823 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1824 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1824 else if ( dateCount == 7 ) mNavigator->selectWeek();
1825 else mNavigator->selectDates( dateCount ); 1825 else mNavigator->selectDates( dateCount );
1826 // mViewManager->readSettings( config ); 1826 // mViewManager->readSettings( config );
1827 updateConfig(); 1827 updateConfig();
1828 globalFlagBlockAgenda = 2; 1828 globalFlagBlockAgenda = 2;
1829 mViewManager->readSettings( config ); 1829 mViewManager->readSettings( config );
1830#ifdef DESKTOP_VERSION 1830#ifdef DESKTOP_VERSION
1831 config->setGroup("WidgetLayout"); 1831 config->setGroup("WidgetLayout");
1832 QStringList list; 1832 QStringList list;
1833 list = config->readListEntry("MainLayout"); 1833 list = config->readListEntry("MainLayout");
1834 int x,y,w,h; 1834 int x,y,w,h;
1835 if ( ! list.isEmpty() ) { 1835 if ( ! list.isEmpty() ) {
1836 x = list[0].toInt(); 1836 x = list[0].toInt();
1837 y = list[1].toInt(); 1837 y = list[1].toInt();
1838 w = list[2].toInt(); 1838 w = list[2].toInt();
1839 h = list[3].toInt(); 1839 h = list[3].toInt();
1840 topLevelWidget()->setGeometry(x,y,w,h); 1840 topLevelWidget()->setGeometry(x,y,w,h);
1841 1841
1842 } else { 1842 } else {
1843 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1843 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1844 } 1844 }
1845 list = config->readListEntry("EditEventLayout"); 1845 list = config->readListEntry("EditEventLayout");
1846 if ( ! list.isEmpty() ) { 1846 if ( ! list.isEmpty() ) {
1847 x = list[0].toInt(); 1847 x = list[0].toInt();
1848 y = list[1].toInt(); 1848 y = list[1].toInt();
1849 w = list[2].toInt(); 1849 w = list[2].toInt();
1850 h = list[3].toInt(); 1850 h = list[3].toInt();
1851 mEventEditor->setGeometry(x,y,w,h); 1851 mEventEditor->setGeometry(x,y,w,h);
1852 1852
1853 } 1853 }
1854 list = config->readListEntry("EditTodoLayout"); 1854 list = config->readListEntry("EditTodoLayout");
1855 if ( ! list.isEmpty() ) { 1855 if ( ! list.isEmpty() ) {
1856 x = list[0].toInt(); 1856 x = list[0].toInt();
1857 y = list[1].toInt(); 1857 y = list[1].toInt();
1858 w = list[2].toInt(); 1858 w = list[2].toInt();
1859 h = list[3].toInt(); 1859 h = list[3].toInt();
1860 mTodoEditor->setGeometry(x,y,w,h); 1860 mTodoEditor->setGeometry(x,y,w,h);
1861 1861
1862 } 1862 }
1863 list = config->readListEntry("ViewerLayout"); 1863 list = config->readListEntry("ViewerLayout");
1864 if ( ! list.isEmpty() ) { 1864 if ( ! list.isEmpty() ) {
1865 x = list[0].toInt(); 1865 x = list[0].toInt();
1866 y = list[1].toInt(); 1866 y = list[1].toInt();
1867 w = list[2].toInt(); 1867 w = list[2].toInt();
1868 h = list[3].toInt(); 1868 h = list[3].toInt();
1869 getEventViewerDialog()->setGeometry(x,y,w,h); 1869 getEventViewerDialog()->setGeometry(x,y,w,h);
1870 } 1870 }
1871#endif 1871#endif
1872 1872
1873} 1873}
1874 1874
1875 1875
1876void CalendarView::writeSettings() 1876void CalendarView::writeSettings()
1877{ 1877{
1878 // kdDebug() << "CalendarView::writeSettings" << endl; 1878 // kdDebug() << "CalendarView::writeSettings" << endl;
1879 1879
1880 KConfig *config = KOGlobals::config(); 1880 KConfig *config = KOGlobals::config();
1881 1881
1882#ifndef KORG_NOSPLITTER 1882#ifndef KORG_NOSPLITTER
1883 config->setGroup("KOrganizer Geometry"); 1883 config->setGroup("KOrganizer Geometry");
1884 1884
1885 QValueList<int> list = mPanner->sizes(); 1885 QValueList<int> list = mPanner->sizes();
1886 config->writeEntry("Separator1",list); 1886 config->writeEntry("Separator1",list);
1887 1887
1888 list = mLeftSplitter->sizes(); 1888 list = mLeftSplitter->sizes();
1889 config->writeEntry("Separator2",list); 1889 config->writeEntry("Separator2",list);
1890#endif 1890#endif
1891 1891
1892 mViewManager->writeSettings( config ); 1892 mViewManager->writeSettings( config );
1893 mTodoList->saveLayout(config,QString("Todo Layout")); 1893 mTodoList->saveLayout(config,QString("Todo Layout"));
1894 mDialogManager->writeSettings( config ); 1894 mDialogManager->writeSettings( config );
1895 //KOPrefs::instance()->usrWriteConfig(); 1895 //KOPrefs::instance()->usrWriteConfig();
1896 KOPrefs::instance()->writeConfig(); 1896 KOPrefs::instance()->writeConfig();
1897 1897
1898 writeFilterSettings(config); 1898 writeFilterSettings(config);
1899 1899
1900 config->setGroup( "Views" ); 1900 config->setGroup( "Views" );
1901 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1901 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1902 1902
1903#ifdef DESKTOP_VERSION 1903#ifdef DESKTOP_VERSION
1904 config->setGroup("WidgetLayout"); 1904 config->setGroup("WidgetLayout");
1905 QStringList list ;//= config->readListEntry("MainLayout"); 1905 QStringList list ;//= config->readListEntry("MainLayout");
1906 int x,y,w,h; 1906 int x,y,w,h;
1907 QWidget* wid; 1907 QWidget* wid;
1908 wid = topLevelWidget(); 1908 wid = topLevelWidget();
1909 x = wid->geometry().x(); 1909 x = wid->geometry().x();
1910 y = wid->geometry().y(); 1910 y = wid->geometry().y();
1911 w = wid->width(); 1911 w = wid->width();
1912 h = wid->height(); 1912 h = wid->height();
1913 list.clear(); 1913 list.clear();
1914 list << QString::number( x ); 1914 list << QString::number( x );
1915 list << QString::number( y ); 1915 list << QString::number( y );
1916 list << QString::number( w ); 1916 list << QString::number( w );
1917 list << QString::number( h ); 1917 list << QString::number( h );
1918 config->writeEntry("MainLayout",list ); 1918 config->writeEntry("MainLayout",list );
1919 1919
1920 wid = mEventEditor; 1920 wid = mEventEditor;
1921 x = wid->geometry().x(); 1921 x = wid->geometry().x();
1922 y = wid->geometry().y(); 1922 y = wid->geometry().y();
1923 w = wid->width(); 1923 w = wid->width();
1924 h = wid->height(); 1924 h = wid->height();
1925 list.clear(); 1925 list.clear();
1926 list << QString::number( x ); 1926 list << QString::number( x );
1927 list << QString::number( y ); 1927 list << QString::number( y );
1928 list << QString::number( w ); 1928 list << QString::number( w );
1929 list << QString::number( h ); 1929 list << QString::number( h );
1930 config->writeEntry("EditEventLayout",list ); 1930 config->writeEntry("EditEventLayout",list );
1931 1931
1932 wid = mTodoEditor; 1932 wid = mTodoEditor;
1933 x = wid->geometry().x(); 1933 x = wid->geometry().x();
1934 y = wid->geometry().y(); 1934 y = wid->geometry().y();
1935 w = wid->width(); 1935 w = wid->width();
1936 h = wid->height(); 1936 h = wid->height();
1937 list.clear(); 1937 list.clear();
1938 list << QString::number( x ); 1938 list << QString::number( x );
1939 list << QString::number( y ); 1939 list << QString::number( y );
1940 list << QString::number( w ); 1940 list << QString::number( w );
1941 list << QString::number( h ); 1941 list << QString::number( h );
1942 config->writeEntry("EditTodoLayout",list ); 1942 config->writeEntry("EditTodoLayout",list );
1943 wid = getEventViewerDialog(); 1943 wid = getEventViewerDialog();
1944 x = wid->geometry().x(); 1944 x = wid->geometry().x();
1945 y = wid->geometry().y(); 1945 y = wid->geometry().y();
1946 w = wid->width(); 1946 w = wid->width();
1947 h = wid->height(); 1947 h = wid->height();
1948 list.clear(); 1948 list.clear();
1949 list << QString::number( x ); 1949 list << QString::number( x );
1950 list << QString::number( y ); 1950 list << QString::number( y );
1951 list << QString::number( w ); 1951 list << QString::number( w );
1952 list << QString::number( h ); 1952 list << QString::number( h );
1953 config->writeEntry("ViewerLayout",list ); 1953 config->writeEntry("ViewerLayout",list );
1954 wid = mDialogManager->getSearchDialog(); 1954 wid = mDialogManager->getSearchDialog();
1955 if ( wid ) { 1955 if ( wid ) {
1956 x = wid->geometry().x(); 1956 x = wid->geometry().x();
1957 y = wid->geometry().y(); 1957 y = wid->geometry().y();
1958 w = wid->width(); 1958 w = wid->width();
1959 h = wid->height(); 1959 h = wid->height();
1960 list.clear(); 1960 list.clear();
1961 list << QString::number( x ); 1961 list << QString::number( x );
1962 list << QString::number( y ); 1962 list << QString::number( y );
1963 list << QString::number( w ); 1963 list << QString::number( w );
1964 list << QString::number( h ); 1964 list << QString::number( h );
1965 config->writeEntry("SearchLayout",list ); 1965 config->writeEntry("SearchLayout",list );
1966 } 1966 }
1967#endif 1967#endif
1968 1968
1969 1969
1970 config->sync(); 1970 config->sync();
1971} 1971}
1972 1972
1973void CalendarView::readFilterSettings(KConfig *config) 1973void CalendarView::readFilterSettings(KConfig *config)
1974{ 1974{
1975 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1975 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1976 1976
1977 mFilters.clear(); 1977 mFilters.clear();
1978 1978
1979 config->setGroup("General"); 1979 config->setGroup("General");
1980 QStringList filterList = config->readListEntry("CalendarFilters"); 1980 QStringList filterList = config->readListEntry("CalendarFilters");
1981 1981
1982 QStringList::ConstIterator it = filterList.begin(); 1982 QStringList::ConstIterator it = filterList.begin();
1983 QStringList::ConstIterator end = filterList.end(); 1983 QStringList::ConstIterator end = filterList.end();
1984 while(it != end) { 1984 while(it != end) {
1985 // kdDebug() << " filter: " << (*it) << endl; 1985 // kdDebug() << " filter: " << (*it) << endl;
1986 1986
1987 CalFilter *filter; 1987 CalFilter *filter;
1988 filter = new CalFilter(*it); 1988 filter = new CalFilter(*it);
1989 config->setGroup("Filter_" + (*it)); 1989 config->setGroup("Filter_" + (*it));
1990 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1990 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1991 filter->setCriteria(config->readNumEntry("Criteria",0)); 1991 filter->setCriteria(config->readNumEntry("Criteria",0));
1992 filter->setCategoryList(config->readListEntry("CategoryList")); 1992 filter->setCategoryList(config->readListEntry("CategoryList"));
1993 mFilters.append(filter); 1993 mFilters.append(filter);
1994 1994
1995 ++it; 1995 ++it;
1996 } 1996 }
1997 1997
1998 if (mFilters.count() == 0) { 1998 if (mFilters.count() == 0) {
1999 CalFilter *filter = new CalFilter(i18n("Default")); 1999 CalFilter *filter = new CalFilter(i18n("Default"));
2000 mFilters.append(filter); 2000 mFilters.append(filter);
2001 } 2001 }
2002 mFilterView->updateFilters(); 2002 mFilterView->updateFilters();
2003 config->setGroup("FilterView"); 2003 config->setGroup("FilterView");
2004 2004
2005 mFilterView->blockSignals(true); 2005 mFilterView->blockSignals(true);
2006 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2006 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2007 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2007 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2008 mFilterView->blockSignals(false); 2008 mFilterView->blockSignals(false);
2009 // We do it manually to avoid it being done twice by the above calls 2009 // We do it manually to avoid it being done twice by the above calls
2010 updateFilter(); 2010 updateFilter();
2011} 2011}
2012 2012
2013void CalendarView::writeFilterSettings(KConfig *config) 2013void CalendarView::writeFilterSettings(KConfig *config)
2014{ 2014{
2015 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2015 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2016 2016
2017 QStringList filterList; 2017 QStringList filterList;
2018 2018
2019 CalFilter *filter = mFilters.first(); 2019 CalFilter *filter = mFilters.first();
2020 while(filter) { 2020 while(filter) {
2021 // kdDebug() << " fn: " << filter->name() << endl; 2021 // kdDebug() << " fn: " << filter->name() << endl;
2022 filterList << filter->name(); 2022 filterList << filter->name();
2023 config->setGroup("Filter_" + filter->name()); 2023 config->setGroup("Filter_" + filter->name());
2024 config->writeEntry("Criteria",filter->criteria()); 2024 config->writeEntry("Criteria",filter->criteria());
2025 config->writeEntry("CategoryList",filter->categoryList()); 2025 config->writeEntry("CategoryList",filter->categoryList());
2026 filter = mFilters.next(); 2026 filter = mFilters.next();
2027 } 2027 }
2028 config->setGroup("General"); 2028 config->setGroup("General");
2029 config->writeEntry("CalendarFilters",filterList); 2029 config->writeEntry("CalendarFilters",filterList);
2030 2030
2031 config->setGroup("FilterView"); 2031 config->setGroup("FilterView");
2032 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2032 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2033 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2033 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2034} 2034}
2035 2035
2036 2036
2037void CalendarView::goToday() 2037void CalendarView::goToday()
2038{ 2038{
2039 if ( mViewManager->currentView()->isMonthView() ) 2039 if ( mViewManager->currentView()->isMonthView() )
2040 mNavigator->selectTodayMonth(); 2040 mNavigator->selectTodayMonth();
2041 else 2041 else
2042 mNavigator->selectToday(); 2042 mNavigator->selectToday();
2043} 2043}
2044 2044
2045void CalendarView::goNext() 2045void CalendarView::goNext()
2046{ 2046{
2047 mNavigator->selectNext(); 2047 mNavigator->selectNext();
2048} 2048}
2049 2049
2050void CalendarView::goPrevious() 2050void CalendarView::goPrevious()
2051{ 2051{
2052 mNavigator->selectPrevious(); 2052 mNavigator->selectPrevious();
2053} 2053}
2054void CalendarView::goNextMonth() 2054void CalendarView::goNextMonth()
2055{ 2055{
2056 mNavigator->selectNextMonth(); 2056 mNavigator->selectNextMonth();
2057} 2057}
2058 2058
2059void CalendarView::goPreviousMonth() 2059void CalendarView::goPreviousMonth()
2060{ 2060{
2061 mNavigator->selectPreviousMonth(); 2061 mNavigator->selectPreviousMonth();
2062} 2062}
2063void CalendarView::writeLocale() 2063void CalendarView::writeLocale()
2064{ 2064{
2065 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2065 //KPimGlobalPrefs::instance()->setGlobalConfig();
2066#if 0 2066#if 0
2067 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2067 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2068 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2068 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2069 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2069 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2070 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2070 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2071 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2071 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2072 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2072 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2073 dummy = KOPrefs::instance()->mUserDateFormatShort; 2073 dummy = KOPrefs::instance()->mUserDateFormatShort;
2074 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2074 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2075 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2075 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2076 KOPrefs::instance()->mDaylightsavingStart, 2076 KOPrefs::instance()->mDaylightsavingStart,
2077 KOPrefs::instance()->mDaylightsavingEnd ); 2077 KOPrefs::instance()->mDaylightsavingEnd );
2078 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2078 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2079#endif 2079#endif
2080} 2080}
2081void CalendarView::updateConfig() 2081void CalendarView::updateConfig()
2082{ 2082{
2083 writeLocale(); 2083 writeLocale();
2084 if ( KOPrefs::instance()->mUseAppColors ) 2084 if ( KOPrefs::instance()->mUseAppColors )
2085 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2085 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2086 emit configChanged(); 2086 emit configChanged();
2087 mTodoList->updateConfig(); 2087 mTodoList->updateConfig();
2088 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2088 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2089 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2089 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2090 // To make the "fill window" configurations work 2090 // To make the "fill window" configurations work
2091 //mViewManager->raiseCurrentView(); 2091 //mViewManager->raiseCurrentView();
2092} 2092}
2093 2093
2094 2094
2095void CalendarView::eventChanged(Event *event) 2095void CalendarView::eventChanged(Event *event)
2096{ 2096{
2097 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2097 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2098 //updateUnmanagedViews(); 2098 //updateUnmanagedViews();
2099} 2099}
2100 2100
2101void CalendarView::eventAdded(Event *event) 2101void CalendarView::eventAdded(Event *event)
2102{ 2102{
2103 changeEventDisplay(event,KOGlobals::EVENTADDED); 2103 changeEventDisplay(event,KOGlobals::EVENTADDED);
2104} 2104}
2105 2105
2106void CalendarView::eventToBeDeleted(Event *) 2106void CalendarView::eventToBeDeleted(Event *)
2107{ 2107{
2108 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2108 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2109} 2109}
2110 2110
2111void CalendarView::eventDeleted() 2111void CalendarView::eventDeleted()
2112{ 2112{
2113 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2113 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2114} 2114}
2115void CalendarView::changeTodoDisplay(Todo *which, int action) 2115void CalendarView::changeTodoDisplay(Todo *which, int action)
2116{ 2116{
2117 changeIncidenceDisplay((Incidence *)which, action); 2117 changeIncidenceDisplay((Incidence *)which, action);
2118 mDateNavigator->updateView(); //LR 2118 mDateNavigator->updateView(); //LR
2119 //mDialogManager->updateSearchDialog(); 2119 //mDialogManager->updateSearchDialog();
2120 2120
2121 if (which) { 2121 if (which) {
2122 mViewManager->updateWNview(); 2122 mViewManager->updateWNview();
2123 //mTodoList->updateView(); 2123 //mTodoList->updateView();
2124 } 2124 }
2125 2125
2126} 2126}
2127 2127
2128void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2128void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2129{ 2129{
2130 updateUnmanagedViews(); 2130 updateUnmanagedViews();
2131 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2131 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2132 if ( action == KOGlobals::EVENTDELETED ) { //delete 2132 if ( action == KOGlobals::EVENTDELETED ) { //delete
2133 mCalendar->checkAlarmForIncidence( 0, true ); 2133 mCalendar->checkAlarmForIncidence( 0, true );
2134 if ( mEventViewerDialog ) 2134 if ( mEventViewerDialog )
2135 mEventViewerDialog->hide(); 2135 mEventViewerDialog->hide();
2136 } 2136 }
2137 else 2137 else
2138 mCalendar->checkAlarmForIncidence( which , false ); 2138 mCalendar->checkAlarmForIncidence( which , false );
2139} 2139}
2140 2140
2141// most of the changeEventDisplays() right now just call the view's 2141// most of the changeEventDisplays() right now just call the view's
2142// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2142// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2143void CalendarView::changeEventDisplay(Event *which, int action) 2143void CalendarView::changeEventDisplay(Event *which, int action)
2144{ 2144{
2145 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2145 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2146 changeIncidenceDisplay((Incidence *)which, action); 2146 changeIncidenceDisplay((Incidence *)which, action);
2147 mDateNavigator->updateView(); 2147 mDateNavigator->updateView();
2148 //mDialogManager->updateSearchDialog(); 2148 //mDialogManager->updateSearchDialog();
2149 2149
2150 if (which) { 2150 if (which) {
2151 // If there is an event view visible update the display 2151 // If there is an event view visible update the display
2152 mViewManager->currentView()->changeEventDisplay(which,action); 2152 mViewManager->currentView()->changeEventDisplay(which,action);
2153 // TODO: check, if update needed 2153 // TODO: check, if update needed
2154 // if (which->getTodoStatus()) { 2154 // if (which->getTodoStatus()) {
2155 mTodoList->updateView(); 2155 mTodoList->updateView();
2156 // } 2156 // }
2157 } else { 2157 } else {
2158 mViewManager->currentView()->updateView(); 2158 mViewManager->currentView()->updateView();
2159 } 2159 }
2160} 2160}
2161 2161
2162 2162
2163void CalendarView::updateTodoViews() 2163void CalendarView::updateTodoViews()
2164{ 2164{
2165 mTodoList->updateView(); 2165 mTodoList->updateView();
2166 mViewManager->currentView()->updateView(); 2166 mViewManager->currentView()->updateView();
2167 2167
2168} 2168}
2169 2169
2170 2170
2171void CalendarView::updateView(const QDate &start, const QDate &end) 2171void CalendarView::updateView(const QDate &start, const QDate &end)
2172{ 2172{
2173 mTodoList->updateView(); 2173 mTodoList->updateView();
2174 mViewManager->updateView(start, end); 2174 mViewManager->updateView(start, end);
2175 //mDateNavigator->updateView(); 2175 //mDateNavigator->updateView();
2176} 2176}
2177 2177
2178void CalendarView::updateView() 2178void CalendarView::updateView()
2179{ 2179{
2180 DateList tmpList = mNavigator->selectedDates(); 2180 DateList tmpList = mNavigator->selectedDates();
2181 2181
2182 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2182 if ( KOPrefs::instance()->mHideNonStartedTodos )
2183 mTodoList->updateView(); 2183 mTodoList->updateView();
2184 // We assume that the navigator only selects consecutive days. 2184 // We assume that the navigator only selects consecutive days.
2185 updateView( tmpList.first(), tmpList.last() ); 2185 updateView( tmpList.first(), tmpList.last() );
2186} 2186}
2187 2187
2188void CalendarView::updateUnmanagedViews() 2188void CalendarView::updateUnmanagedViews()
2189{ 2189{
2190 mDateNavigator->updateDayMatrix(); 2190 mDateNavigator->updateDayMatrix();
2191} 2191}
2192 2192
2193int CalendarView::msgItemDelete(const QString name) 2193int CalendarView::msgItemDelete(const QString name)
2194{ 2194{
2195 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2195 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2196 i18n("This item will be\npermanently deleted."), 2196 i18n("This item will be\npermanently deleted."),
2197 i18n("KO/Pi Confirmation"),i18n("Delete")); 2197 i18n("KO/Pi Confirmation"),i18n("Delete"));
2198} 2198}
2199 2199
2200 2200
2201void CalendarView::edit_cut() 2201void CalendarView::edit_cut()
2202{ 2202{
2203 Event *anEvent=0; 2203 Event *anEvent=0;
2204 2204
2205 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2205 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2206 2206
2207 if (mViewManager->currentView()->isEventView()) { 2207 if (mViewManager->currentView()->isEventView()) {
2208 if ( incidence && incidence->type() == "Event" ) { 2208 if ( incidence && incidence->type() == "Event" ) {
2209 anEvent = static_cast<Event *>(incidence); 2209 anEvent = static_cast<Event *>(incidence);
2210 } 2210 }
2211 } 2211 }
2212 2212
2213 if (!anEvent) { 2213 if (!anEvent) {
2214 KNotifyClient::beep(); 2214 KNotifyClient::beep();
2215 return; 2215 return;
2216 } 2216 }
2217 DndFactory factory( mCalendar ); 2217 DndFactory factory( mCalendar );
2218 factory.cutIncidence(anEvent); 2218 factory.cutIncidence(anEvent);
2219 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2219 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2220} 2220}
2221 2221
2222void CalendarView::edit_copy() 2222void CalendarView::edit_copy()
2223{ 2223{
2224 Event *anEvent=0; 2224 Event *anEvent=0;
2225 2225
2226 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2226 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2227 2227
2228 if (mViewManager->currentView()->isEventView()) { 2228 if (mViewManager->currentView()->isEventView()) {
2229 if ( incidence && incidence->type() == "Event" ) { 2229 if ( incidence && incidence->type() == "Event" ) {
2230 anEvent = static_cast<Event *>(incidence); 2230 anEvent = static_cast<Event *>(incidence);
2231 } 2231 }
2232 } 2232 }
2233 2233
2234 if (!anEvent) { 2234 if (!anEvent) {
2235 KNotifyClient::beep(); 2235 KNotifyClient::beep();
2236 return; 2236 return;
2237 } 2237 }
2238 DndFactory factory( mCalendar ); 2238 DndFactory factory( mCalendar );
2239 factory.copyIncidence(anEvent); 2239 factory.copyIncidence(anEvent);
2240} 2240}
2241 2241
2242void CalendarView::edit_paste() 2242void CalendarView::edit_paste()
2243{ 2243{
2244 QDate date = mNavigator->selectedDates().first(); 2244 QDate date = mNavigator->selectedDates().first();
2245 2245
2246 DndFactory factory( mCalendar ); 2246 DndFactory factory( mCalendar );
2247 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2247 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2248 2248
2249 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2249 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2250} 2250}
2251 2251
2252void CalendarView::edit_options() 2252void CalendarView::edit_options()
2253{ 2253{
2254 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2255 emit save();
2256 emit saveStopTimer();
2254 mDialogManager->showOptionsDialog(); 2257 mDialogManager->showOptionsDialog();
2255 //writeSettings(); 2258 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2259 emit saveStopTimer();
2260 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!"),
2261 i18n("Timezone settings"),i18n("Reload"))) {
2262 qDebug("KO: TZ reload cancelled ");
2263 return;
2264 }
2265 qDebug("KO: Timezone change ");
2266 openCalendar( MainWindow::defaultFileName() );
2267 setModified(true);
2268 }
2269 else
2270 qDebug("KO: No tz change ");
2271
2256} 2272}
2257 2273
2258 2274
2259void CalendarView::slotSelectPickerDate( QDate d) 2275void CalendarView::slotSelectPickerDate( QDate d)
2260{ 2276{
2261 mDateFrame->hide(); 2277 mDateFrame->hide();
2262 if ( mDatePickerMode == 1 ) { 2278 if ( mDatePickerMode == 1 ) {
2263 mNavigator->slotDaySelect( d ); 2279 mNavigator->slotDaySelect( d );
2264 } else if ( mDatePickerMode == 2 ) { 2280 } else if ( mDatePickerMode == 2 ) {
2265 if ( mMoveIncidence->type() == "Todo" ) { 2281 if ( mMoveIncidence->type() == "Todo" ) {
2266 Todo * to = (Todo *) mMoveIncidence; 2282 Todo * to = (Todo *) mMoveIncidence;
2267 QTime tim; 2283 QTime tim;
2268 if ( to->hasDueDate() ) 2284 if ( to->hasDueDate() )
2269 tim = to->dtDue().time(); 2285 tim = to->dtDue().time();
2270 else { 2286 else {
2271 tim = QTime ( 0,0,0 ); 2287 tim = QTime ( 0,0,0 );
2272 to->setFloats( true ); 2288 to->setFloats( true );
2273 to->setHasDueDate( true ); 2289 to->setHasDueDate( true );
2274 } 2290 }
2275 QDateTime dt ( d,tim ); 2291 QDateTime dt ( d,tim );
2276 to->setDtDue( dt ); 2292 to->setDtDue( dt );
2277 todoChanged( to ); 2293 todoChanged( to );
2278 } else { 2294 } else {
2279 if ( mMoveIncidence->doesRecur() ) { 2295 if ( mMoveIncidence->doesRecur() ) {
2280#if 0 2296#if 0
2281 // PENDING implement this 2297 // PENDING implement this
2282 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2298 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2283 mCalendar()->addIncidence( newInc ); 2299 mCalendar()->addIncidence( newInc );
2284 if ( mMoveIncidence->type() == "Todo" ) 2300 if ( mMoveIncidence->type() == "Todo" )
2285 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2301 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2286 else 2302 else
2287 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2303 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2288 mMoveIncidence = newInc; 2304 mMoveIncidence = newInc;
2289 2305
2290#endif 2306#endif
2291 } 2307 }
2292 QTime tim = mMoveIncidence->dtStart().time(); 2308 QTime tim = mMoveIncidence->dtStart().time();
2293 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2309 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2294 QDateTime dt ( d,tim ); 2310 QDateTime dt ( d,tim );
2295 mMoveIncidence->setDtStart( dt ); 2311 mMoveIncidence->setDtStart( dt );
2296 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2312 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2297 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2313 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2298 } 2314 }
2299 2315
2300 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2316 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2301 } 2317 }
2302} 2318}
2303 2319
2304void CalendarView::removeCategories() 2320void CalendarView::removeCategories()
2305{ 2321{
2306 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2322 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2307 QStringList catList = KOPrefs::instance()->mCustomCategories; 2323 QStringList catList = KOPrefs::instance()->mCustomCategories;
2308 QStringList catIncList; 2324 QStringList catIncList;
2309 QStringList newCatList; 2325 QStringList newCatList;
2310 Incidence* inc = incList.first(); 2326 Incidence* inc = incList.first();
2311 int i; 2327 int i;
2312 int count = 0; 2328 int count = 0;
2313 while ( inc ) { 2329 while ( inc ) {
2314 newCatList.clear(); 2330 newCatList.clear();
2315 catIncList = inc->categories() ; 2331 catIncList = inc->categories() ;
2316 for( i = 0; i< catIncList.count(); ++i ) { 2332 for( i = 0; i< catIncList.count(); ++i ) {
2317 if ( catList.contains (catIncList[i])) 2333 if ( catList.contains (catIncList[i]))
2318 newCatList.append( catIncList[i] ); 2334 newCatList.append( catIncList[i] );
2319 } 2335 }
2320 newCatList.sort(); 2336 newCatList.sort();
2321 inc->setCategories( newCatList.join(",") ); 2337 inc->setCategories( newCatList.join(",") );
2322 inc = incList.next(); 2338 inc = incList.next();
2323 } 2339 }
2324} 2340}
2325 2341
2326int CalendarView::addCategories() 2342int CalendarView::addCategories()
2327{ 2343{
2328 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2344 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2329 QStringList catList = KOPrefs::instance()->mCustomCategories; 2345 QStringList catList = KOPrefs::instance()->mCustomCategories;
2330 QStringList catIncList; 2346 QStringList catIncList;
2331 Incidence* inc = incList.first(); 2347 Incidence* inc = incList.first();
2332 int i; 2348 int i;
2333 int count = 0; 2349 int count = 0;
2334 while ( inc ) { 2350 while ( inc ) {
2335 catIncList = inc->categories() ; 2351 catIncList = inc->categories() ;
2336 for( i = 0; i< catIncList.count(); ++i ) { 2352 for( i = 0; i< catIncList.count(); ++i ) {
2337 if ( !catList.contains (catIncList[i])) { 2353 if ( !catList.contains (catIncList[i])) {
2338 catList.append( catIncList[i] ); 2354 catList.append( catIncList[i] );
2339 //qDebug("add cat %s ", catIncList[i].latin1()); 2355 //qDebug("add cat %s ", catIncList[i].latin1());
2340 ++count; 2356 ++count;
2341 } 2357 }
2342 } 2358 }
2343 inc = incList.next(); 2359 inc = incList.next();
2344 } 2360 }
2345 catList.sort(); 2361 catList.sort();
2346 KOPrefs::instance()->mCustomCategories = catList; 2362 KOPrefs::instance()->mCustomCategories = catList;
2347 return count; 2363 return count;
2348} 2364}
2349 2365
2350void CalendarView::manageCategories() 2366void CalendarView::manageCategories()
2351{ 2367{
2352 KOCatPrefs* cp = new KOCatPrefs(); 2368 KOCatPrefs* cp = new KOCatPrefs();
2353 cp->show(); 2369 cp->show();
2354 int w =cp->sizeHint().width() ; 2370 int w =cp->sizeHint().width() ;
2355 int h = cp->sizeHint().height() ; 2371 int h = cp->sizeHint().height() ;
2356 int dw = QApplication::desktop()->width(); 2372 int dw = QApplication::desktop()->width();
2357 int dh = QApplication::desktop()->height(); 2373 int dh = QApplication::desktop()->height();
2358 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2374 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2359 if ( !cp->exec() ) { 2375 if ( !cp->exec() ) {
2360 delete cp; 2376 delete cp;
2361 return; 2377 return;
2362 } 2378 }
2363 int count = 0; 2379 int count = 0;
2364 if ( cp->addCat() ) { 2380 if ( cp->addCat() ) {
2365 count = addCategories(); 2381 count = addCategories();
2366 if ( count ) { 2382 if ( count ) {
2367 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2383 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2368 writeSettings(); 2384 writeSettings();
2369 } else 2385 } else
2370 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2386 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2371 } else { 2387 } else {
2372 removeCategories(); 2388 removeCategories();
2373 updateView(); 2389 updateView();
2374 } 2390 }
2375 delete cp; 2391 delete cp;
2376} 2392}
2377 2393
2378void CalendarView::beamIncidence(Incidence * Inc) 2394void CalendarView::beamIncidence(Incidence * Inc)
2379{ 2395{
2380 QPtrList<Incidence> delSel ; 2396 QPtrList<Incidence> delSel ;
2381 delSel.append(Inc); 2397 delSel.append(Inc);
2382 beamIncidenceList( delSel ); 2398 beamIncidenceList( delSel );
2383} 2399}
2384void CalendarView::beamCalendar() 2400void CalendarView::beamCalendar()
2385{ 2401{
2386 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2402 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2387 //qDebug("beamCalendar() "); 2403 //qDebug("beamCalendar() ");
2388 beamIncidenceList( delSel ); 2404 beamIncidenceList( delSel );
2389} 2405}
2390void CalendarView::beamFilteredCalendar() 2406void CalendarView::beamFilteredCalendar()
2391{ 2407{
2392 QPtrList<Incidence> delSel = mCalendar->incidences(); 2408 QPtrList<Incidence> delSel = mCalendar->incidences();
2393 //qDebug("beamFilteredCalendar() "); 2409 //qDebug("beamFilteredCalendar() ");
2394 beamIncidenceList( delSel ); 2410 beamIncidenceList( delSel );
2395} 2411}
2396void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2412void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2397{ 2413{
2398 if ( beamDialog->exec () == QDialog::Rejected ) 2414 if ( beamDialog->exec () == QDialog::Rejected )
2399 return; 2415 return;
2400#ifdef DESKTOP_VERSION 2416#ifdef DESKTOP_VERSION
2401 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2417 QString fn = locateLocal( "tmp", "kopibeamfile" );
2402#else 2418#else
2403 QString fn = "/tmp/kopibeamfile"; 2419 QString fn = "/tmp/kopibeamfile";
2404#endif 2420#endif
2405 QString mes; 2421 QString mes;
2406 bool createbup = true; 2422 bool createbup = true;
2407 if ( createbup ) { 2423 if ( createbup ) {
2408 QString description = "\n"; 2424 QString description = "\n";
2409 CalendarLocal* cal = new CalendarLocal(); 2425 CalendarLocal* cal = new CalendarLocal();
2410 if ( beamDialog->beamLocal() ) 2426 if ( beamDialog->beamLocal() )
2411 cal->setLocalTime(); 2427 cal->setLocalTime();
2412 else 2428 else
2413 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2429 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2414 Incidence *incidence = delSel.first(); 2430 Incidence *incidence = delSel.first();
2415 bool addText = false; 2431 bool addText = false;
2416 if ( delSel.count() < 10 ) 2432 if ( delSel.count() < 10 )
2417 addText = true; 2433 addText = true;
2418 else { 2434 else {
2419 description.sprintf(i18n(" %d items?"),delSel.count() ); 2435 description.sprintf(i18n(" %d items?"),delSel.count() );
2420 } 2436 }
2421 while ( incidence ) { 2437 while ( incidence ) {
2422 Incidence *in = incidence->clone(); 2438 Incidence *in = incidence->clone();
2423 if ( ! in->summary().isEmpty() ) { 2439 if ( ! in->summary().isEmpty() ) {
2424 in->setDescription(""); 2440 in->setDescription("");
2425 } else { 2441 } else {
2426 in->setSummary( in->description().left(20)); 2442 in->setSummary( in->description().left(20));
2427 in->setDescription(""); 2443 in->setDescription("");
2428 } 2444 }
2429 if ( addText ) 2445 if ( addText )
2430 description += in->summary() + "\n"; 2446 description += in->summary() + "\n";
2431 cal->addIncidence( in ); 2447 cal->addIncidence( in );
2432 incidence = delSel.next(); 2448 incidence = delSel.next();
2433 } 2449 }
2434 if ( beamDialog->beamVcal() ) { 2450 if ( beamDialog->beamVcal() ) {
2435 fn += ".vcs"; 2451 fn += ".vcs";
2436 FileStorage storage( cal, fn, new VCalFormat ); 2452 FileStorage storage( cal, fn, new VCalFormat );
2437 storage.save(); 2453 storage.save();
2438 } else { 2454 } else {
2439 fn += ".ics"; 2455 fn += ".ics";
2440 FileStorage storage( cal, fn, new ICalFormat( ) ); 2456 FileStorage storage( cal, fn, new ICalFormat( ) );
2441 storage.save(); 2457 storage.save();
2442 } 2458 }
2443 delete cal; 2459 delete cal;
2444 mes = i18n("KO/Pi: Ready for beaming"); 2460 mes = i18n("KO/Pi: Ready for beaming");
2445 topLevelWidget()->setCaption(mes); 2461 topLevelWidget()->setCaption(mes);
2446 KApplication::convert2latin1( fn ); 2462 KApplication::convert2latin1( fn );
2447#ifndef DESKTOP_VERSION 2463#ifndef DESKTOP_VERSION
2448 Ir *ir = new Ir( this ); 2464 Ir *ir = new Ir( this );
2449 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2465 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2450 ir->send( fn, description, "text/x-vCalendar" ); 2466 ir->send( fn, description, "text/x-vCalendar" );
2451#endif 2467#endif
2452 } 2468 }
2453} 2469}
2454void CalendarView::beamDone( Ir *ir ) 2470void CalendarView::beamDone( Ir *ir )
2455{ 2471{
2456#ifndef DESKTOP_VERSION 2472#ifndef DESKTOP_VERSION
2457 delete ir; 2473 delete ir;
2458#endif 2474#endif
2459 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2475 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2460 topLevelWidget()->raise(); 2476 topLevelWidget()->raise();
2461} 2477}
2462 2478
2463void CalendarView::moveIncidence(Incidence * inc ) 2479void CalendarView::moveIncidence(Incidence * inc )
2464{ 2480{
2465 if ( !inc ) return; 2481 if ( !inc ) return;
2466 // qDebug("showDatePickerForIncidence( ) "); 2482 // qDebug("showDatePickerForIncidence( ) ");
2467 if ( mDateFrame->isVisible() ) 2483 if ( mDateFrame->isVisible() )
2468 mDateFrame->hide(); 2484 mDateFrame->hide();
2469 else { 2485 else {
2470 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2486 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2471 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2487 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2472 int dw = QApplication::desktop()->width(); 2488 int dw = QApplication::desktop()->width();
2473 int dh = QApplication::desktop()->height(); 2489 int dh = QApplication::desktop()->height();
2474 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2490 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2475 mDateFrame->show(); 2491 mDateFrame->show();
2476 } 2492 }
2477 mDatePickerMode = 2; 2493 mDatePickerMode = 2;
2478 mMoveIncidence = inc ; 2494 mMoveIncidence = inc ;
2479 QDate da; 2495 QDate da;
2480 if ( mMoveIncidence->type() == "Todo" ) { 2496 if ( mMoveIncidence->type() == "Todo" ) {
2481 Todo * to = (Todo *) mMoveIncidence; 2497 Todo * to = (Todo *) mMoveIncidence;
2482 if ( to->hasDueDate() ) 2498 if ( to->hasDueDate() )
2483 da = to->dtDue().date(); 2499 da = to->dtDue().date();
2484 else 2500 else
2485 da = QDate::currentDate(); 2501 da = QDate::currentDate();
2486 } else { 2502 } else {
2487 da = mMoveIncidence->dtStart().date(); 2503 da = mMoveIncidence->dtStart().date();
2488 } 2504 }
2489 //PENDING set date for recurring incidence to date of recurrence 2505 //PENDING set date for recurring incidence to date of recurrence
2490 //mMoveIncidenceOldDate; 2506 //mMoveIncidenceOldDate;
2491 mDatePicker->setDate( da ); 2507 mDatePicker->setDate( da );
2492} 2508}
2493void CalendarView::showDatePicker( ) 2509void CalendarView::showDatePicker( )
2494{ 2510{
2495 //qDebug("CalendarView::showDatePicker( ) "); 2511 //qDebug("CalendarView::showDatePicker( ) ");
2496 if ( mDateFrame->isVisible() ) 2512 if ( mDateFrame->isVisible() )
2497 mDateFrame->hide(); 2513 mDateFrame->hide();
2498 else { 2514 else {
2499 int w =mDatePicker->sizeHint().width() ; 2515 int w =mDatePicker->sizeHint().width() ;
2500 int h = mDatePicker->sizeHint().height() ; 2516 int h = mDatePicker->sizeHint().height() ;
2501 int dw = QApplication::desktop()->width(); 2517 int dw = QApplication::desktop()->width();
2502 int dh = QApplication::desktop()->height(); 2518 int dh = QApplication::desktop()->height();
2503 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2519 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2504 mDateFrame->show(); 2520 mDateFrame->show();
2505 } 2521 }
2506 mDatePickerMode = 1; 2522 mDatePickerMode = 1;
2507 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2523 mDatePicker->setDate( mNavigator->selectedDates().first() );
2508} 2524}
2509 2525
2510void CalendarView::showEventEditor() 2526void CalendarView::showEventEditor()
2511{ 2527{
2512#ifdef DESKTOP_VERSION 2528#ifdef DESKTOP_VERSION
2513 mEventEditor->show(); 2529 mEventEditor->show();
2514#else 2530#else
2515 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2531 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2516 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2532 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2517 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2533 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2518 qApp->processEvents(); 2534 qApp->processEvents();
2519 delete mEventEditor; 2535 delete mEventEditor;
2520 mEventEditor = mDialogManager->getEventEditor(); 2536 mEventEditor = mDialogManager->getEventEditor();
2521 topLevelWidget()->setCaption( i18n("") ); 2537 topLevelWidget()->setCaption( i18n("") );
2522 } 2538 }
2523 mEventEditor->showMaximized(); 2539 mEventEditor->showMaximized();
2524#endif 2540#endif
2525} 2541}
2526void CalendarView::showTodoEditor() 2542void CalendarView::showTodoEditor()
2527{ 2543{
2528#ifdef DESKTOP_VERSION 2544#ifdef DESKTOP_VERSION
2529 mTodoEditor->show(); 2545 mTodoEditor->show();
2530#else 2546#else
2531 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2547 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2532 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2548 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2533 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2549 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2534 qApp->processEvents(); 2550 qApp->processEvents();
2535 delete mTodoEditor; 2551 delete mTodoEditor;
2536 mTodoEditor = mDialogManager->getTodoEditor(); 2552 mTodoEditor = mDialogManager->getTodoEditor();
2537 topLevelWidget()->setCaption( i18n("") ); 2553 topLevelWidget()->setCaption( i18n("") );
2538 } 2554 }
2539 mTodoEditor->showMaximized(); 2555 mTodoEditor->showMaximized();
2540#endif 2556#endif
2541} 2557}
2542 2558
2543void CalendarView::cloneIncidence() 2559void CalendarView::cloneIncidence()
2544{ 2560{
2545 Incidence *incidence = currentSelection(); 2561 Incidence *incidence = currentSelection();
2546 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2562 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2547 if ( incidence ) { 2563 if ( incidence ) {
2548 cloneIncidence(incidence); 2564 cloneIncidence(incidence);
2549 } 2565 }
2550} 2566}
2551void CalendarView::moveIncidence() 2567void CalendarView::moveIncidence()
2552{ 2568{
2553 Incidence *incidence = currentSelection(); 2569 Incidence *incidence = currentSelection();
2554 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2570 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2555 if ( incidence ) { 2571 if ( incidence ) {
2556 moveIncidence(incidence); 2572 moveIncidence(incidence);
2557 } 2573 }
2558} 2574}
2559void CalendarView::beamIncidence() 2575void CalendarView::beamIncidence()
2560{ 2576{
2561 Incidence *incidence = currentSelection(); 2577 Incidence *incidence = currentSelection();
2562 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2578 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2563 if ( incidence ) { 2579 if ( incidence ) {
2564 beamIncidence(incidence); 2580 beamIncidence(incidence);
2565 } 2581 }
2566} 2582}
2567void CalendarView::toggleCancelIncidence() 2583void CalendarView::toggleCancelIncidence()
2568{ 2584{
2569 Incidence *incidence = currentSelection(); 2585 Incidence *incidence = currentSelection();
2570 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2586 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2571 if ( incidence ) { 2587 if ( incidence ) {
2572 cancelIncidence(incidence); 2588 cancelIncidence(incidence);
2573 } 2589 }
2574} 2590}
2575 2591
2576 2592
2577void CalendarView::cancelIncidence(Incidence * inc ) 2593void CalendarView::cancelIncidence(Incidence * inc )
2578{ 2594{
2579 inc->setCancelled( ! inc->cancelled() ); 2595 inc->setCancelled( ! inc->cancelled() );
2580 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2596 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2581 updateView(); 2597 updateView();
2582} 2598}
2583void CalendarView::cloneIncidence(Incidence * orgInc ) 2599void CalendarView::cloneIncidence(Incidence * orgInc )
2584{ 2600{
2585 Incidence * newInc = orgInc->clone(); 2601 Incidence * newInc = orgInc->clone();
2586 newInc->recreate(); 2602 newInc->recreate();
2587 2603
2588 if ( newInc->type() == "Todo" ) { 2604 if ( newInc->type() == "Todo" ) {
2589 Todo* t = (Todo*) newInc; 2605 Todo* t = (Todo*) newInc;
2590 showTodoEditor(); 2606 showTodoEditor();
2591 mTodoEditor->editTodo( t ); 2607 mTodoEditor->editTodo( t );
2592 if ( mTodoEditor->exec() ) { 2608 if ( mTodoEditor->exec() ) {
2593 mCalendar->addTodo( t ); 2609 mCalendar->addTodo( t );
2594 updateView(); 2610 updateView();
2595 } else { 2611 } else {
2596 delete t; 2612 delete t;
2597 } 2613 }
2598 } 2614 }
2599 else { 2615 else {
2600 Event* e = (Event*) newInc; 2616 Event* e = (Event*) newInc;
2601 showEventEditor(); 2617 showEventEditor();
2602 mEventEditor->editEvent( e ); 2618 mEventEditor->editEvent( e );
2603 if ( mEventEditor->exec() ) { 2619 if ( mEventEditor->exec() ) {
2604 mCalendar->addEvent( e ); 2620 mCalendar->addEvent( e );
2605 updateView(); 2621 updateView();
2606 } else { 2622 } else {
2607 delete e; 2623 delete e;
2608 } 2624 }
2609 } 2625 }
2610} 2626}
2611 2627
2612void CalendarView::newEvent() 2628void CalendarView::newEvent()
2613{ 2629{
2614 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2630 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2615 KOAgendaView *aView = mViewManager->agendaView(); 2631 KOAgendaView *aView = mViewManager->agendaView();
2616 if (aView) { 2632 if (aView) {
2617 if (aView->selectionStart().isValid()) { 2633 if (aView->selectionStart().isValid()) {
2618 if (aView->selectedIsAllDay()) { 2634 if (aView->selectedIsAllDay()) {
2619 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2635 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2620 } else { 2636 } else {
2621 newEvent(aView->selectionStart(),aView->selectionEnd()); 2637 newEvent(aView->selectionStart(),aView->selectionEnd());
2622 } 2638 }
2623 return; 2639 return;
2624 } 2640 }
2625 } 2641 }
2626 2642
2627 QDate date = mNavigator->selectedDates().first(); 2643 QDate date = mNavigator->selectedDates().first();
2628 QDateTime current = QDateTime::currentDateTime(); 2644 QDateTime current = QDateTime::currentDateTime();
2629 if ( date <= current.date() ) { 2645 if ( date <= current.date() ) {
2630 int hour = current.time().hour() +1; 2646 int hour = current.time().hour() +1;
2631 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2647 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2632 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2648 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2633 } else 2649 } else
2634 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2650 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2635 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2651 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2636 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2652 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2637} 2653}
2638 2654
2639void CalendarView::newEvent(QDateTime fh) 2655void CalendarView::newEvent(QDateTime fh)
2640{ 2656{
2641 newEvent(fh, 2657 newEvent(fh,
2642 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2658 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2643} 2659}
2644 2660
2645void CalendarView::newEvent(QDate dt) 2661void CalendarView::newEvent(QDate dt)
2646{ 2662{
2647 newEvent(QDateTime(dt, QTime(0,0,0)), 2663 newEvent(QDateTime(dt, QTime(0,0,0)),
2648 QDateTime(dt, QTime(0,0,0)), true); 2664 QDateTime(dt, QTime(0,0,0)), true);
2649} 2665}
2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2666void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2651{ 2667{
2652 newEvent(fromHint, toHint, false); 2668 newEvent(fromHint, toHint, false);
2653} 2669}
2654void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2670void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2655{ 2671{
2656 2672
2657 showEventEditor(); 2673 showEventEditor();
2658 mEventEditor->newEvent(fromHint,toHint,allDay); 2674 mEventEditor->newEvent(fromHint,toHint,allDay);
2659 if ( mFilterView->filtersEnabled() ) { 2675 if ( mFilterView->filtersEnabled() ) {
2660 CalFilter *filter = mFilterView->selectedFilter(); 2676 CalFilter *filter = mFilterView->selectedFilter();
2661 if (filter && filter->showCategories()) { 2677 if (filter && filter->showCategories()) {
2662 mEventEditor->setCategories(filter->categoryList().join(",") ); 2678 mEventEditor->setCategories(filter->categoryList().join(",") );
2663 } 2679 }
2664 if ( filter ) 2680 if ( filter )
2665 mEventEditor->setSecrecy( filter->getSecrecy() ); 2681 mEventEditor->setSecrecy( filter->getSecrecy() );
2666 } 2682 }
2667} 2683}
2668void CalendarView::todoAdded(Todo * t) 2684void CalendarView::todoAdded(Todo * t)
2669{ 2685{
2670 2686
2671 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2687 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2672 updateTodoViews(); 2688 updateTodoViews();
2673} 2689}
2674void CalendarView::todoChanged(Todo * t) 2690void CalendarView::todoChanged(Todo * t)
2675{ 2691{
2676 emit todoModified( t, 4 ); 2692 emit todoModified( t, 4 );
2677 // updateTodoViews(); 2693 // updateTodoViews();
2678} 2694}
2679void CalendarView::todoToBeDeleted(Todo *) 2695void CalendarView::todoToBeDeleted(Todo *)
2680{ 2696{
2681 //qDebug("todoToBeDeleted(Todo *) "); 2697 //qDebug("todoToBeDeleted(Todo *) ");
2682 updateTodoViews(); 2698 updateTodoViews();
2683} 2699}
2684void CalendarView::todoDeleted() 2700void CalendarView::todoDeleted()
2685{ 2701{
2686 //qDebug(" todoDeleted()"); 2702 //qDebug(" todoDeleted()");
2687 updateTodoViews(); 2703 updateTodoViews();
2688} 2704}
2689 2705
2690 2706
2691void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2707void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2692{ 2708{
2693 showTodoEditor(); 2709 showTodoEditor();
2694 mTodoEditor->newTodo(dt,0,allday); 2710 mTodoEditor->newTodo(dt,0,allday);
2695 if ( mFilterView->filtersEnabled() ) { 2711 if ( mFilterView->filtersEnabled() ) {
2696 CalFilter *filter = mFilterView->selectedFilter(); 2712 CalFilter *filter = mFilterView->selectedFilter();
2697 if (filter && filter->showCategories()) { 2713 if (filter && filter->showCategories()) {
2698 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2714 mTodoEditor->setCategories(filter->categoryList().join(",") );
2699 } 2715 }
2700 if ( filter ) 2716 if ( filter )
2701 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2717 mTodoEditor->setSecrecy( filter->getSecrecy() );
2702 } 2718 }
2703} 2719}
2704 2720
2705void CalendarView::newTodo() 2721void CalendarView::newTodo()
2706{ 2722{
2707 newTodoDateTime( QDateTime(),true ); 2723 newTodoDateTime( QDateTime(),true );
2708} 2724}
2709 2725
2710void CalendarView::newSubTodo() 2726void CalendarView::newSubTodo()
2711{ 2727{
2712 Todo *todo = selectedTodo(); 2728 Todo *todo = selectedTodo();
2713 if ( todo ) newSubTodo( todo ); 2729 if ( todo ) newSubTodo( todo );
2714} 2730}
2715 2731
2716void CalendarView::newSubTodo(Todo *parentEvent) 2732void CalendarView::newSubTodo(Todo *parentEvent)
2717{ 2733{
2718 2734
2719 showTodoEditor(); 2735 showTodoEditor();
2720 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2736 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2721} 2737}
2722 2738
2723void CalendarView::newFloatingEvent() 2739void CalendarView::newFloatingEvent()
2724{ 2740{
2725 DateList tmpList = mNavigator->selectedDates(); 2741 DateList tmpList = mNavigator->selectedDates();
2726 QDate date = tmpList.first(); 2742 QDate date = tmpList.first();
2727 2743
2728 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2744 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2729 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2745 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2730} 2746}
2731 2747
2732 2748
2733void CalendarView::editEvent( Event *event ) 2749void CalendarView::editEvent( Event *event )
2734{ 2750{
2735 2751
2736 if ( !event ) return; 2752 if ( !event ) return;
2737 if ( event->isReadOnly() ) { 2753 if ( event->isReadOnly() ) {
2738 showEvent( event ); 2754 showEvent( event );
2739 return; 2755 return;
2740 } 2756 }
2741 showEventEditor(); 2757 showEventEditor();
2742 mEventEditor->editEvent( event , mFlagEditDescription); 2758 mEventEditor->editEvent( event , mFlagEditDescription);
2743} 2759}
2744void CalendarView::editJournal( Journal *jour ) 2760void CalendarView::editJournal( Journal *jour )
2745{ 2761{
2746 if ( !jour ) return; 2762 if ( !jour ) return;
2747 mDialogManager->hideSearchDialog(); 2763 mDialogManager->hideSearchDialog();
2748 mViewManager->showJournalView(); 2764 mViewManager->showJournalView();
2749 mNavigator->slotDaySelect( jour->dtStart().date() ); 2765 mNavigator->slotDaySelect( jour->dtStart().date() );
2750} 2766}
2751void CalendarView::editTodo( Todo *todo ) 2767void CalendarView::editTodo( Todo *todo )
2752{ 2768{
2753 if ( !todo ) return; 2769 if ( !todo ) return;
2754 2770
2755 if ( todo->isReadOnly() ) { 2771 if ( todo->isReadOnly() ) {
2756 showTodo( todo ); 2772 showTodo( todo );
2757 return; 2773 return;
2758 } 2774 }
2759 showTodoEditor(); 2775 showTodoEditor();
2760 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2776 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2761 2777
2762} 2778}
2763 2779
2764KOEventViewerDialog* CalendarView::getEventViewerDialog() 2780KOEventViewerDialog* CalendarView::getEventViewerDialog()
2765{ 2781{
2766 if ( !mEventViewerDialog ) { 2782 if ( !mEventViewerDialog ) {
2767 mEventViewerDialog = new KOEventViewerDialog(this); 2783 mEventViewerDialog = new KOEventViewerDialog(this);
2768 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2784 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2769 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2785 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2770 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2786 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2771 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2787 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2772 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2788 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2773 viewManager(), SLOT( showAgendaView( bool ) ) ); 2789 viewManager(), SLOT( showAgendaView( bool ) ) );
2774 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2790 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2775 this, SLOT( todoChanged(Todo *) ) ); 2791 this, SLOT( todoChanged(Todo *) ) );
2776 mEventViewerDialog->resize( 640, 480 ); 2792 mEventViewerDialog->resize( 640, 480 );
2777 2793
2778 } 2794 }
2779 return mEventViewerDialog; 2795 return mEventViewerDialog;
2780} 2796}
2781void CalendarView::showEvent(Event *event) 2797void CalendarView::showEvent(Event *event)
2782{ 2798{
2783 getEventViewerDialog()->setEvent(event); 2799 getEventViewerDialog()->setEvent(event);
2784 getEventViewerDialog()->showMe(); 2800 getEventViewerDialog()->showMe();
2785} 2801}
2786 2802
2787void CalendarView::showTodo(Todo *event) 2803void CalendarView::showTodo(Todo *event)
2788{ 2804{
2789 getEventViewerDialog()->setTodo(event); 2805 getEventViewerDialog()->setTodo(event);
2790 getEventViewerDialog()->showMe(); 2806 getEventViewerDialog()->showMe();
2791} 2807}
2792void CalendarView::showJournal( Journal *jour ) 2808void CalendarView::showJournal( Journal *jour )
2793{ 2809{
2794 getEventViewerDialog()->setJournal(jour); 2810 getEventViewerDialog()->setJournal(jour);
2795 getEventViewerDialog()->showMe(); 2811 getEventViewerDialog()->showMe();
2796 2812
2797} 2813}
2798// void CalendarView::todoModified (Todo *event, int changed) 2814// void CalendarView::todoModified (Todo *event, int changed)
2799// { 2815// {
2800// // if (mDialogList.find (event) != mDialogList.end ()) { 2816// // if (mDialogList.find (event) != mDialogList.end ()) {
2801// // kdDebug() << "Todo modified and open" << endl; 2817// // kdDebug() << "Todo modified and open" << endl;
2802// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2818// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2803// // temp->modified (changed); 2819// // temp->modified (changed);
2804 2820
2805// // } 2821// // }
2806 2822
2807// mViewManager->updateView(); 2823// mViewManager->updateView();
2808// } 2824// }
2809 2825
2810void CalendarView::appointment_show() 2826void CalendarView::appointment_show()
2811{ 2827{
2812 Event *anEvent = 0; 2828 Event *anEvent = 0;
2813 2829
2814 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2830 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2815 2831
2816 if (mViewManager->currentView()->isEventView()) { 2832 if (mViewManager->currentView()->isEventView()) {
2817 if ( incidence && incidence->type() == "Event" ) { 2833 if ( incidence && incidence->type() == "Event" ) {
2818 anEvent = static_cast<Event *>(incidence); 2834 anEvent = static_cast<Event *>(incidence);
2819 } 2835 }
2820 } 2836 }
2821 2837
2822 if (!anEvent) { 2838 if (!anEvent) {
2823 KNotifyClient::beep(); 2839 KNotifyClient::beep();
2824 return; 2840 return;
2825 } 2841 }
2826 2842
2827 showEvent(anEvent); 2843 showEvent(anEvent);
2828} 2844}
2829 2845
2830void CalendarView::appointment_edit() 2846void CalendarView::appointment_edit()
2831{ 2847{
2832 Event *anEvent = 0; 2848 Event *anEvent = 0;
2833 2849
2834 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2850 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2835 2851
2836 if (mViewManager->currentView()->isEventView()) { 2852 if (mViewManager->currentView()->isEventView()) {
2837 if ( incidence && incidence->type() == "Event" ) { 2853 if ( incidence && incidence->type() == "Event" ) {
2838 anEvent = static_cast<Event *>(incidence); 2854 anEvent = static_cast<Event *>(incidence);
2839 } 2855 }
2840 } 2856 }
2841 2857
2842 if (!anEvent) { 2858 if (!anEvent) {
2843 KNotifyClient::beep(); 2859 KNotifyClient::beep();
2844 return; 2860 return;
2845 } 2861 }
2846 2862
2847 editEvent(anEvent); 2863 editEvent(anEvent);
2848} 2864}
2849 2865
2850void CalendarView::appointment_delete() 2866void CalendarView::appointment_delete()
2851{ 2867{
2852 Event *anEvent = 0; 2868 Event *anEvent = 0;
2853 2869
2854 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2870 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2855 2871
2856 if (mViewManager->currentView()->isEventView()) { 2872 if (mViewManager->currentView()->isEventView()) {
2857 if ( incidence && incidence->type() == "Event" ) { 2873 if ( incidence && incidence->type() == "Event" ) {
2858 anEvent = static_cast<Event *>(incidence); 2874 anEvent = static_cast<Event *>(incidence);
2859 } 2875 }
2860 } 2876 }
2861 2877
2862 if (!anEvent) { 2878 if (!anEvent) {
2863 KNotifyClient::beep(); 2879 KNotifyClient::beep();
2864 return; 2880 return;
2865 } 2881 }
2866 2882
2867 deleteEvent(anEvent); 2883 deleteEvent(anEvent);
2868} 2884}
2869 2885
2870void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2886void CalendarView::todo_resub( Todo * parent, Todo * sub )
2871{ 2887{
2872 if (!sub) return; 2888 if (!sub) return;
2873 if (!parent) return; 2889 if (!parent) return;
2874 if ( sub->relatedTo() ) 2890 if ( sub->relatedTo() )
2875 sub->relatedTo()->removeRelation(sub); 2891 sub->relatedTo()->removeRelation(sub);
2876 sub->setRelatedTo(parent); 2892 sub->setRelatedTo(parent);
2877 sub->setRelatedToUid(parent->uid()); 2893 sub->setRelatedToUid(parent->uid());
2878 parent->addRelation(sub); 2894 parent->addRelation(sub);
2879 sub->updated(); 2895 sub->updated();
2880 parent->updated(); 2896 parent->updated();
2881 setModified(true); 2897 setModified(true);
2882 updateView(); 2898 updateView();
2883} 2899}
2884void CalendarView::todo_unsub(Todo *anTodo ) 2900void CalendarView::todo_unsub(Todo *anTodo )
2885{ 2901{
2886 // Todo *anTodo = selectedTodo(); 2902 // Todo *anTodo = selectedTodo();
2887 if (!anTodo) return; 2903 if (!anTodo) return;
2888 if (!anTodo->relatedTo()) return; 2904 if (!anTodo->relatedTo()) return;
2889 anTodo->relatedTo()->removeRelation(anTodo); 2905 anTodo->relatedTo()->removeRelation(anTodo);
2890 anTodo->setRelatedTo(0); 2906 anTodo->setRelatedTo(0);
2891 anTodo->updated(); 2907 anTodo->updated();
2892 anTodo->setRelatedToUid(""); 2908 anTodo->setRelatedToUid("");
2893 setModified(true); 2909 setModified(true);
2894 updateView(); 2910 updateView();
2895} 2911}
2896 2912
2897void CalendarView::deleteTodo(Todo *todo) 2913void CalendarView::deleteTodo(Todo *todo)
2898{ 2914{
2899 if (!todo) { 2915 if (!todo) {
2900 KNotifyClient::beep(); 2916 KNotifyClient::beep();
2901 return; 2917 return;
2902 } 2918 }
2903 if (KOPrefs::instance()->mConfirm) { 2919 if (KOPrefs::instance()->mConfirm) {
2904 QString text = todo->summary().left(20); 2920 QString text = todo->summary().left(20);
2905 if (!todo->relations().isEmpty()) { 2921 if (!todo->relations().isEmpty()) {
2906 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2922 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2907 2923
2908 } 2924 }
2909 switch (msgItemDelete(text)) { 2925 switch (msgItemDelete(text)) {
2910 case KMessageBox::Continue: // OK 2926 case KMessageBox::Continue: // OK
2911 bool deleteT = false; 2927 bool deleteT = false;
2912 if (!todo->relations().isEmpty()) { 2928 if (!todo->relations().isEmpty()) {
2913 deleteT = removeCompletedSubTodos( todo ); 2929 deleteT = removeCompletedSubTodos( todo );
2914 } 2930 }
2915 // deleteT == true: todo already deleted in removeCompletedSubTodos 2931 // deleteT == true: todo already deleted in removeCompletedSubTodos
2916 if ( !deleteT ) { 2932 if ( !deleteT ) {
2917 checkExternalId( todo ); 2933 checkExternalId( todo );
2918 calendar()->deleteTodo(todo); 2934 calendar()->deleteTodo(todo);
2919 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2935 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2920 updateView(); 2936 updateView();
2921 } 2937 }
2922 break; 2938 break;
2923 } // switch 2939 } // switch
2924 } else { 2940 } else {
2925 checkExternalId( todo ); 2941 checkExternalId( todo );
2926 mCalendar->deleteTodo(todo); 2942 mCalendar->deleteTodo(todo);
2927 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2943 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2928 updateView(); 2944 updateView();
2929 } 2945 }
2930 2946
2931 emit updateSearchDialog(); 2947 emit updateSearchDialog();
2932} 2948}
2933void CalendarView::deleteJournal(Journal *jour) 2949void CalendarView::deleteJournal(Journal *jour)
2934{ 2950{
2935 if (!jour) { 2951 if (!jour) {
2936 KNotifyClient::beep(); 2952 KNotifyClient::beep();
2937 return; 2953 return;
2938 } 2954 }
2939 if (KOPrefs::instance()->mConfirm) { 2955 if (KOPrefs::instance()->mConfirm) {
2940 switch (msgItemDelete( jour->description().left(20))) { 2956 switch (msgItemDelete( jour->description().left(20))) {
2941 case KMessageBox::Continue: // OK 2957 case KMessageBox::Continue: // OK
2942 calendar()->deleteJournal(jour); 2958 calendar()->deleteJournal(jour);
2943 updateView(); 2959 updateView();
2944 break; 2960 break;
2945 } // switch 2961 } // switch
2946 } else { 2962 } else {
2947 calendar()->deleteJournal(jour);; 2963 calendar()->deleteJournal(jour);;
2948 updateView(); 2964 updateView();
2949 } 2965 }
2950 emit updateSearchDialog(); 2966 emit updateSearchDialog();
2951} 2967}
2952 2968
2953void CalendarView::deleteEvent(Event *anEvent) 2969void CalendarView::deleteEvent(Event *anEvent)
2954{ 2970{
2955 if (!anEvent) { 2971 if (!anEvent) {
2956 KNotifyClient::beep(); 2972 KNotifyClient::beep();
2957 return; 2973 return;
2958 } 2974 }
2959 2975
2960 if (anEvent->recurrence()->doesRecur()) { 2976 if (anEvent->recurrence()->doesRecur()) {
2961 QDate itemDate = mViewManager->currentSelectionDate(); 2977 QDate itemDate = mViewManager->currentSelectionDate();
2962 int km; 2978 int km;
2963 if (!itemDate.isValid()) { 2979 if (!itemDate.isValid()) {
2964 //kdDebug() << "Date Not Valid" << endl; 2980 //kdDebug() << "Date Not Valid" << endl;
2965 if (KOPrefs::instance()->mConfirm) { 2981 if (KOPrefs::instance()->mConfirm) {
2966 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2982 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2967 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2983 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2968 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2984 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2969 if ( km == KMessageBox::Continue ) 2985 if ( km == KMessageBox::Continue )
2970 km = KMessageBox::No; // No = all below 2986 km = KMessageBox::No; // No = all below
2971 } else 2987 } else
2972 km = KMessageBox::No; 2988 km = KMessageBox::No;
2973 } else { 2989 } else {
2974 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2990 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2975 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2991 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2976 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2992 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2977 i18n("KO/Pi Confirmation"),i18n("Current"), 2993 i18n("KO/Pi Confirmation"),i18n("Current"),
2978 i18n("All")); 2994 i18n("All"));
2979 } 2995 }
2980 switch(km) { 2996 switch(km) {
2981 2997
2982 case KMessageBox::No: // Continue // all 2998 case KMessageBox::No: // Continue // all
2983 //qDebug("KMessageBox::No "); 2999 //qDebug("KMessageBox::No ");
2984 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3000 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2985 schedule(Scheduler::Cancel,anEvent); 3001 schedule(Scheduler::Cancel,anEvent);
2986 3002
2987 checkExternalId( anEvent); 3003 checkExternalId( anEvent);
2988 mCalendar->deleteEvent(anEvent); 3004 mCalendar->deleteEvent(anEvent);
2989 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3005 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2990 break; 3006 break;
2991 3007
2992 // Disabled because it does not work 3008 // Disabled because it does not work
2993 //#if 0 3009 //#if 0
2994 case KMessageBox::Yes: // just this one 3010 case KMessageBox::Yes: // just this one
2995 //QDate qd = mNavigator->selectedDates().first(); 3011 //QDate qd = mNavigator->selectedDates().first();
2996 //if (!qd.isValid()) { 3012 //if (!qd.isValid()) {
2997 // kdDebug() << "no date selected, or invalid date" << endl; 3013 // kdDebug() << "no date selected, or invalid date" << endl;
2998 // KNotifyClient::beep(); 3014 // KNotifyClient::beep();
2999 // return; 3015 // return;
3000 //} 3016 //}
3001 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3017 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3002 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3018 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3003 anEvent->addExDate(itemDate); 3019 anEvent->addExDate(itemDate);
3004 int duration = anEvent->recurrence()->duration(); 3020 int duration = anEvent->recurrence()->duration();
3005 if ( duration > 0 ) { 3021 if ( duration > 0 ) {
3006 anEvent->recurrence()->setDuration( duration - 1 ); 3022 anEvent->recurrence()->setDuration( duration - 1 );
3007 } 3023 }
3008 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3024 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3009 } 3025 }
3010 break; 3026 break;
3011 //#endif 3027 //#endif
3012 } // switch 3028 } // switch
3013 } else { 3029 } else {
3014 if (KOPrefs::instance()->mConfirm) { 3030 if (KOPrefs::instance()->mConfirm) {
3015 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3031 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3016 i18n("\nAre you sure you want\nto delete this event?"), 3032 i18n("\nAre you sure you want\nto delete this event?"),
3017 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3033 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3018 case KMessageBox::Continue: // OK 3034 case KMessageBox::Continue: // OK
3019 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3035 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3020 schedule(Scheduler::Cancel,anEvent); 3036 schedule(Scheduler::Cancel,anEvent);
3021 checkExternalId( anEvent); 3037 checkExternalId( anEvent);
3022 mCalendar->deleteEvent(anEvent); 3038 mCalendar->deleteEvent(anEvent);
3023 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3039 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3024 break; 3040 break;
3025 } // switch 3041 } // switch
3026 } else { 3042 } else {
3027 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3043 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3028 schedule(Scheduler::Cancel,anEvent); 3044 schedule(Scheduler::Cancel,anEvent);
3029 checkExternalId( anEvent); 3045 checkExternalId( anEvent);
3030 mCalendar->deleteEvent(anEvent); 3046 mCalendar->deleteEvent(anEvent);
3031 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3047 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3032 } 3048 }
3033 } // if-else 3049 } // if-else
3034 emit updateSearchDialog(); 3050 emit updateSearchDialog();
3035} 3051}
3036 3052
3037bool CalendarView::deleteEvent(const QString &uid) 3053bool CalendarView::deleteEvent(const QString &uid)
3038{ 3054{
3039 Event *ev = mCalendar->event(uid); 3055 Event *ev = mCalendar->event(uid);
3040 if (ev) { 3056 if (ev) {
3041 deleteEvent(ev); 3057 deleteEvent(ev);
3042 return true; 3058 return true;
3043 } else { 3059 } else {
3044 return false; 3060 return false;
3045 } 3061 }
3046} 3062}
3047 3063
3048/*****************************************************************************/ 3064/*****************************************************************************/
3049 3065
3050void CalendarView::action_mail() 3066void CalendarView::action_mail()
3051{ 3067{
3052#ifndef KORG_NOMAIL 3068#ifndef KORG_NOMAIL
3053 KOMailClient mailClient; 3069 KOMailClient mailClient;
3054 3070
3055 Incidence *incidence = currentSelection(); 3071 Incidence *incidence = currentSelection();
3056 3072
3057 if (!incidence) { 3073 if (!incidence) {
3058 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3074 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3059 return; 3075 return;
3060 } 3076 }
3061 if(incidence->attendeeCount() == 0 ) { 3077 if(incidence->attendeeCount() == 0 ) {
3062 KMessageBox::sorry(this, 3078 KMessageBox::sorry(this,
3063 i18n("Can't generate mail:\nNo attendees defined.\n")); 3079 i18n("Can't generate mail:\nNo attendees defined.\n"));
3064 return; 3080 return;
3065 } 3081 }
3066 3082
3067 CalendarLocal cal_tmp; 3083 CalendarLocal cal_tmp;
3068 Event *event = 0; 3084 Event *event = 0;
3069 Event *ev = 0; 3085 Event *ev = 0;
3070 if ( incidence && incidence->type() == "Event" ) { 3086 if ( incidence && incidence->type() == "Event" ) {
3071 event = static_cast<Event *>(incidence); 3087 event = static_cast<Event *>(incidence);
3072 ev = new Event(*event); 3088 ev = new Event(*event);
3073 cal_tmp.addEvent(ev); 3089 cal_tmp.addEvent(ev);
3074 } 3090 }
3075 ICalFormat mForm(); 3091 ICalFormat mForm();
3076 QString attachment = mForm.toString( &cal_tmp ); 3092 QString attachment = mForm.toString( &cal_tmp );
3077 if (ev) delete(ev); 3093 if (ev) delete(ev);
3078 3094
3079 mailClient.mailAttendees(currentSelection(), attachment); 3095 mailClient.mailAttendees(currentSelection(), attachment);
3080 3096
3081#endif 3097#endif
3082 3098
3083#if 0 3099#if 0
3084 Event *anEvent = 0; 3100 Event *anEvent = 0;
3085 if (mViewManager->currentView()->isEventView()) { 3101 if (mViewManager->currentView()->isEventView()) {
3086 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3102 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3087 } 3103 }
3088 3104
3089 if (!anEvent) { 3105 if (!anEvent) {
3090 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3106 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3091 return; 3107 return;
3092 } 3108 }
3093 if(anEvent->attendeeCount() == 0 ) { 3109 if(anEvent->attendeeCount() == 0 ) {
3094 KMessageBox::sorry(this, 3110 KMessageBox::sorry(this,
3095 i18n("Can't generate mail:\nNo attendees defined.\n")); 3111 i18n("Can't generate mail:\nNo attendees defined.\n"));
3096 return; 3112 return;
3097 } 3113 }
3098 3114
3099 mailobject.emailEvent(anEvent); 3115 mailobject.emailEvent(anEvent);
3100#endif 3116#endif
3101} 3117}
3102 3118
3103 3119
3104void CalendarView::schedule_publish(Incidence *incidence) 3120void CalendarView::schedule_publish(Incidence *incidence)
3105{ 3121{
3106 Event *event = 0; 3122 Event *event = 0;
3107 Todo *todo = 0; 3123 Todo *todo = 0;
3108 3124
3109 if (incidence == 0) { 3125 if (incidence == 0) {
3110 incidence = mViewManager->currentView()->selectedIncidences().first(); 3126 incidence = mViewManager->currentView()->selectedIncidences().first();
3111 if (incidence == 0) { 3127 if (incidence == 0) {
3112 incidence = mTodoList->selectedIncidences().first(); 3128 incidence = mTodoList->selectedIncidences().first();
3113 } 3129 }
3114 } 3130 }
3115 if ( incidence && incidence->type() == "Event" ) { 3131 if ( incidence && incidence->type() == "Event" ) {
3116 event = static_cast<Event *>(incidence); 3132 event = static_cast<Event *>(incidence);
3117 } else { 3133 } else {
3118 if ( incidence && incidence->type() == "Todo" ) { 3134 if ( incidence && incidence->type() == "Todo" ) {
3119 todo = static_cast<Todo *>(incidence); 3135 todo = static_cast<Todo *>(incidence);
3120 } 3136 }
3121 } 3137 }
3122 3138
3123 if (!event && !todo) { 3139 if (!event && !todo) {
3124 KMessageBox::sorry(this,i18n("No event selected.")); 3140 KMessageBox::sorry(this,i18n("No event selected."));
3125 return; 3141 return;
3126 } 3142 }
3127 3143
3128 PublishDialog *publishdlg = new PublishDialog(); 3144 PublishDialog *publishdlg = new PublishDialog();
3129 if (incidence->attendeeCount()>0) { 3145 if (incidence->attendeeCount()>0) {
3130 QPtrList<Attendee> attendees = incidence->attendees(); 3146 QPtrList<Attendee> attendees = incidence->attendees();
3131 attendees.first(); 3147 attendees.first();
3132 while ( attendees.current()!=0 ) { 3148 while ( attendees.current()!=0 ) {
3133 publishdlg->addAttendee(attendees.current()); 3149 publishdlg->addAttendee(attendees.current());
3134 attendees.next(); 3150 attendees.next();
3135 } 3151 }
3136 } 3152 }
3137 bool send = true; 3153 bool send = true;
3138 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3154 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3139 if ( publishdlg->exec() != QDialog::Accepted ) 3155 if ( publishdlg->exec() != QDialog::Accepted )
3140 send = false; 3156 send = false;
3141 } 3157 }
3142 if ( send ) { 3158 if ( send ) {
3143 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3159 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3144 if ( event ) { 3160 if ( event ) {
3145 Event *ev = new Event(*event); 3161 Event *ev = new Event(*event);
3146 ev->registerObserver(0); 3162 ev->registerObserver(0);
3147 ev->clearAttendees(); 3163 ev->clearAttendees();
3148 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3164 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3149 delete(ev); 3165 delete(ev);
3150 } 3166 }
3151 } else { 3167 } else {
3152 if ( todo ) { 3168 if ( todo ) {
3153 Todo *ev = new Todo(*todo); 3169 Todo *ev = new Todo(*todo);
3154 ev->registerObserver(0); 3170 ev->registerObserver(0);
3155 ev->clearAttendees(); 3171 ev->clearAttendees();
3156 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3172 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3157 delete(ev); 3173 delete(ev);
3158 } 3174 }
3159 } 3175 }
3160 } 3176 }
3161 } 3177 }
3162 delete publishdlg; 3178 delete publishdlg;
3163} 3179}
3164 3180
3165void CalendarView::schedule_request(Incidence *incidence) 3181void CalendarView::schedule_request(Incidence *incidence)
3166{ 3182{
3167 schedule(Scheduler::Request,incidence); 3183 schedule(Scheduler::Request,incidence);
3168} 3184}
3169 3185
3170void CalendarView::schedule_refresh(Incidence *incidence) 3186void CalendarView::schedule_refresh(Incidence *incidence)
3171{ 3187{
3172 schedule(Scheduler::Refresh,incidence); 3188 schedule(Scheduler::Refresh,incidence);
3173} 3189}
3174 3190
3175void CalendarView::schedule_cancel(Incidence *incidence) 3191void CalendarView::schedule_cancel(Incidence *incidence)
3176{ 3192{
3177 schedule(Scheduler::Cancel,incidence); 3193 schedule(Scheduler::Cancel,incidence);
3178} 3194}
3179 3195
3180void CalendarView::schedule_add(Incidence *incidence) 3196void CalendarView::schedule_add(Incidence *incidence)
3181{ 3197{
3182 schedule(Scheduler::Add,incidence); 3198 schedule(Scheduler::Add,incidence);
3183} 3199}
3184 3200
3185void CalendarView::schedule_reply(Incidence *incidence) 3201void CalendarView::schedule_reply(Incidence *incidence)
3186{ 3202{
3187 schedule(Scheduler::Reply,incidence); 3203 schedule(Scheduler::Reply,incidence);
3188} 3204}
3189 3205
3190void CalendarView::schedule_counter(Incidence *incidence) 3206void CalendarView::schedule_counter(Incidence *incidence)
3191{ 3207{
3192 schedule(Scheduler::Counter,incidence); 3208 schedule(Scheduler::Counter,incidence);
3193} 3209}
3194 3210
3195void CalendarView::schedule_declinecounter(Incidence *incidence) 3211void CalendarView::schedule_declinecounter(Incidence *incidence)
3196{ 3212{
3197 schedule(Scheduler::Declinecounter,incidence); 3213 schedule(Scheduler::Declinecounter,incidence);
3198} 3214}
3199 3215
3200void CalendarView::schedule_publish_freebusy(int daysToPublish) 3216void CalendarView::schedule_publish_freebusy(int daysToPublish)
3201{ 3217{
3202 QDateTime start = QDateTime::currentDateTime(); 3218 QDateTime start = QDateTime::currentDateTime();
3203 QDateTime end = start.addDays(daysToPublish); 3219 QDateTime end = start.addDays(daysToPublish);
3204 3220
3205 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3221 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3206 freebusy->setOrganizer(KOPrefs::instance()->email()); 3222 freebusy->setOrganizer(KOPrefs::instance()->email());
3207 3223
3208 3224
3209 PublishDialog *publishdlg = new PublishDialog(); 3225 PublishDialog *publishdlg = new PublishDialog();
3210 if ( publishdlg->exec() == QDialog::Accepted ) { 3226 if ( publishdlg->exec() == QDialog::Accepted ) {
3211 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3227 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3212 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3228 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3213 delete(freebusy); 3229 delete(freebusy);
3214 } 3230 }
3215 } 3231 }
3216 delete publishdlg; 3232 delete publishdlg;
3217} 3233}
3218 3234
3219void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3235void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3220{ 3236{
3221 Event *event = 0; 3237 Event *event = 0;
3222 Todo *todo = 0; 3238 Todo *todo = 0;
3223 3239
3224 if (incidence == 0) { 3240 if (incidence == 0) {
3225 incidence = mViewManager->currentView()->selectedIncidences().first(); 3241 incidence = mViewManager->currentView()->selectedIncidences().first();
3226 if (incidence == 0) { 3242 if (incidence == 0) {
3227 incidence = mTodoList->selectedIncidences().first(); 3243 incidence = mTodoList->selectedIncidences().first();
3228 } 3244 }
3229 } 3245 }
3230 if ( incidence && incidence->type() == "Event" ) { 3246 if ( incidence && incidence->type() == "Event" ) {
3231 event = static_cast<Event *>(incidence); 3247 event = static_cast<Event *>(incidence);
3232 } 3248 }
3233 if ( incidence && incidence->type() == "Todo" ) { 3249 if ( incidence && incidence->type() == "Todo" ) {
3234 todo = static_cast<Todo *>(incidence); 3250 todo = static_cast<Todo *>(incidence);
3235 } 3251 }
3236 3252
3237 if (!event && !todo) { 3253 if (!event && !todo) {
3238 KMessageBox::sorry(this,i18n("No event selected.")); 3254 KMessageBox::sorry(this,i18n("No event selected."));
3239 return; 3255 return;
3240 } 3256 }
3241 3257
3242 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3258 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3243 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3259 KMessageBox::sorry(this,i18n("The event has no attendees."));
3244 return; 3260 return;
3245 } 3261 }
3246 3262
3247 Event *ev = 0; 3263 Event *ev = 0;
3248 if (event) ev = new Event(*event); 3264 if (event) ev = new Event(*event);
3249 Todo *to = 0; 3265 Todo *to = 0;
3250 if (todo) to = new Todo(*todo); 3266 if (todo) to = new Todo(*todo);
3251 3267
3252 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3268 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3253 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3269 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3254 if (!me) { 3270 if (!me) {
3255 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3271 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3256 return; 3272 return;
3257 } 3273 }
3258 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3274 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3259 StatusDialog *statdlg = new StatusDialog(this); 3275 StatusDialog *statdlg = new StatusDialog(this);
3260 if (!statdlg->exec()==QDialog::Accepted) return; 3276 if (!statdlg->exec()==QDialog::Accepted) return;
3261 me->setStatus( statdlg->status() ); 3277 me->setStatus( statdlg->status() );
3262 delete(statdlg); 3278 delete(statdlg);
3263 } 3279 }
3264 Attendee *menew = new Attendee(*me); 3280 Attendee *menew = new Attendee(*me);
3265 if (ev) { 3281 if (ev) {
3266 ev->clearAttendees(); 3282 ev->clearAttendees();
3267 ev->addAttendee(menew,false); 3283 ev->addAttendee(menew,false);
3268 } else { 3284 } else {
3269 if (to) { 3285 if (to) {
3270 todo->clearAttendees(); 3286 todo->clearAttendees();
3271 todo->addAttendee(menew,false); 3287 todo->addAttendee(menew,false);
3272 } 3288 }
3273 } 3289 }
3274 } 3290 }
3275 3291
3276 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3292 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3277 if (ev) { 3293 if (ev) {
3278 if ( !dlg->addMessage(ev,method) ) delete(ev); 3294 if ( !dlg->addMessage(ev,method) ) delete(ev);
3279 } else { 3295 } else {
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 6ea8287..8d7ff36 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,613 +1,615 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar; 60class NavigatorBar;
61class KOEventEditor; 61class KOEventEditor;
62class KOTodoEditor ; 62class KOTodoEditor ;
63class KOEventViewerDialog; 63class KOEventViewerDialog;
64class KOBeamPrefs; 64class KOBeamPrefs;
65class KSyncProfile; 65class KSyncProfile;
66class AlarmDialog; 66class AlarmDialog;
67class KCal::Attendee; 67class KCal::Attendee;
68 68
69namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
70 70
71using namespace KCal; 71using namespace KCal;
72 72
73/** 73/**
74 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 77 event editor, search dialog etc.
78 78
79 @short main calendar view widget 79 @short main calendar view widget
80 @author Cornelius Schumacher 80 @author Cornelius Schumacher
81*/ 81*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 void save ();
121 void saveStopTimer ();
120 void tempDisableBR(bool); 122 void tempDisableBR(bool);
121 /** This todo has been modified */ 123 /** This todo has been modified */
122 void todoModified(Todo *, int); 124 void todoModified(Todo *, int);
123 125
124 /** when change is made to options dialog, the topwidget will catch this 126 /** when change is made to options dialog, the topwidget will catch this
125 * and emit this signal which notifies all widgets which have registered 127 * and emit this signal which notifies all widgets which have registered
126 * for notification to update their settings. */ 128 * for notification to update their settings. */
127 void configChanged(); 129 void configChanged();
128 /** emitted when the topwidget is closing down, so that any attached 130 /** emitted when the topwidget is closing down, so that any attached
129 child windows can also close. */ 131 child windows can also close. */
130 void closingDown(); 132 void closingDown();
131 /** emitted right before we die */ 133 /** emitted right before we die */
132 void closed(QWidget *); 134 void closed(QWidget *);
133 135
134 /** Emitted when state of modified flag changes */ 136 /** Emitted when state of modified flag changes */
135 void modifiedChanged(bool); 137 void modifiedChanged(bool);
136 void signalmodified(); 138 void signalmodified();
137 139
138 /** Emitted when state of read-only flag changes */ 140 /** Emitted when state of read-only flag changes */
139 void readOnlyChanged(bool); 141 void readOnlyChanged(bool);
140 142
141 /** Emitted when the unit of navigation changes */ 143 /** Emitted when the unit of navigation changes */
142 void changeNavStringPrev(const QString &); 144 void changeNavStringPrev(const QString &);
143 void changeNavStringNext(const QString &); 145 void changeNavStringNext(const QString &);
144 146
145 /** Emitted when state of events selection has changed and user is organizer*/ 147 /** Emitted when state of events selection has changed and user is organizer*/
146 void organizerEventsSelected(bool); 148 void organizerEventsSelected(bool);
147 /** Emitted when state of events selection has changed and user is attendee*/ 149 /** Emitted when state of events selection has changed and user is attendee*/
148 void groupEventsSelected(bool); 150 void groupEventsSelected(bool);
149 /** 151 /**
150 Emitted when an incidence gets selected. If the selection is cleared the 152 Emitted when an incidence gets selected. If the selection is cleared the
151 signal is emitted with 0 as argument. 153 signal is emitted with 0 as argument.
152 */ 154 */
153 void incidenceSelected( Incidence * ); 155 void incidenceSelected( Incidence * );
154 /** Emitted, when a todoitem is selected or deselected. */ 156 /** Emitted, when a todoitem is selected or deselected. */
155 void todoSelected( bool ); 157 void todoSelected( bool );
156 158
157 /** 159 /**
158 Emitted, when clipboard content changes. Parameter indicates if paste 160 Emitted, when clipboard content changes. Parameter indicates if paste
159 is possible or not. 161 is possible or not.
160 */ 162 */
161 void pasteEnabled(bool); 163 void pasteEnabled(bool);
162 164
163 /** Emitted, when the number of incoming messages has changed. */ 165 /** Emitted, when the number of incoming messages has changed. */
164 void numIncomingChanged(int); 166 void numIncomingChanged(int);
165 167
166 /** Emitted, when the number of outgoing messages has changed. */ 168 /** Emitted, when the number of outgoing messages has changed. */
167 void numOutgoingChanged(int); 169 void numOutgoingChanged(int);
168 170
169 /** Send status message, which can e.g. be displayed in the status bar. */ 171 /** Send status message, which can e.g. be displayed in the status bar. */
170 void statusMessage(const QString &); 172 void statusMessage(const QString &);
171 173
172 void calendarViewExpanded( bool ); 174 void calendarViewExpanded( bool );
173 void updateSearchDialog(); 175 void updateSearchDialog();
174 176
175 177
176 public slots: 178 public slots:
177 void showNavigatorBar(bool); 179 void showNavigatorBar(bool);
178 void showOpenError(); 180 void showOpenError();
179 void watchSavedFile(); 181 void watchSavedFile();
180 void recheckTimerAlarm(); 182 void recheckTimerAlarm();
181 void checkNextTimerAlarm(); 183 void checkNextTimerAlarm();
182 void addAlarm(const QDateTime &qdt, const QString &noti ); 184 void addAlarm(const QDateTime &qdt, const QString &noti );
183 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 185 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
184 void removeAlarm(const QDateTime &qdt, const QString &noti ); 186 void removeAlarm(const QDateTime &qdt, const QString &noti );
185 187
186 /** options dialog made a changed to the configuration. we catch this 188 /** options dialog made a changed to the configuration. we catch this
187 * and notify all widgets which need to update their configuration. */ 189 * and notify all widgets which need to update their configuration. */
188 void updateConfig(); 190 void updateConfig();
189 191
190 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 192 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
191 const QStringList& anniversaryList, const QStringList& realNameList, 193 const QStringList& anniversaryList, const QStringList& realNameList,
192 const QStringList& emailList, const QStringList& assembledNameList, 194 const QStringList& emailList, const QStringList& assembledNameList,
193 const QStringList& uidList); 195 const QStringList& uidList);
194 196
195 /** 197 /**
196 Load calendar from file \a filename. If \a merge is true, load 198 Load calendar from file \a filename. If \a merge is true, load
197 calendar into existing one, if it is false, clear calendar, before 199 calendar into existing one, if it is false, clear calendar, before
198 loading. Return true, if calendar could be successfully loaded. 200 loading. Return true, if calendar could be successfully loaded.
199 */ 201 */
200 bool openCalendar(QString filename, bool merge=false); 202 bool openCalendar(QString filename, bool merge=false);
201 bool syncCalendar(QString filename,int mode = 0 ); 203 bool syncCalendar(QString filename,int mode = 0 );
202 204
203 /** 205 /**
204 Save calendar data to file. Return true if calendar could be 206 Save calendar data to file. Return true if calendar could be
205 successfully saved. 207 successfully saved.
206 */ 208 */
207 bool saveCalendar(QString filename); 209 bool saveCalendar(QString filename);
208 210
209 /** 211 /**
210 Close calendar. Clear calendar data and reset views to display an empty 212 Close calendar. Clear calendar data and reset views to display an empty
211 calendar. 213 calendar.
212 */ 214 */
213 void closeCalendar(); 215 void closeCalendar();
214 216
215 /** Archive old events of calendar */ 217 /** Archive old events of calendar */
216 void archiveCalendar(); 218 void archiveCalendar();
217 219
218 void showIncidence(); 220 void showIncidence();
219 void editIncidence(); 221 void editIncidence();
220 void editIncidenceDescription(); 222 void editIncidenceDescription();
221 void deleteIncidence(); 223 void deleteIncidence();
222 void cloneIncidence(); 224 void cloneIncidence();
223 void moveIncidence(); 225 void moveIncidence();
224 void beamIncidence(); 226 void beamIncidence();
225 void toggleCancelIncidence(); 227 void toggleCancelIncidence();
226 228
227 /** create an editeventwin with supplied date/time, and if bool is true, 229 /** create an editeventwin with supplied date/time, and if bool is true,
228 * make the event take all day. */ 230 * make the event take all day. */
229 void newEvent(QDateTime, QDateTime, bool allDay ); 231 void newEvent(QDateTime, QDateTime, bool allDay );
230 void newEvent(QDateTime, QDateTime); 232 void newEvent(QDateTime, QDateTime);
231 void newEvent(QDateTime fh); 233 void newEvent(QDateTime fh);
232 void newEvent(QDate dt); 234 void newEvent(QDate dt);
233 /** create new event without having a date hint. Takes current date as 235 /** create new event without having a date hint. Takes current date as
234 default hint. */ 236 default hint. */
235 void newEvent(); 237 void newEvent();
236 void newFloatingEvent(); 238 void newFloatingEvent();
237 239
238 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 240 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
239 void showIncidence(Incidence *); 241 void showIncidence(Incidence *);
240 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 242 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
241 void editIncidence(Incidence *); 243 void editIncidence(Incidence *);
242 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 244 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
243 void deleteIncidence(Incidence *); 245 void deleteIncidence(Incidence *);
244 void cloneIncidence(Incidence *); 246 void cloneIncidence(Incidence *);
245 void cancelIncidence(Incidence *); 247 void cancelIncidence(Incidence *);
246 /** Create an editor for the supplied event. */ 248 /** Create an editor for the supplied event. */
247 void editEvent(Event *); 249 void editEvent(Event *);
248 /** Delete the supplied event. */ 250 /** Delete the supplied event. */
249 void deleteEvent(Event *); 251 void deleteEvent(Event *);
250 /** Delete the event with the given unique ID. Returns false, if event wasn't 252 /** Delete the event with the given unique ID. Returns false, if event wasn't
251 found. */ 253 found. */
252 bool deleteEvent(const QString &uid); 254 bool deleteEvent(const QString &uid);
253 /** Create a read-only viewer dialog for the supplied event. */ 255 /** Create a read-only viewer dialog for the supplied event. */
254 void showEvent(Event *); 256 void showEvent(Event *);
255 257
256 void editJournal(Journal *); 258 void editJournal(Journal *);
257 void showJournal(Journal *); 259 void showJournal(Journal *);
258 void deleteJournal(Journal *); 260 void deleteJournal(Journal *);
259 /** Create an editor dialog for a todo */ 261 /** Create an editor dialog for a todo */
260 void editTodo(Todo *); 262 void editTodo(Todo *);
261 /** Create a read-only viewer dialog for the supplied todo */ 263 /** Create a read-only viewer dialog for the supplied todo */
262 void showTodo(Todo *); 264 void showTodo(Todo *);
263 /** create new todo */ 265 /** create new todo */
264 void newTodo(); 266 void newTodo();
265 void newTodoDateTime(QDateTime, bool allday); 267 void newTodoDateTime(QDateTime, bool allday);
266 /** create new todo with a parent todo */ 268 /** create new todo with a parent todo */
267 void newSubTodo(); 269 void newSubTodo();
268 /** create new todo with a parent todo */ 270 /** create new todo with a parent todo */
269 void newSubTodo(Todo *); 271 void newSubTodo(Todo *);
270 /** Delete todo */ 272 /** Delete todo */
271 void deleteTodo(Todo *); 273 void deleteTodo(Todo *);
272 274
273 275
274 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 276 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
275 * emitted as result. */ 277 * emitted as result. */
276 void checkClipboard(); 278 void checkClipboard();
277 279
278 /** using the KConfig associated with the kapp variable, read in the 280 /** using the KConfig associated with the kapp variable, read in the
279 * settings from the config file. 281 * settings from the config file.
280 */ 282 */
281 void readSettings(); 283 void readSettings();
282 284
283 /** write current state to config file. */ 285 /** write current state to config file. */
284 void writeSettings(); 286 void writeSettings();
285 287
286 /** read settings for calendar filters */ 288 /** read settings for calendar filters */
287 void readFilterSettings(KConfig *config); 289 void readFilterSettings(KConfig *config);
288 290
289 /** write settings for calendar filters */ 291 /** write settings for calendar filters */
290 void writeFilterSettings(KConfig *config); 292 void writeFilterSettings(KConfig *config);
291 293
292 /** passes on the message that an event has changed to the currently 294 /** passes on the message that an event has changed to the currently
293 * activated view so that it can make appropriate display changes. */ 295 * activated view so that it can make appropriate display changes. */
294 void changeEventDisplay(Event *, int); 296 void changeEventDisplay(Event *, int);
295 void changeIncidenceDisplay(Incidence *, int); 297 void changeIncidenceDisplay(Incidence *, int);
296 void changeTodoDisplay(Todo *, int); 298 void changeTodoDisplay(Todo *, int);
297 299
298 void eventAdded(Event *); 300 void eventAdded(Event *);
299 void eventChanged(Event *); 301 void eventChanged(Event *);
300 void eventToBeDeleted(Event *); 302 void eventToBeDeleted(Event *);
301 void eventDeleted(); 303 void eventDeleted();
302 304
303 void todoAdded(Todo *); 305 void todoAdded(Todo *);
304 void todoChanged(Todo *); 306 void todoChanged(Todo *);
305 void todoToBeDeleted(Todo *); 307 void todoToBeDeleted(Todo *);
306 void todoDeleted(); 308 void todoDeleted();
307 309
308 void updateView(const QDate &start, const QDate &end); 310 void updateView(const QDate &start, const QDate &end);
309 void updateView(); 311 void updateView();
310 312
311 /** Full update of visible todo views */ 313 /** Full update of visible todo views */
312 void updateTodoViews(); 314 void updateTodoViews();
313 315
314 void updateUnmanagedViews(); 316 void updateUnmanagedViews();
315 317
316 /** cut the current appointment to the clipboard */ 318 /** cut the current appointment to the clipboard */
317 void edit_cut(); 319 void edit_cut();
318 320
319 /** copy the current appointment(s) to the clipboard */ 321 /** copy the current appointment(s) to the clipboard */
320 void edit_copy(); 322 void edit_copy();
321 323
322 /** paste the current vobject(s) in the clipboard buffer into calendar */ 324 /** paste the current vobject(s) in the clipboard buffer into calendar */
323 void edit_paste(); 325 void edit_paste();
324 326
325 /** edit viewing and configuration options. */ 327 /** edit viewing and configuration options. */
326 void edit_options(); 328 void edit_options();
327 /** 329 /**
328 Functions for printing, previewing a print, and setting up printing 330 Functions for printing, previewing a print, and setting up printing
329 parameters. 331 parameters.
330 */ 332 */
331 void print(); 333 void print();
332 void printSetup(); 334 void printSetup();
333 void printPreview(); 335 void printPreview();
334 336
335 /** Export as iCalendar file */ 337 /** Export as iCalendar file */
336 void exportICalendar(); 338 void exportICalendar();
337 339
338 /** Export as vCalendar file */ 340 /** Export as vCalendar file */
339 bool exportVCalendar( QString fn); 341 bool exportVCalendar( QString fn);
340 342
341 /** pop up a dialog to show an existing appointment. */ 343 /** pop up a dialog to show an existing appointment. */
342 void appointment_show(); 344 void appointment_show();
343 /** 345 /**
344 * pop up an Appointment Dialog to edit an existing appointment.Get 346 * pop up an Appointment Dialog to edit an existing appointment.Get
345 * information on the appointment from the list of unique IDs that is 347 * information on the appointment from the list of unique IDs that is
346 * currently in the View, called currIds. 348 * currently in the View, called currIds.
347 */ 349 */
348 void appointment_edit(); 350 void appointment_edit();
349 /** 351 /**
350 * pop up dialog confirming deletion of currently selected event in the 352 * pop up dialog confirming deletion of currently selected event in the
351 * View. 353 * View.
352 */ 354 */
353 void appointment_delete(); 355 void appointment_delete();
354 356
355 /** mails the currently selected event to a particular user as a vCalendar 357 /** mails the currently selected event to a particular user as a vCalendar
356 attachment. */ 358 attachment. */
357 void action_mail(); 359 void action_mail();
358 360
359 /* frees a subtodo from it's relation */ 361 /* frees a subtodo from it's relation */
360 void todo_unsub( Todo * ); 362 void todo_unsub( Todo * );
361 void todo_resub( Todo * parent, Todo * sub ); 363 void todo_resub( Todo * parent, Todo * sub );
362 364
363 /** Take ownership of selected event. */ 365 /** Take ownership of selected event. */
364 void takeOverEvent(); 366 void takeOverEvent();
365 367
366 /** Take ownership of all events in calendar. */ 368 /** Take ownership of all events in calendar. */
367 void takeOverCalendar(); 369 void takeOverCalendar();
368 370
369 /** query whether or not the calendar is "dirty". */ 371 /** query whether or not the calendar is "dirty". */
370 bool isModified(); 372 bool isModified();
371 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 373 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
372 void setModified(bool modified=true); 374 void setModified(bool modified=true);
373 375
374 /** query if the calendar is read-only. */ 376 /** query if the calendar is read-only. */
375 bool isReadOnly(); 377 bool isReadOnly();
376 /** set state of calendar to read-only */ 378 /** set state of calendar to read-only */
377 void setReadOnly(bool readOnly=true); 379 void setReadOnly(bool readOnly=true);
378 380
379 void eventUpdated(Incidence *); 381 void eventUpdated(Incidence *);
380 382
381 /* iTIP scheduling actions */ 383 /* iTIP scheduling actions */
382 void schedule_publish(Incidence *incidence = 0); 384 void schedule_publish(Incidence *incidence = 0);
383 void schedule_request(Incidence *incidence = 0); 385 void schedule_request(Incidence *incidence = 0);
384 void schedule_refresh(Incidence *incidence = 0); 386 void schedule_refresh(Incidence *incidence = 0);
385 void schedule_cancel(Incidence *incidence = 0); 387 void schedule_cancel(Incidence *incidence = 0);
386 void schedule_add(Incidence *incidence = 0); 388 void schedule_add(Incidence *incidence = 0);
387 void schedule_reply(Incidence *incidence = 0); 389 void schedule_reply(Incidence *incidence = 0);
388 void schedule_counter(Incidence *incidence = 0); 390 void schedule_counter(Incidence *incidence = 0);
389 void schedule_declinecounter(Incidence *incidence = 0); 391 void schedule_declinecounter(Incidence *incidence = 0);
390 void schedule_publish_freebusy(int daysToPublish = 30); 392 void schedule_publish_freebusy(int daysToPublish = 30);
391 393
392 void openAddressbook(); 394 void openAddressbook();
393 395
394 void editFilters(); 396 void editFilters();
395 void toggleFilerEnabled(); 397 void toggleFilerEnabled();
396 QPtrList<CalFilter> filters(); 398 QPtrList<CalFilter> filters();
397 void toggleFilter(); 399 void toggleFilter();
398 void showFilter(bool visible); 400 void showFilter(bool visible);
399 void updateFilter(); 401 void updateFilter();
400 void filterEdited(); 402 void filterEdited();
401 void selectFilter( int ); 403 void selectFilter( int );
402 KOFilterView *filterView(); 404 KOFilterView *filterView();
403 405
404 void showIntro(); 406 void showIntro();
405 407
406 /** Move the curdatepient view date to today */ 408 /** Move the curdatepient view date to today */
407 void goToday(); 409 void goToday();
408 410
409 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
410 void goNext(); 412 void goNext();
411 413
412 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
413 void goPrevious(); 415 void goPrevious();
414 /** Move to the next date(s) in the current view */ 416 /** Move to the next date(s) in the current view */
415 void goNextMonth(); 417 void goNextMonth();
416 418
417 /** Move to the previous date(s) in the current view */ 419 /** Move to the previous date(s) in the current view */
418 void goPreviousMonth(); 420 void goPreviousMonth();
419 421
420 void toggleExpand(); 422 void toggleExpand();
421 void toggleDateNavigatorWidget(); 423 void toggleDateNavigatorWidget();
422 void toggleAllDaySize(); 424 void toggleAllDaySize();
423 void dialogClosing(Incidence *); 425 void dialogClosing(Incidence *);
424 426
425 /** Look for new messages in the inbox */ 427 /** Look for new messages in the inbox */
426 void lookForIncomingMessages(); 428 void lookForIncomingMessages();
427 /** Look for new messages in the outbox */ 429 /** Look for new messages in the outbox */
428 void lookForOutgoingMessages(); 430 void lookForOutgoingMessages();
429 431
430 void processMainViewSelection( Incidence * ); 432 void processMainViewSelection( Incidence * );
431 void processTodoListSelection( Incidence * ); 433 void processTodoListSelection( Incidence * );
432 434
433 void processIncidenceSelection( Incidence * ); 435 void processIncidenceSelection( Incidence * );
434 436
435 void purgeCompleted(); 437 void purgeCompleted();
436 bool removeCompletedSubTodos( Todo* ); 438 bool removeCompletedSubTodos( Todo* );
437 void slotCalendarChanged(); 439 void slotCalendarChanged();
438 bool importBday(); 440 bool importBday();
439 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 441 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
440 bool importQtopia( const QString &categoriesFile, 442 bool importQtopia( const QString &categoriesFile,
441 const QString &datebookFile, 443 const QString &datebookFile,
442 const QString &tasklistFile ); 444 const QString &tasklistFile );
443 void syncExternal( int mode ); 445 void syncExternal( int mode );
444 void slotSelectPickerDate( QDate ) ; 446 void slotSelectPickerDate( QDate ) ;
445 void showDatePicker( ) ; 447 void showDatePicker( ) ;
446 void moveIncidence(Incidence *) ; 448 void moveIncidence(Incidence *) ;
447 void beamIncidence(Incidence *) ; 449 void beamIncidence(Incidence *) ;
448 void beamCalendar() ; 450 void beamCalendar() ;
449 void beamFilteredCalendar() ; 451 void beamFilteredCalendar() ;
450 void beamIncidenceList(QPtrList<Incidence>) ; 452 void beamIncidenceList(QPtrList<Incidence>) ;
451 void manageCategories(); 453 void manageCategories();
452 int addCategories(); 454 int addCategories();
453 void removeCategories(); 455 void removeCategories();
454 void setSyncDevice( QString ); 456 void setSyncDevice( QString );
455 void setSyncName( QString ); 457 void setSyncName( QString );
456 void showDay( QDate ); 458 void showDay( QDate );
457 void undo_delete(); 459 void undo_delete();
458 protected slots: 460 protected slots:
459 void timerAlarm(); 461 void timerAlarm();
460 void suspendAlarm(); 462 void suspendAlarm();
461 void beamDone( Ir *ir ); 463 void beamDone( Ir *ir );
462 /** Select a view or adapt the current view to display the specified dates. */ 464 /** Select a view or adapt the current view to display the specified dates. */
463 void showDates( const KCal::DateList & ); 465 void showDates( const KCal::DateList & );
464 void selectWeekNum ( int ); 466 void selectWeekNum ( int );
465 467
466 public: 468 public:
467 // show a standard warning 469 // show a standard warning
468 // returns KMsgBox::yesNoCancel() 470 // returns KMsgBox::yesNoCancel()
469 int msgCalModified(); 471 int msgCalModified();
470 virtual bool sync(KSyncManager* manager, QString filename, int mode); 472 virtual bool sync(KSyncManager* manager, QString filename, int mode);
471 473
472 virtual bool syncExternal(KSyncManager* manager, QString resource); 474 virtual bool syncExternal(KSyncManager* manager, QString resource);
473 virtual void removeSyncInfo( QString syncProfile); 475 virtual void removeSyncInfo( QString syncProfile);
474 void setSyncManager(KSyncManager* manager); 476 void setSyncManager(KSyncManager* manager);
475 void setLoadedFileVersion(QDateTime); 477 void setLoadedFileVersion(QDateTime);
476 bool checkFileVersion(QString fn); 478 bool checkFileVersion(QString fn);
477 bool checkFileChanged(QString fn); 479 bool checkFileChanged(QString fn);
478 Event* getLastSyncEvent(); 480 Event* getLastSyncEvent();
479 /** Adapt navigation units correpsonding to step size of navigation of the 481 /** Adapt navigation units correpsonding to step size of navigation of the
480 * current view. 482 * current view.
481 */ 483 */
482 void adaptNavigationUnits(); 484 void adaptNavigationUnits();
483 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 485 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
484 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 486 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
485 //Attendee* getYourAttendee(Event *event); 487 //Attendee* getYourAttendee(Event *event);
486 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 488 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
487 protected: 489 protected:
488 void schedule(Scheduler::Method, Incidence *incidence = 0); 490 void schedule(Scheduler::Method, Incidence *incidence = 0);
489 491
490 // returns KMsgBox::OKCandel() 492 // returns KMsgBox::OKCandel()
491 int msgItemDelete(const QString name); 493 int msgItemDelete(const QString name);
492 void showEventEditor(); 494 void showEventEditor();
493 void showTodoEditor(); 495 void showTodoEditor();
494 void writeLocale(); 496 void writeLocale();
495 Todo *selectedTodo(); 497 Todo *selectedTodo();
496 498
497 private: 499 private:
498 bool mBlockShowDates; 500 bool mBlockShowDates;
499 KSyncManager* mSyncManager; 501 KSyncManager* mSyncManager;
500 AlarmDialog * mAlarmDialog; 502 AlarmDialog * mAlarmDialog;
501 QString mAlarmNotification; 503 QString mAlarmNotification;
502 QString mSuspendAlarmNotification; 504 QString mSuspendAlarmNotification;
503 QTimer* mSuspendTimer; 505 QTimer* mSuspendTimer;
504 QTimer* mAlarmTimer; 506 QTimer* mAlarmTimer;
505 QTimer* mRecheckAlarmTimer; 507 QTimer* mRecheckAlarmTimer;
506 void computeAlarm( QString ); 508 void computeAlarm( QString );
507 void startAlarm( QString, QString ); 509 void startAlarm( QString, QString );
508 void setSyncEventsReadOnly(); 510 void setSyncEventsReadOnly();
509 511
510 QDateTime loadedFileVersion; 512 QDateTime loadedFileVersion;
511 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 513 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
512 void checkExternalId( Incidence * inc ); 514 void checkExternalId( Incidence * inc );
513 int mGlobalSyncMode; 515 int mGlobalSyncMode;
514 QString mCurrentSyncDevice; 516 QString mCurrentSyncDevice;
515 QString mCurrentSyncName; 517 QString mCurrentSyncName;
516 KOBeamPrefs* beamDialog; 518 KOBeamPrefs* beamDialog;
517 void init(); 519 void init();
518 int mDatePickerMode; 520 int mDatePickerMode;
519 bool mFlagEditDescription; 521 bool mFlagEditDescription;
520 QDateTime mLastCalendarSync; 522 QDateTime mLastCalendarSync;
521 void createPrinter(); 523 void createPrinter();
522 524
523 void calendarModified( bool, Calendar * ); 525 void calendarModified( bool, Calendar * );
524 526
525 CalPrinter *mCalPrinter; 527 CalPrinter *mCalPrinter;
526 528
527 QSplitter *mPanner; 529 QSplitter *mPanner;
528 QSplitter *mLeftSplitter; 530 QSplitter *mLeftSplitter;
529 QWidget *mLeftFrame; 531 QWidget *mLeftFrame;
530 QWidgetStack *mRightFrame; 532 QWidgetStack *mRightFrame;
531 533
532 KDatePicker* mDatePicker; 534 KDatePicker* mDatePicker;
533 QVBox* mDateFrame; 535 QVBox* mDateFrame;
534 NavigatorBar *mNavigatorBar; 536 NavigatorBar *mNavigatorBar;
535 537
536 KDateNavigator *mDateNavigator; // widget showing small month view. 538 KDateNavigator *mDateNavigator; // widget showing small month view.
537 539
538 KOFilterView *mFilterView; 540 KOFilterView *mFilterView;
539 541
540 ResourceView *mResourceView; 542 ResourceView *mResourceView;
541 543
542 // calendar object for this viewing instance 544 // calendar object for this viewing instance
543 Calendar *mCalendar; 545 Calendar *mCalendar;
544 546
545 CalendarResourceManager *mResourceManager; 547 CalendarResourceManager *mResourceManager;
546 548
547 FileStorage *mStorage; 549 FileStorage *mStorage;
548 550
549 DateNavigator *mNavigator; 551 DateNavigator *mNavigator;
550 552
551 KOViewManager *mViewManager; 553 KOViewManager *mViewManager;
552 KODialogManager *mDialogManager; 554 KODialogManager *mDialogManager;
553 555
554 // Calendar filters 556 // Calendar filters
555 QPtrList<CalFilter> mFilters; 557 QPtrList<CalFilter> mFilters;
556 558
557 // various housekeeping variables. 559 // various housekeeping variables.
558 bool mModified; // flag indicating if calendar is modified 560 bool mModified; // flag indicating if calendar is modified
559 bool mReadOnly; // flag indicating if calendar is read-only 561 bool mReadOnly; // flag indicating if calendar is read-only
560 QDate mSaveSingleDate; 562 QDate mSaveSingleDate;
561 563
562 Incidence *mSelectedIncidence; 564 Incidence *mSelectedIncidence;
563 Incidence *mMoveIncidence; 565 Incidence *mMoveIncidence;
564 QDate mMoveIncidenceOldDate; 566 QDate mMoveIncidenceOldDate;
565 KOTodoView *mTodoList; 567 KOTodoView *mTodoList;
566 KOEventEditor * mEventEditor; 568 KOEventEditor * mEventEditor;
567 KOTodoEditor * mTodoEditor; 569 KOTodoEditor * mTodoEditor;
568 KOEventViewerDialog * mEventViewerDialog; 570 KOEventViewerDialog * mEventViewerDialog;
569 void keyPressEvent ( QKeyEvent *e) ; 571 void keyPressEvent ( QKeyEvent *e) ;
570 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 572 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
571}; 573};
572 574
573 575
574class CalendarViewVisitor : public Incidence::Visitor 576class CalendarViewVisitor : public Incidence::Visitor
575{ 577{
576 public: 578 public:
577 CalendarViewVisitor() : mView( 0 ) {} 579 CalendarViewVisitor() : mView( 0 ) {}
578 580
579 bool act( Incidence *incidence, CalendarView *view ) 581 bool act( Incidence *incidence, CalendarView *view )
580 { 582 {
581 mView = view; 583 mView = view;
582 return incidence->accept( *this ); 584 return incidence->accept( *this );
583 } 585 }
584 586
585 protected: 587 protected:
586 CalendarView *mView; 588 CalendarView *mView;
587}; 589};
588 590
589class ShowIncidenceVisitor : public CalendarViewVisitor 591class ShowIncidenceVisitor : public CalendarViewVisitor
590{ 592{
591 protected: 593 protected:
592 bool visit( Event *event ) { mView->showEvent( event ); return true; } 594 bool visit( Event *event ) { mView->showEvent( event ); return true; }
593 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 595 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
594 bool visit( Journal * j ) { mView->showJournal( j );return true; } 596 bool visit( Journal * j ) { mView->showJournal( j );return true; }
595}; 597};
596 598
597class EditIncidenceVisitor : public CalendarViewVisitor 599class EditIncidenceVisitor : public CalendarViewVisitor
598{ 600{
599 protected: 601 protected:
600 bool visit( Event *event ) { mView->editEvent( event ); return true; } 602 bool visit( Event *event ) { mView->editEvent( event ); return true; }
601 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 603 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
602 bool visit( Journal *j ) { mView->editJournal( j); return true; } 604 bool visit( Journal *j ) { mView->editJournal( j); return true; }
603}; 605};
604 606
605class DeleteIncidenceVisitor : public CalendarViewVisitor 607class DeleteIncidenceVisitor : public CalendarViewVisitor
606{ 608{
607 protected: 609 protected:
608 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 610 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
609 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 611 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
610 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 612 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
611}; 613};
612 614
613#endif 615#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 3feb4ab..a2c20a8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1929 +1,1942 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75class KOex2phonePrefs : public QDialog 75class KOex2phonePrefs : public QDialog
76{ 76{
77 public: 77 public:
78 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 78 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
79 QDialog( parent, name, true ) 79 QDialog( parent, name, true )
80 { 80 {
81 setCaption( i18n("Export to phone options") ); 81 setCaption( i18n("Export to phone options") );
82 QVBoxLayout* lay = new QVBoxLayout( this ); 82 QVBoxLayout* lay = new QVBoxLayout( this );
83 lay->setSpacing( 3 ); 83 lay->setSpacing( 3 );
84 lay->setMargin( 3 ); 84 lay->setMargin( 3 );
85 QLabel *lab; 85 QLabel *lab;
86 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 86 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
87 lab->setAlignment (AlignHCenter ); 87 lab->setAlignment (AlignHCenter );
88 QHBox* temphb; 88 QHBox* temphb;
89 temphb = new QHBox( this ); 89 temphb = new QHBox( this );
90 new QLabel( i18n("I/O device: "), temphb ); 90 new QLabel( i18n("I/O device: "), temphb );
91 mPhoneDevice = new QLineEdit( temphb); 91 mPhoneDevice = new QLineEdit( temphb);
92 lay->addWidget( temphb ); 92 lay->addWidget( temphb );
93 temphb = new QHBox( this ); 93 temphb = new QHBox( this );
94 new QLabel( i18n("Connection: "), temphb ); 94 new QLabel( i18n("Connection: "), temphb );
95 mPhoneConnection = new QLineEdit( temphb); 95 mPhoneConnection = new QLineEdit( temphb);
96 lay->addWidget( temphb ); 96 lay->addWidget( temphb );
97 temphb = new QHBox( this ); 97 temphb = new QHBox( this );
98 new QLabel( i18n("Model(opt.): "), temphb ); 98 new QLabel( i18n("Model(opt.): "), temphb );
99 mPhoneModel = new QLineEdit( temphb); 99 mPhoneModel = new QLineEdit( temphb);
100 lay->addWidget( temphb ); 100 lay->addWidget( temphb );
101 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 101 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
102 mWriteBackFuture->setChecked( true ); 102 mWriteBackFuture->setChecked( true );
103 lay->addWidget( mWriteBackFuture ); 103 lay->addWidget( mWriteBackFuture );
104 temphb = new QHBox( this ); 104 temphb = new QHBox( this );
105 new QLabel( i18n("Max. weeks in future: ") , temphb ); 105 new QLabel( i18n("Max. weeks in future: ") , temphb );
106 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 106 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
107 mWriteBackFutureWeeks->setValue( 8 ); 107 mWriteBackFutureWeeks->setValue( 8 );
108 lay->addWidget( temphb ); 108 lay->addWidget( temphb );
109 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 109 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
110 lab->setAlignment (AlignHCenter ); 110 lab->setAlignment (AlignHCenter );
111 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 111 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
112 lay->addWidget( ok ); 112 lay->addWidget( ok );
113 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 113 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
114 lay->addWidget( cancel ); 114 lay->addWidget( cancel );
115 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 115 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
116 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 116 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
117 resize( 220, 240 ); 117 resize( 220, 240 );
118 qApp->processEvents(); 118 qApp->processEvents();
119 int dw = QApplication::desktop()->width(); 119 int dw = QApplication::desktop()->width();
120 int dh = QApplication::desktop()->height(); 120 int dh = QApplication::desktop()->height();
121 move( (dw-width())/2, (dh - height() )/2 ); 121 move( (dw-width())/2, (dh - height() )/2 );
122 } 122 }
123 123
124public: 124public:
125 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 125 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
126 QCheckBox* mWriteBackFuture; 126 QCheckBox* mWriteBackFuture;
127 QSpinBox* mWriteBackFutureWeeks; 127 QSpinBox* mWriteBackFutureWeeks;
128}; 128};
129 129
130int globalFlagBlockStartup; 130int globalFlagBlockStartup;
131MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 131MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
132 QMainWindow( parent, name ) 132 QMainWindow( parent, name )
133{ 133{
134 134
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 setFont( QFont("Arial"), 14 ); 136 setFont( QFont("Arial"), 14 );
137#endif 137#endif
138 mClosed = false; 138 mClosed = false;
139 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 139 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
140 QString confFile = locateLocal("config","korganizerrc"); 140 QString confFile = locateLocal("config","korganizerrc");
141 QFileInfo finf ( confFile ); 141 QFileInfo finf ( confFile );
142 bool showWarning = !finf.exists(); 142 bool showWarning = !finf.exists();
143 setIcon(SmallIcon( "ko24" ) ); 143 setIcon(SmallIcon( "ko24" ) );
144 mBlockAtStartup = true; 144 mBlockAtStartup = true;
145 mFlagKeyPressed = false; 145 mFlagKeyPressed = false;
146 setCaption("KOrganizer/Pi"); 146 setCaption("KOrganizer/Pi");
147 KOPrefs *p = KOPrefs::instance(); 147 KOPrefs *p = KOPrefs::instance();
148 KPimGlobalPrefs::instance()->setGlobalConfig(); 148 KPimGlobalPrefs::instance()->setGlobalConfig();
149 if ( p->mHourSize > 18 ) 149 if ( p->mHourSize > 18 )
150 p->mHourSize = 18; 150 p->mHourSize = 18;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 mCalendarModifiedFlag = false; 169 mCalendarModifiedFlag = false;
170 170
171 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 171 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
172 splash->setAlignment ( AlignCenter ); 172 splash->setAlignment ( AlignCenter );
173 setCentralWidget( splash ); 173 setCentralWidget( splash );
174#ifndef DESKTOP_VERSION 174#ifndef DESKTOP_VERSION
175 showMaximized(); 175 showMaximized();
176#endif 176#endif
177 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 177 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
178 setDefaultPreferences(); 178 setDefaultPreferences();
179 mCalendar = new CalendarLocal(); 179 mCalendar = new CalendarLocal();
180 mView = new CalendarView( mCalendar, this,"mCalendar " ); 180 mView = new CalendarView( mCalendar, this,"mCalendar " );
181 mView->hide(); 181 mView->hide();
182 //mView->resize(splash->size() ); 182 //mView->resize(splash->size() );
183 initActions(); 183 initActions();
184 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 184 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
185 mSyncManager->setBlockSave(false); 185 mSyncManager->setBlockSave(false);
186 mView->setSyncManager(mSyncManager); 186 mView->setSyncManager(mSyncManager);
187#ifndef DESKTOP_VERSION 187#ifndef DESKTOP_VERSION
188 iconToolBar->show(); 188 iconToolBar->show();
189 qApp->processEvents(); 189 qApp->processEvents();
190#endif 190#endif
191 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 191 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
192 int vh = height() ; 192 int vh = height() ;
193 int vw = width(); 193 int vw = width();
194 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 194 //qDebug("Toolbar hei %d ",iconToolBar->height() );
195 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 195 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
196 vh -= iconToolBar->height(); 196 vh -= iconToolBar->height();
197 } else { 197 } else {
198 vw -= iconToolBar->height(); 198 vw -= iconToolBar->height();
199 } 199 }
200 //mView->setMaximumSize( splash->size() ); 200 //mView->setMaximumSize( splash->size() );
201 //mView->resize( splash->size() ); 201 //mView->resize( splash->size() );
202 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 202 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
203 mView->readSettings(); 203 mView->readSettings();
204 bool newFile = false; 204 bool newFile = false;
205 if( !QFile::exists( defaultFileName() ) ) { 205 if( !QFile::exists( defaultFileName() ) ) {
206 QFileInfo finfo ( defaultFileName() ); 206 QFileInfo finfo ( defaultFileName() );
207 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 207 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
208 qDebug("oldfile %s ", oldFile.latin1()); 208 qDebug("oldfile %s ", oldFile.latin1());
209 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 209 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
210 finfo.setFile( oldFile ); 210 finfo.setFile( oldFile );
211 if (finfo.exists() ) { 211 if (finfo.exists() ) {
212 KMessageBox::information( this, message); 212 KMessageBox::information( this, message);
213 mView->openCalendar( oldFile ); 213 mView->openCalendar( oldFile );
214 qApp->processEvents(); 214 qApp->processEvents();
215 } else { 215 } else {
216 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 216 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
217 finfo.setFile( oldFile ); 217 finfo.setFile( oldFile );
218 if (finfo.exists() ) { 218 if (finfo.exists() ) {
219 KMessageBox::information( this, message); 219 KMessageBox::information( this, message);
220 mView->openCalendar( oldFile ); 220 mView->openCalendar( oldFile );
221 qApp->processEvents(); 221 qApp->processEvents();
222 } 222 }
223 } 223 }
224 mView->saveCalendar( defaultFileName() ); 224 mView->saveCalendar( defaultFileName() );
225 newFile = true; 225 newFile = true;
226 } 226 }
227 227
228 QTime neededSaveTime = QDateTime::currentDateTime().time(); 228 QTime neededSaveTime = QDateTime::currentDateTime().time();
229 mView->openCalendar( defaultFileName() ); 229 mView->openCalendar( defaultFileName() );
230 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 230 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
231 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 231 qDebug("KO: Calendar loading time: %d ms",msNeeded );
232 232
233 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 233 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
234 KOPrefs::instance()->setCategoryDefaults(); 234 KOPrefs::instance()->setCategoryDefaults();
235 int count = mView->addCategories(); 235 int count = mView->addCategories();
236 } 236 }
237 processIncidenceSelection( 0 ); 237 processIncidenceSelection( 0 );
238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
239 SLOT( processIncidenceSelection( Incidence * ) ) ); 239 SLOT( processIncidenceSelection( Incidence * ) ) );
240 connect( mView, SIGNAL( modifiedChanged( bool ) ), 240 connect( mView, SIGNAL( modifiedChanged( bool ) ),
241 SLOT( slotModifiedChanged( bool ) ) ); 241 SLOT( slotModifiedChanged( bool ) ) );
242 242
243 243
244 connect( mView, SIGNAL( tempDisableBR(bool) ), 244 connect( mView, SIGNAL( tempDisableBR(bool) ),
245 SLOT( disableBR(bool) ) ); 245 SLOT( disableBR(bool) ) );
246 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 246 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
247 mView->setModified( false ); 247 mView->setModified( false );
248 mBlockAtStartup = false; 248 mBlockAtStartup = false;
249 mView->setModified( false ); 249 mView->setModified( false );
250 setCentralWidget( mView ); 250 setCentralWidget( mView );
251 globalFlagBlockStartup = 0; 251 globalFlagBlockStartup = 0;
252 mView->show(); 252 mView->show();
253 delete splash; 253 delete splash;
254 if ( newFile ) 254 if ( newFile )
255 mView->updateConfig(); 255 mView->updateConfig();
256 // qApp->processEvents(); 256 // qApp->processEvents();
257 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 257 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
258 //fillSyncMenu(); 258 //fillSyncMenu();
259 259
260 260
261 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 261 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
262 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
263 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 264 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 265 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
264 mSyncManager->setDefaultFileName( defaultFileName()); 266 mSyncManager->setDefaultFileName( defaultFileName());
265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 267 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
266 mSyncManager->fillSyncMenu(); 268 mSyncManager->fillSyncMenu();
267 269
268 270
269 271
270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 272 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
271 if ( showWarning ) { 273 if ( showWarning ) {
272 KMessageBox::information( this, 274 KMessageBox::information( this,
273 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 275 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
274 qApp->processEvents(); 276 qApp->processEvents();
275 mView->dialogManager()->showSyncOptions(); 277 mView->dialogManager()->showSyncOptions();
276 } 278 }
277 279
278 //US listen for result adressed from Ka/Pi 280 //US listen for result adressed from Ka/Pi
279#ifndef DESKTOP_VERSION 281#ifndef DESKTOP_VERSION
280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 282 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
281#endif 283#endif
282#ifndef DESKTOP_VERSION 284#ifndef DESKTOP_VERSION
283 infrared = 0; 285 infrared = 0;
284#endif 286#endif
285 287
286 mBRdisabled = false; 288 mBRdisabled = false;
287 //toggleBeamReceive(); 289 //toggleBeamReceive();
288} 290}
289MainWindow::~MainWindow() 291MainWindow::~MainWindow()
290{ 292{
291 //qDebug("MainWindow::~MainWindow() "); 293 //qDebug("MainWindow::~MainWindow() ");
292 //save toolbar location 294 //save toolbar location
293 delete mCalendar; 295 delete mCalendar;
294 delete mSyncManager; 296 delete mSyncManager;
295#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
296 if ( infrared ) 298 if ( infrared )
297 delete infrared; 299 delete infrared;
298#endif 300#endif
299 301
300 302
301} 303}
302 304
303void MainWindow::disableBR(bool b) 305void MainWindow::disableBR(bool b)
304{ 306{
305#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
306 if ( b ) { 308 if ( b ) {
307 if ( infrared ) { 309 if ( infrared ) {
308 toggleBeamReceive(); 310 toggleBeamReceive();
309 mBRdisabled = true; 311 mBRdisabled = true;
310 } 312 }
311 mBRdisabled = true; 313 mBRdisabled = true;
312 } else { 314 } else {
313 if ( mBRdisabled ) { 315 if ( mBRdisabled ) {
314 mBRdisabled = false; 316 mBRdisabled = false;
315 //makes no sense,because other cal ap is probably running 317 //makes no sense,because other cal ap is probably running
316 // toggleBeamReceive(); 318 // toggleBeamReceive();
317 } 319 }
318 } 320 }
319#endif 321#endif
320 322
321} 323}
322bool MainWindow::beamReceiveEnabled() 324bool MainWindow::beamReceiveEnabled()
323{ 325{
324#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
325 return ( infrared != 0 ); 327 return ( infrared != 0 );
326#endif 328#endif
327 return false; 329 return false;
328} 330}
329 331
330void MainWindow::toggleBeamReceive() 332void MainWindow::toggleBeamReceive()
331{ 333{
332 if ( mBRdisabled ) 334 if ( mBRdisabled )
333 return; 335 return;
334#ifndef DESKTOP_VERSION 336#ifndef DESKTOP_VERSION
335 if ( infrared ) { 337 if ( infrared ) {
336 qDebug("disable BeamReceive "); 338 qDebug("disable BeamReceive ");
337 delete infrared; 339 delete infrared;
338 infrared = 0; 340 infrared = 0;
339 brAction->setOn(false); 341 brAction->setOn(false);
340 return; 342 return;
341 } 343 }
342 qDebug("enable BeamReceive "); 344 qDebug("enable BeamReceive ");
343 brAction->setOn(true); 345 brAction->setOn(true);
344 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
345 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
346#endif 348#endif
347} 349}
348void MainWindow::showMaximized () 350void MainWindow::showMaximized ()
349{ 351{
350#ifndef DESKTOP_VERSION 352#ifndef DESKTOP_VERSION
351 if ( ! globalFlagBlockStartup ) 353 if ( ! globalFlagBlockStartup )
352 if ( mClosed ) 354 if ( mClosed )
353 mView->goToday(); 355 mView->goToday();
354#endif 356#endif
355 QWidget::showMaximized () ; 357 QWidget::showMaximized () ;
356 mClosed = false; 358 mClosed = false;
357} 359}
358void MainWindow::closeEvent( QCloseEvent* ce ) 360void MainWindow::closeEvent( QCloseEvent* ce )
359{ 361{
360 362
361 363
362 364
363 if ( ! KOPrefs::instance()->mAskForQuit ) { 365 if ( ! KOPrefs::instance()->mAskForQuit ) {
364 saveOnClose(); 366 saveOnClose();
365 mClosed = true; 367 mClosed = true;
366 ce->accept(); 368 ce->accept();
367 return; 369 return;
368 370
369 } 371 }
370 372
371 switch( QMessageBox::information( this, "KO/Pi", 373 switch( QMessageBox::information( this, "KO/Pi",
372 i18n("Do you really want\nto close KO/Pi?"), 374 i18n("Do you really want\nto close KO/Pi?"),
373 i18n("Close"), i18n("No"), 375 i18n("Close"), i18n("No"),
374 0, 0 ) ) { 376 0, 0 ) ) {
375 case 0: 377 case 0:
376 saveOnClose(); 378 saveOnClose();
377 mClosed = true; 379 mClosed = true;
378 ce->accept(); 380 ce->accept();
379 break; 381 break;
380 case 1: 382 case 1:
381 ce->ignore(); 383 ce->ignore();
382 break; 384 break;
383 case 2: 385 case 2:
384 386
385 default: 387 default:
386 break; 388 break;
387 } 389 }
388 390
389 391
390} 392}
391 393
392void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
393{ 395{
394 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
395 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
396 //QString datamess; 398 //QString datamess;
397 //qDebug("message "); 399 //qDebug("message ");
398 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 400 qDebug("KO: QCOP message received: %s ", cmsg.data() );
399 401
400 if ( cmsg == "setDocument(QString)" ) { 402 if ( cmsg == "setDocument(QString)" ) {
401 QDataStream stream( data, IO_ReadOnly ); 403 QDataStream stream( data, IO_ReadOnly );
402 QString fileName; 404 QString fileName;
403 stream >> fileName; 405 stream >> fileName;
404 //qDebug("filename %s ", fileName.latin1()); 406 //qDebug("filename %s ", fileName.latin1());
405 showMaximized(); 407 showMaximized();
406 raise(); 408 raise();
407 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
408 mSyncManager->slotSyncMenu( 1002 ); 410 mSyncManager->slotSyncMenu( 1002 );
409 return; 411 return;
410 } 412 }
411 413
412 if ( cmsg == "-writeFile" ) { 414 if ( cmsg == "-writeFile" ) {
413 // I made from the "-writeFile" an "-writeAlarm" 415 // I made from the "-writeFile" an "-writeAlarm"
414 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
415 mCalendar->checkAlarmForIncidence( 0, true); 417 mCalendar->checkAlarmForIncidence( 0, true);
416 showMaximized(); 418 showMaximized();
417 raise(); 419 raise();
418 return; 420 return;
419 421
420 } 422 }
421 if ( cmsg == "-writeFileSilent" ) { 423 if ( cmsg == "-writeFileSilent" ) {
422 // I made from the "-writeFile" an "-writeAlarm" 424 // I made from the "-writeFile" an "-writeAlarm"
423 // mView->viewManager()->showWhatsNextView(); 425 // mView->viewManager()->showWhatsNextView();
424 mCalendar->checkAlarmForIncidence( 0, true); 426 mCalendar->checkAlarmForIncidence( 0, true);
425 //showMaximized(); 427 //showMaximized();
426 //raise(); 428 //raise();
427 hide(); 429 hide();
428 return; 430 return;
429 } 431 }
430 if ( cmsg == "-newCountdown" ) { 432 if ( cmsg == "-newCountdown" ) {
431 qDebug("newCountdown "); 433 qDebug("newCountdown ");
432 434
433 } 435 }
434 QString msg ; 436 QString msg ;
435 QString allmsg = cmsg; 437 QString allmsg = cmsg;
436 while ( allmsg.length() > 0 ) { 438 while ( allmsg.length() > 0 ) {
437 int nextC = allmsg.find( "-", 1 ); 439 int nextC = allmsg.find( "-", 1 );
438 if ( nextC == -1 ) { 440 if ( nextC == -1 ) {
439 msg = allmsg; 441 msg = allmsg;
440 allmsg = ""; 442 allmsg = "";
441 } else{ 443 } else{
442 msg = allmsg.left( nextC ); 444 msg = allmsg.left( nextC );
443 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
444 } 446 }
445 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
446 if ( msg == "-newEvent" ) { 448 if ( msg == "-newEvent" ) {
447 mView->newEvent(); 449 mView->newEvent();
448 } 450 }
449 if ( msg == "-newTodo" ) { 451 if ( msg == "-newTodo" ) {
450 mView->newTodo(); 452 mView->newTodo();
451 453
452 } 454 }
453 if ( msg == "-showWN" ) { 455 if ( msg == "-showWN" ) {
454 mView->viewManager()->showWhatsNextView(); 456 mView->viewManager()->showWhatsNextView();
455 } 457 }
456 if ( msg == "-showTodo" ) { 458 if ( msg == "-showTodo" ) {
457 mView->viewManager()->showTodoView(); 459 mView->viewManager()->showTodoView();
458 } 460 }
459 if ( msg == "-showList" ) { 461 if ( msg == "-showList" ) {
460 mView->viewManager()->showListView(); 462 mView->viewManager()->showListView();
461 } 463 }
462 else if ( msg == "-showDay" ) { 464 else if ( msg == "-showDay" ) {
463 mView->viewManager()->showDayView(); 465 mView->viewManager()->showDayView();
464 } 466 }
465 else if ( msg == "-showWWeek" ) { 467 else if ( msg == "-showWWeek" ) {
466 mView->viewManager()->showWorkWeekView(); 468 mView->viewManager()->showWorkWeekView();
467 } 469 }
468 else if ( msg == "-ringSync" ) { 470 else if ( msg == "-ringSync" ) {
469 mSyncManager->multiSync( false ); 471 mSyncManager->multiSync( false );
470 } 472 }
471 else if ( msg == "-showWeek" ) { 473 else if ( msg == "-showWeek" ) {
472 mView->viewManager()->showWeekView(); 474 mView->viewManager()->showWeekView();
473 } 475 }
474 else if ( msg == "-showTodo" ) { 476 else if ( msg == "-showTodo" ) {
475 mView->viewManager()->showTodoView(); 477 mView->viewManager()->showTodoView();
476 } 478 }
477 else if ( msg == "-showJournal" ) { 479 else if ( msg == "-showJournal" ) {
478 mView->dateNavigator()->selectDates( 1 ); 480 mView->dateNavigator()->selectDates( 1 );
479 mView->dateNavigator()->selectToday(); 481 mView->dateNavigator()->selectToday();
480 mView->viewManager()->showJournalView(); 482 mView->viewManager()->showJournalView();
481 } 483 }
482 else if ( msg == "-showKO" ) { 484 else if ( msg == "-showKO" ) {
483 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
484 } 486 }
485 else if ( msg == "-showWNext" || msg == "nextView()" ) { 487 else if ( msg == "-showWNext" || msg == "nextView()" ) {
486 mView->viewManager()->showWhatsNextView(); 488 mView->viewManager()->showWhatsNextView();
487 } 489 }
488 else if ( msg == "-showNextXView" ) { 490 else if ( msg == "-showNextXView" ) {
489 mView->viewManager()->showNextXView(); 491 mView->viewManager()->showNextXView();
490 } 492 }
491 493
492 494
493 } 495 }
494 496
495 showMaximized(); 497 showMaximized();
496 raise(); 498 raise();
497} 499}
498 500
499QPixmap MainWindow::loadPixmap( QString name ) 501QPixmap MainWindow::loadPixmap( QString name )
500{ 502{
501 return SmallIcon( name ); 503 return SmallIcon( name );
502 504
503} 505}
504void MainWindow::initActions() 506void MainWindow::initActions()
505{ 507{
506 //KOPrefs::instance()->mShowFullMenu 508 //KOPrefs::instance()->mShowFullMenu
507 iconToolBar->clear(); 509 iconToolBar->clear();
508 KOPrefs *p = KOPrefs::instance(); 510 KOPrefs *p = KOPrefs::instance();
509 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
510 512
511 QPopupMenu *viewMenu = new QPopupMenu( this ); 513 QPopupMenu *viewMenu = new QPopupMenu( this );
512 QPopupMenu *actionMenu = new QPopupMenu( this ); 514 QPopupMenu *actionMenu = new QPopupMenu( this );
513 QPopupMenu *importMenu = new QPopupMenu( this ); 515 QPopupMenu *importMenu = new QPopupMenu( this );
514 selectFilterMenu = new QPopupMenu( this ); 516 selectFilterMenu = new QPopupMenu( this );
515 selectFilterMenu->setCheckable( true ); 517 selectFilterMenu->setCheckable( true );
516 syncMenu = new QPopupMenu( this ); 518 syncMenu = new QPopupMenu( this );
517 configureAgendaMenu = new QPopupMenu( this ); 519 configureAgendaMenu = new QPopupMenu( this );
518 configureToolBarMenu = new QPopupMenu( this ); 520 configureToolBarMenu = new QPopupMenu( this );
519 QPopupMenu *helpMenu = new QPopupMenu( this ); 521 QPopupMenu *helpMenu = new QPopupMenu( this );
520 if ( KOPrefs::instance()->mShowFullMenu ) { 522 if ( KOPrefs::instance()->mShowFullMenu ) {
521 QMenuBar *menuBar1; 523 QMenuBar *menuBar1;
522 menuBar1 = menuBar(); 524 menuBar1 = menuBar();
523 menuBar1->insertItem( i18n("File"), importMenu ); 525 menuBar1->insertItem( i18n("File"), importMenu );
524 menuBar1->insertItem( i18n("View"), viewMenu ); 526 menuBar1->insertItem( i18n("View"), viewMenu );
525 menuBar1->insertItem( i18n("Actions"), actionMenu ); 527 menuBar1->insertItem( i18n("Actions"), actionMenu );
526#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
527 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 529 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
528 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 530 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
529#else 531#else
530 menuBar1->insertItem( i18n("Sync"), syncMenu ); 532 menuBar1->insertItem( i18n("Sync"), syncMenu );
531 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 533 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
532#endif 534#endif
533 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 535 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
534 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 536 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
535 menuBar1->insertItem( i18n("Help"), helpMenu ); 537 menuBar1->insertItem( i18n("Help"), helpMenu );
536 } else { 538 } else {
537 QPEMenuBar *menuBar1; 539 QPEMenuBar *menuBar1;
538 menuBar1 = new QPEMenuBar( iconToolBar ); 540 menuBar1 = new QPEMenuBar( iconToolBar );
539 QPopupMenu *menuBar = new QPopupMenu( this ); 541 QPopupMenu *menuBar = new QPopupMenu( this );
540 menuBar1->insertItem( i18n("ME"), menuBar); 542 menuBar1->insertItem( i18n("ME"), menuBar);
541 menuBar->insertItem( i18n("File"), importMenu ); 543 menuBar->insertItem( i18n("File"), importMenu );
542 menuBar->insertItem( i18n("View"), viewMenu ); 544 menuBar->insertItem( i18n("View"), viewMenu );
543 menuBar->insertItem( i18n("Actions"), actionMenu ); 545 menuBar->insertItem( i18n("Actions"), actionMenu );
544 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 546 menuBar->insertItem( i18n("Synchronize"), syncMenu );
545 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 547 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
546 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 548 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
547 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 549 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
548 menuBar->insertItem( i18n("Help"), helpMenu ); 550 menuBar->insertItem( i18n("Help"), helpMenu );
549 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 551 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
550 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 552 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
551 } 553 }
552 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 554 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
553 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 555 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
554 556
555 // ****************** 557 // ******************
556 QAction *action; 558 QAction *action;
557 QIconSet icon; 559 QIconSet icon;
558 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 560 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
559 configureToolBarMenu->setCheckable( true ); 561 configureToolBarMenu->setCheckable( true );
560 562
561 QString pathString = ""; 563 QString pathString = "";
562 if ( !p->mToolBarMiniIcons ) { 564 if ( !p->mToolBarMiniIcons ) {
563 if ( QApplication::desktop()->width() < 480 ) 565 if ( QApplication::desktop()->width() < 480 )
564 pathString += "icons16/"; 566 pathString += "icons16/";
565 } else 567 } else
566 pathString += "iconsmini/"; 568 pathString += "iconsmini/";
567 configureAgendaMenu->setCheckable( true ); 569 configureAgendaMenu->setCheckable( true );
568 int iii ; 570 int iii ;
569 for ( iii = 1;iii<= 10 ;++iii ){ 571 for ( iii = 1;iii<= 10 ;++iii ){
570 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 572 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
571 } 573 }
572 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 574 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
573 575
574 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 576 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
575 this, SLOT( showConfigureAgenda( ) ) ); 577 this, SLOT( showConfigureAgenda( ) ) );
576 578
577 icon = loadPixmap( pathString + "configure" ); 579 icon = loadPixmap( pathString + "configure" );
578 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 580 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
579 action->addTo( actionMenu ); 581 action->addTo( actionMenu );
580 connect( action, SIGNAL( activated() ), 582 connect( action, SIGNAL( activated() ),
581 mView, SLOT( edit_options() ) ); 583 mView, SLOT( edit_options() ) );
582 actionMenu->insertSeparator(); 584 actionMenu->insertSeparator();
583 585
584 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 586 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
585 action->addTo( actionMenu ); 587 action->addTo( actionMenu );
586 connect( action, SIGNAL( activated() ), 588 connect( action, SIGNAL( activated() ),
587 mView, SLOT( undo_delete() ) ); 589 mView, SLOT( undo_delete() ) );
588 actionMenu->insertSeparator(); 590 actionMenu->insertSeparator();
589 591
590 icon = loadPixmap( pathString + "newevent" ); 592 icon = loadPixmap( pathString + "newevent" );
591 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 593 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
592 configureToolBarMenu->insertSeparator(); 594 configureToolBarMenu->insertSeparator();
593 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 595 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
594 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 596 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
595 ne_action->addTo( actionMenu ); 597 ne_action->addTo( actionMenu );
596 connect( ne_action, SIGNAL( activated() ), 598 connect( ne_action, SIGNAL( activated() ),
597 mView, SLOT( newEvent() ) ); 599 mView, SLOT( newEvent() ) );
598 icon = loadPixmap( pathString + "newtodo" ); 600 icon = loadPixmap( pathString + "newtodo" );
599 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 601 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
600 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 602 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
601 nt_action->addTo( actionMenu ); 603 nt_action->addTo( actionMenu );
602 connect( nt_action, SIGNAL( activated() ), 604 connect( nt_action, SIGNAL( activated() ),
603 mView, SLOT( newTodo() ) ); 605 mView, SLOT( newTodo() ) );
604 606
605 icon = loadPixmap( pathString + "today" ); 607 icon = loadPixmap( pathString + "today" );
606 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 608 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
607 today_action->addTo( viewMenu ); 609 today_action->addTo( viewMenu );
608 connect( today_action, SIGNAL( activated() ), 610 connect( today_action, SIGNAL( activated() ),
609 mView, SLOT( goToday() ) ); 611 mView, SLOT( goToday() ) );
610 viewMenu->insertSeparator(); 612 viewMenu->insertSeparator();
611 613
612 icon = loadPixmap( pathString + "navi" ); 614 icon = loadPixmap( pathString + "navi" );
613 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 615 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
614 action->addTo( viewMenu ); 616 action->addTo( viewMenu );
615 connect( action, SIGNAL( activated() ), 617 connect( action, SIGNAL( activated() ),
616 mView, SLOT( toggleDateNavigatorWidget() ) ); 618 mView, SLOT( toggleDateNavigatorWidget() ) );
617 mToggleNav = action ; 619 mToggleNav = action ;
618 icon = loadPixmap( pathString + "filter" ); 620 icon = loadPixmap( pathString + "filter" );
619 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 621 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
620 action->addTo( viewMenu ); 622 action->addTo( viewMenu );
621 connect( action, SIGNAL( activated() ), 623 connect( action, SIGNAL( activated() ),
622 mView, SLOT( toggleFilter() ) ); 624 mView, SLOT( toggleFilter() ) );
623 mToggleFilter = action; 625 mToggleFilter = action;
624 icon = loadPixmap( pathString + "allday" ); 626 icon = loadPixmap( pathString + "allday" );
625 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 627 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
626 action->addTo( viewMenu ); 628 action->addTo( viewMenu );
627 connect( action, SIGNAL( activated() ), 629 connect( action, SIGNAL( activated() ),
628 mView, SLOT( toggleAllDaySize() ) ); 630 mView, SLOT( toggleAllDaySize() ) );
629 mToggleAllday = action; 631 mToggleAllday = action;
630 632
631 633
632 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 634 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
633 mToggleNav, SLOT( setEnabled ( bool ) ) ); 635 mToggleNav, SLOT( setEnabled ( bool ) ) );
634 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 636 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
635 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 637 mToggleFilter, SLOT( setEnabled ( bool ) ) );
636 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 638 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
637 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 639 mToggleAllday, SLOT( setEnabled ( bool ) ) );
638 640
639 viewMenu->insertSeparator(); 641 viewMenu->insertSeparator();
640 icon = loadPixmap( pathString + "picker" ); 642 icon = loadPixmap( pathString + "picker" );
641 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 643 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
642 action->addTo( viewMenu ); 644 action->addTo( viewMenu );
643 connect( action, SIGNAL( activated() ), 645 connect( action, SIGNAL( activated() ),
644 mView, SLOT( showDatePicker() ) ); 646 mView, SLOT( showDatePicker() ) );
645 action->addTo( iconToolBar ); 647 action->addTo( iconToolBar );
646 viewMenu->insertSeparator(); 648 viewMenu->insertSeparator();
647 icon = loadPixmap( pathString + "list" ); 649 icon = loadPixmap( pathString + "list" );
648 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 650 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
649 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 651 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
650 showlist_action->addTo( viewMenu ); 652 showlist_action->addTo( viewMenu );
651 connect( showlist_action, SIGNAL( activated() ), 653 connect( showlist_action, SIGNAL( activated() ),
652 mView->viewManager(), SLOT( showListView() ) ); 654 mView->viewManager(), SLOT( showListView() ) );
653 655
654 656
655 icon = loadPixmap( pathString + "day" ); 657 icon = loadPixmap( pathString + "day" );
656 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 658 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
657 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 659 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
658 day1_action->addTo( viewMenu ); 660 day1_action->addTo( viewMenu );
659 // action->addTo( toolBar ); 661 // action->addTo( toolBar );
660 connect( day1_action, SIGNAL( activated() ), 662 connect( day1_action, SIGNAL( activated() ),
661 mView->viewManager(), SLOT( showDayView() ) ); 663 mView->viewManager(), SLOT( showDayView() ) );
662 664
663 icon = loadPixmap( pathString + "workweek" ); 665 icon = loadPixmap( pathString + "workweek" );
664 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 666 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
665 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 667 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
666 day5_action->addTo( viewMenu ); 668 day5_action->addTo( viewMenu );
667 connect( day5_action, SIGNAL( activated() ), 669 connect( day5_action, SIGNAL( activated() ),
668 mView->viewManager(), SLOT( showWorkWeekView() ) ); 670 mView->viewManager(), SLOT( showWorkWeekView() ) );
669 671
670 icon = loadPixmap( pathString + "week" ); 672 icon = loadPixmap( pathString + "week" );
671 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 673 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
672 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 674 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
673 day7_action->addTo( viewMenu ); 675 day7_action->addTo( viewMenu );
674 connect( day7_action, SIGNAL( activated() ), 676 connect( day7_action, SIGNAL( activated() ),
675 mView->viewManager(), SLOT( showWeekView() ) ); 677 mView->viewManager(), SLOT( showWeekView() ) );
676 678
677 icon = loadPixmap( pathString + "month" ); 679 icon = loadPixmap( pathString + "month" );
678 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 680 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
679 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 681 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
680 month_action->addTo( viewMenu ); 682 month_action->addTo( viewMenu );
681 connect( month_action, SIGNAL( activated() ), 683 connect( month_action, SIGNAL( activated() ),
682 mView->viewManager(), SLOT( showMonthView() ) ); 684 mView->viewManager(), SLOT( showMonthView() ) );
683 685
684 icon = loadPixmap( pathString + "todo" ); 686 icon = loadPixmap( pathString + "todo" );
685 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 687 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
686 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 688 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
687 todoview_action->addTo( viewMenu ); 689 todoview_action->addTo( viewMenu );
688 connect( todoview_action, SIGNAL( activated() ), 690 connect( todoview_action, SIGNAL( activated() ),
689 mView->viewManager(), SLOT( showTodoView() ) ); 691 mView->viewManager(), SLOT( showTodoView() ) );
690 692
691 icon = loadPixmap( pathString + "journal" ); 693 icon = loadPixmap( pathString + "journal" );
692 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 694 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
693 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 695 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
694 viewjournal_action->addTo( viewMenu ); 696 viewjournal_action->addTo( viewMenu );
695 connect( viewjournal_action, SIGNAL( activated() ), 697 connect( viewjournal_action, SIGNAL( activated() ),
696 mView->viewManager(), SLOT( showJournalView() ) ); 698 mView->viewManager(), SLOT( showJournalView() ) );
697 699
698 icon = loadPixmap( pathString + "xdays" ); 700 icon = loadPixmap( pathString + "xdays" );
699 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 701 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
700 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 702 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
701 xdays_action->addTo( viewMenu ); 703 xdays_action->addTo( viewMenu );
702 connect( xdays_action, SIGNAL( activated() ), 704 connect( xdays_action, SIGNAL( activated() ),
703 mView->viewManager(), SLOT( showNextXView() ) ); 705 mView->viewManager(), SLOT( showNextXView() ) );
704 706
705 icon = loadPixmap( pathString + "whatsnext" ); 707 icon = loadPixmap( pathString + "whatsnext" );
706 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 708 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
707 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 709 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
708 whatsnext_action->addTo( viewMenu ); 710 whatsnext_action->addTo( viewMenu );
709 connect( whatsnext_action, SIGNAL( activated() ), 711 connect( whatsnext_action, SIGNAL( activated() ),
710 mView->viewManager(), SLOT( showWhatsNextView() ) ); 712 mView->viewManager(), SLOT( showWhatsNextView() ) );
711 713
712#if 0 714#if 0
713 action = new QAction( "view_timespan", "Time Span", 0, this ); 715 action = new QAction( "view_timespan", "Time Span", 0, this );
714 action->addTo( viewMenu ); 716 action->addTo( viewMenu );
715 connect( action, SIGNAL( activated() ), 717 connect( action, SIGNAL( activated() ),
716 mView->viewManager(), SLOT( showTimeSpanView() ) ); 718 mView->viewManager(), SLOT( showTimeSpanView() ) );
717#endif 719#endif
718 720
719 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 721 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
720 this ); 722 this );
721 mNewSubTodoAction->addTo( actionMenu ); 723 mNewSubTodoAction->addTo( actionMenu );
722 connect( mNewSubTodoAction, SIGNAL( activated() ), 724 connect( mNewSubTodoAction, SIGNAL( activated() ),
723 mView, SLOT( newSubTodo() ) ); 725 mView, SLOT( newSubTodo() ) );
724 726
725 actionMenu->insertSeparator(); 727 actionMenu->insertSeparator();
726 728
727 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 729 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
728 mShowAction->addTo( actionMenu ); 730 mShowAction->addTo( actionMenu );
729 connect( mShowAction, SIGNAL( activated() ), 731 connect( mShowAction, SIGNAL( activated() ),
730 mView, SLOT( showIncidence() ) ); 732 mView, SLOT( showIncidence() ) );
731 733
732 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 734 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
733 mEditAction->addTo( actionMenu ); 735 mEditAction->addTo( actionMenu );
734 connect( mEditAction, SIGNAL( activated() ), 736 connect( mEditAction, SIGNAL( activated() ),
735 mView, SLOT( editIncidence() ) ); 737 mView, SLOT( editIncidence() ) );
736 738
737 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 739 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
738 mDeleteAction->addTo( actionMenu ); 740 mDeleteAction->addTo( actionMenu );
739 connect( mDeleteAction, SIGNAL( activated() ), 741 connect( mDeleteAction, SIGNAL( activated() ),
740 mView, SLOT( deleteIncidence() ) ); 742 mView, SLOT( deleteIncidence() ) );
741 743
742 744
743 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 745 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
744 mCloneAction->addTo( actionMenu ); 746 mCloneAction->addTo( actionMenu );
745 connect( mCloneAction, SIGNAL( activated() ), 747 connect( mCloneAction, SIGNAL( activated() ),
746 mView, SLOT( cloneIncidence() ) ); 748 mView, SLOT( cloneIncidence() ) );
747 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 749 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
748 mMoveAction->addTo( actionMenu ); 750 mMoveAction->addTo( actionMenu );
749 connect( mMoveAction, SIGNAL( activated() ), 751 connect( mMoveAction, SIGNAL( activated() ),
750 mView, SLOT( moveIncidence() ) ); 752 mView, SLOT( moveIncidence() ) );
751 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 753 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
752 mBeamAction->addTo( actionMenu ); 754 mBeamAction->addTo( actionMenu );
753 connect( mBeamAction, SIGNAL( activated() ), 755 connect( mBeamAction, SIGNAL( activated() ),
754 mView, SLOT( beamIncidence() ) ); 756 mView, SLOT( beamIncidence() ) );
755 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 757 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
756 mCancelAction->addTo( actionMenu ); 758 mCancelAction->addTo( actionMenu );
757 connect( mCancelAction, SIGNAL( activated() ), 759 connect( mCancelAction, SIGNAL( activated() ),
758 mView, SLOT( toggleCancelIncidence() ) ); 760 mView, SLOT( toggleCancelIncidence() ) );
759 761
760 actionMenu->insertSeparator(); 762 actionMenu->insertSeparator();
761 763
762 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 764 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
763 this ); 765 this );
764 action->addTo( actionMenu ); 766 action->addTo( actionMenu );
765 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 767 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
766 768
767 icon = loadPixmap( pathString + "search" ); 769 icon = loadPixmap( pathString + "search" );
768 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 770 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
769 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 771 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
770 search_action->addTo( actionMenu ); 772 search_action->addTo( actionMenu );
771 connect( search_action, SIGNAL( activated() ), 773 connect( search_action, SIGNAL( activated() ),
772 mView->dialogManager(), SLOT( showSearchDialog() ) ); 774 mView->dialogManager(), SLOT( showSearchDialog() ) );
773 775
774 776
775 777
776 if ( KOPrefs::instance()->mShowFullMenu ) { 778 if ( KOPrefs::instance()->mShowFullMenu ) {
777 actionMenu->insertSeparator(); 779 actionMenu->insertSeparator();
778 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 780 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
779 781
780 } 782 }
781 // actionMenu->insertSeparator(); 783 // actionMenu->insertSeparator();
782 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 784 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
783 this ); 785 this );
784 action->addTo( importMenu ); 786 action->addTo( importMenu );
785 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 787 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
786 action = new QAction( "import_quick", i18n("Import last file"), 0, 788 action = new QAction( "import_quick", i18n("Import last file"), 0,
787 this ); 789 this );
788 action->addTo( importMenu ); 790 action->addTo( importMenu );
789 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 791 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
790 importMenu->insertSeparator(); 792 importMenu->insertSeparator();
791 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 793 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
792 this ); 794 this );
793 action->addTo( importMenu ); 795 action->addTo( importMenu );
794 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 796 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
795#ifndef DESKTOP_VERSION 797#ifndef DESKTOP_VERSION
796 importMenu->insertSeparator(); 798 importMenu->insertSeparator();
797 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 799 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
798 this ); 800 this );
799 action->addTo( importMenu ); 801 action->addTo( importMenu );
800 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 802 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
801#else 803#else
802#ifdef _OL_IMPORT_ 804#ifdef _OL_IMPORT_
803 importMenu->insertSeparator(); 805 importMenu->insertSeparator();
804 action = new QAction( "import_ol", i18n("Import from OL"), 0, 806 action = new QAction( "import_ol", i18n("Import from OL"), 0,
805 this ); 807 this );
806 action->addTo( importMenu ); 808 action->addTo( importMenu );
807 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 809 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
808#endif 810#endif
809#endif 811#endif
810 812
811 importMenu->insertSeparator(); 813 importMenu->insertSeparator();
812 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 814 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
813 this ); 815 this );
814 action->addTo( importMenu ); 816 action->addTo( importMenu );
815 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 817 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
816 818
817 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 819 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
818 this ); 820 this );
819 action->addTo( importMenu ); 821 action->addTo( importMenu );
820 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 822 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
821 823
822 importMenu->insertSeparator(); 824 importMenu->insertSeparator();
823 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 825 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
824 this ); 826 this );
825 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 827 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
826 828
827 829
828 //LR 830 //LR
829 QPopupMenu *ex2phone = new QPopupMenu( this ); 831 QPopupMenu *ex2phone = new QPopupMenu( this );
830 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 832 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
831 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 833 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
832 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 834 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
833 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 835 importMenu->insertItem( i18n("Export to phone"), ex2phone );
834 836
835 importMenu->insertSeparator(); 837 importMenu->insertSeparator();
836 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 838 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
837 this ); 839 this );
838 action->addTo( importMenu ); 840 action->addTo( importMenu );
839 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 841 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
840#ifndef DESKTOP_VERSION 842#ifndef DESKTOP_VERSION
841 importMenu->insertSeparator(); 843 importMenu->insertSeparator();
842 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 844 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
843 this ); 845 this );
844 brAction->addTo( importMenu ); 846 brAction->addTo( importMenu );
845 brAction->setToggleAction (true ) ; 847 brAction->setToggleAction (true ) ;
846 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 848 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
847 849
848 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 850 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
849 this ); 851 this );
850 action->addTo( importMenu ); 852 action->addTo( importMenu );
851 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 853 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
852 854
853 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 855 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
854 this ); 856 this );
855 action->addTo( importMenu ); 857 action->addTo( importMenu );
856 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 858 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
857#else 859#else
858 importMenu->insertSeparator(); 860 importMenu->insertSeparator();
859 icon = loadPixmap( pathString + "print" ); 861 icon = loadPixmap( pathString + "print" );
860 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 862 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
861 action->addTo( importMenu ); 863 action->addTo( importMenu );
862 connect( action, SIGNAL( activated() ), 864 connect( action, SIGNAL( activated() ),
863 this, SLOT( printCal() ) ); 865 this, SLOT( printCal() ) );
864 866
865 icon = loadPixmap( pathString + "print" ); 867 icon = loadPixmap( pathString + "print" );
866 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 868 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
867 action->addTo( importMenu ); 869 action->addTo( importMenu );
868 connect( action, SIGNAL( activated() ), 870 connect( action, SIGNAL( activated() ),
869 this, SLOT( printSel() ) ); 871 this, SLOT( printSel() ) );
870 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 872 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
871 action->addTo( importMenu ); 873 action->addTo( importMenu );
872 connect( action, SIGNAL( activated() ), 874 connect( action, SIGNAL( activated() ),
873 mView->viewManager(), SIGNAL( printWNV() ) ); 875 mView->viewManager(), SIGNAL( printWNV() ) );
874#endif 876#endif
875 importMenu->insertSeparator(); 877 importMenu->insertSeparator();
876 action = new QAction( "beam all", i18n("Save"), 0, 878 action = new QAction( "beam all", i18n("Save"), 0,
877 this ); 879 this );
878 action->addTo( importMenu ); 880 action->addTo( importMenu );
879 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 881 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
880 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 882 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
881 this ); 883 this );
882 action->addTo( importMenu ); 884 action->addTo( importMenu );
883 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 885 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
884 886
885 //menuBar->insertItem( "Configure",configureMenu ); 887 //menuBar->insertItem( "Configure",configureMenu );
886 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 888 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
887 icon = loadPixmap( "korganizer/korganizer" ); 889 icon = loadPixmap( "korganizer/korganizer" );
888 890
889 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 891 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
890 action->addTo( helpMenu ); 892 action->addTo( helpMenu );
891 connect( action, SIGNAL( activated() ), 893 connect( action, SIGNAL( activated() ),
892 SLOT( whatsNew() ) ); 894 SLOT( whatsNew() ) );
893 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 895 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
894 action->addTo( helpMenu ); 896 action->addTo( helpMenu );
895 connect( action, SIGNAL( activated() ), 897 connect( action, SIGNAL( activated() ),
896 SLOT( features() ) ); 898 SLOT( features() ) );
897 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 899 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
898 action->addTo( helpMenu ); 900 action->addTo( helpMenu );
899 connect( action, SIGNAL( activated() ), 901 connect( action, SIGNAL( activated() ),
900 SLOT( keyBindings() ) ); 902 SLOT( keyBindings() ) );
901 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 903 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
902 action->addTo( helpMenu ); 904 action->addTo( helpMenu );
903 connect( action, SIGNAL( activated() ), 905 connect( action, SIGNAL( activated() ),
904 SLOT( synchowto() ) ); 906 SLOT( synchowto() ) );
905 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 907 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
906 action->addTo( helpMenu ); 908 action->addTo( helpMenu );
907 connect( action, SIGNAL( activated() ), 909 connect( action, SIGNAL( activated() ),
908 SLOT( kdesynchowto() ) ); 910 SLOT( kdesynchowto() ) );
909 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 911 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
910 action->addTo( helpMenu ); 912 action->addTo( helpMenu );
911 connect( action, SIGNAL( activated() ), 913 connect( action, SIGNAL( activated() ),
912 SLOT( multisynchowto() ) ); 914 SLOT( multisynchowto() ) );
913 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 915 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
914 action->addTo( helpMenu ); 916 action->addTo( helpMenu );
915 connect( action, SIGNAL( activated() ), 917 connect( action, SIGNAL( activated() ),
916 SLOT( aboutAutoSaving() ) ); 918 SLOT( aboutAutoSaving() ) );
917 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 919 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
918 action->addTo( helpMenu ); 920 action->addTo( helpMenu );
919 connect( action, SIGNAL( activated() ), 921 connect( action, SIGNAL( activated() ),
920 SLOT( aboutKnownBugs() ) ); 922 SLOT( aboutKnownBugs() ) );
921 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 923 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
922 action->addTo( helpMenu ); 924 action->addTo( helpMenu );
923 connect( action, SIGNAL( activated() ), 925 connect( action, SIGNAL( activated() ),
924 SLOT( usertrans() ) ); 926 SLOT( usertrans() ) );
925 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 927 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
926 action->addTo( helpMenu ); 928 action->addTo( helpMenu );
927 connect( action, SIGNAL( activated() ), 929 connect( action, SIGNAL( activated() ),
928 SLOT( faq() ) ); 930 SLOT( faq() ) );
929 action = new QAction( "licence", i18n("Licence..."), 0, this ); 931 action = new QAction( "licence", i18n("Licence..."), 0, this );
930 action->addTo( helpMenu ); 932 action->addTo( helpMenu );
931 connect( action, SIGNAL( activated() ), 933 connect( action, SIGNAL( activated() ),
932 SLOT( licence() ) ); 934 SLOT( licence() ) );
933 action = new QAction( "about", i18n("About..."), 0, this ); 935 action = new QAction( "about", i18n("About..."), 0, this );
934 action->addTo( helpMenu ); 936 action->addTo( helpMenu );
935 connect( action, SIGNAL( activated() ), 937 connect( action, SIGNAL( activated() ),
936 SLOT( about() ) ); 938 SLOT( about() ) );
937 //menuBar->insertSeparator(); 939 //menuBar->insertSeparator();
938 940
939 // ****************************************************** 941 // ******************************************************
940 // menubar icons 942 // menubar icons
941 943
942 944
943 iconToolBar->setHorizontalStretchable (true ); 945 iconToolBar->setHorizontalStretchable (true );
944 //menuBar->insertItem( iconToolBar ); 946 //menuBar->insertItem( iconToolBar );
945 //xdays_action 947 //xdays_action
946 if (p-> mShowIconNewEvent) 948 if (p-> mShowIconNewEvent)
947 ne_action->addTo( iconToolBar ); 949 ne_action->addTo( iconToolBar );
948 if (p->mShowIconNewTodo ) 950 if (p->mShowIconNewTodo )
949 nt_action->addTo( iconToolBar ); 951 nt_action->addTo( iconToolBar );
950 if (p-> mShowIconSearch) 952 if (p-> mShowIconSearch)
951 search_action->addTo( iconToolBar ); 953 search_action->addTo( iconToolBar );
952 if (p-> mShowIconNext) 954 if (p-> mShowIconNext)
953 whatsnext_action->addTo( iconToolBar ); 955 whatsnext_action->addTo( iconToolBar );
954 if (p-> mShowIconNextDays) 956 if (p-> mShowIconNextDays)
955 xdays_action->addTo( iconToolBar ); 957 xdays_action->addTo( iconToolBar );
956 if (p-> mShowIconList) 958 if (p-> mShowIconList)
957 showlist_action->addTo( iconToolBar ); 959 showlist_action->addTo( iconToolBar );
958 if (p-> mShowIconDay1) 960 if (p-> mShowIconDay1)
959 day1_action->addTo( iconToolBar ); 961 day1_action->addTo( iconToolBar );
960 if (p-> mShowIconDay5) 962 if (p-> mShowIconDay5)
961 day5_action->addTo( iconToolBar ); 963 day5_action->addTo( iconToolBar );
962 if (p-> mShowIconDay7) 964 if (p-> mShowIconDay7)
963 day7_action->addTo( iconToolBar ); 965 day7_action->addTo( iconToolBar );
964 if (p-> mShowIconMonth) 966 if (p-> mShowIconMonth)
965 month_action->addTo( iconToolBar ); 967 month_action->addTo( iconToolBar );
966 if (p-> mShowIconTodoview) 968 if (p-> mShowIconTodoview)
967 todoview_action->addTo( iconToolBar ); 969 todoview_action->addTo( iconToolBar );
968 if (p-> mShowIconJournal) 970 if (p-> mShowIconJournal)
969 viewjournal_action->addTo( iconToolBar ); 971 viewjournal_action->addTo( iconToolBar );
970 icon = loadPixmap( pathString + "2leftarrowB" ); 972 icon = loadPixmap( pathString + "2leftarrowB" );
971 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 973 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
972 if (p-> mShowIconBackFast) { 974 if (p-> mShowIconBackFast) {
973 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 975 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
974 connect( action, SIGNAL( activated() ), 976 connect( action, SIGNAL( activated() ),
975 mView, SLOT( goPreviousMonth() ) ); 977 mView, SLOT( goPreviousMonth() ) );
976 action->addTo( iconToolBar ); 978 action->addTo( iconToolBar );
977 } 979 }
978 icon = loadPixmap( pathString + "1leftarrowB" ); 980 icon = loadPixmap( pathString + "1leftarrowB" );
979 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 981 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
980 if (p-> mShowIconBack) { 982 if (p-> mShowIconBack) {
981 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 983 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
982 connect( action, SIGNAL( activated() ), 984 connect( action, SIGNAL( activated() ),
983 mView, SLOT( goPrevious() ) ); 985 mView, SLOT( goPrevious() ) );
984 action->addTo( iconToolBar ); 986 action->addTo( iconToolBar );
985 } 987 }
986 icon = loadPixmap( pathString + "today" ); 988 icon = loadPixmap( pathString + "today" );
987 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 989 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
988 if (p-> mShowIconToday) 990 if (p-> mShowIconToday)
989 today_action->addTo( iconToolBar ); 991 today_action->addTo( iconToolBar );
990 icon = loadPixmap( pathString + "1rightarrowB" ); 992 icon = loadPixmap( pathString + "1rightarrowB" );
991 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 993 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
992 if (p-> mShowIconForward) { 994 if (p-> mShowIconForward) {
993 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 995 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
994 connect( action, SIGNAL( activated() ), 996 connect( action, SIGNAL( activated() ),
995 mView, SLOT( goNext() ) ); 997 mView, SLOT( goNext() ) );
996 action->addTo( iconToolBar ); 998 action->addTo( iconToolBar );
997 } 999 }
998 icon = loadPixmap( pathString + "2rightarrowB" ); 1000 icon = loadPixmap( pathString + "2rightarrowB" );
999 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1001 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1000 if (p-> mShowIconForwardFast) { 1002 if (p-> mShowIconForwardFast) {
1001 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1003 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1002 connect( action, SIGNAL( activated() ), 1004 connect( action, SIGNAL( activated() ),
1003 mView, SLOT( goNextMonth() ) ); 1005 mView, SLOT( goNextMonth() ) );
1004 action->addTo( iconToolBar ); 1006 action->addTo( iconToolBar );
1005 } 1007 }
1006 1008
1007 1009
1008 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1010 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1009 1011
1010 if (p-> mShowIconNewEvent) 1012 if (p-> mShowIconNewEvent)
1011 configureToolBarMenu->setItemChecked( 10, true ); 1013 configureToolBarMenu->setItemChecked( 10, true );
1012 if (p->mShowIconNewTodo ) 1014 if (p->mShowIconNewTodo )
1013 configureToolBarMenu->setItemChecked( 20, true ); 1015 configureToolBarMenu->setItemChecked( 20, true );
1014 if (p-> mShowIconSearch) 1016 if (p-> mShowIconSearch)
1015 configureToolBarMenu->setItemChecked( 120, true ); 1017 configureToolBarMenu->setItemChecked( 120, true );
1016 if (p-> mShowIconList) 1018 if (p-> mShowIconList)
1017 configureToolBarMenu->setItemChecked( 30, true ); 1019 configureToolBarMenu->setItemChecked( 30, true );
1018 if (p-> mShowIconDay1) 1020 if (p-> mShowIconDay1)
1019 configureToolBarMenu->setItemChecked( 40, true ); 1021 configureToolBarMenu->setItemChecked( 40, true );
1020 if (p-> mShowIconDay5) 1022 if (p-> mShowIconDay5)
1021 configureToolBarMenu->setItemChecked( 50, true ); 1023 configureToolBarMenu->setItemChecked( 50, true );
1022 if (p-> mShowIconDay7) 1024 if (p-> mShowIconDay7)
1023 configureToolBarMenu->setItemChecked( 60, true ); 1025 configureToolBarMenu->setItemChecked( 60, true );
1024 if (p-> mShowIconMonth) 1026 if (p-> mShowIconMonth)
1025 configureToolBarMenu->setItemChecked( 70, true ); 1027 configureToolBarMenu->setItemChecked( 70, true );
1026 if (p-> mShowIconTodoview) 1028 if (p-> mShowIconTodoview)
1027 configureToolBarMenu->setItemChecked( 80, true ); 1029 configureToolBarMenu->setItemChecked( 80, true );
1028 if (p-> mShowIconBackFast) 1030 if (p-> mShowIconBackFast)
1029 configureToolBarMenu->setItemChecked( 200, true ); 1031 configureToolBarMenu->setItemChecked( 200, true );
1030 if (p-> mShowIconBack) 1032 if (p-> mShowIconBack)
1031 configureToolBarMenu->setItemChecked( 210, true ); 1033 configureToolBarMenu->setItemChecked( 210, true );
1032 if (p-> mShowIconToday) 1034 if (p-> mShowIconToday)
1033 configureToolBarMenu->setItemChecked( 130, true ); 1035 configureToolBarMenu->setItemChecked( 130, true );
1034 if (p-> mShowIconForward) 1036 if (p-> mShowIconForward)
1035 configureToolBarMenu->setItemChecked( 220, true ); 1037 configureToolBarMenu->setItemChecked( 220, true );
1036 if (p-> mShowIconForwardFast) 1038 if (p-> mShowIconForwardFast)
1037 configureToolBarMenu->setItemChecked( 230, true ); 1039 configureToolBarMenu->setItemChecked( 230, true );
1038 if (p-> mShowIconNextDays) 1040 if (p-> mShowIconNextDays)
1039 configureToolBarMenu->setItemChecked( 100, true ); 1041 configureToolBarMenu->setItemChecked( 100, true );
1040 if (p-> mShowIconNext) 1042 if (p-> mShowIconNext)
1041 configureToolBarMenu->setItemChecked( 110, true ); 1043 configureToolBarMenu->setItemChecked( 110, true );
1042 if (p-> mShowIconJournal) 1044 if (p-> mShowIconJournal)
1043 configureToolBarMenu->setItemChecked( 90, true ); 1045 configureToolBarMenu->setItemChecked( 90, true );
1044 if (p-> mShowIconWhatsThis) 1046 if (p-> mShowIconWhatsThis)
1045 configureToolBarMenu->setItemChecked( 300, true ); 1047 configureToolBarMenu->setItemChecked( 300, true );
1046 1048
1047 QLabel* dummy = new QLabel( iconToolBar ); 1049 QLabel* dummy = new QLabel( iconToolBar );
1048 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1050 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1049 if (!p-> mShowIconStretch) 1051 if (!p-> mShowIconStretch)
1050 iconToolBar->setStretchableWidget ( dummy ) ; 1052 iconToolBar->setStretchableWidget ( dummy ) ;
1051 else 1053 else
1052 configureToolBarMenu->setItemChecked( 5, true ); 1054 configureToolBarMenu->setItemChecked( 5, true );
1053 if (p-> mShowIconWhatsThis) 1055 if (p-> mShowIconWhatsThis)
1054 QWhatsThis::whatsThisButton ( iconToolBar ); 1056 QWhatsThis::whatsThisButton ( iconToolBar );
1055 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1057 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1056 configureAgenda( p->mHourSize ); 1058 configureAgenda( p->mHourSize );
1057 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1059 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1058} 1060}
1059 1061
1060void MainWindow::exportToPhone( int mode ) 1062void MainWindow::exportToPhone( int mode )
1061{ 1063{
1062 1064
1063 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1065 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1064 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1066 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1065 KOex2phonePrefs ex2phone; 1067 KOex2phonePrefs ex2phone;
1066 1068
1067 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1069 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1068 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1070 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1069 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1071 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1070 if ( mode == 1 ) 1072 if ( mode == 1 )
1071 ex2phone.setCaption(i18n("Export complete calendar")); 1073 ex2phone.setCaption(i18n("Export complete calendar"));
1072 if ( mode == 2 ) 1074 if ( mode == 2 )
1073 ex2phone.setCaption(i18n("Export filtered calendar")); 1075 ex2phone.setCaption(i18n("Export filtered calendar"));
1074 1076
1075 if ( !ex2phone.exec() ) { 1077 if ( !ex2phone.exec() ) {
1076 return; 1078 return;
1077 } 1079 }
1078 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1080 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1079 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1081 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1080 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1082 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1081 1083
1082 int inFuture = 0; 1084 int inFuture = 0;
1083 if ( ex2phone.mWriteBackFuture->isChecked() ) 1085 if ( ex2phone.mWriteBackFuture->isChecked() )
1084 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1086 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1085 QPtrList<Incidence> delSel; 1087 QPtrList<Incidence> delSel;
1086 if ( mode == 1 ) 1088 if ( mode == 1 )
1087 delSel = mCalendar->rawIncidences(); 1089 delSel = mCalendar->rawIncidences();
1088 if ( mode == 2 ) 1090 if ( mode == 2 )
1089 delSel = mCalendar->incidences(); 1091 delSel = mCalendar->incidences();
1090 CalendarLocal* cal = new CalendarLocal(); 1092 CalendarLocal* cal = new CalendarLocal();
1091 cal->setLocalTime(); 1093 cal->setLocalTime();
1092 Incidence *incidence = delSel.first(); 1094 Incidence *incidence = delSel.first();
1093 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1095 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1094 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1096 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1095 while ( incidence ) { 1097 while ( incidence ) {
1096 if ( incidence->type() != "Journal" ) { 1098 if ( incidence->type() != "Journal" ) {
1097 bool add = true; 1099 bool add = true;
1098 if ( inFuture ) { 1100 if ( inFuture ) {
1099 QDateTime dt; 1101 QDateTime dt;
1100 if ( incidence->type() == "Todo" ) { 1102 if ( incidence->type() == "Todo" ) {
1101 Todo * t = (Todo*)incidence; 1103 Todo * t = (Todo*)incidence;
1102 if ( t->hasDueDate() ) 1104 if ( t->hasDueDate() )
1103 dt = t->dtDue(); 1105 dt = t->dtDue();
1104 else 1106 else
1105 dt = cur.addSecs( 62 ); 1107 dt = cur.addSecs( 62 );
1106 } 1108 }
1107 else { 1109 else {
1108 bool ok; 1110 bool ok;
1109 dt = incidence->getNextOccurence( cur, &ok ); 1111 dt = incidence->getNextOccurence( cur, &ok );
1110 if ( !ok ) 1112 if ( !ok )
1111 dt = cur.addSecs( -62 ); 1113 dt = cur.addSecs( -62 );
1112 } 1114 }
1113 if ( dt < cur || dt > end ) { 1115 if ( dt < cur || dt > end ) {
1114 add = false; 1116 add = false;
1115 } 1117 }
1116 } 1118 }
1117 if ( add ) { 1119 if ( add ) {
1118 Incidence *in = incidence->clone(); 1120 Incidence *in = incidence->clone();
1119 cal->addIncidence( in ); 1121 cal->addIncidence( in );
1120 } 1122 }
1121 } 1123 }
1122 incidence = delSel.next(); 1124 incidence = delSel.next();
1123 } 1125 }
1124 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1126 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1125 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1127 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1126 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1128 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1127 1129
1128 setCaption( i18n("Writing to phone...")); 1130 setCaption( i18n("Writing to phone..."));
1129 if ( PhoneFormat::writeToPhone( cal ) ) 1131 if ( PhoneFormat::writeToPhone( cal ) )
1130 setCaption( i18n("Export to phone successful!")); 1132 setCaption( i18n("Export to phone successful!"));
1131 else 1133 else
1132 setCaption( i18n("Error exporting to phone!")); 1134 setCaption( i18n("Error exporting to phone!"));
1133 delete cal; 1135 delete cal;
1134} 1136}
1135 1137
1136 1138
1137void MainWindow::setDefaultPreferences() 1139void MainWindow::setDefaultPreferences()
1138{ 1140{
1139 KOPrefs *p = KOPrefs::instance(); 1141 KOPrefs *p = KOPrefs::instance();
1140 1142
1141 p->mCompactDialogs = true; 1143 p->mCompactDialogs = true;
1142 p->mConfirm = true; 1144 p->mConfirm = true;
1143 // p->mEnableQuickTodo = false; 1145 // p->mEnableQuickTodo = false;
1144 1146
1145} 1147}
1146 1148
1147QString MainWindow::resourcePath() 1149QString MainWindow::resourcePath()
1148{ 1150{
1149 return KGlobal::iconLoader()->iconPath(); 1151 return KGlobal::iconLoader()->iconPath();
1150} 1152}
1151 1153
1152void MainWindow::displayText( QString text ,QString cap ) 1154void MainWindow::displayText( QString text ,QString cap )
1153{ 1155{
1154 QDialog dia( this, "name", true ); ; 1156 QDialog dia( this, "name", true ); ;
1155 dia.setCaption( cap ); 1157 dia.setCaption( cap );
1156 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1158 QVBoxLayout* lay = new QVBoxLayout( &dia );
1157 lay->setSpacing( 3 ); 1159 lay->setSpacing( 3 );
1158 lay->setMargin( 3 ); 1160 lay->setMargin( 3 );
1159 QTextBrowser tb ( &dia ); 1161 QTextBrowser tb ( &dia );
1160 lay->addWidget( &tb ); 1162 lay->addWidget( &tb );
1161 tb.setText( text ); 1163 tb.setText( text );
1162#ifdef DESKTOP_VERSION 1164#ifdef DESKTOP_VERSION
1163 dia.resize( 640, 480); 1165 dia.resize( 640, 480);
1164#else 1166#else
1165 dia.showMaximized(); 1167 dia.showMaximized();
1166#endif 1168#endif
1167 dia.exec(); 1169 dia.exec();
1168} 1170}
1169 1171
1170void MainWindow::features() 1172void MainWindow::features()
1171{ 1173{
1172 1174
1173 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1175 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1174} 1176}
1175 1177
1176void MainWindow::usertrans() 1178void MainWindow::usertrans()
1177{ 1179{
1178 1180
1179 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1181 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1180} 1182}
1181 1183
1182void MainWindow::kdesynchowto() 1184void MainWindow::kdesynchowto()
1183{ 1185{
1184 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1186 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1185} 1187}
1186void MainWindow::multisynchowto() 1188void MainWindow::multisynchowto()
1187{ 1189{
1188 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1190 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1189} 1191}
1190void MainWindow::synchowto() 1192void MainWindow::synchowto()
1191{ 1193{
1192 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1194 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1193} 1195}
1194void MainWindow::faq() 1196void MainWindow::faq()
1195{ 1197{
1196 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1198 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1197 1199
1198} 1200}
1199void MainWindow::whatsNew() 1201void MainWindow::whatsNew()
1200{ 1202{
1201 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1203 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1202 1204
1203} 1205}
1204void MainWindow::licence() 1206void MainWindow::licence()
1205{ 1207{
1206 KApplication::showLicence(); 1208 KApplication::showLicence();
1207 1209
1208} 1210}
1209void MainWindow::about() 1211void MainWindow::about()
1210{ 1212{
1211 QString version; 1213 QString version;
1212#include <../version> 1214#include <../version>
1213 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1215 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1214 i18n("KOrganizer/Platform-independent\n") + 1216 i18n("KOrganizer/Platform-independent\n") +
1215 "(KO/Pi) " + version + " - " + 1217 "(KO/Pi) " + version + " - " +
1216 1218
1217#ifdef DESKTOP_VERSION 1219#ifdef DESKTOP_VERSION
1218 i18n("Desktop Edition\n") + 1220 i18n("Desktop Edition\n") +
1219#else 1221#else
1220 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1222 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1221#endif 1223#endif
1222 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1224 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1223} 1225}
1224void MainWindow::keyBindings() 1226void MainWindow::keyBindings()
1225{ 1227{
1226 QString cap = i18n("KO/Pi Keys + Colors"); 1228 QString cap = i18n("KO/Pi Keys + Colors");
1227 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1229 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1228 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1230 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1229 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1231 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1230 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1232 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1231 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1233 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1232 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1234 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1233 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1235 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1234 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1236 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1235 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1237 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1236 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1238 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1237 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1239 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1238 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1240 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1239 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1241 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1240 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1242 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1241 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1243 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1242 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1244 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1243 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1245 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1244 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1246 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1245 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1247 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1246 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1248 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1247 i18n("<p><h3>In agenda view:</h3></p>\n") + 1249 i18n("<p><h3>In agenda view:</h3></p>\n") +
1248 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1250 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1249 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1251 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1250 i18n("<p><h3>In todo view:</h3></p>\n") + 1252 i18n("<p><h3>In todo view:</h3></p>\n") +
1251 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1253 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1252 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1254 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1253 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1255 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1254 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1256 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1255 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1257 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1256 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1258 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1257 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1259 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1258 i18n("<p><h3>In list view:</h3></p>\n") + 1260 i18n("<p><h3>In list view:</h3></p>\n") +
1259 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1261 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1260 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1262 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1261 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1263 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1262 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1264 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1263 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1265 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1264 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1266 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1265 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1267 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1266 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1268 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1267 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1269 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1268 i18n("<p><b>E</b>: Edit item</p>\n") + 1270 i18n("<p><b>E</b>: Edit item</p>\n") +
1269 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1271 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1270 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1272 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1271 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1273 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1272 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1274 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1273 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1275 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1274 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1276 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1275 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1277 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1276 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1278 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1277 i18n("<p><b>White</b>: Item readonly</p>\n"); 1279 i18n("<p><b>White</b>: Item readonly</p>\n");
1278 displayText( text, cap); 1280 displayText( text, cap);
1279} 1281}
1280void MainWindow::aboutAutoSaving() 1282void MainWindow::aboutAutoSaving()
1281{ 1283{
1282 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1284 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1283 1285
1284 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1286 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1285 1287
1286} 1288}
1287void MainWindow::aboutKnownBugs() 1289void MainWindow::aboutKnownBugs()
1288{ 1290{
1289 QMessageBox* msg; 1291 QMessageBox* msg;
1290 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1292 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1291 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1293 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1292 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1294 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1293 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1295 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1294 i18n("\nor report them in the bugtracker on\n") + 1296 i18n("\nor report them in the bugtracker on\n") +
1295 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1297 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1296 QMessageBox::NoIcon, 1298 QMessageBox::NoIcon,
1297 QMessageBox::Ok, 1299 QMessageBox::Ok,
1298 QMessageBox::NoButton, 1300 QMessageBox::NoButton,
1299 QMessageBox::NoButton); 1301 QMessageBox::NoButton);
1300 msg->exec(); 1302 msg->exec();
1301 delete msg; 1303 delete msg;
1302 1304
1303} 1305}
1304 1306
1305QString MainWindow::defaultFileName() 1307QString MainWindow::defaultFileName()
1306{ 1308{
1307 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1309 return locateLocal( "data", "korganizer/mycalendar.ics" );
1308} 1310}
1309QString MainWindow::syncFileName() 1311QString MainWindow::syncFileName()
1310{ 1312{
1311#ifdef DESKTOP_VERSION 1313#ifdef DESKTOP_VERSION
1312 return locateLocal( "tmp", "synccalendar.ics" ); 1314 return locateLocal( "tmp", "synccalendar.ics" );
1313#else 1315#else
1314 return QString( "/tmp/synccalendar.ics" ); 1316 return QString( "/tmp/synccalendar.ics" );
1315#endif 1317#endif
1316} 1318}
1317 1319
1318void MainWindow::processIncidenceSelection( Incidence *incidence ) 1320void MainWindow::processIncidenceSelection( Incidence *incidence )
1319{ 1321{
1320 if ( !incidence ) { 1322 if ( !incidence ) {
1321 enableIncidenceActions( false ); 1323 enableIncidenceActions( false );
1322 1324
1323 mNewSubTodoAction->setEnabled( false ); 1325 mNewSubTodoAction->setEnabled( false );
1324 setCaptionToDates(); 1326 setCaptionToDates();
1325 return; 1327 return;
1326 1328
1327 } 1329 }
1328 1330
1329 //KGlobal::locale()->formatDateTime(nextA, true); 1331 //KGlobal::locale()->formatDateTime(nextA, true);
1330 QString startString = ""; 1332 QString startString = "";
1331 if ( incidence->type() != "Todo" ) { 1333 if ( incidence->type() != "Todo" ) {
1332 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1334 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1333 if ( incidence->doesFloat() ) { 1335 if ( incidence->doesFloat() ) {
1334 startString += ": "+incidence->dtStartDateStr( true ); 1336 startString += ": "+incidence->dtStartDateStr( true );
1335 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1337 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1336 1338
1337 } else { 1339 } else {
1338 startString = ": "+incidence->dtStartStr(true); 1340 startString = ": "+incidence->dtStartStr(true);
1339 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1341 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1340 1342
1341 } 1343 }
1342 1344
1343 } else { 1345 } else {
1344 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1346 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1345 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1347 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1346 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1348 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1347 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1349 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1348 } 1350 }
1349 1351
1350 } 1352 }
1351 else 1353 else
1352 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1354 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1353 if ( !incidence->location().isEmpty() ) 1355 if ( !incidence->location().isEmpty() )
1354 startString += " (" +incidence->location()+")"; 1356 startString += " (" +incidence->location()+")";
1355 setCaption( incidence->summary()+startString); 1357 setCaption( incidence->summary()+startString);
1356 1358
1357 enableIncidenceActions( true ); 1359 enableIncidenceActions( true );
1358 1360
1359 if ( incidence->type() == "Event" ) { 1361 if ( incidence->type() == "Event" ) {
1360 mShowAction->setText( i18n("Show Event...") ); 1362 mShowAction->setText( i18n("Show Event...") );
1361 mEditAction->setText( i18n("Edit Event...") ); 1363 mEditAction->setText( i18n("Edit Event...") );
1362 mDeleteAction->setText( i18n("Delete Event...") ); 1364 mDeleteAction->setText( i18n("Delete Event...") );
1363 1365
1364 mNewSubTodoAction->setEnabled( false ); 1366 mNewSubTodoAction->setEnabled( false );
1365 } else if ( incidence->type() == "Todo" ) { 1367 } else if ( incidence->type() == "Todo" ) {
1366 mShowAction->setText( i18n("Show Todo...") ); 1368 mShowAction->setText( i18n("Show Todo...") );
1367 mEditAction->setText( i18n("Edit Todo...") ); 1369 mEditAction->setText( i18n("Edit Todo...") );
1368 mDeleteAction->setText( i18n("Delete Todo...") ); 1370 mDeleteAction->setText( i18n("Delete Todo...") );
1369 1371
1370 mNewSubTodoAction->setEnabled( true ); 1372 mNewSubTodoAction->setEnabled( true );
1371 } else { 1373 } else {
1372 mShowAction->setText( i18n("Show...") ); 1374 mShowAction->setText( i18n("Show...") );
1373 mShowAction->setText( i18n("Edit...") ); 1375 mShowAction->setText( i18n("Edit...") );
1374 mShowAction->setText( i18n("Delete...") ); 1376 mShowAction->setText( i18n("Delete...") );
1375 1377
1376 mNewSubTodoAction->setEnabled( false ); 1378 mNewSubTodoAction->setEnabled( false );
1377 } 1379 }
1378} 1380}
1379 1381
1380void MainWindow::enableIncidenceActions( bool enabled ) 1382void MainWindow::enableIncidenceActions( bool enabled )
1381{ 1383{
1382 mShowAction->setEnabled( enabled ); 1384 mShowAction->setEnabled( enabled );
1383 mEditAction->setEnabled( enabled ); 1385 mEditAction->setEnabled( enabled );
1384 mDeleteAction->setEnabled( enabled ); 1386 mDeleteAction->setEnabled( enabled );
1385 1387
1386 mCloneAction->setEnabled( enabled ); 1388 mCloneAction->setEnabled( enabled );
1387 mMoveAction->setEnabled( enabled ); 1389 mMoveAction->setEnabled( enabled );
1388 mBeamAction->setEnabled( enabled ); 1390 mBeamAction->setEnabled( enabled );
1389 mCancelAction->setEnabled( enabled ); 1391 mCancelAction->setEnabled( enabled );
1390} 1392}
1391 1393
1392void MainWindow::importOL() 1394void MainWindow::importOL()
1393{ 1395{
1394#ifdef _OL_IMPORT_ 1396#ifdef _OL_IMPORT_
1395 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1397 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1396 id->exec(); 1398 id->exec();
1397 delete id; 1399 delete id;
1398 mView->updateView(); 1400 mView->updateView();
1399#endif 1401#endif
1400} 1402}
1401void MainWindow::importBday() 1403void MainWindow::importBday()
1402{ 1404{
1403 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1405 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1404 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1406 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1405 i18n("Import!"), i18n("Cancel"), 0, 1407 i18n("Import!"), i18n("Cancel"), 0,
1406 0, 1 ); 1408 0, 1 );
1407 if ( result == 0 ) { 1409 if ( result == 0 ) {
1408 mView->importBday(); 1410 mView->importBday();
1409 1411
1410 } 1412 }
1411 1413
1412 1414
1413} 1415}
1414void MainWindow::importQtopia() 1416void MainWindow::importQtopia()
1415{ 1417{
1416#ifndef DESKTOP_VERSION 1418#ifndef DESKTOP_VERSION
1417 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1419 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1418 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1420 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1419 i18n("Import!"), i18n("Cancel"), 0, 1421 i18n("Import!"), i18n("Cancel"), 0,
1420 0, 1 ); 1422 0, 1 );
1421 if ( result == 0 ) { 1423 if ( result == 0 ) {
1422 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1424 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1423 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1425 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1424 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1426 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1425 mView->importQtopia( categories, datebook, todolist ); 1427 mView->importQtopia( categories, datebook, todolist );
1426 } 1428 }
1427#else 1429#else
1428 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1430 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1429 i18n("Not supported \non desktop!\n"), 1431 i18n("Not supported \non desktop!\n"),
1430 i18n("Ok"), i18n("Cancel"), 0, 1432 i18n("Ok"), i18n("Cancel"), 0,
1431 0, 1 ); 1433 0, 1 );
1432 1434
1433#endif 1435#endif
1434} 1436}
1435 1437
1436void MainWindow::saveOnClose() 1438void MainWindow::saveOnClose()
1437{ 1439{
1438 KOPrefs *p = KOPrefs::instance(); 1440 KOPrefs *p = KOPrefs::instance();
1439 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1441 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1440 p->mToolBarUp = iconToolBar->x() > width()/2 || 1442 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1441 iconToolBar->y() > height()/2; 1443 iconToolBar->y() > height()/2;
1442 mView->writeSettings(); 1444 mView->writeSettings();
1443 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1445 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1444 save(); 1446 save();
1445} 1447}
1446void MainWindow::slotModifiedChanged( bool changed ) 1448void MainWindow::slotModifiedChanged( bool changed )
1447{ 1449{
1448 if ( mBlockAtStartup ) 1450 if ( mBlockAtStartup )
1449 return; 1451 return;
1452
1450 int msec; 1453 int msec;
1451 // we store the changes after 1 minute, 1454 // we store the changes after 1 minute,
1452 // and for safety reasons after 10 minutes again 1455 // and for safety reasons after 10 minutes again
1453 if ( !mSyncManager->blockSave() ) 1456 if ( !mSyncManager->blockSave() )
1454 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1457 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1455 else 1458 else
1456 msec = 1000 * 600; 1459 msec = 1000 * 600;
1457 mSaveTimer.start( msec, true ); // 1 minute 1460 mSaveTimer.start( msec, true ); // 1 minute
1458 qDebug("KO: Saving File in %d secs!", msec/1000); 1461 qDebug("KO: Saving File in %d secs!", msec/1000);
1459 mCalendarModifiedFlag = true; 1462 mCalendarModifiedFlag = true;
1460} 1463}
1464void MainWindow::saveStopTimer()
1465{
1466 mSaveTimer.stop();
1467 if (mSaveTimer.isActive() )
1468 qDebug("ti active ");
1469 else
1470 qDebug("KO: Save timer stopped");
1471}
1461void MainWindow::save() 1472void MainWindow::save()
1462{ 1473{
1474 if ( !mCalendarModifiedFlag ) {
1475 qDebug("KO: Calendar not modified. Nothing saved.");
1476 return;
1477 }
1463 if ( mSyncManager->blockSave() ) 1478 if ( mSyncManager->blockSave() )
1464 return; 1479 return;
1465 mSyncManager->setBlockSave(true); 1480 mSyncManager->setBlockSave(true);
1466 if ( mView->checkFileVersion( defaultFileName()) ) { 1481 if ( mView->checkFileVersion( defaultFileName()) ) {
1467
1468 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1482 QTime neededSaveTime = QDateTime::currentDateTime().time();
1469 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1483 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1470 qDebug("KO: Start saving data to file!"); 1484 qDebug("KO: Start saving data to file!");
1471 mView->saveCalendar( defaultFileName() ); 1485 mView->saveCalendar( defaultFileName() );
1472 1486 mCalendarModifiedFlag = false;
1473 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1487 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1474 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1488 qDebug("KO: Needed %d ms for saving.",msNeeded );
1475 QString savemes; 1489 QString savemes;
1476 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1490 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1477 setCaption(savemes); 1491 setCaption(savemes);
1478 } else 1492 } else
1479 setCaption(i18n("Saving cancelled!")); 1493 setCaption(i18n("Saving cancelled!"));
1480 mCalendarModifiedFlag = false;
1481 mSyncManager->setBlockSave( false ); 1494 mSyncManager->setBlockSave( false );
1482} 1495}
1483 1496
1484void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1497void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1485{ 1498{
1486 if ( !e->isAutoRepeat() ) { 1499 if ( !e->isAutoRepeat() ) {
1487 mFlagKeyPressed = false; 1500 mFlagKeyPressed = false;
1488 } 1501 }
1489} 1502}
1490void MainWindow::keyPressEvent ( QKeyEvent * e ) 1503void MainWindow::keyPressEvent ( QKeyEvent * e )
1491{ 1504{
1492 qApp->processEvents(); 1505 qApp->processEvents();
1493 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1506 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1494 e->ignore(); 1507 e->ignore();
1495 // qDebug(" ignore %d",e->isAutoRepeat() ); 1508 // qDebug(" ignore %d",e->isAutoRepeat() );
1496 return; 1509 return;
1497 } 1510 }
1498 if (! e->isAutoRepeat() ) 1511 if (! e->isAutoRepeat() )
1499 mFlagKeyPressed = true; 1512 mFlagKeyPressed = true;
1500 KOPrefs *p = KOPrefs::instance(); 1513 KOPrefs *p = KOPrefs::instance();
1501 bool showSelectedDates = false; 1514 bool showSelectedDates = false;
1502 int size; 1515 int size;
1503 int pro = 0; 1516 int pro = 0;
1504 //qDebug("MainWindow::keyPressEvent "); 1517 //qDebug("MainWindow::keyPressEvent ");
1505 switch ( e->key() ) { 1518 switch ( e->key() ) {
1506 case Qt::Key_Right: 1519 case Qt::Key_Right:
1507 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1520 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1508 mView->goNextMonth(); 1521 mView->goNextMonth();
1509 else 1522 else
1510 mView->goNext(); 1523 mView->goNext();
1511 showSelectedDates = true; 1524 showSelectedDates = true;
1512 break; 1525 break;
1513 case Qt::Key_Left: 1526 case Qt::Key_Left:
1514 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1527 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1515 mView->goPreviousMonth(); 1528 mView->goPreviousMonth();
1516 else 1529 else
1517 mView->goPrevious(); 1530 mView->goPrevious();
1518 showSelectedDates = true; 1531 showSelectedDates = true;
1519 break; 1532 break;
1520 case Qt::Key_Down: 1533 case Qt::Key_Down:
1521 mView->viewManager()->agendaView()->scrollOneHourDown(); 1534 mView->viewManager()->agendaView()->scrollOneHourDown();
1522 break; 1535 break;
1523 case Qt::Key_Up: 1536 case Qt::Key_Up:
1524 mView->viewManager()->agendaView()->scrollOneHourUp(); 1537 mView->viewManager()->agendaView()->scrollOneHourUp();
1525 break; 1538 break;
1526 case Qt::Key_I: 1539 case Qt::Key_I:
1527 mView->showIncidence(); 1540 mView->showIncidence();
1528 break; 1541 break;
1529 case Qt::Key_Delete: 1542 case Qt::Key_Delete:
1530 case Qt::Key_Backspace: 1543 case Qt::Key_Backspace:
1531 mView->deleteIncidence(); 1544 mView->deleteIncidence();
1532 break; 1545 break;
1533 case Qt::Key_D: 1546 case Qt::Key_D:
1534 mView->viewManager()->showDayView(); 1547 mView->viewManager()->showDayView();
1535 showSelectedDates = true; 1548 showSelectedDates = true;
1536 break; 1549 break;
1537 case Qt::Key_O: 1550 case Qt::Key_O:
1538 mView->toggleFilerEnabled( ); 1551 mView->toggleFilerEnabled( );
1539 break; 1552 break;
1540 case Qt::Key_0: 1553 case Qt::Key_0:
1541 case Qt::Key_1: 1554 case Qt::Key_1:
1542 case Qt::Key_2: 1555 case Qt::Key_2:
1543 case Qt::Key_3: 1556 case Qt::Key_3:
1544 case Qt::Key_4: 1557 case Qt::Key_4:
1545 case Qt::Key_5: 1558 case Qt::Key_5:
1546 case Qt::Key_6: 1559 case Qt::Key_6:
1547 case Qt::Key_7: 1560 case Qt::Key_7:
1548 case Qt::Key_8: 1561 case Qt::Key_8:
1549 case Qt::Key_9: 1562 case Qt::Key_9:
1550 pro = e->key()-48; 1563 pro = e->key()-48;
1551 if ( pro == 0 ) 1564 if ( pro == 0 )
1552 pro = 10; 1565 pro = 10;
1553 if ( e->state() == Qt::ControlButton) 1566 if ( e->state() == Qt::ControlButton)
1554 pro += 10; 1567 pro += 10;
1555 break; 1568 break;
1556 case Qt::Key_M: 1569 case Qt::Key_M:
1557 mView->viewManager()->showMonthView(); 1570 mView->viewManager()->showMonthView();
1558 showSelectedDates = true; 1571 showSelectedDates = true;
1559 break; 1572 break;
1560 case Qt::Key_Insert: 1573 case Qt::Key_Insert:
1561 mView->newEvent(); 1574 mView->newEvent();
1562 break; 1575 break;
1563 case Qt::Key_S : 1576 case Qt::Key_S :
1564 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1577 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1565 mView->newSubTodo(); 1578 mView->newSubTodo();
1566 else 1579 else
1567 mView->dialogManager()->showSearchDialog(); 1580 mView->dialogManager()->showSearchDialog();
1568 break; 1581 break;
1569 case Qt::Key_Y : 1582 case Qt::Key_Y :
1570 case Qt::Key_Z : 1583 case Qt::Key_Z :
1571 mView->viewManager()->showWorkWeekView(); 1584 mView->viewManager()->showWorkWeekView();
1572 showSelectedDates = true; 1585 showSelectedDates = true;
1573 break; 1586 break;
1574 case Qt::Key_U : 1587 case Qt::Key_U :
1575 mView->viewManager()->showWeekView(); 1588 mView->viewManager()->showWeekView();
1576 showSelectedDates = true; 1589 showSelectedDates = true;
1577 break; 1590 break;
1578 case Qt::Key_H : 1591 case Qt::Key_H :
1579 keyBindings(); 1592 keyBindings();
1580 break; 1593 break;
1581 case Qt::Key_W: 1594 case Qt::Key_W:
1582 mView->viewManager()->showWhatsNextView(); 1595 mView->viewManager()->showWhatsNextView();
1583 break; 1596 break;
1584 case Qt::Key_L: 1597 case Qt::Key_L:
1585 mView->viewManager()->showListView(); 1598 mView->viewManager()->showListView();
1586 break; 1599 break;
1587 case Qt::Key_N: 1600 case Qt::Key_N:
1588 mView->viewManager()->showNextXView(); 1601 mView->viewManager()->showNextXView();
1589 showSelectedDates = true; 1602 showSelectedDates = true;
1590 break; 1603 break;
1591 case Qt::Key_V: 1604 case Qt::Key_V:
1592 mView->viewManager()->showTodoView(); 1605 mView->viewManager()->showTodoView();
1593 break; 1606 break;
1594 case Qt::Key_C: 1607 case Qt::Key_C:
1595 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1608 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1596 break; 1609 break;
1597 case Qt::Key_P: 1610 case Qt::Key_P:
1598 mView->showDatePicker( ); 1611 mView->showDatePicker( );
1599 break; 1612 break;
1600 case Qt::Key_F: 1613 case Qt::Key_F:
1601 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1614 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1602 mView->editFilters(); 1615 mView->editFilters();
1603 else 1616 else
1604 mView->toggleFilter(); 1617 mView->toggleFilter();
1605 break; 1618 break;
1606 case Qt::Key_X: 1619 case Qt::Key_X:
1607 mView->toggleDateNavigatorWidget(); 1620 mView->toggleDateNavigatorWidget();
1608 break; 1621 break;
1609 case Qt::Key_Space: 1622 case Qt::Key_Space:
1610 mView->toggleExpand(); 1623 mView->toggleExpand();
1611 break; 1624 break;
1612 case Qt::Key_A: 1625 case Qt::Key_A:
1613 mView->toggleAllDaySize(); 1626 mView->toggleAllDaySize();
1614 break; 1627 break;
1615 case Qt::Key_T: 1628 case Qt::Key_T:
1616 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1629 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1617 mView->newTodo(); 1630 mView->newTodo();
1618 else { 1631 else {
1619 mView->goToday(); 1632 mView->goToday();
1620 showSelectedDates = true; 1633 showSelectedDates = true;
1621 } 1634 }
1622 break; 1635 break;
1623 case Qt::Key_J: 1636 case Qt::Key_J:
1624 mView->viewManager()->showJournalView(); 1637 mView->viewManager()->showJournalView();
1625 break; 1638 break;
1626 case Qt::Key_B: 1639 case Qt::Key_B:
1627 mView->editIncidenceDescription();; 1640 mView->editIncidenceDescription();;
1628 break; 1641 break;
1629 // case Qt::Key_Return: 1642 // case Qt::Key_Return:
1630 case Qt::Key_E: 1643 case Qt::Key_E:
1631 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1644 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1632 mView->newEvent(); 1645 mView->newEvent();
1633 else 1646 else
1634 mView->editIncidence(); 1647 mView->editIncidence();
1635 break; 1648 break;
1636 case Qt::Key_Plus: 1649 case Qt::Key_Plus:
1637 size = p->mHourSize +2; 1650 size = p->mHourSize +2;
1638 if ( size <= 18 ) 1651 if ( size <= 18 )
1639 configureAgenda( size ); 1652 configureAgenda( size );
1640 break; 1653 break;
1641 case Qt::Key_Minus: 1654 case Qt::Key_Minus:
1642 size = p->mHourSize - 2; 1655 size = p->mHourSize - 2;
1643 if ( size >= 4 ) 1656 if ( size >= 4 )
1644 configureAgenda( size ); 1657 configureAgenda( size );
1645 break; 1658 break;
1646 1659
1647 1660
1648 default: 1661 default:
1649 e->ignore(); 1662 e->ignore();
1650 } 1663 }
1651 if ( pro > 0 ) { 1664 if ( pro > 0 ) {
1652 mView->selectFilter( pro-1 ); 1665 mView->selectFilter( pro-1 );
1653 } 1666 }
1654 if ( showSelectedDates ) { 1667 if ( showSelectedDates ) {
1655 ;// setCaptionToDates(); 1668 ;// setCaptionToDates();
1656 } 1669 }
1657 1670
1658} 1671}
1659 1672
1660void MainWindow::fillFilterMenu() 1673void MainWindow::fillFilterMenu()
1661{ 1674{
1662 selectFilterMenu->clear(); 1675 selectFilterMenu->clear();
1663 bool disable = false; 1676 bool disable = false;
1664 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1677 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1665 selectFilterMenu->insertSeparator(); 1678 selectFilterMenu->insertSeparator();
1666 if ( mView->filterView()->filtersEnabled() ) { 1679 if ( mView->filterView()->filtersEnabled() ) {
1667 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1680 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1668 } 1681 }
1669 else { 1682 else {
1670 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1683 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1671 disable = true; 1684 disable = true;
1672 } 1685 }
1673 selectFilterMenu->insertSeparator(); 1686 selectFilterMenu->insertSeparator();
1674 QPtrList<CalFilter> fili = mView->filters(); 1687 QPtrList<CalFilter> fili = mView->filters();
1675 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1688 CalFilter *curfilter = mView->filterView()->selectedFilter();
1676 CalFilter *filter = fili.first(); 1689 CalFilter *filter = fili.first();
1677 int iii = 2; 1690 int iii = 2;
1678 while(filter) { 1691 while(filter) {
1679 selectFilterMenu->insertItem( filter->name(), iii ); 1692 selectFilterMenu->insertItem( filter->name(), iii );
1680 if ( filter == curfilter) 1693 if ( filter == curfilter)
1681 selectFilterMenu->setItemChecked( iii, true ); 1694 selectFilterMenu->setItemChecked( iii, true );
1682 if ( disable ) 1695 if ( disable )
1683 selectFilterMenu->setItemEnabled( iii, false ); 1696 selectFilterMenu->setItemEnabled( iii, false );
1684 filter = fili.next(); 1697 filter = fili.next();
1685 ++iii; 1698 ++iii;
1686 } 1699 }
1687} 1700}
1688void MainWindow::selectFilter( int fil ) 1701void MainWindow::selectFilter( int fil )
1689{ 1702{
1690 if ( fil == 0 ) { 1703 if ( fil == 0 ) {
1691 mView->editFilters( ); 1704 mView->editFilters( );
1692 } else if ( fil == 1 ){ 1705 } else if ( fil == 1 ){
1693 mView->toggleFilerEnabled( ); 1706 mView->toggleFilerEnabled( );
1694 } else { 1707 } else {
1695 mView->selectFilter( fil-2 ); 1708 mView->selectFilter( fil-2 );
1696 } 1709 }
1697} 1710}
1698void MainWindow::configureToolBar( int item ) 1711void MainWindow::configureToolBar( int item )
1699{ 1712{
1700 1713
1701 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1714 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1702 KOPrefs *p = KOPrefs::instance(); 1715 KOPrefs *p = KOPrefs::instance();
1703 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1716 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1704 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1717 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1705 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1718 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1706 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1719 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1707 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1720 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1708 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1721 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1709 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1722 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1710 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1723 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1711 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1724 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1712 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1725 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1713 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1726 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1714 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1727 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1715 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1728 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1716 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1729 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1717 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1730 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1718 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1731 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1719 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1732 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1720 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1733 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1721 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1734 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1722 // initActions(); 1735 // initActions();
1723} 1736}
1724 1737
1725void MainWindow::setCaptionToDates() 1738void MainWindow::setCaptionToDates()
1726{ 1739{
1727 QString selDates; 1740 QString selDates;
1728 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1741 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1729 if (mView->startDate() < mView->endDate() ) 1742 if (mView->startDate() < mView->endDate() )
1730 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1743 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1731 else { 1744 else {
1732 QString addString; 1745 QString addString;
1733 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1746 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1734 addString = i18n("Today"); 1747 addString = i18n("Today");
1735 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1748 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1736 addString = i18n("Tomorrow"); 1749 addString = i18n("Tomorrow");
1737 if ( !addString.isEmpty() ) 1750 if ( !addString.isEmpty() )
1738 selDates = addString+", "+selDates ; 1751 selDates = addString+", "+selDates ;
1739 } 1752 }
1740 setCaption( i18n("Dates: ") + selDates ); 1753 setCaption( i18n("Dates: ") + selDates );
1741 1754
1742} 1755}
1743void MainWindow::showConfigureAgenda( ) 1756void MainWindow::showConfigureAgenda( )
1744{ 1757{
1745 int iii; 1758 int iii;
1746 for ( iii = 1;iii<= 10 ;++iii ){ 1759 for ( iii = 1;iii<= 10 ;++iii ){
1747 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1760 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1748 } 1761 }
1749 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1762 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1750} 1763}
1751void MainWindow::configureAgenda( int item ) 1764void MainWindow::configureAgenda( int item )
1752{ 1765{
1753 if ( KOPrefs::instance()->mHourSize == item ) 1766 if ( KOPrefs::instance()->mHourSize == item )
1754 return; 1767 return;
1755 KOPrefs::instance()->mHourSize=item; 1768 KOPrefs::instance()->mHourSize=item;
1756 mView->viewManager()->agendaView()->updateConfig(); 1769 mView->viewManager()->agendaView()->updateConfig();
1757} 1770}
1758 1771
1759void MainWindow::saveCalendar() 1772void MainWindow::saveCalendar()
1760{ 1773{
1761 QString fn = KOPrefs::instance()->mLastSaveFile; 1774 QString fn = KOPrefs::instance()->mLastSaveFile;
1762 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1775 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1763 1776
1764 if ( fn == "" ) 1777 if ( fn == "" )
1765 return; 1778 return;
1766 QFileInfo info; 1779 QFileInfo info;
1767 info.setFile( fn ); 1780 info.setFile( fn );
1768 QString mes; 1781 QString mes;
1769 bool createbup = true; 1782 bool createbup = true;
1770 if ( info. exists() ) { 1783 if ( info. exists() ) {
1771 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1784 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1772 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1785 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1773 i18n("Overwrite!"), i18n("Cancel"), 0, 1786 i18n("Overwrite!"), i18n("Cancel"), 0,
1774 0, 1 ); 1787 0, 1 );
1775 if ( result != 0 ) { 1788 if ( result != 0 ) {
1776 createbup = false; 1789 createbup = false;
1777 } 1790 }
1778 } 1791 }
1779 if ( createbup ) { 1792 if ( createbup ) {
1780 mView->saveCalendar( fn ); 1793 mView->saveCalendar( fn );
1781 mes = i18n("KO/Pi:Saved %1").arg(fn); 1794 mes = i18n("KO/Pi:Saved %1").arg(fn);
1782 KOPrefs::instance()->mLastSaveFile = fn; 1795 KOPrefs::instance()->mLastSaveFile = fn;
1783 setCaption(mes); 1796 setCaption(mes);
1784 } 1797 }
1785} 1798}
1786void MainWindow::loadCalendar() 1799void MainWindow::loadCalendar()
1787{ 1800{
1788 1801
1789 QString fn = KOPrefs::instance()->mLastLoadFile; 1802 QString fn = KOPrefs::instance()->mLastLoadFile;
1790 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1803 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1791 1804
1792 if ( fn == "" ) 1805 if ( fn == "" )
1793 return; 1806 return;
1794 QFileInfo info; 1807 QFileInfo info;
1795 info.setFile( fn ); 1808 info.setFile( fn );
1796 QString mess; 1809 QString mess;
1797 bool loadbup = true; 1810 bool loadbup = true;
1798 if ( info. exists() ) { 1811 if ( info. exists() ) {
1799 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1812 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1800 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1813 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1801 mess, 1814 mess,
1802 i18n("Load!"), i18n("Cancel"), 0, 1815 i18n("Load!"), i18n("Cancel"), 0,
1803 0, 1 ); 1816 0, 1 );
1804 if ( result != 0 ) { 1817 if ( result != 0 ) {
1805 loadbup = false; 1818 loadbup = false;
1806 } 1819 }
1807 } else { 1820 } else {
1808 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1821 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1809 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1822 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1810 0, 1 ); 1823 0, 1 );
1811 1824
1812 return; 1825 return;
1813 } 1826 }
1814 if ( loadbup ) { 1827 if ( loadbup ) {
1815 mView->openCalendar( fn ); 1828 mView->openCalendar( fn );
1816 KOPrefs::instance()->mLastLoadFile = fn; 1829 KOPrefs::instance()->mLastLoadFile = fn;
1817 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1830 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1818 setCaption(mess); 1831 setCaption(mess);
1819 } 1832 }
1820 1833
1821} 1834}
1822void MainWindow::quickImportIcal() 1835void MainWindow::quickImportIcal()
1823{ 1836{
1824 importFile( KOPrefs::instance()->mLastImportFile, false ); 1837 importFile( KOPrefs::instance()->mLastImportFile, false );
1825} 1838}
1826void MainWindow::importFile( QString fn, bool quick ) 1839void MainWindow::importFile( QString fn, bool quick )
1827{ 1840{
1828 QFileInfo info; 1841 QFileInfo info;
1829 info.setFile( fn ); 1842 info.setFile( fn );
1830 QString mess; 1843 QString mess;
1831 bool loadbup = true; 1844 bool loadbup = true;
1832 if ( !info. exists() ) { 1845 if ( !info. exists() ) {
1833 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1846 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1834 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1847 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1835 mess ); 1848 mess );
1836 return; 1849 return;
1837 } 1850 }
1838 int result = 0; 1851 int result = 0;
1839 if ( !quick ) { 1852 if ( !quick ) {
1840 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1853 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1841 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1854 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1842 mess, 1855 mess,
1843 "Import", "Cancel", 0, 1856 "Import", "Cancel", 0,
1844 0, 1 ); 1857 0, 1 );
1845 } 1858 }
1846 if ( result == 0 ) { 1859 if ( result == 0 ) {
1847 if ( mView->openCalendar( fn, true )) { 1860 if ( mView->openCalendar( fn, true )) {
1848 KOPrefs::instance()->mLastImportFile = fn; 1861 KOPrefs::instance()->mLastImportFile = fn;
1849 setCaption(i18n("Imported file successfully")); 1862 setCaption(i18n("Imported file successfully"));
1850 } else { 1863 } else {
1851 setCaption(i18n("Error importing file")); 1864 setCaption(i18n("Error importing file"));
1852 } 1865 }
1853 } 1866 }
1854} 1867}
1855 1868
1856void MainWindow::importIcal() 1869void MainWindow::importIcal()
1857{ 1870{
1858 1871
1859 QString fn =KOPrefs::instance()->mLastImportFile; 1872 QString fn =KOPrefs::instance()->mLastImportFile;
1860 1873
1861 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1874 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1862 if ( fn == "" ) 1875 if ( fn == "" )
1863 return; 1876 return;
1864 importFile( fn, true ); 1877 importFile( fn, true );
1865 1878
1866} 1879}
1867 1880
1868void MainWindow::exportVCalendar() 1881void MainWindow::exportVCalendar()
1869{ 1882{
1870 QString fn = KOPrefs::instance()->mLastVcalFile; 1883 QString fn = KOPrefs::instance()->mLastVcalFile;
1871 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1884 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1872 if ( fn == "" ) 1885 if ( fn == "" )
1873 return; 1886 return;
1874 QFileInfo info; 1887 QFileInfo info;
1875 info.setFile( fn ); 1888 info.setFile( fn );
1876 QString mes; 1889 QString mes;
1877 bool createbup = true; 1890 bool createbup = true;
1878 if ( info. exists() ) { 1891 if ( info. exists() ) {
1879 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1892 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1880 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1893 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1881 i18n("Overwrite!"), i18n("Cancel"), 0, 1894 i18n("Overwrite!"), i18n("Cancel"), 0,
1882 0, 1 ); 1895 0, 1 );
1883 if ( result != 0 ) { 1896 if ( result != 0 ) {
1884 createbup = false; 1897 createbup = false;
1885 } 1898 }
1886 } 1899 }
1887 if ( createbup ) { 1900 if ( createbup ) {
1888 if ( mView->exportVCalendar( fn ) ) { 1901 if ( mView->exportVCalendar( fn ) ) {
1889 KOPrefs::instance()->mLastVcalFile = fn; 1902 KOPrefs::instance()->mLastVcalFile = fn;
1890 if ( fn.length() > 20 ) 1903 if ( fn.length() > 20 )
1891 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1904 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1892 else 1905 else
1893 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1906 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1894 setCaption(mes); 1907 setCaption(mes);
1895 } 1908 }
1896 } 1909 }
1897 1910
1898} 1911}
1899 1912
1900void MainWindow::syncFileRequest() 1913void MainWindow::syncFileRequest()
1901{ 1914{
1902 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1915 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1903 mSyncManager->slotSyncMenu( 999 ); 1916 mSyncManager->slotSyncMenu( 999 );
1904 } 1917 }
1905 save(); 1918 save();
1906} 1919}
1907void MainWindow::getFile( bool success ) 1920void MainWindow::getFile( bool success )
1908{ 1921{
1909 if ( ! success ) { 1922 if ( ! success ) {
1910 setCaption( i18n("Error receiving file. Nothing changed!") ); 1923 setCaption( i18n("Error receiving file. Nothing changed!") );
1911 return; 1924 return;
1912 } 1925 }
1913 mView->openCalendar( defaultFileName() ); 1926 mView->openCalendar( defaultFileName() );
1914 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1927 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1915 mSyncManager->slotSyncMenu( 999 ); 1928 mSyncManager->slotSyncMenu( 999 );
1916 } 1929 }
1917 setCaption( i18n("Pi-Sync successful!") ); 1930 setCaption( i18n("Pi-Sync successful!") );
1918} 1931}
1919 1932
1920void MainWindow::printSel( ) 1933void MainWindow::printSel( )
1921{ 1934{
1922 mView->viewManager()->agendaView()->agenda()->printSelection(); 1935 mView->viewManager()->agendaView()->agenda()->printSelection();
1923} 1936}
1924 1937
1925void MainWindow::printCal() 1938void MainWindow::printCal()
1926{ 1939{
1927 mView->print();//mCp->showDialog(); 1940 mView->print();//mCp->showDialog();
1928} 1941}
1929 1942
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 6de0543..8dd55ac 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,141 +1,142 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qtextstream.h> 8#include <qtextstream.h>
9#include <qregexp.h> 9#include <qregexp.h>
10 10
11#include <libkcal/incidence.h> 11#include <libkcal/incidence.h>
12#include "simplealarmclient.h" 12#include "simplealarmclient.h"
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#ifndef DESKTOP_VERSION 14#ifndef DESKTOP_VERSION
15#include <qcopchannel_qws.h> 15#include <qcopchannel_qws.h>
16#endif 16#endif
17class QAction; 17class QAction;
18class CalendarView; 18class CalendarView;
19class KSyncProfile; 19class KSyncProfile;
20#ifdef DESKTOP_VERSION 20#ifdef DESKTOP_VERSION
21 21
22#define QPEToolBar QToolBar 22#define QPEToolBar QToolBar
23#define QPEMenuBar QMenuBar 23#define QPEMenuBar QMenuBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26 26
27 27
28namespace KCal { 28namespace KCal {
29class CalendarLocal; 29class CalendarLocal;
30} 30}
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 38 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
39 ~MainWindow(); 39 ~MainWindow();
40 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
41 static QString defaultFileName(); 41 static QString defaultFileName();
42 static QString syncFileName(); 42 static QString syncFileName();
43 static QString resourcePath(); 43 static QString resourcePath();
44 public slots: 44 public slots:
45 virtual void showMaximized (); 45 virtual void showMaximized ();
46 void configureAgenda( int ); 46 void configureAgenda( int );
47 void recieve( const QCString& msg, const QByteArray& data ); 47 void recieve( const QCString& msg, const QByteArray& data );
48 protected slots: 48 protected slots:
49 void setCaptionToDates(); 49 void setCaptionToDates();
50 void about(); 50 void about();
51 void licence(); 51 void licence();
52 void faq(); 52 void faq();
53 void usertrans(); 53 void usertrans();
54 void features(); 54 void features();
55 void synchowto(); 55 void synchowto();
56 void kdesynchowto(); 56 void kdesynchowto();
57 void multisynchowto(); 57 void multisynchowto();
58 void whatsNew(); 58 void whatsNew();
59 void keyBindings(); 59 void keyBindings();
60 void aboutAutoSaving();; 60 void aboutAutoSaving();;
61 void aboutKnownBugs(); 61 void aboutKnownBugs();
62 62
63 void processIncidenceSelection( Incidence * ); 63 void processIncidenceSelection( Incidence * );
64 64
65 void importQtopia(); 65 void importQtopia();
66 void importBday(); 66 void importBday();
67 void importOL(); 67 void importOL();
68 void importIcal(); 68 void importIcal();
69 void importFile( QString, bool ); 69 void importFile( QString, bool );
70 void quickImportIcal(); 70 void quickImportIcal();
71 71
72 void slotModifiedChanged( bool ); 72 void slotModifiedChanged( bool );
73 73
74 void save(); 74 void save();
75 void saveStopTimer();
75 void configureToolBar( int ); 76 void configureToolBar( int );
76 void printSel(); 77 void printSel();
77 void printCal(); 78 void printCal();
78 void saveCalendar(); 79 void saveCalendar();
79 void loadCalendar(); 80 void loadCalendar();
80 void exportVCalendar(); 81 void exportVCalendar();
81 void fillFilterMenu(); 82 void fillFilterMenu();
82 void selectFilter( int ); 83 void selectFilter( int );
83 void exportToPhone( int ); 84 void exportToPhone( int );
84 void toggleBeamReceive(); 85 void toggleBeamReceive();
85 void disableBR(bool); 86 void disableBR(bool);
86 87
87 private slots: 88 private slots:
88 void showConfigureAgenda(); 89 void showConfigureAgenda();
89 void getFile( bool ); 90 void getFile( bool );
90 void syncFileRequest(); 91 void syncFileRequest();
91 92
92 protected: 93 protected:
93 void displayText( QString, QString); 94 void displayText( QString, QString);
94 void enableIncidenceActions( bool ); 95 void enableIncidenceActions( bool );
95 96
96 private: 97 private:
97 bool mBRdisabled; 98 bool mBRdisabled;
98#ifndef DESKTOP_VERSION 99#ifndef DESKTOP_VERSION
99 QCopChannel* infrared; 100 QCopChannel* infrared;
100#endif 101#endif
101 QAction* brAction; 102 QAction* brAction;
102 KSyncManager* mSyncManager; 103 KSyncManager* mSyncManager;
103 bool mClosed; 104 bool mClosed;
104 void saveOnClose(); 105 void saveOnClose();
105 bool mFlagKeyPressed; 106 bool mFlagKeyPressed;
106 bool mBlockAtStartup; 107 bool mBlockAtStartup;
107 QPEToolBar *iconToolBar; 108 QPEToolBar *iconToolBar;
108 void initActions(); 109 void initActions();
109 void setDefaultPreferences(); 110 void setDefaultPreferences();
110 void keyPressEvent ( QKeyEvent * ) ; 111 void keyPressEvent ( QKeyEvent * ) ;
111 void keyReleaseEvent ( QKeyEvent * ) ; 112 void keyReleaseEvent ( QKeyEvent * ) ;
112 QPopupMenu *configureToolBarMenu; 113 QPopupMenu *configureToolBarMenu;
113 QPopupMenu *selectFilterMenu; 114 QPopupMenu *selectFilterMenu;
114 QPopupMenu *configureAgendaMenu, *syncMenu; 115 QPopupMenu *configureAgendaMenu, *syncMenu;
115 CalendarLocal *mCalendar; 116 CalendarLocal *mCalendar;
116 CalendarView *mView; 117 CalendarView *mView;
117 QAction *mNewSubTodoAction; 118 QAction *mNewSubTodoAction;
118 119
119 QAction *mShowAction; 120 QAction *mShowAction;
120 QAction *mEditAction; 121 QAction *mEditAction;
121 QAction *mDeleteAction; 122 QAction *mDeleteAction;
122 QAction *mCloneAction; 123 QAction *mCloneAction;
123 QAction *mMoveAction; 124 QAction *mMoveAction;
124 QAction *mBeamAction; 125 QAction *mBeamAction;
125 QAction *mCancelAction; 126 QAction *mCancelAction;
126 127
127 QAction *mToggleNav; 128 QAction *mToggleNav;
128 QAction *mToggleFilter; 129 QAction *mToggleFilter;
129 QAction *mToggleAllday; 130 QAction *mToggleAllday;
130 131
131 132
132 void closeEvent( QCloseEvent* ce ); 133 void closeEvent( QCloseEvent* ce );
133 SimpleAlarmClient mAlarmClient; 134 SimpleAlarmClient mAlarmClient;
134 QTimer mSaveTimer; 135 QTimer mSaveTimer;
135 //bool mBlockSaveFlag; 136 //bool mBlockSaveFlag;
136 bool mCalendarModifiedFlag; 137 bool mCalendarModifiedFlag;
137 QPixmap loadPixmap( QString ); 138 QPixmap loadPixmap( QString );
138}; 139};
139 140
140 141
141#endif 142#endif