summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 07:59:05 (UTC)
committer zautrix <zautrix>2004-10-07 07:59:05 (UTC)
commitf1699230250cdfb37216121257196b5be9f094fa (patch) (unidiff)
treee6bf9c6a3814e9a5ee617a726266489aa820bb9c
parent77280f6a176a15b60004f312e6cacdfbbd3909c1 (diff)
downloadkdepimpi-f1699230250cdfb37216121257196b5be9f094fa.zip
kdepimpi-f1699230250cdfb37216121257196b5be9f094fa.tar.gz
kdepimpi-f1699230250cdfb37216121257196b5be9f094fa.tar.bz2
Fixed debug messages
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b3b4cdb..d71ea08 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1299,290 +1299,291 @@ void CalendarView::syncExternal( int mode )
1299 if ( loc ) { 1299 if ( loc ) {
1300 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1300 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1301 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1301 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1302 } 1302 }
1303 } 1303 }
1304 inc = iL.next(); 1304 inc = iL.next();
1305 } 1305 }
1306 Incidence* lse = getLastSyncEvent(); 1306 Incidence* lse = getLastSyncEvent();
1307 if ( lse ) { 1307 if ( lse ) {
1308 lse->setReadOnly( false ); 1308 lse->setReadOnly( false );
1309 lse->setDescription( "" ); 1309 lse->setDescription( "" );
1310 lse->setReadOnly( true ); 1310 lse->setReadOnly( true );
1311 } 1311 }
1312 } 1312 }
1313 } 1313 }
1314 setModified( true ); 1314 setModified( true );
1315 } else { 1315 } else {
1316 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1316 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1317 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1317 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1318 question, i18n("Ok")) ; 1318 question, i18n("Ok")) ;
1319 1319
1320 } 1320 }
1321 delete calendar; 1321 delete calendar;
1322 updateView(); 1322 updateView();
1323 return ;//syncOK; 1323 return ;//syncOK;
1324 1324
1325} 1325}
1326void CalendarView::syncSharp() 1326void CalendarView::syncSharp()
1327{ 1327{
1328 syncExternal( 0 ); 1328 syncExternal( 0 );
1329 1329
1330} 1330}
1331 1331
1332 1332
1333//#include <kabc/stdaddressbook.h> 1333//#include <kabc/stdaddressbook.h>
1334bool CalendarView::importBday() 1334bool CalendarView::importBday()
1335{ 1335{
1336#ifndef KORG_NOKABC 1336#ifndef KORG_NOKABC
1337 1337
1338#ifdef DESKTOP_VERSION 1338#ifdef DESKTOP_VERSION
1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1340 KABC::AddressBook::Iterator it; 1340 KABC::AddressBook::Iterator it;
1341 int count = 0; 1341 int count = 0;
1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1343 ++count; 1343 ++count;
1344 } 1344 }
1345 QProgressBar bar(count,0 ); 1345 QProgressBar bar(count,0 );
1346 int w = 300; 1346 int w = 300;
1347 if ( QApplication::desktop()->width() < 320 ) 1347 if ( QApplication::desktop()->width() < 320 )
1348 w = 220; 1348 w = 220;
1349 int h = bar.sizeHint().height() ; 1349 int h = bar.sizeHint().height() ;
1350 int dw = QApplication::desktop()->width(); 1350 int dw = QApplication::desktop()->width();
1351 int dh = QApplication::desktop()->height(); 1351 int dh = QApplication::desktop()->height();
1352 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1352 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1353 bar.show(); 1353 bar.show();
1354 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1354 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1355 qApp->processEvents(); 1355 qApp->processEvents();
1356 count = 0; 1356 count = 0;
1357 int addCount = 0; 1357 int addCount = 0;
1358 KCal::Attendee* a = 0; 1358 KCal::Attendee* a = 0;
1359 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1359 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1360 if ( ! bar.isVisible() ) 1360 if ( ! bar.isVisible() )
1361 return false; 1361 return false;
1362 bar.setProgress( count++ ); 1362 bar.setProgress( count++ );
1363 qApp->processEvents(); 1363 qApp->processEvents();
1364 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1364 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1365 if ( (*it).birthday().date().isValid() ){ 1365 if ( (*it).birthday().date().isValid() ){
1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1367 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1367 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1368 ++addCount; 1368 ++addCount;
1369 } 1369 }
1370 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1370 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1371 if ( anni.isValid() ){ 1371 if ( anni.isValid() ){
1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1374 ++addCount; 1374 ++addCount;
1375 } 1375 }
1376 } 1376 }
1377 updateView(); 1377 updateView();
1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1379#else //DESKTOP_VERSION 1379#else //DESKTOP_VERSION
1380 1380
1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1382 // the result should now arrive through method insertBirthdays 1382 // the result should now arrive through method insertBirthdays
1383 1383
1384#endif //DESKTOP_VERSION 1384#endif //DESKTOP_VERSION
1385 1385
1386#endif //KORG_NOKABC 1386#endif //KORG_NOKABC
1387 1387
1388 1388
1389 return true; 1389 return true;
1390} 1390}
1391 1391
1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1394 const QStringList& anniversaryList, const QStringList& realNameList, 1394 const QStringList& anniversaryList, const QStringList& realNameList,
1395 const QStringList& emailList, const QStringList& assembledNameList, 1395 const QStringList& emailList, const QStringList& assembledNameList,
1396 const QStringList& uidList) 1396 const QStringList& uidList)
1397{ 1397{
1398 qDebug("CalendarView::insertBirthdays"); 1398 qDebug("CalendarView::insertBirthdays");
1399 if (uid == this->name()) 1399 if (uid == this->name())
1400 { 1400 {
1401 int count = birthdayList.count(); 1401 int count = birthdayList.count();
1402 int addCount = 0; 1402 int addCount = 0;
1403 KCal::Attendee* a = 0; 1403 KCal::Attendee* a = 0;
1404 1404
1405 qDebug("CalView 1 %i", count); 1405 qDebug("CalView 1 %i", count);
1406 1406
1407 QProgressBar bar(count,0 ); 1407 QProgressBar bar(count,0 );
1408 int w = 300; 1408 int w = 300;
1409 if ( QApplication::desktop()->width() < 320 ) 1409 if ( QApplication::desktop()->width() < 320 )
1410 w = 220; 1410 w = 220;
1411 int h = bar.sizeHint().height() ; 1411 int h = bar.sizeHint().height() ;
1412 int dw = QApplication::desktop()->width(); 1412 int dw = QApplication::desktop()->width();
1413 int dh = QApplication::desktop()->height(); 1413 int dh = QApplication::desktop()->height();
1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1415 bar.show(); 1415 bar.show();
1416 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1416 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1417 qApp->processEvents(); 1417 qApp->processEvents();
1418 1418
1419 QDate birthday; 1419 QDate birthday;
1420 QDate anniversary; 1420 QDate anniversary;
1421 QString realName; 1421 QString realName;
1422 QString email; 1422 QString email;
1423 QString assembledName; 1423 QString assembledName;
1424 QString uid; 1424 QString uid;
1425 bool ok = true; 1425 bool ok = true;
1426 for ( int i = 0; i < count; i++) 1426 for ( int i = 0; i < count; i++)
1427 { 1427 {
1428 if ( ! bar.isVisible() ) 1428 if ( ! bar.isVisible() )
1429 return; 1429 return;
1430 bar.setProgress( i ); 1430 bar.setProgress( i );
1431 qApp->processEvents(); 1431 qApp->processEvents();
1432
1433 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() );
1434
1435 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1436 if (!ok)
1437 qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1438
1439 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1440 if (!ok)
1441 qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1442 realName = realNameList[i];
1443 email = emailList[i];
1444 assembledName = assembledNameList[i];
1445 uid = uidList[i];
1446 1432
1447 if ( birthday.isValid() ){ 1433 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1448 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1434 if (!ok) {
1449 KCal::Attendee::ReqParticipant,uid) ; 1435 ; //qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1450 if ( addAnniversary( birthday, assembledName, a, true ) ) 1436 }
1451 ++addCount;
1452 }
1453 1437
1454 if ( anniversary.isValid() ){ 1438 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1455 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1439 if (!ok) {
1456 KCal::Attendee::ReqParticipant,uid) ; 1440 ;// qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1457 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1441 }
1458 ++addCount; 1442 realName = realNameList[i];
1443 email = emailList[i];
1444 assembledName = assembledNameList[i];
1445 uid = uidList[i];
1446 //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() );
1447
1448 if ( birthday.isValid() ){
1449 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1450 KCal::Attendee::ReqParticipant,uid) ;
1451 if ( addAnniversary( birthday, assembledName, a, true ) )
1452 ++addCount;
1453 }
1454
1455 if ( anniversary.isValid() ){
1456 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1457 KCal::Attendee::ReqParticipant,uid) ;
1458 if ( addAnniversary( anniversary, assembledName, a, false ) )
1459 ++addCount;
1460 }
1459 } 1461 }
1460 }
1461 1462
1462 updateView(); 1463 updateView();
1463 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1464 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1464 1465
1465 } 1466 }
1466 1467
1467} 1468}
1468 1469
1469 1470
1470 1471
1471bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1472bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1472{ 1473{
1473 //qDebug("addAnni "); 1474 //qDebug("addAnni ");
1474 Event * ev = new Event(); 1475 Event * ev = new Event();
1475 if ( a ) { 1476 if ( a ) {
1476 ev->addAttendee( a ); 1477 ev->addAttendee( a );
1477 } 1478 }
1478 QString kind; 1479 QString kind;
1479 if ( birthday ) 1480 if ( birthday )
1480 kind = i18n( "Birthday" ); 1481 kind = i18n( "Birthday" );
1481 else 1482 else
1482 kind = i18n( "Anniversary" ); 1483 kind = i18n( "Anniversary" );
1483 ev->setSummary( name + " - " + kind ); 1484 ev->setSummary( name + " - " + kind );
1484 ev->setOrganizer( "nobody@nowhere" ); 1485 ev->setOrganizer( "nobody@nowhere" );
1485 ev->setCategories( kind ); 1486 ev->setCategories( kind );
1486 ev->setDtStart( QDateTime(date) ); 1487 ev->setDtStart( QDateTime(date) );
1487 ev->setDtEnd( QDateTime(date) ); 1488 ev->setDtEnd( QDateTime(date) );
1488 ev->setFloats( true ); 1489 ev->setFloats( true );
1489 Recurrence * rec = ev->recurrence(); 1490 Recurrence * rec = ev->recurrence();
1490 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1491 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1491 rec->addYearlyNum( date.month() ); 1492 rec->addYearlyNum( date.month() );
1492 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1493 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1493 delete ev; 1494 delete ev;
1494 return false; 1495 return false;
1495 } 1496 }
1496 return true; 1497 return true;
1497 1498
1498} 1499}
1499bool CalendarView::importQtopia( const QString &categories, 1500bool CalendarView::importQtopia( const QString &categories,
1500 const QString &datebook, 1501 const QString &datebook,
1501 const QString &todolist ) 1502 const QString &todolist )
1502{ 1503{
1503 1504
1504 QtopiaFormat qtopiaFormat; 1505 QtopiaFormat qtopiaFormat;
1505 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1506 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1506 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1507 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1507 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1508 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1508 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1509 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1509 1510
1510 updateView(); 1511 updateView();
1511 return true; 1512 return true;
1512 1513
1513#if 0 1514#if 0
1514 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1515 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1515 mCurrentSyncDevice = "qtopia-XML"; 1516 mCurrentSyncDevice = "qtopia-XML";
1516 if ( KOPrefs::instance()->mAskForPreferences ) 1517 if ( KOPrefs::instance()->mAskForPreferences )
1517 edit_sync_options(); 1518 edit_sync_options();
1518 qApp->processEvents(); 1519 qApp->processEvents();
1519 CalendarLocal* calendar = new CalendarLocal(); 1520 CalendarLocal* calendar = new CalendarLocal();
1520 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1521 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1521 bool syncOK = false; 1522 bool syncOK = false;
1522 QtopiaFormat qtopiaFormat; 1523 QtopiaFormat qtopiaFormat;
1523 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1524 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1524 bool loadOk = true; 1525 bool loadOk = true;
1525 if ( !categories.isEmpty() ) 1526 if ( !categories.isEmpty() )
1526 loadOk = qtopiaFormat.load( calendar, categories ); 1527 loadOk = qtopiaFormat.load( calendar, categories );
1527 if ( loadOk && !datebook.isEmpty() ) 1528 if ( loadOk && !datebook.isEmpty() )
1528 loadOk = qtopiaFormat.load( calendar, datebook ); 1529 loadOk = qtopiaFormat.load( calendar, datebook );
1529 if ( loadOk && !todolist.isEmpty() ) 1530 if ( loadOk && !todolist.isEmpty() )
1530 loadOk = qtopiaFormat.load( calendar, todolist ); 1531 loadOk = qtopiaFormat.load( calendar, todolist );
1531 1532
1532 if ( loadOk ) { 1533 if ( loadOk ) {
1533 getEventViewerDialog()->setSyncMode( true ); 1534 getEventViewerDialog()->setSyncMode( true );
1534 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1535 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1535 getEventViewerDialog()->setSyncMode( false ); 1536 getEventViewerDialog()->setSyncMode( false );
1536 qApp->processEvents(); 1537 qApp->processEvents();
1537 if ( syncOK ) { 1538 if ( syncOK ) {
1538 if ( KOPrefs::instance()->mWriteBackFile ) 1539 if ( KOPrefs::instance()->mWriteBackFile )
1539 { 1540 {
1540 // write back XML file 1541 // write back XML file
1541 1542
1542 } 1543 }
1543 setModified( true ); 1544 setModified( true );
1544 } 1545 }
1545 } else { 1546 } else {
1546 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1547 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1547 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1548 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1548 question, i18n("Ok")) ; 1549 question, i18n("Ok")) ;
1549 } 1550 }
1550 delete calendar; 1551 delete calendar;
1551 updateView(); 1552 updateView();
1552 return syncOK; 1553 return syncOK;
1553 1554
1554 1555
1555#endif 1556#endif
1556 1557
1557} 1558}
1558 1559
1559void CalendarView::setSyncEventsReadOnly() 1560void CalendarView::setSyncEventsReadOnly()
1560{ 1561{
1561 Event * ev; 1562 Event * ev;
1562 QPtrList<Event> eL = mCalendar->rawEvents(); 1563 QPtrList<Event> eL = mCalendar->rawEvents();
1563 ev = eL.first(); 1564 ev = eL.first();
1564 while ( ev ) { 1565 while ( ev ) {
1565 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1566 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1566 ev->setReadOnly( true ); 1567 ev->setReadOnly( true );
1567 ev = eL.next(); 1568 ev = eL.next();
1568 } 1569 }
1569} 1570}
1570bool CalendarView::openCalendar(QString filename, bool merge) 1571bool CalendarView::openCalendar(QString filename, bool merge)
1571{ 1572{
1572 1573
1573 if (filename.isEmpty()) { 1574 if (filename.isEmpty()) {
1574 return false; 1575 return false;
1575 } 1576 }
1576 1577
1577 if (!QFile::exists(filename)) { 1578 if (!QFile::exists(filename)) {
1578 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1579 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1579 return false; 1580 return false;
1580 } 1581 }
1581 1582
1582 globalFlagBlockAgenda = 1; 1583 globalFlagBlockAgenda = 1;
1583 if (!merge) mCalendar->close(); 1584 if (!merge) mCalendar->close();
1584 1585
1585 mStorage->setFileName( filename ); 1586 mStorage->setFileName( filename );
1586 1587
1587 if ( mStorage->load() ) { 1588 if ( mStorage->load() ) {
1588 if ( merge ) ;//setModified( true ); 1589 if ( merge ) ;//setModified( true );