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