summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--korganizer/kowhatsnextview.cpp13
2 files changed, 20 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1d5a57e..257a4dd 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1270,517 +1270,520 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1270 // qDebug("loading ... "); 1270 // qDebug("loading ... ");
1271 if ( storage->load() ) { 1271 if ( storage->load() ) {
1272 getEventViewerDialog()->setSyncMode( true ); 1272 getEventViewerDialog()->setSyncMode( true );
1273 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1273 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1274 getEventViewerDialog()->setSyncMode( false ); 1274 getEventViewerDialog()->setSyncMode( false );
1275 if ( syncOK ) { 1275 if ( syncOK ) {
1276 if ( mSyncManager->mWriteBackFile ) 1276 if ( mSyncManager->mWriteBackFile )
1277 { 1277 {
1278 storage->setSaveFormat( new ICalFormat() ); 1278 storage->setSaveFormat( new ICalFormat() );
1279 storage->save(); 1279 storage->save();
1280 } 1280 }
1281 } 1281 }
1282 setModified( true ); 1282 setModified( true );
1283 } 1283 }
1284 delete storage; 1284 delete storage;
1285 delete calendar; 1285 delete calendar;
1286 if ( syncOK ) 1286 if ( syncOK )
1287 updateView(); 1287 updateView();
1288 return syncOK; 1288 return syncOK;
1289} 1289}
1290 1290
1291void CalendarView::syncExternal( int mode ) 1291void CalendarView::syncExternal( int mode )
1292{ 1292{
1293 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1293 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1294 1294
1295 qApp->processEvents(); 1295 qApp->processEvents();
1296 CalendarLocal* calendar = new CalendarLocal(); 1296 CalendarLocal* calendar = new CalendarLocal();
1297 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1297 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1298 bool syncOK = false; 1298 bool syncOK = false;
1299 bool loadSuccess = false; 1299 bool loadSuccess = false;
1300 PhoneFormat* phoneFormat = 0; 1300 PhoneFormat* phoneFormat = 0;
1301 emit tempDisableBR(true); 1301 emit tempDisableBR(true);
1302#ifndef DESKTOP_VERSION 1302#ifndef DESKTOP_VERSION
1303 SharpFormat* sharpFormat = 0; 1303 SharpFormat* sharpFormat = 0;
1304 if ( mode == 0 ) { // sharp 1304 if ( mode == 0 ) { // sharp
1305 sharpFormat = new SharpFormat () ; 1305 sharpFormat = new SharpFormat () ;
1306 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1306 loadSuccess = sharpFormat->load( calendar, mCalendar );
1307 1307
1308 } else 1308 } else
1309#endif 1309#endif
1310 if ( mode == 1 ) { // phone 1310 if ( mode == 1 ) { // phone
1311 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1311 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1312 mSyncManager->mPhoneDevice, 1312 mSyncManager->mPhoneDevice,
1313 mSyncManager->mPhoneConnection, 1313 mSyncManager->mPhoneConnection,
1314 mSyncManager->mPhoneModel); 1314 mSyncManager->mPhoneModel);
1315 loadSuccess = phoneFormat->load( calendar,mCalendar); 1315 loadSuccess = phoneFormat->load( calendar,mCalendar);
1316 1316
1317 } else { 1317 } else {
1318 emit tempDisableBR(false); 1318 emit tempDisableBR(false);
1319 return; 1319 return;
1320 } 1320 }
1321 if ( loadSuccess ) { 1321 if ( loadSuccess ) {
1322 getEventViewerDialog()->setSyncMode( true ); 1322 getEventViewerDialog()->setSyncMode( true );
1323 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1323 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1324 getEventViewerDialog()->setSyncMode( false ); 1324 getEventViewerDialog()->setSyncMode( false );
1325 qApp->processEvents(); 1325 qApp->processEvents();
1326 if ( syncOK ) { 1326 if ( syncOK ) {
1327 if ( mSyncManager->mWriteBackFile ) 1327 if ( mSyncManager->mWriteBackFile )
1328 { 1328 {
1329 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1329 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1330 Incidence* inc = iL.first(); 1330 Incidence* inc = iL.first();
1331 if ( phoneFormat ) { 1331 if ( phoneFormat ) {
1332 while ( inc ) { 1332 while ( inc ) {
1333 inc->removeID(mCurrentSyncDevice); 1333 inc->removeID(mCurrentSyncDevice);
1334 inc = iL.next(); 1334 inc = iL.next();
1335 } 1335 }
1336 } 1336 }
1337#ifndef DESKTOP_VERSION 1337#ifndef DESKTOP_VERSION
1338 if ( sharpFormat ) 1338 if ( sharpFormat )
1339 sharpFormat->save(calendar); 1339 sharpFormat->save(calendar);
1340#endif 1340#endif
1341 if ( phoneFormat ) 1341 if ( phoneFormat )
1342 phoneFormat->save(calendar); 1342 phoneFormat->save(calendar);
1343 iL = calendar->rawIncidences(); 1343 iL = calendar->rawIncidences();
1344 inc = iL.first(); 1344 inc = iL.first();
1345 Incidence* loc; 1345 Incidence* loc;
1346 while ( inc ) { 1346 while ( inc ) {
1347 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1347 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1348 loc = mCalendar->incidence(inc->uid() ); 1348 loc = mCalendar->incidence(inc->uid() );
1349 if ( loc ) { 1349 if ( loc ) {
1350 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1350 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1351 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1351 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1352 } 1352 }
1353 } 1353 }
1354 inc = iL.next(); 1354 inc = iL.next();
1355 } 1355 }
1356 Incidence* lse = getLastSyncEvent(); 1356 Incidence* lse = getLastSyncEvent();
1357 if ( lse ) { 1357 if ( lse ) {
1358 lse->setReadOnly( false ); 1358 lse->setReadOnly( false );
1359 lse->setDescription( "" ); 1359 lse->setDescription( "" );
1360 lse->setReadOnly( true ); 1360 lse->setReadOnly( true );
1361 } 1361 }
1362 } 1362 }
1363 } else { 1363 } else {
1364 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1364 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1365 } 1365 }
1366 setModified( true ); 1366 setModified( true );
1367 } else { 1367 } else {
1368 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1368 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1369 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1369 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1370 question, i18n("Ok")) ; 1370 question, i18n("Ok")) ;
1371 1371
1372 } 1372 }
1373 delete calendar; 1373 delete calendar;
1374 updateView(); 1374 updateView();
1375 emit tempDisableBR(false); 1375 emit tempDisableBR(false);
1376 return ;//syncOK; 1376 return ;//syncOK;
1377 1377
1378} 1378}
1379 1379
1380bool CalendarView::importBday() 1380bool CalendarView::importBday()
1381{ 1381{
1382#ifndef KORG_NOKABC 1382#ifndef KORG_NOKABC
1383 1383
1384#ifdef DESKTOP_VERSION 1384#ifdef DESKTOP_VERSION
1385 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1385 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1386 KABC::AddressBook::Iterator it; 1386 KABC::AddressBook::Iterator it;
1387 int count = 0; 1387 int count = 0;
1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1389 ++count; 1389 ++count;
1390 } 1390 }
1391 QProgressBar bar(count,0 ); 1391 QProgressBar bar(count,0 );
1392 int w = 300; 1392 int w = 300;
1393 if ( QApplication::desktop()->width() < 320 ) 1393 if ( QApplication::desktop()->width() < 320 )
1394 w = 220; 1394 w = 220;
1395 int h = bar.sizeHint().height() ; 1395 int h = bar.sizeHint().height() ;
1396 int dw = QApplication::desktop()->width(); 1396 int dw = QApplication::desktop()->width();
1397 int dh = QApplication::desktop()->height(); 1397 int dh = QApplication::desktop()->height();
1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1399 bar.show(); 1399 bar.show();
1400 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1400 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1401 qApp->processEvents(); 1401 qApp->processEvents();
1402 count = 0; 1402 count = 0;
1403 int addCount = 0; 1403 int addCount = 0;
1404 KCal::Attendee* a = 0; 1404 KCal::Attendee* a = 0;
1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1406 if ( ! bar.isVisible() ) 1406 if ( ! bar.isVisible() )
1407 return false; 1407 return false;
1408 bar.setProgress( count++ ); 1408 bar.setProgress( count++ );
1409 qApp->processEvents(); 1409 qApp->processEvents();
1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1411 if ( (*it).birthday().date().isValid() ){ 1411 if ( (*it).birthday().date().isValid() ){
1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1414 ++addCount; 1414 ++addCount;
1415 } 1415 }
1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1417 if ( anni.isValid() ){ 1417 if ( anni.isValid() ){
1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1420 ++addCount; 1420 ++addCount;
1421 } 1421 }
1422 } 1422 }
1423 updateView(); 1423 updateView();
1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1425#else //DESKTOP_VERSION 1425#else //DESKTOP_VERSION
1426 1426
1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1428 // the result should now arrive through method insertBirthdays 1428 // the result should now arrive through method insertBirthdays
1429 1429
1430#endif //DESKTOP_VERSION 1430#endif //DESKTOP_VERSION
1431 1431
1432#endif //KORG_NOKABC 1432#endif //KORG_NOKABC
1433 1433
1434 1434
1435 return true; 1435 return true;
1436} 1436}
1437 1437
1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1440 const QStringList& anniversaryList, const QStringList& realNameList, 1440 const QStringList& anniversaryList, const QStringList& realNameList,
1441 const QStringList& emailList, const QStringList& assembledNameList, 1441 const QStringList& emailList, const QStringList& assembledNameList,
1442 const QStringList& uidList) 1442 const QStringList& uidList)
1443{ 1443{
1444 //qDebug("KO::CalendarView::insertBirthdays"); 1444 //qDebug("KO::CalendarView::insertBirthdays");
1445 if (uid == this->name()) 1445 if (uid == this->name())
1446 { 1446 {
1447 int count = birthdayList.count(); 1447 int count = birthdayList.count();
1448 int addCount = 0; 1448 int addCount = 0;
1449 KCal::Attendee* a = 0; 1449 KCal::Attendee* a = 0;
1450 1450
1451 //qDebug("CalView 1 %i", count); 1451 //qDebug("CalView 1 %i", count);
1452 1452
1453 QProgressBar bar(count,0 ); 1453 QProgressBar bar(count,0 );
1454 int w = 300; 1454 int w = 300;
1455 if ( QApplication::desktop()->width() < 320 ) 1455 if ( QApplication::desktop()->width() < 320 )
1456 w = 220; 1456 w = 220;
1457 int h = bar.sizeHint().height() ; 1457 int h = bar.sizeHint().height() ;
1458 int dw = QApplication::desktop()->width(); 1458 int dw = QApplication::desktop()->width();
1459 int dh = QApplication::desktop()->height(); 1459 int dh = QApplication::desktop()->height();
1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1461 bar.show(); 1461 bar.show();
1462 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1462 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1463 qApp->processEvents(); 1463 qApp->processEvents();
1464 1464
1465 QDate birthday; 1465 QDate birthday;
1466 QDate anniversary; 1466 QDate anniversary;
1467 QString realName; 1467 QString realName;
1468 QString email; 1468 QString email;
1469 QString assembledName; 1469 QString assembledName;
1470 QString uid; 1470 QString uid;
1471 bool ok = true; 1471 bool ok = true;
1472 for ( int i = 0; i < count; i++) 1472 for ( int i = 0; i < count; i++)
1473 { 1473 {
1474 if ( ! bar.isVisible() ) 1474 if ( ! bar.isVisible() )
1475 return; 1475 return;
1476 bar.setProgress( i ); 1476 bar.setProgress( i );
1477 qApp->processEvents(); 1477 qApp->processEvents();
1478 1478
1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1480 if (!ok) { 1480 if (!ok) {
1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1482 } 1482 }
1483 1483
1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1485 if (!ok) { 1485 if (!ok) {
1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1487 } 1487 }
1488 realName = realNameList[i]; 1488 realName = realNameList[i];
1489 email = emailList[i]; 1489 email = emailList[i];
1490 assembledName = assembledNameList[i]; 1490 assembledName = assembledNameList[i];
1491 uid = uidList[i]; 1491 uid = uidList[i];
1492 //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() ); 1492 //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() );
1493 1493
1494 if ( birthday.isValid() ){ 1494 if ( birthday.isValid() ){
1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1496 KCal::Attendee::ReqParticipant,uid) ; 1496 KCal::Attendee::ReqParticipant,uid) ;
1497 if ( addAnniversary( birthday, assembledName, a, true ) ) 1497 if ( addAnniversary( birthday, assembledName, a, true ) )
1498 ++addCount; 1498 ++addCount;
1499 } 1499 }
1500 1500
1501 if ( anniversary.isValid() ){ 1501 if ( anniversary.isValid() ){
1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1503 KCal::Attendee::ReqParticipant,uid) ; 1503 KCal::Attendee::ReqParticipant,uid) ;
1504 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1504 if ( addAnniversary( anniversary, assembledName, a, false ) )
1505 ++addCount; 1505 ++addCount;
1506 } 1506 }
1507 } 1507 }
1508 1508
1509 updateView(); 1509 updateView();
1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1511 1511
1512 } 1512 }
1513 1513
1514} 1514}
1515 1515
1516 1516
1517 1517
1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1519{ 1519{
1520 //qDebug("addAnni "); 1520 //qDebug("addAnni ");
1521 Event * ev = new Event(); 1521 Event * ev = new Event();
1522 if ( a ) { 1522 if ( a ) {
1523 ev->addAttendee( a ); 1523 ev->addAttendee( a );
1524 } 1524 }
1525 QString kind; 1525 QString kind;
1526 if ( birthday ) 1526 if ( birthday ) {
1527 kind = i18n( "Birthday" ); 1527 kind = i18n( "Birthday" );
1528 else 1528 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1529 }
1530 else {
1529 kind = i18n( "Anniversary" ); 1531 kind = i18n( "Anniversary" );
1530 ev->setSummary( name + " - " + kind ); 1532 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1533 }
1531 ev->setOrganizer(a->email()); 1534 ev->setOrganizer(a->email());
1532 ev->setCategories( kind ); 1535 ev->setCategories( kind );
1533 ev->setDtStart( QDateTime(date) ); 1536 ev->setDtStart( QDateTime(date) );
1534 ev->setDtEnd( QDateTime(date) ); 1537 ev->setDtEnd( QDateTime(date) );
1535 ev->setFloats( true ); 1538 ev->setFloats( true );
1536 Recurrence * rec = ev->recurrence(); 1539 Recurrence * rec = ev->recurrence();
1537 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1540 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1538 rec->addYearlyNum( date.month() ); 1541 rec->addYearlyNum( date.month() );
1539 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1542 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1540 delete ev; 1543 delete ev;
1541 return false; 1544 return false;
1542 } 1545 }
1543 return true; 1546 return true;
1544 1547
1545} 1548}
1546bool CalendarView::importQtopia( const QString &categories, 1549bool CalendarView::importQtopia( const QString &categories,
1547 const QString &datebook, 1550 const QString &datebook,
1548 const QString &todolist ) 1551 const QString &todolist )
1549{ 1552{
1550 1553
1551 QtopiaFormat qtopiaFormat; 1554 QtopiaFormat qtopiaFormat;
1552 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1555 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1553 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1556 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1554 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1557 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1555 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1558 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1556 1559
1557 updateView(); 1560 updateView();
1558 return true; 1561 return true;
1559 1562
1560#if 0 1563#if 0
1561 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1564 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1562 mCurrentSyncDevice = "qtopia-XML"; 1565 mCurrentSyncDevice = "qtopia-XML";
1563 if ( mSyncManager->mAskForPreferences ) 1566 if ( mSyncManager->mAskForPreferences )
1564 edit_sync_options(); 1567 edit_sync_options();
1565 qApp->processEvents(); 1568 qApp->processEvents();
1566 CalendarLocal* calendar = new CalendarLocal(); 1569 CalendarLocal* calendar = new CalendarLocal();
1567 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1570 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1568 bool syncOK = false; 1571 bool syncOK = false;
1569 QtopiaFormat qtopiaFormat; 1572 QtopiaFormat qtopiaFormat;
1570 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1573 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1571 bool loadOk = true; 1574 bool loadOk = true;
1572 if ( !categories.isEmpty() ) 1575 if ( !categories.isEmpty() )
1573 loadOk = qtopiaFormat.load( calendar, categories ); 1576 loadOk = qtopiaFormat.load( calendar, categories );
1574 if ( loadOk && !datebook.isEmpty() ) 1577 if ( loadOk && !datebook.isEmpty() )
1575 loadOk = qtopiaFormat.load( calendar, datebook ); 1578 loadOk = qtopiaFormat.load( calendar, datebook );
1576 if ( loadOk && !todolist.isEmpty() ) 1579 if ( loadOk && !todolist.isEmpty() )
1577 loadOk = qtopiaFormat.load( calendar, todolist ); 1580 loadOk = qtopiaFormat.load( calendar, todolist );
1578 1581
1579 if ( loadOk ) { 1582 if ( loadOk ) {
1580 getEventViewerDialog()->setSyncMode( true ); 1583 getEventViewerDialog()->setSyncMode( true );
1581 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1584 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1582 getEventViewerDialog()->setSyncMode( false ); 1585 getEventViewerDialog()->setSyncMode( false );
1583 qApp->processEvents(); 1586 qApp->processEvents();
1584 if ( syncOK ) { 1587 if ( syncOK ) {
1585 if ( mSyncManager->mWriteBackFile ) 1588 if ( mSyncManager->mWriteBackFile )
1586 { 1589 {
1587 // write back XML file 1590 // write back XML file
1588 1591
1589 } 1592 }
1590 setModified( true ); 1593 setModified( true );
1591 } 1594 }
1592 } else { 1595 } else {
1593 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1596 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1594 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1597 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1595 question, i18n("Ok")) ; 1598 question, i18n("Ok")) ;
1596 } 1599 }
1597 delete calendar; 1600 delete calendar;
1598 updateView(); 1601 updateView();
1599 return syncOK; 1602 return syncOK;
1600 1603
1601 1604
1602#endif 1605#endif
1603 1606
1604} 1607}
1605 1608
1606void CalendarView::setSyncEventsReadOnly() 1609void CalendarView::setSyncEventsReadOnly()
1607{ 1610{
1608 Event * ev; 1611 Event * ev;
1609 QPtrList<Event> eL = mCalendar->rawEvents(); 1612 QPtrList<Event> eL = mCalendar->rawEvents();
1610 ev = eL.first(); 1613 ev = eL.first();
1611 while ( ev ) { 1614 while ( ev ) {
1612 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1615 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1613 ev->setReadOnly( true ); 1616 ev->setReadOnly( true );
1614 ev = eL.next(); 1617 ev = eL.next();
1615 } 1618 }
1616} 1619}
1617bool CalendarView::openCalendar(QString filename, bool merge) 1620bool CalendarView::openCalendar(QString filename, bool merge)
1618{ 1621{
1619 1622
1620 if (filename.isEmpty()) { 1623 if (filename.isEmpty()) {
1621 return false; 1624 return false;
1622 } 1625 }
1623 1626
1624 if (!QFile::exists(filename)) { 1627 if (!QFile::exists(filename)) {
1625 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1628 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1626 return false; 1629 return false;
1627 } 1630 }
1628 1631
1629 globalFlagBlockAgenda = 1; 1632 globalFlagBlockAgenda = 1;
1630 if (!merge) mCalendar->close(); 1633 if (!merge) mCalendar->close();
1631 1634
1632 mStorage->setFileName( filename ); 1635 mStorage->setFileName( filename );
1633 1636
1634 if ( mStorage->load() ) { 1637 if ( mStorage->load() ) {
1635 if ( merge ) ;//setModified( true ); 1638 if ( merge ) ;//setModified( true );
1636 else { 1639 else {
1637 //setModified( true ); 1640 //setModified( true );
1638 mViewManager->setDocumentId( filename ); 1641 mViewManager->setDocumentId( filename );
1639 mDialogManager->setDocumentId( filename ); 1642 mDialogManager->setDocumentId( filename );
1640 mTodoList->setDocumentId( filename ); 1643 mTodoList->setDocumentId( filename );
1641 } 1644 }
1642 globalFlagBlockAgenda = 2; 1645 globalFlagBlockAgenda = 2;
1643 // if ( getLastSyncEvent() ) 1646 // if ( getLastSyncEvent() )
1644 // getLastSyncEvent()->setReadOnly( true ); 1647 // getLastSyncEvent()->setReadOnly( true );
1645 mCalendar->reInitAlarmSettings(); 1648 mCalendar->reInitAlarmSettings();
1646 setSyncEventsReadOnly(); 1649 setSyncEventsReadOnly();
1647 updateUnmanagedViews(); 1650 updateUnmanagedViews();
1648 updateView(); 1651 updateView();
1649 if ( filename != MainWindow::defaultFileName() ) { 1652 if ( filename != MainWindow::defaultFileName() ) {
1650 saveCalendar( MainWindow::defaultFileName() ); 1653 saveCalendar( MainWindow::defaultFileName() );
1651 } else { 1654 } else {
1652 QFileInfo finf ( MainWindow::defaultFileName()); 1655 QFileInfo finf ( MainWindow::defaultFileName());
1653 if ( finf.exists() ) { 1656 if ( finf.exists() ) {
1654 setLoadedFileVersion( finf.lastModified () ); 1657 setLoadedFileVersion( finf.lastModified () );
1655 } 1658 }
1656 } 1659 }
1657 return true; 1660 return true;
1658 } else { 1661 } else {
1659 // while failing to load, the calendar object could 1662 // while failing to load, the calendar object could
1660 // have become partially populated. Clear it out. 1663 // have become partially populated. Clear it out.
1661 if ( !merge ) { 1664 if ( !merge ) {
1662 mCalendar->close(); 1665 mCalendar->close();
1663 mViewManager->setDocumentId( filename ); 1666 mViewManager->setDocumentId( filename );
1664 mDialogManager->setDocumentId( filename ); 1667 mDialogManager->setDocumentId( filename );
1665 mTodoList->setDocumentId( filename ); 1668 mTodoList->setDocumentId( filename );
1666 } 1669 }
1667 1670
1668 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1671 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1669 1672
1670 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1673 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1671 globalFlagBlockAgenda = 2; 1674 globalFlagBlockAgenda = 2;
1672 mCalendar->reInitAlarmSettings(); 1675 mCalendar->reInitAlarmSettings();
1673 setSyncEventsReadOnly(); 1676 setSyncEventsReadOnly();
1674 updateUnmanagedViews(); 1677 updateUnmanagedViews();
1675 updateView(); 1678 updateView();
1676 } 1679 }
1677 return false; 1680 return false;
1678} 1681}
1679void CalendarView::showOpenError() 1682void CalendarView::showOpenError()
1680{ 1683{
1681 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1684 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1682} 1685}
1683void CalendarView::setLoadedFileVersion(QDateTime dt) 1686void CalendarView::setLoadedFileVersion(QDateTime dt)
1684{ 1687{
1685 loadedFileVersion = dt; 1688 loadedFileVersion = dt;
1686} 1689}
1687bool CalendarView::checkFileChanged(QString fn) 1690bool CalendarView::checkFileChanged(QString fn)
1688{ 1691{
1689 QFileInfo finf ( fn ); 1692 QFileInfo finf ( fn );
1690 if ( !finf.exists() ) 1693 if ( !finf.exists() )
1691 return true; 1694 return true;
1692 QDateTime dt = finf.lastModified (); 1695 QDateTime dt = finf.lastModified ();
1693 if ( dt <= loadedFileVersion ) 1696 if ( dt <= loadedFileVersion )
1694 return false; 1697 return false;
1695 return true; 1698 return true;
1696 1699
1697} 1700}
1698void CalendarView::watchSavedFile() 1701void CalendarView::watchSavedFile()
1699{ 1702{
1700 QFileInfo finf ( MainWindow::defaultFileName()); 1703 QFileInfo finf ( MainWindow::defaultFileName());
1701 if ( !finf.exists() ) 1704 if ( !finf.exists() )
1702 return; 1705 return;
1703 QDateTime dt = finf.lastModified (); 1706 QDateTime dt = finf.lastModified ();
1704 if ( dt < loadedFileVersion ) { 1707 if ( dt < loadedFileVersion ) {
1705 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1708 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1706 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1709 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1707 return; 1710 return;
1708 } 1711 }
1709 loadedFileVersion = dt; 1712 loadedFileVersion = dt;
1710} 1713}
1711 1714
1712bool CalendarView::checkFileVersion(QString fn) 1715bool CalendarView::checkFileVersion(QString fn)
1713{ 1716{
1714 QFileInfo finf ( fn ); 1717 QFileInfo finf ( fn );
1715 if ( !finf.exists() ) 1718 if ( !finf.exists() )
1716 return true; 1719 return true;
1717 QDateTime dt = finf.lastModified (); 1720 QDateTime dt = finf.lastModified ();
1718 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1721 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1719 //qDebug("file on disk version %s",dt.toString().latin1()); 1722 //qDebug("file on disk version %s",dt.toString().latin1());
1720 if ( dt <= loadedFileVersion ) 1723 if ( dt <= loadedFileVersion )
1721 return true; 1724 return true;
1722 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)) , 1725 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)) ,
1723 i18n("KO/Pi Warning"),i18n("Overwrite"), 1726 i18n("KO/Pi Warning"),i18n("Overwrite"),
1724 i18n("Sync+save")); 1727 i18n("Sync+save"));
1725 1728
1726 if ( km == KMessageBox::Cancel ) 1729 if ( km == KMessageBox::Cancel )
1727 return false; 1730 return false;
1728 if ( km == KMessageBox::Yes ) 1731 if ( km == KMessageBox::Yes )
1729 return true; 1732 return true;
1730 1733
1731 setSyncDevice("deleteaftersync" ); 1734 setSyncDevice("deleteaftersync" );
1732 mSyncManager->mAskForPreferences = true; 1735 mSyncManager->mAskForPreferences = true;
1733 mSyncManager->mSyncAlgoPrefs = 3; 1736 mSyncManager->mSyncAlgoPrefs = 3;
1734 mSyncManager->mWriteBackFile = false; 1737 mSyncManager->mWriteBackFile = false;
1735 mSyncManager->mWriteBackExistingOnly = false; 1738 mSyncManager->mWriteBackExistingOnly = false;
1736 mSyncManager->mShowSyncSummary = false; 1739 mSyncManager->mShowSyncSummary = false;
1737 syncCalendar( fn, 3 ); 1740 syncCalendar( fn, 3 );
1738 Event * e = getLastSyncEvent(); 1741 Event * e = getLastSyncEvent();
1739 mCalendar->deleteEvent ( e ); 1742 mCalendar->deleteEvent ( e );
1740 updateView(); 1743 updateView();
1741 return true; 1744 return true;
1742} 1745}
1743 1746
1744bool CalendarView::saveCalendar( QString filename ) 1747bool CalendarView::saveCalendar( QString filename )
1745{ 1748{
1746 1749
1747 // Store back all unsaved data into calendar object 1750 // Store back all unsaved data into calendar object
1748 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1751 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1749 if ( mViewManager->currentView() ) 1752 if ( mViewManager->currentView() )
1750 mViewManager->currentView()->flushView(); 1753 mViewManager->currentView()->flushView();
1751 1754
1752 1755
1753 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1756 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1754 mStorage->setSaveFormat( new ICalFormat() ); 1757 mStorage->setSaveFormat( new ICalFormat() );
1755 mStorage->setFileName( filename ); 1758 mStorage->setFileName( filename );
1756 bool success; 1759 bool success;
1757 success = mStorage->save(); 1760 success = mStorage->save();
1758 if ( !success ) { 1761 if ( !success ) {
1759 return false; 1762 return false;
1760 } 1763 }
1761 if ( filename == MainWindow::defaultFileName() ) { 1764 if ( filename == MainWindow::defaultFileName() ) {
1762 setLoadedFileVersion( lfv ); 1765 setLoadedFileVersion( lfv );
1763 watchSavedFile(); 1766 watchSavedFile();
1764 } 1767 }
1765 return true; 1768 return true;
1766} 1769}
1767 1770
1768void CalendarView::closeCalendar() 1771void CalendarView::closeCalendar()
1769{ 1772{
1770 1773
1771 // child windows no longer valid 1774 // child windows no longer valid
1772 emit closingDown(); 1775 emit closingDown();
1773 1776
1774 mCalendar->close(); 1777 mCalendar->close();
1775 setModified(false); 1778 setModified(false);
1776 updateView(); 1779 updateView();
1777} 1780}
1778 1781
1779void CalendarView::archiveCalendar() 1782void CalendarView::archiveCalendar()
1780{ 1783{
1781 mDialogManager->showArchiveDialog(); 1784 mDialogManager->showArchiveDialog();
1782} 1785}
1783 1786
1784 1787
1785void CalendarView::readSettings() 1788void CalendarView::readSettings()
1786{ 1789{
@@ -2258,527 +2261,529 @@ void CalendarView::slotSelectPickerDate( QDate d)
2258 if ( mDatePickerMode == 1 ) { 2261 if ( mDatePickerMode == 1 ) {
2259 mNavigator->slotDaySelect( d ); 2262 mNavigator->slotDaySelect( d );
2260 } else if ( mDatePickerMode == 2 ) { 2263 } else if ( mDatePickerMode == 2 ) {
2261 if ( mMoveIncidence->type() == "Todo" ) { 2264 if ( mMoveIncidence->type() == "Todo" ) {
2262 Todo * to = (Todo *) mMoveIncidence; 2265 Todo * to = (Todo *) mMoveIncidence;
2263 QTime tim; 2266 QTime tim;
2264 if ( to->hasDueDate() ) 2267 if ( to->hasDueDate() )
2265 tim = to->dtDue().time(); 2268 tim = to->dtDue().time();
2266 else { 2269 else {
2267 tim = QTime ( 0,0,0 ); 2270 tim = QTime ( 0,0,0 );
2268 to->setFloats( true ); 2271 to->setFloats( true );
2269 to->setHasDueDate( true ); 2272 to->setHasDueDate( true );
2270 } 2273 }
2271 QDateTime dt ( d,tim ); 2274 QDateTime dt ( d,tim );
2272 to->setDtDue( dt ); 2275 to->setDtDue( dt );
2273 todoChanged( to ); 2276 todoChanged( to );
2274 } else { 2277 } else {
2275 if ( mMoveIncidence->doesRecur() ) { 2278 if ( mMoveIncidence->doesRecur() ) {
2276#if 0 2279#if 0
2277 // PENDING implement this 2280 // PENDING implement this
2278 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2281 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2279 mCalendar()->addIncidence( newInc ); 2282 mCalendar()->addIncidence( newInc );
2280 if ( mMoveIncidence->type() == "Todo" ) 2283 if ( mMoveIncidence->type() == "Todo" )
2281 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2284 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2282 else 2285 else
2283 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2286 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2284 mMoveIncidence = newInc; 2287 mMoveIncidence = newInc;
2285 2288
2286#endif 2289#endif
2287 } 2290 }
2288 QTime tim = mMoveIncidence->dtStart().time(); 2291 QTime tim = mMoveIncidence->dtStart().time();
2289 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2292 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2290 QDateTime dt ( d,tim ); 2293 QDateTime dt ( d,tim );
2291 mMoveIncidence->setDtStart( dt ); 2294 mMoveIncidence->setDtStart( dt );
2292 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2295 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2293 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2296 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2294 } 2297 }
2295 2298
2296 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2299 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2297 } 2300 }
2298} 2301}
2299 2302
2300void CalendarView::removeCategories() 2303void CalendarView::removeCategories()
2301{ 2304{
2302 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2305 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2303 QStringList catList = KOPrefs::instance()->mCustomCategories; 2306 QStringList catList = KOPrefs::instance()->mCustomCategories;
2304 QStringList catIncList; 2307 QStringList catIncList;
2305 QStringList newCatList; 2308 QStringList newCatList;
2306 Incidence* inc = incList.first(); 2309 Incidence* inc = incList.first();
2307 int i; 2310 int i;
2308 int count = 0; 2311 int count = 0;
2309 while ( inc ) { 2312 while ( inc ) {
2310 newCatList.clear(); 2313 newCatList.clear();
2311 catIncList = inc->categories() ; 2314 catIncList = inc->categories() ;
2312 for( i = 0; i< catIncList.count(); ++i ) { 2315 for( i = 0; i< catIncList.count(); ++i ) {
2313 if ( catList.contains (catIncList[i])) 2316 if ( catList.contains (catIncList[i]))
2314 newCatList.append( catIncList[i] ); 2317 newCatList.append( catIncList[i] );
2315 } 2318 }
2316 newCatList.sort(); 2319 newCatList.sort();
2317 inc->setCategories( newCatList.join(",") ); 2320 inc->setCategories( newCatList.join(",") );
2318 inc = incList.next(); 2321 inc = incList.next();
2319 } 2322 }
2320} 2323}
2321 2324
2322int CalendarView::addCategories() 2325int CalendarView::addCategories()
2323{ 2326{
2324 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2327 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2325 QStringList catList = KOPrefs::instance()->mCustomCategories; 2328 QStringList catList = KOPrefs::instance()->mCustomCategories;
2326 QStringList catIncList; 2329 QStringList catIncList;
2327 Incidence* inc = incList.first(); 2330 Incidence* inc = incList.first();
2328 int i; 2331 int i;
2329 int count = 0; 2332 int count = 0;
2330 while ( inc ) { 2333 while ( inc ) {
2331 catIncList = inc->categories() ; 2334 catIncList = inc->categories() ;
2332 for( i = 0; i< catIncList.count(); ++i ) { 2335 for( i = 0; i< catIncList.count(); ++i ) {
2333 if ( !catList.contains (catIncList[i])) { 2336 if ( !catList.contains (catIncList[i])) {
2334 catList.append( catIncList[i] ); 2337 catList.append( catIncList[i] );
2335 //qDebug("add cat %s ", catIncList[i].latin1()); 2338 //qDebug("add cat %s ", catIncList[i].latin1());
2336 ++count; 2339 ++count;
2337 } 2340 }
2338 } 2341 }
2339 inc = incList.next(); 2342 inc = incList.next();
2340 } 2343 }
2341 catList.sort(); 2344 catList.sort();
2342 KOPrefs::instance()->mCustomCategories = catList; 2345 KOPrefs::instance()->mCustomCategories = catList;
2343 return count; 2346 return count;
2344} 2347}
2345 2348
2346void CalendarView::manageCategories() 2349void CalendarView::manageCategories()
2347{ 2350{
2348 KOCatPrefs* cp = new KOCatPrefs(); 2351 KOCatPrefs* cp = new KOCatPrefs();
2349 cp->show(); 2352 cp->show();
2350 int w =cp->sizeHint().width() ; 2353 int w =cp->sizeHint().width() ;
2351 int h = cp->sizeHint().height() ; 2354 int h = cp->sizeHint().height() ;
2352 int dw = QApplication::desktop()->width(); 2355 int dw = QApplication::desktop()->width();
2353 int dh = QApplication::desktop()->height(); 2356 int dh = QApplication::desktop()->height();
2354 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2357 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2355 if ( !cp->exec() ) { 2358 if ( !cp->exec() ) {
2356 delete cp; 2359 delete cp;
2357 return; 2360 return;
2358 } 2361 }
2359 int count = 0; 2362 int count = 0;
2360 if ( cp->addCat() ) { 2363 if ( cp->addCat() ) {
2361 count = addCategories(); 2364 count = addCategories();
2362 if ( count ) { 2365 if ( count ) {
2363 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2366 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2364 writeSettings(); 2367 writeSettings();
2365 } else 2368 } else
2366 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2369 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2367 } else { 2370 } else {
2368 removeCategories(); 2371 removeCategories();
2369 updateView(); 2372 updateView();
2370 } 2373 }
2371 delete cp; 2374 delete cp;
2372} 2375}
2373 2376
2374void CalendarView::beamIncidence(Incidence * Inc) 2377void CalendarView::beamIncidence(Incidence * Inc)
2375{ 2378{
2376 QPtrList<Incidence> delSel ; 2379 QPtrList<Incidence> delSel ;
2377 delSel.append(Inc); 2380 delSel.append(Inc);
2378 beamIncidenceList( delSel ); 2381 beamIncidenceList( delSel );
2379} 2382}
2380void CalendarView::beamCalendar() 2383void CalendarView::beamCalendar()
2381{ 2384{
2382 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2385 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2383 //qDebug("beamCalendar() "); 2386 //qDebug("beamCalendar() ");
2384 beamIncidenceList( delSel ); 2387 beamIncidenceList( delSel );
2385} 2388}
2386void CalendarView::beamFilteredCalendar() 2389void CalendarView::beamFilteredCalendar()
2387{ 2390{
2388 QPtrList<Incidence> delSel = mCalendar->incidences(); 2391 QPtrList<Incidence> delSel = mCalendar->incidences();
2389 //qDebug("beamFilteredCalendar() "); 2392 //qDebug("beamFilteredCalendar() ");
2390 beamIncidenceList( delSel ); 2393 beamIncidenceList( delSel );
2391} 2394}
2392void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2395void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2393{ 2396{
2394 if ( beamDialog->exec () == QDialog::Rejected ) 2397 if ( beamDialog->exec () == QDialog::Rejected )
2395 return; 2398 return;
2396#ifdef DESKTOP_VERSION 2399#ifdef DESKTOP_VERSION
2397 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2400 QString fn = locateLocal( "tmp", "kopibeamfile" );
2398#else 2401#else
2399 QString fn = "/tmp/kopibeamfile"; 2402 QString fn = "/tmp/kopibeamfile";
2400#endif 2403#endif
2401 QString mes; 2404 QString mes;
2402 bool createbup = true; 2405 bool createbup = true;
2403 if ( createbup ) { 2406 if ( createbup ) {
2404 QString description = "\n"; 2407 QString description = "\n";
2405 CalendarLocal* cal = new CalendarLocal(); 2408 CalendarLocal* cal = new CalendarLocal();
2406 if ( beamDialog->beamLocal() ) 2409 if ( beamDialog->beamLocal() )
2407 cal->setLocalTime(); 2410 cal->setLocalTime();
2408 else 2411 else
2409 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2412 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2410 Incidence *incidence = delSel.first(); 2413 Incidence *incidence = delSel.first();
2411 bool addText = false; 2414 bool addText = false;
2412 if ( delSel.count() < 10 ) 2415 if ( delSel.count() < 10 )
2413 addText = true; 2416 addText = true;
2414 else { 2417 else {
2415 description.sprintf(i18n(" %d items?"),delSel.count() ); 2418 description.sprintf(i18n(" %d items?"),delSel.count() );
2416 } 2419 }
2417 while ( incidence ) { 2420 while ( incidence ) {
2418 Incidence *in = incidence->clone(); 2421 Incidence *in = incidence->clone();
2419 if ( ! in->summary().isEmpty() ) { 2422 if ( ! in->summary().isEmpty() ) {
2420 in->setDescription(""); 2423 in->setDescription("");
2421 } else { 2424 } else {
2422 in->setSummary( in->description().left(20)); 2425 in->setSummary( in->description().left(20));
2423 in->setDescription(""); 2426 in->setDescription("");
2424 } 2427 }
2425 if ( addText ) 2428 if ( addText )
2426 description += in->summary() + "\n"; 2429 description += in->summary() + "\n";
2427 cal->addIncidence( in ); 2430 cal->addIncidence( in );
2428 incidence = delSel.next(); 2431 incidence = delSel.next();
2429 } 2432 }
2430 if ( beamDialog->beamVcal() ) { 2433 if ( beamDialog->beamVcal() ) {
2431 fn += ".vcs"; 2434 fn += ".vcs";
2432 FileStorage storage( cal, fn, new VCalFormat ); 2435 FileStorage storage( cal, fn, new VCalFormat );
2433 storage.save(); 2436 storage.save();
2434 } else { 2437 } else {
2435 fn += ".ics"; 2438 fn += ".ics";
2436 FileStorage storage( cal, fn, new ICalFormat( ) ); 2439 FileStorage storage( cal, fn, new ICalFormat( ) );
2437 storage.save(); 2440 storage.save();
2438 } 2441 }
2439 delete cal; 2442 delete cal;
2440 mes = i18n("KO/Pi: Ready for beaming"); 2443 mes = i18n("KO/Pi: Ready for beaming");
2441 topLevelWidget()->setCaption(mes); 2444 topLevelWidget()->setCaption(mes);
2442 KApplication::convert2latin1( fn ); 2445 KApplication::convert2latin1( fn );
2443#ifndef DESKTOP_VERSION 2446#ifndef DESKTOP_VERSION
2444 Ir *ir = new Ir( this ); 2447 Ir *ir = new Ir( this );
2445 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2448 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2446 ir->send( fn, description, "text/x-vCalendar" ); 2449 ir->send( fn, description, "text/x-vCalendar" );
2447#endif 2450#endif
2448 } 2451 }
2449} 2452}
2450void CalendarView::beamDone( Ir *ir ) 2453void CalendarView::beamDone( Ir *ir )
2451{ 2454{
2452#ifndef DESKTOP_VERSION 2455#ifndef DESKTOP_VERSION
2453 delete ir; 2456 delete ir;
2454#endif 2457#endif
2455 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2458 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2456 topLevelWidget()->raise(); 2459 topLevelWidget()->raise();
2457} 2460}
2458 2461
2459void CalendarView::moveIncidence(Incidence * inc ) 2462void CalendarView::moveIncidence(Incidence * inc )
2460{ 2463{
2461 if ( !inc ) return; 2464 if ( !inc ) return;
2462 // qDebug("showDatePickerForIncidence( ) "); 2465 // qDebug("showDatePickerForIncidence( ) ");
2463 if ( mDateFrame->isVisible() ) 2466 if ( mDateFrame->isVisible() )
2464 mDateFrame->hide(); 2467 mDateFrame->hide();
2465 else { 2468 else {
2466 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2469 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2467 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2470 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2468 int dw = QApplication::desktop()->width(); 2471 int dw = QApplication::desktop()->width();
2469 int dh = QApplication::desktop()->height(); 2472 int dh = QApplication::desktop()->height();
2470 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2473 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2471 mDateFrame->show(); 2474 mDateFrame->show();
2472 } 2475 }
2473 mDatePickerMode = 2; 2476 mDatePickerMode = 2;
2474 mMoveIncidence = inc ; 2477 mMoveIncidence = inc ;
2475 QDate da; 2478 QDate da;
2476 if ( mMoveIncidence->type() == "Todo" ) { 2479 if ( mMoveIncidence->type() == "Todo" ) {
2477 Todo * to = (Todo *) mMoveIncidence; 2480 Todo * to = (Todo *) mMoveIncidence;
2478 if ( to->hasDueDate() ) 2481 if ( to->hasDueDate() )
2479 da = to->dtDue().date(); 2482 da = to->dtDue().date();
2480 else 2483 else
2481 da = QDate::currentDate(); 2484 da = QDate::currentDate();
2482 } else { 2485 } else {
2483 da = mMoveIncidence->dtStart().date(); 2486 da = mMoveIncidence->dtStart().date();
2484 } 2487 }
2485 //PENDING set date for recurring incidence to date of recurrence 2488 //PENDING set date for recurring incidence to date of recurrence
2486 //mMoveIncidenceOldDate; 2489 //mMoveIncidenceOldDate;
2487 mDatePicker->setDate( da ); 2490 mDatePicker->setDate( da );
2488} 2491}
2489void CalendarView::showDatePicker( ) 2492void CalendarView::showDatePicker( )
2490{ 2493{
2491 //qDebug("CalendarView::showDatePicker( ) "); 2494 //qDebug("CalendarView::showDatePicker( ) ");
2492 if ( mDateFrame->isVisible() ) 2495 if ( mDateFrame->isVisible() )
2493 mDateFrame->hide(); 2496 mDateFrame->hide();
2494 else { 2497 else {
2495 int w =mDatePicker->sizeHint().width() ; 2498 int w =mDatePicker->sizeHint().width() ;
2496 int h = mDatePicker->sizeHint().height() ; 2499 int h = mDatePicker->sizeHint().height() ;
2497 int dw = QApplication::desktop()->width(); 2500 int dw = QApplication::desktop()->width();
2498 int dh = QApplication::desktop()->height(); 2501 int dh = QApplication::desktop()->height();
2499 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2502 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2500 mDateFrame->show(); 2503 mDateFrame->show();
2501 } 2504 }
2502 mDatePickerMode = 1; 2505 mDatePickerMode = 1;
2503 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2506 mDatePicker->setDate( mNavigator->selectedDates().first() );
2504} 2507}
2505 2508
2506void CalendarView::showEventEditor() 2509void CalendarView::showEventEditor()
2507{ 2510{
2508#ifdef DESKTOP_VERSION 2511#ifdef DESKTOP_VERSION
2509 mEventEditor->show(); 2512 mEventEditor->show();
2510#else 2513#else
2511 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2514 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2512 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2515 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2513 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2516 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2517 qApp->processEvents();
2514 delete mEventEditor; 2518 delete mEventEditor;
2515 mEventEditor = mDialogManager->getEventEditor(); 2519 mEventEditor = mDialogManager->getEventEditor();
2516 topLevelWidget()->setCaption( i18n("") ); 2520 topLevelWidget()->setCaption( i18n("") );
2517 } 2521 }
2518 mEventEditor->showMaximized(); 2522 mEventEditor->showMaximized();
2519#endif 2523#endif
2520} 2524}
2521void CalendarView::showTodoEditor() 2525void CalendarView::showTodoEditor()
2522{ 2526{
2523#ifdef DESKTOP_VERSION 2527#ifdef DESKTOP_VERSION
2524 mTodoEditor->show(); 2528 mTodoEditor->show();
2525#else 2529#else
2526 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2530 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2527 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2531 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2528 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2532 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2533 qApp->processEvents();
2529 delete mTodoEditor; 2534 delete mTodoEditor;
2530 mTodoEditor = mDialogManager->getTodoEditor(); 2535 mTodoEditor = mDialogManager->getTodoEditor();
2531 topLevelWidget()->setCaption( i18n("") ); 2536 topLevelWidget()->setCaption( i18n("") );
2532 } 2537 }
2533 mTodoEditor->showMaximized(); 2538 mTodoEditor->showMaximized();
2534#endif 2539#endif
2535} 2540}
2536 2541
2537void CalendarView::cloneIncidence() 2542void CalendarView::cloneIncidence()
2538{ 2543{
2539 Incidence *incidence = currentSelection(); 2544 Incidence *incidence = currentSelection();
2540 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2545 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2541 if ( incidence ) { 2546 if ( incidence ) {
2542 cloneIncidence(incidence); 2547 cloneIncidence(incidence);
2543 } 2548 }
2544} 2549}
2545void CalendarView::moveIncidence() 2550void CalendarView::moveIncidence()
2546{ 2551{
2547 Incidence *incidence = currentSelection(); 2552 Incidence *incidence = currentSelection();
2548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2553 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2549 if ( incidence ) { 2554 if ( incidence ) {
2550 moveIncidence(incidence); 2555 moveIncidence(incidence);
2551 } 2556 }
2552} 2557}
2553void CalendarView::beamIncidence() 2558void CalendarView::beamIncidence()
2554{ 2559{
2555 Incidence *incidence = currentSelection(); 2560 Incidence *incidence = currentSelection();
2556 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2561 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2557 if ( incidence ) { 2562 if ( incidence ) {
2558 beamIncidence(incidence); 2563 beamIncidence(incidence);
2559 } 2564 }
2560} 2565}
2561void CalendarView::toggleCancelIncidence() 2566void CalendarView::toggleCancelIncidence()
2562{ 2567{
2563 Incidence *incidence = currentSelection(); 2568 Incidence *incidence = currentSelection();
2564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2569 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2565 if ( incidence ) { 2570 if ( incidence ) {
2566 cancelIncidence(incidence); 2571 cancelIncidence(incidence);
2567 } 2572 }
2568} 2573}
2569 2574
2570 2575
2571void CalendarView::cancelIncidence(Incidence * inc ) 2576void CalendarView::cancelIncidence(Incidence * inc )
2572{ 2577{
2573 inc->setCancelled( ! inc->cancelled() ); 2578 inc->setCancelled( ! inc->cancelled() );
2574 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2579 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2575 updateView(); 2580 updateView();
2576} 2581}
2577void CalendarView::cloneIncidence(Incidence * orgInc ) 2582void CalendarView::cloneIncidence(Incidence * orgInc )
2578{ 2583{
2579 Incidence * newInc = orgInc->clone(); 2584 Incidence * newInc = orgInc->clone();
2580 newInc->recreate(); 2585 newInc->recreate();
2581 2586
2582 if ( newInc->type() == "Todo" ) { 2587 if ( newInc->type() == "Todo" ) {
2583 Todo* t = (Todo*) newInc; 2588 Todo* t = (Todo*) newInc;
2584 showTodoEditor(); 2589 showTodoEditor();
2585 mTodoEditor->editTodo( t ); 2590 mTodoEditor->editTodo( t );
2586 if ( mTodoEditor->exec() ) { 2591 if ( mTodoEditor->exec() ) {
2587 mCalendar->addTodo( t ); 2592 mCalendar->addTodo( t );
2588 updateView(); 2593 updateView();
2589 } else { 2594 } else {
2590 delete t; 2595 delete t;
2591 } 2596 }
2592 } 2597 }
2593 else { 2598 else {
2594 Event* e = (Event*) newInc; 2599 Event* e = (Event*) newInc;
2595 showEventEditor(); 2600 showEventEditor();
2596 mEventEditor->editEvent( e ); 2601 mEventEditor->editEvent( e );
2597 if ( mEventEditor->exec() ) { 2602 if ( mEventEditor->exec() ) {
2598 mCalendar->addEvent( e ); 2603 mCalendar->addEvent( e );
2599 updateView(); 2604 updateView();
2600 } else { 2605 } else {
2601 delete e; 2606 delete e;
2602 } 2607 }
2603 } 2608 }
2604} 2609}
2605 2610
2606void CalendarView::newEvent() 2611void CalendarView::newEvent()
2607{ 2612{
2608 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2613 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2609 KOAgendaView *aView = mViewManager->agendaView(); 2614 KOAgendaView *aView = mViewManager->agendaView();
2610 if (aView) { 2615 if (aView) {
2611 if (aView->selectionStart().isValid()) { 2616 if (aView->selectionStart().isValid()) {
2612 if (aView->selectedIsAllDay()) { 2617 if (aView->selectedIsAllDay()) {
2613 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2618 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2614 } else { 2619 } else {
2615 newEvent(aView->selectionStart(),aView->selectionEnd()); 2620 newEvent(aView->selectionStart(),aView->selectionEnd());
2616 } 2621 }
2617 return; 2622 return;
2618 } 2623 }
2619 } 2624 }
2620 2625
2621 QDate date = mNavigator->selectedDates().first(); 2626 QDate date = mNavigator->selectedDates().first();
2622 QDateTime current = QDateTime::currentDateTime(); 2627 QDateTime current = QDateTime::currentDateTime();
2623 if ( date <= current.date() ) { 2628 if ( date <= current.date() ) {
2624 int hour = current.time().hour() +1; 2629 int hour = current.time().hour() +1;
2625 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2630 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2626 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2631 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2627 } else 2632 } else
2628 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2633 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2629 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2634 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2630 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2635 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2631} 2636}
2632 2637
2633void CalendarView::newEvent(QDateTime fh) 2638void CalendarView::newEvent(QDateTime fh)
2634{ 2639{
2635 newEvent(fh, 2640 newEvent(fh,
2636 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2641 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2637} 2642}
2638 2643
2639void CalendarView::newEvent(QDate dt) 2644void CalendarView::newEvent(QDate dt)
2640{ 2645{
2641 newEvent(QDateTime(dt, QTime(0,0,0)), 2646 newEvent(QDateTime(dt, QTime(0,0,0)),
2642 QDateTime(dt, QTime(0,0,0)), true); 2647 QDateTime(dt, QTime(0,0,0)), true);
2643} 2648}
2644 2649
2645void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2646{ 2651{
2647 2652
2648 showEventEditor(); 2653 showEventEditor();
2649 mEventEditor->newEvent(fromHint,toHint,allDay); 2654 mEventEditor->newEvent(fromHint,toHint,allDay);
2650 if ( mFilterView->filtersEnabled() ) { 2655 if ( mFilterView->filtersEnabled() ) {
2651 CalFilter *filter = mFilterView->selectedFilter(); 2656 CalFilter *filter = mFilterView->selectedFilter();
2652 if (filter && filter->showCategories()) { 2657 if (filter && filter->showCategories()) {
2653 mEventEditor->setCategories(filter->categoryList().join(",") ); 2658 mEventEditor->setCategories(filter->categoryList().join(",") );
2654 } 2659 }
2655 if ( filter ) 2660 if ( filter )
2656 mEventEditor->setSecrecy( filter->getSecrecy() ); 2661 mEventEditor->setSecrecy( filter->getSecrecy() );
2657 } 2662 }
2658} 2663}
2659void CalendarView::todoAdded(Todo * t) 2664void CalendarView::todoAdded(Todo * t)
2660{ 2665{
2661 2666
2662 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2667 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2663 updateTodoViews(); 2668 updateTodoViews();
2664} 2669}
2665void CalendarView::todoChanged(Todo * t) 2670void CalendarView::todoChanged(Todo * t)
2666{ 2671{
2667 emit todoModified( t, 4 ); 2672 emit todoModified( t, 4 );
2668 // updateTodoViews(); 2673 // updateTodoViews();
2669} 2674}
2670void CalendarView::todoToBeDeleted(Todo *) 2675void CalendarView::todoToBeDeleted(Todo *)
2671{ 2676{
2672 //qDebug("todoToBeDeleted(Todo *) "); 2677 //qDebug("todoToBeDeleted(Todo *) ");
2673 updateTodoViews(); 2678 updateTodoViews();
2674} 2679}
2675void CalendarView::todoDeleted() 2680void CalendarView::todoDeleted()
2676{ 2681{
2677 //qDebug(" todoDeleted()"); 2682 //qDebug(" todoDeleted()");
2678 updateTodoViews(); 2683 updateTodoViews();
2679} 2684}
2680 2685
2681 2686
2682 2687
2683void CalendarView::newTodo() 2688void CalendarView::newTodo()
2684{ 2689{
2685 2690
2686 showTodoEditor(); 2691 showTodoEditor();
2687 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2692 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2688 if ( mFilterView->filtersEnabled() ) { 2693 if ( mFilterView->filtersEnabled() ) {
2689 CalFilter *filter = mFilterView->selectedFilter(); 2694 CalFilter *filter = mFilterView->selectedFilter();
2690 if (filter && filter->showCategories()) { 2695 if (filter && filter->showCategories()) {
2691 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2696 mTodoEditor->setCategories(filter->categoryList().join(",") );
2692 } 2697 }
2693 if ( filter ) 2698 if ( filter )
2694 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2699 mTodoEditor->setSecrecy( filter->getSecrecy() );
2695 } 2700 }
2696} 2701}
2697 2702
2698void CalendarView::newSubTodo() 2703void CalendarView::newSubTodo()
2699{ 2704{
2700 Todo *todo = selectedTodo(); 2705 Todo *todo = selectedTodo();
2701 if ( todo ) newSubTodo( todo ); 2706 if ( todo ) newSubTodo( todo );
2702} 2707}
2703 2708
2704void CalendarView::newSubTodo(Todo *parentEvent) 2709void CalendarView::newSubTodo(Todo *parentEvent)
2705{ 2710{
2706 2711
2707 showTodoEditor(); 2712 showTodoEditor();
2708 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2713 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2709} 2714}
2710 2715
2711void CalendarView::newFloatingEvent() 2716void CalendarView::newFloatingEvent()
2712{ 2717{
2713 DateList tmpList = mNavigator->selectedDates(); 2718 DateList tmpList = mNavigator->selectedDates();
2714 QDate date = tmpList.first(); 2719 QDate date = tmpList.first();
2715 2720
2716 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2721 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2717 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2722 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2718} 2723}
2719 2724
2720 2725
2721void CalendarView::editEvent( Event *event ) 2726void CalendarView::editEvent( Event *event )
2722{ 2727{
2723 2728
2724 if ( !event ) return; 2729 if ( !event ) return;
2725 if ( event->isReadOnly() ) { 2730 if ( event->isReadOnly() ) {
2726 showEvent( event ); 2731 showEvent( event );
2727 return; 2732 return;
2728 } 2733 }
2729 showEventEditor(); 2734 showEventEditor();
2730 mEventEditor->editEvent( event , mFlagEditDescription); 2735 mEventEditor->editEvent( event , mFlagEditDescription);
2731} 2736}
2732void CalendarView::editJournal( Journal *jour ) 2737void CalendarView::editJournal( Journal *jour )
2733{ 2738{
2734 if ( !jour ) return; 2739 if ( !jour ) return;
2735 mDialogManager->hideSearchDialog(); 2740 mDialogManager->hideSearchDialog();
2736 mViewManager->showJournalView(); 2741 mViewManager->showJournalView();
2737 mNavigator->slotDaySelect( jour->dtStart().date() ); 2742 mNavigator->slotDaySelect( jour->dtStart().date() );
2738} 2743}
2739void CalendarView::editTodo( Todo *todo ) 2744void CalendarView::editTodo( Todo *todo )
2740{ 2745{
2741 if ( !todo ) return; 2746 if ( !todo ) return;
2742 2747
2743 if ( todo->isReadOnly() ) { 2748 if ( todo->isReadOnly() ) {
2744 showTodo( todo ); 2749 showTodo( todo );
2745 return; 2750 return;
2746 } 2751 }
2747 showTodoEditor(); 2752 showTodoEditor();
2748 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2753 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2749 2754
2750} 2755}
2751 2756
2752KOEventViewerDialog* CalendarView::getEventViewerDialog() 2757KOEventViewerDialog* CalendarView::getEventViewerDialog()
2753{ 2758{
2754 if ( !mEventViewerDialog ) { 2759 if ( !mEventViewerDialog ) {
2755 mEventViewerDialog = new KOEventViewerDialog(this); 2760 mEventViewerDialog = new KOEventViewerDialog(this);
2756 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2761 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2757 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2762 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2758 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2763 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2759 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2764 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2760 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2765 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2761 viewManager(), SLOT( showAgendaView( bool ) ) ); 2766 viewManager(), SLOT( showAgendaView( bool ) ) );
2762 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2767 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2763 this, SLOT( todoChanged(Todo *) ) ); 2768 this, SLOT( todoChanged(Todo *) ) );
2764 mEventViewerDialog->resize( 640, 480 ); 2769 mEventViewerDialog->resize( 640, 480 );
2765 2770
2766 } 2771 }
2767 return mEventViewerDialog; 2772 return mEventViewerDialog;
2768} 2773}
2769void CalendarView::showEvent(Event *event) 2774void CalendarView::showEvent(Event *event)
2770{ 2775{
2771 getEventViewerDialog()->setEvent(event); 2776 getEventViewerDialog()->setEvent(event);
2772 getEventViewerDialog()->showMe(); 2777 getEventViewerDialog()->showMe();
2773} 2778}
2774 2779
2775void CalendarView::showTodo(Todo *event) 2780void CalendarView::showTodo(Todo *event)
2776{ 2781{
2777 getEventViewerDialog()->setTodo(event); 2782 getEventViewerDialog()->setTodo(event);
2778 getEventViewerDialog()->showMe(); 2783 getEventViewerDialog()->showMe();
2779} 2784}
2780void CalendarView::showJournal( Journal *jour ) 2785void CalendarView::showJournal( Journal *jour )
2781{ 2786{
2782 getEventViewerDialog()->setJournal(jour); 2787 getEventViewerDialog()->setJournal(jour);
2783 getEventViewerDialog()->showMe(); 2788 getEventViewerDialog()->showMe();
2784 2789
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 7166a01..4111c5d 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -347,395 +347,406 @@ void KOWhatsNextView::updateView()
347 appendEvent(ev,true); 347 appendEvent(ev,true);
348 } 348 }
349 } 349 }
350 ev = events.next(); 350 ev = events.next();
351 } 351 }
352 } 352 }
353 todos = calendar()->todos(); 353 todos = calendar()->todos();
354 if (todos.count() > 0) { 354 if (todos.count() > 0) {
355 Todo *to = todos.first(); 355 Todo *to = todos.first();
356 while(to) { 356 while(to) {
357 if ( !to->isCompleted() ){ 357 if ( !to->isCompleted() ){
358 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 358 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
359 if (me!=0) { 359 if (me!=0) {
360 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 360 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
361 if (replys == 0) { 361 if (replys == 0) {
362 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 362 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
363 mText += "<table>\n"; 363 mText += "<table>\n";
364 } 364 }
365 replys++; 365 replys++;
366 appendEvent(to, true); 366 appendEvent(to, true);
367 } 367 }
368 } 368 }
369 } 369 }
370 to = todos.next(); 370 to = todos.next();
371 } 371 }
372 } 372 }
373 if (replys > 0 ) mText += "</table>\n"; 373 if (replys > 0 ) mText += "</table>\n";
374 374
375 375
376 mText += "</td></tr>\n</table>\n"; 376 mText += "</td></tr>\n</table>\n";
377 377
378 mView->setText(mText); 378 mView->setText(mText);
379 mView->setFocus(); 379 mView->setFocus();
380 380
381 // QPixmap bPix = SmallIcon( "back" ); 381 // QPixmap bPix = SmallIcon( "back" );
382 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 382 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
383 // QWidget* test = new QWidget(); 383 // QWidget* test = new QWidget();
384 // test->setBackgroundMode(FixedPixmap ); 384 // test->setBackgroundMode(FixedPixmap );
385 // test->setBackgroundPixmap ( bPix ); 385 // test->setBackgroundPixmap ( bPix );
386 // test->resize( 300, 400 ); 386 // test->resize( 300, 400 );
387 // test->show(); 387 // test->show();
388 // mView->setBackgroundMode(FixedPixmap ); 388 // mView->setBackgroundMode(FixedPixmap );
389 // mView->setBackgroundPixmap ( bPix ); 389 // mView->setBackgroundPixmap ( bPix );
390 // qDebug("%s ",mText.latin1()); 390 // qDebug("%s ",mText.latin1());
391} 391}
392 392
393void KOWhatsNextView::appendDay( int i, QDate eventDate ) 393void KOWhatsNextView::appendDay( int i, QDate eventDate )
394{ 394{
395 QString date; 395 QString date;
396 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 396 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
397 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 397 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
398 if ( i == 0 ) { 398 if ( i == 0 ) {
399 //mText += "<table>\n"; 399 //mText += "<table>\n";
400 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 400 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
401 } 401 }
402 else if ( i == 1 ) 402 else if ( i == 1 )
403 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 403 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
404 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 404 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
405 mText += "<h2>" + date + "</h2>\n"; 405 mText += "<h2>" + date + "</h2>\n";
406 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 406 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
407 mText += "<table>\n"; 407 mText += "<table>\n";
408 408
409 409
410 410
411 } else { 411 } else {
412 if ( i == 0 ) { 412 if ( i == 0 ) {
413 //mText += "<table>\n"; 413 //mText += "<table>\n";
414 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 414 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
415 } 415 }
416 416
417#ifdef DESKTOP_VERSION 417#ifdef DESKTOP_VERSION
418 else if ( i == 1 ) { 418 else if ( i == 1 ) {
419 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 419 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
420 } 420 }
421 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 421 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
422#else 422#else
423 else if ( i == 1 ) { 423 else if ( i == 1 ) {
424 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 424 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
425 } 425 }
426 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 426 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
427 427
428#endif 428#endif
429 mText += "<h2>" + date + "</h2>\n"; 429 mText += "<h2>" + date + "</h2>\n";
430 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 430 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
431 mText += "<table>\n"; 431 mText += "<table>\n";
432 } 432 }
433} 433}
434 434
435 435
436void KOWhatsNextView::showDates(const QDate &, const QDate &) 436void KOWhatsNextView::showDates(const QDate &, const QDate &)
437{ 437{
438 updateView(); 438 updateView();
439} 439}
440 440
441void KOWhatsNextView::showEvents(QPtrList<Event>) 441void KOWhatsNextView::showEvents(QPtrList<Event>)
442{ 442{
443} 443}
444 444
445void KOWhatsNextView::changeEventDisplay(Event *, int action) 445void KOWhatsNextView::changeEventDisplay(Event *, int action)
446{ 446{
447 switch(action) { 447 switch(action) {
448 case KOGlobals::EVENTADDED: 448 case KOGlobals::EVENTADDED:
449 updateView(); 449 updateView();
450 break; 450 break;
451 case KOGlobals::EVENTEDITED: 451 case KOGlobals::EVENTEDITED:
452 updateView(); 452 updateView();
453 break; 453 break;
454 case KOGlobals::EVENTDELETED: 454 case KOGlobals::EVENTDELETED:
455 updateView(); 455 updateView();
456 break; 456 break;
457 default: 457 default:
458 updateView(); 458 updateView();
459 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 459 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
460 } 460 }
461} 461}
462 462
463bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 463bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
464{ 464{
465 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 465 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
466 return false; 466 return false;
467 QDateTime cdt = QDateTime::currentDateTime(); 467 QDateTime cdt = QDateTime::currentDateTime();
468 QDateTime noc; 468 QDateTime noc;
469 QString tempText; 469 QString tempText;
470 if ( appendTable && !notRed ) { 470 if ( appendTable && !notRed ) {
471 tempText = "<table>"; 471 tempText = "<table>";
472 } 472 }
473 bool ok = true; 473 bool ok = true;
474 if ( reply ) { 474 if ( reply ) {
475 noc = ev->getNextOccurence( cdt, &ok ); 475 noc = ev->getNextOccurence( cdt, &ok );
476 if (! ok && ev->type() == "Event") 476 if (! ok && ev->type() == "Event")
477 return false; 477 return false;
478 } 478 }
479 tempText += "<tr><td><b>"; 479 tempText += "<tr><td><b>";
480 if (ev->type()=="Event") { 480 if (ev->type()=="Event") {
481 if (reply) { 481 if (reply) {
482 if (!ev->doesFloat()) 482 if (!ev->doesFloat())
483 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 483 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
484 else 484 else
485 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 485 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
486 486
487 } else { 487 } else {
488 if (!ev->doesFloat()) { 488 if (!ev->doesFloat()) {
489 Event *event = static_cast<Event *>(ev); 489 Event *event = static_cast<Event *>(ev);
490 QDateTime st,end; 490 QDateTime st,end;
491 if ( event->recurrence()->doesRecur() ) { 491 if ( event->recurrence()->doesRecur() ) {
492 QDate recDate= mEventDate; 492 QDate recDate= mEventDate;
493 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 493 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
494 while ( ! event->recursOn( recDate ) ) { 494 while ( ! event->recursOn( recDate ) ) {
495 recDate = recDate.addDays( -1 ); 495 recDate = recDate.addDays( -1 );
496 496
497 } 497 }
498 st = QDateTime ( recDate, event->dtStart().time() ); 498 st = QDateTime ( recDate, event->dtStart().time() );
499 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 499 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
500 } 500 }
501 else { 501 else {
502 st = event->dtStart(); 502 st = event->dtStart();
503 end = event->dtEnd(); 503 end = event->dtEnd();
504 } 504 }
505 505
506 506
507 QString dateText; 507 QString dateText;
508 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 508 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
509 if ( st.date() < mEventDate ) 509 if ( st.date() < mEventDate )
510 dateText = "++:++-"; 510 dateText = "++:++-";
511 else 511 else
512 dateText = event->dtStartTimeStr() + "-"; 512 dateText = event->dtStartTimeStr() + "-";
513 if ( end.date() > mEventDate ) 513 if ( end.date() > mEventDate )
514 dateText += "++:++"; 514 dateText += "++:++";
515 else 515 else
516 dateText += event->dtEndTimeStr(); 516 dateText += event->dtEndTimeStr();
517 if ( notRed ) 517 if ( notRed )
518 tempText += dateText; 518 tempText += dateText;
519 else { 519 else {
520 if ( end < cdt ) { 520 if ( end < cdt ) {
521 if ( !KOPrefs::instance()->mWNViewShowsPast ) 521 if ( !KOPrefs::instance()->mWNViewShowsPast )
522 return false; 522 return false;
523 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 523 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
524 } 524 }
525 else if ( st < cdt ) 525 else if ( st < cdt )
526 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 526 tempText += "<font color=\"#008000\">" + dateText + "</font>";
527 else 527 else
528 tempText += dateText; 528 tempText += dateText;
529 529
530 } 530 }
531 531
532 } else { 532 } else {
533 tempText += i18n("Allday:"); 533 tempText += i18n("Allday:");
534 534
535 } 535 }
536 } 536 }
537 } else { 537 } else {
538 mTodos.append( ev ); 538 mTodos.append( ev );
539 tempText += i18n("ToDo:"); 539 tempText += i18n("ToDo:");
540 if (reply) { 540 if (reply) {
541 tempText += " "; 541 tempText += " ";
542 if ( noc != cdt ) { 542 if ( noc != cdt ) {
543 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 543 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
544 } 544 }
545 } else { 545 } else {
546 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 546 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
547 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 547 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
548 QString dfs = KGlobal::locale()->dateFormatShort(); 548 QString dfs = KGlobal::locale()->dateFormatShort();
549 KGlobal::locale()->setDateFormatShort("%d.%b"); 549 KGlobal::locale()->setDateFormatShort("%d.%b");
550 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 550 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
551 KGlobal::locale()->setDateFormatShort(dfs); 551 KGlobal::locale()->setDateFormatShort(dfs);
552 } else { 552 } else {
553 if (!ev->doesFloat() ) 553 if (!ev->doesFloat() )
554 if( ( (Todo*)ev)->dtDue() < cdt ) { 554 if( ( (Todo*)ev)->dtDue() < cdt ) {
555 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 555 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
556 556
557 557
558 } else 558 } else
559 tempText +=((Todo*)ev)->dtDueTimeStr(); 559 tempText +=((Todo*)ev)->dtDueTimeStr();
560 mTodos.append( ev ); 560 mTodos.append( ev );
561 } 561 }
562 } 562 }
563 } 563 }
564 tempText += "</b></td><td>"; 564 tempText += "</b></td><td>";
565 bool needClose = false; 565 bool needClose = false;
566 if ( ev->cancelled() ) { 566 if ( ev->cancelled() ) {
567 tempText += "<font color=\"#F00000\">[c"; 567 tempText += "<font color=\"#F00000\">[c";
568 needClose =true; 568 needClose =true;
569 569
570 } 570 }
571 if ( ev->isAlarmEnabled() ) { 571 if ( ev->isAlarmEnabled() ) {
572 if ( !needClose) 572 if ( !needClose)
573 tempText +="["; 573 tempText +="[";
574 tempText += "a"; 574 tempText += "a";
575 needClose =true; 575 needClose =true;
576 576
577 } 577 }
578 if ( ev->description().length() > 0 ) { 578 if ( ev->description().length() > 0 ) {
579 if ( !needClose) 579 if ( !needClose)
580 tempText +="["; 580 tempText +="[";
581 tempText += "i"; 581 tempText += "i";
582 needClose =true; 582 needClose =true;
583 } 583 }
584 if ( ev->recurrence()->doesRecur() ) { 584 if ( ev->recurrence()->doesRecur() ) {
585 if ( !needClose) 585 if ( !needClose)
586 tempText +="["; 586 tempText +="[";
587 tempText += "r"; 587 tempText += "r";
588 needClose =true; 588 needClose =true;
589 } 589 }
590 if ( needClose ) { 590 if ( needClose ) {
591 tempText += "] "; 591 tempText += "] ";
592 } 592 }
593 if ( ev->cancelled() ) 593 if ( ev->cancelled() )
594 tempText += "</font>"; 594 tempText += "</font>";
595 tempText += "<a "; 595 tempText += "<a ";
596 if (ev->type()=="Event") tempText += "href=\"event:"; 596 if (ev->type()=="Event") tempText += "href=\"event:";
597 if (ev->type()=="Todo") tempText += "href=\"todo:"; 597 if (ev->type()=="Todo") tempText += "href=\"todo:";
598 tempText += ev->uid() + "\">"; 598 tempText += ev->uid() + "\">";
599 if ( ev->summary().length() > 0 ) 599 if ( ev->summary().length() > 0 )
600 tempText += ev->summary(); 600 tempText += ev->summary();
601 else 601 else
602 tempText += i18n("-no summary-"); 602 tempText += i18n("-no summary-");
603 if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) {
604 noc = ev->getNextOccurence( cdt, &ok );
605 if ( ok ) {
606 int years = noc.date().year() - ev->dtStart().date().year();
607 tempText += i18n(" (%1 y.)"). arg( years );
608 }
609 }
610
603 tempText += "</a>"; 611 tempText += "</a>";
604 if ( KOPrefs::instance()->mWNViewShowLocation ) 612 if ( KOPrefs::instance()->mWNViewShowLocation )
605 if ( !ev->location().isEmpty() ) 613 if ( !ev->location().isEmpty() )
606 tempText += " ("+ev->location() +")"; 614 tempText += " ("+ev->location() +")";
607 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 615 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
608 tempText += " ["+ev->relatedTo()->summary() +"]"; 616 tempText += " ["+ev->relatedTo()->summary() +"]";
609 tempText += "</td></tr>\n"; 617 tempText += "</td></tr>\n";
610 mText += tempText; 618 mText += tempText;
611 return true; 619 return true;
612} 620}
613 621
614bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 622bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
615{ 623{
616 if ( mTodos.find( ev ) != mTodos.end() ) return false; 624 if ( mTodos.find( ev ) != mTodos.end() ) return false;
617 625
618 mTodos.append( ev ); 626 mTodos.append( ev );
619 if ( !isSub ) 627 if ( !isSub )
620 mText += "<p>"; 628 mText += "<p>";
621 else 629 else
622 mText += "<li>"; 630 mText += "<li>";
623 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 631 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
624 632
625 633
626 mText += ind; 634 mText += ind;
627 bool needClose = false; 635 bool needClose = false;
628 if ( ev->cancelled() ) { 636 if ( ev->cancelled() ) {
629 mText += "<font color=\"#F00000\">[c"; 637 mText += "<font color=\"#F00000\">[c";
630 needClose =true; 638 needClose =true;
631 639
632 } 640 }
633 if ( ev->isAlarmEnabled() ) { 641 if ( ev->isAlarmEnabled() ) {
634 if ( !needClose) 642 if ( !needClose)
635 mText +="["; 643 mText +="[";
636 mText += "a"; 644 mText += "a";
637 needClose =true; 645 needClose =true;
638 646
639 } 647 }
640 648
641 if ( ev->description().length() > 0 ) { 649 if ( ev->description().length() > 0 ) {
642 if ( !needClose) 650 if ( !needClose)
643 mText +="["; 651 mText +="[";
644 mText += "i"; 652 mText += "i";
645 needClose =true; 653 needClose =true;
646 } 654 }
647 // if ( ev->recurrence()->doesRecur() ) { 655 // if ( ev->recurrence()->doesRecur() ) {
648 // if ( !needClose) 656 // if ( !needClose)
649 // mText +="("; 657 // mText +="(";
650 // mText += "r"; 658 // mText += "r";
651 // needClose =true; 659 // needClose =true;
652 // } 660 // }
653 if ( needClose ) 661 if ( needClose )
654 mText += "] "; 662 mText += "] ";
655 if ( ev->cancelled() ) 663 if ( ev->cancelled() )
656 mText += "</font>"; 664 mText += "</font>";
657 mText += "<a href=\"todo:" + ev->uid() + "\">"; 665 mText += "<a href=\"todo:" + ev->uid() + "\">";
658 mText += ev->summary(); 666 if ( ev->summary().length() > 0 )
667 mText += ev->summary();
668 else
669 mText += i18n("-no summary-");
659 mText += "</a>"; 670 mText += "</a>";
660 if ( ((Todo*)ev)->hasDueDate () ) { 671 if ( ((Todo*)ev)->hasDueDate () ) {
661 QString year = ""; 672 QString year = "";
662 int ye = ((Todo*)ev)->dtDue().date().year(); 673 int ye = ((Todo*)ev)->dtDue().date().year();
663 if ( QDateTime::currentDateTime().date().year() != ye ) 674 if ( QDateTime::currentDateTime().date().year() != ye )
664 year = QString::number( ye ); 675 year = QString::number( ye );
665 QString dfs = KGlobal::locale()->dateFormatShort(); 676 QString dfs = KGlobal::locale()->dateFormatShort();
666 KGlobal::locale()->setDateFormatShort("%d.%b"); 677 KGlobal::locale()->setDateFormatShort("%d.%b");
667 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 678 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
668 KGlobal::locale()->setDateFormatShort(dfs); 679 KGlobal::locale()->setDateFormatShort(dfs);
669 } 680 }
670 if ( KOPrefs::instance()->mWNViewShowLocation ) 681 if ( KOPrefs::instance()->mWNViewShowLocation )
671 if ( !ev->location().isEmpty() ) 682 if ( !ev->location().isEmpty() )
672 mText += " ("+ev->location() +")"; 683 mText += " ("+ev->location() +")";
673 if ( !isSub ) { 684 if ( !isSub ) {
674 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 685 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
675 mText += " ["+ev->relatedTo()->summary() +"]"; 686 mText += " ["+ev->relatedTo()->summary() +"]";
676 mText += "</p>\n"; 687 mText += "</p>\n";
677 } 688 }
678 else { 689 else {
679 ind += "-"; 690 ind += "-";
680 mText += "</li>\n"; 691 mText += "</li>\n";
681 } 692 }
682 QPtrList<Incidence> Relations = ev->relations(); 693 QPtrList<Incidence> Relations = ev->relations();
683 Incidence *to; 694 Incidence *to;
684 for (to=Relations.first();to;to=Relations.next()) { 695 for (to=Relations.first();to;to=Relations.next()) {
685 if (!((Todo*)to)->isCompleted()) 696 if (!((Todo*)to)->isCompleted())
686 appendTodo( to, ind , true ); 697 appendTodo( to, ind , true );
687 } 698 }
688 699
689 return true; 700 return true;
690} 701}
691 702
692/* 703/*
693 void KOWhatsNextView::createEventViewer() 704 void KOWhatsNextView::createEventViewer()
694 { 705 {
695 if (!mEventViewer) { 706 if (!mEventViewer) {
696 707
697 mEventViewer = new KOEventViewerDialog(this); 708 mEventViewer = new KOEventViewerDialog(this);
698 } 709 }
699 } 710 }
700*/ 711*/
701void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 712void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
702{ 713{
703 mEventViewer = v; 714 mEventViewer = v;
704} 715}
705 716
706// TODO: Create this function in CalendarView and remove it from here 717// TODO: Create this function in CalendarView and remove it from here
707void KOWhatsNextView::showIncidence(const QString &uid) 718void KOWhatsNextView::showIncidence(const QString &uid)
708{ 719{
709 720
710 if ( !mEventViewer ) { 721 if ( !mEventViewer ) {
711 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 722 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
712 return; 723 return;
713 } 724 }
714 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 725 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
715 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 726 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
716 if (uid.startsWith("event:")) { 727 if (uid.startsWith("event:")) {
717#ifdef DESKTOP_VERSION 728#ifdef DESKTOP_VERSION
718 Event *event = calendar()->event(uid.mid(8)); 729 Event *event = calendar()->event(uid.mid(8));
719#else 730#else
720 Event *event = calendar()->event(uid.mid(6)); 731 Event *event = calendar()->event(uid.mid(6));
721#endif 732#endif
722 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 733 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
723 if (!event) return; 734 if (!event) return;
724 //createEventViewer(); 735 //createEventViewer();
725 mEventViewer->setEvent(event); 736 mEventViewer->setEvent(event);
726 } else if (uid.startsWith("todo:")) { 737 } else if (uid.startsWith("todo:")) {
727#ifdef DESKTOP_VERSION 738#ifdef DESKTOP_VERSION
728 Todo *todo = calendar()->todo(uid.mid(7)); 739 Todo *todo = calendar()->todo(uid.mid(7));
729#else 740#else
730 Todo *todo = calendar()->todo(uid.mid(5)); 741 Todo *todo = calendar()->todo(uid.mid(5));
731#endif 742#endif
732 if (!todo) return; 743 if (!todo) return;
733 //createEventViewer(); 744 //createEventViewer();
734 mEventViewer->setTodo(todo); 745 mEventViewer->setTodo(todo);
735 } else { 746 } else {
736 return; 747 return;
737 748
738 } 749 }
739 mEventViewer->showMe(); 750 mEventViewer->showMe();
740 mEventViewer->raise(); 751 mEventViewer->raise();
741} 752}