summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 13cf69b..a62145a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1421,385 +1421,385 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1421 if ( t->hasDueDate() ) 1421 if ( t->hasDueDate() )
1422 dt = t->dtDue(); 1422 dt = t->dtDue();
1423 else 1423 else
1424 dt = cur.addSecs( 62 ); 1424 dt = cur.addSecs( 62 );
1425 } 1425 }
1426 else if (inR->typeID() == eventID ) { 1426 else if (inR->typeID() == eventID ) {
1427 bool ok; 1427 bool ok;
1428 dt = inR->getNextOccurence( cur, &ok ); 1428 dt = inR->getNextOccurence( cur, &ok );
1429 if ( !ok ) 1429 if ( !ok )
1430 dt = cur.addSecs( -62 ); 1430 dt = cur.addSecs( -62 );
1431 } 1431 }
1432 else 1432 else
1433 dt = inR->dtStart(); 1433 dt = inR->dtStart();
1434 if ( dt < cur || dt > end ) { 1434 if ( dt < cur || dt > end ) {
1435 remote->deleteIncidence( inR ); 1435 remote->deleteIncidence( inR );
1436 ++delFut; 1436 ++delFut;
1437 } 1437 }
1438 inR = er.next(); 1438 inR = er.next();
1439 } 1439 }
1440 } 1440 }
1441 bar.hide(); 1441 bar.hide();
1442 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1442 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1443 eventLSync->setReadOnly( false ); 1443 eventLSync->setReadOnly( false );
1444 eventLSync->setDtStart( mLastCalendarSync ); 1444 eventLSync->setDtStart( mLastCalendarSync );
1445 eventRSync->setDtStart( mLastCalendarSync ); 1445 eventRSync->setDtStart( mLastCalendarSync );
1446 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1446 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1447 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1447 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1448 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1448 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1449 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1449 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1450 eventLSync->setReadOnly( true ); 1450 eventLSync->setReadOnly( true );
1451 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1451 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1452 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1452 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1453 remote->addEvent( eventRSync ); 1453 remote->addEvent( eventRSync );
1454 else 1454 else
1455 delete eventRSync; 1455 delete eventRSync;
1456 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1456 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1457 QString mes; 1457 QString mes;
1458 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1458 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1459 QString delmess; 1459 QString delmess;
1460 if ( delFut ) { 1460 if ( delFut ) {
1461 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1461 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1462 mes += delmess; 1462 mes += delmess;
1463 } 1463 }
1464 mes = i18n("Local calendar changed!\n") +mes; 1464 mes = i18n("Local calendar changed!\n") +mes;
1465 mCalendar->checkAlarmForIncidence( 0, true ); 1465 mCalendar->checkAlarmForIncidence( 0, true );
1466 qDebug( mes ); 1466 qDebug( mes );
1467 if ( mSyncManager->mShowSyncSummary ) { 1467 if ( mSyncManager->mShowSyncSummary ) {
1468 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1468 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1469 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1469 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1470 qDebug("KO: WB cancelled "); 1470 qDebug("KO: WB cancelled ");
1471 mSyncManager->mWriteBackFile = false; 1471 mSyncManager->mWriteBackFile = false;
1472 return syncOK; 1472 return syncOK;
1473 } 1473 }
1474 } 1474 }
1475 return syncOK; 1475 return syncOK;
1476} 1476}
1477 1477
1478void CalendarView::setSyncDevice( QString s ) 1478void CalendarView::setSyncDevice( QString s )
1479{ 1479{
1480 mCurrentSyncDevice= s; 1480 mCurrentSyncDevice= s;
1481} 1481}
1482void CalendarView::setSyncName( QString s ) 1482void CalendarView::setSyncName( QString s )
1483{ 1483{
1484 mCurrentSyncName= s; 1484 mCurrentSyncName= s;
1485} 1485}
1486bool CalendarView::syncCalendar(QString filename, int mode) 1486bool CalendarView::syncCalendar(QString filename, int mode)
1487{ 1487{
1488 //qDebug("syncCalendar %s ", filename.latin1()); 1488 //qDebug("syncCalendar %s ", filename.latin1());
1489 mGlobalSyncMode = SYNC_MODE_NORMAL; 1489 mGlobalSyncMode = SYNC_MODE_NORMAL;
1490 CalendarLocal* calendar = new CalendarLocal(); 1490 CalendarLocal* calendar = new CalendarLocal();
1491 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1491 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1492 FileStorage* storage = new FileStorage( calendar ); 1492 FileStorage* storage = new FileStorage( calendar );
1493 bool syncOK = false; 1493 bool syncOK = false;
1494 storage->setFileName( filename ); 1494 storage->setFileName( filename );
1495 // qDebug("loading ... "); 1495 // qDebug("loading ... ");
1496 if ( storage->load() ) { 1496 if ( storage->load() ) {
1497 getEventViewerDialog()->setSyncMode( true ); 1497 getEventViewerDialog()->setSyncMode( true );
1498 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1498 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1499 getEventViewerDialog()->setSyncMode( false ); 1499 getEventViewerDialog()->setSyncMode( false );
1500 if ( syncOK ) { 1500 if ( syncOK ) {
1501 if ( mSyncManager->mWriteBackFile ) 1501 if ( mSyncManager->mWriteBackFile )
1502 { 1502 {
1503 storage->setSaveFormat( new ICalFormat() ); 1503 storage->setSaveFormat( new ICalFormat() );
1504 storage->save(); 1504 storage->save();
1505 } 1505 }
1506 } 1506 }
1507 setModified( true ); 1507 setModified( true );
1508 } 1508 }
1509 delete storage; 1509 delete storage;
1510 delete calendar; 1510 delete calendar;
1511 if ( syncOK ) 1511 if ( syncOK )
1512 updateView(); 1512 updateView();
1513 return syncOK; 1513 return syncOK;
1514} 1514}
1515 1515
1516void CalendarView::syncExternal( int mode ) 1516void CalendarView::syncExternal( int mode )
1517{ 1517{
1518 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1518 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1519 1519
1520 qApp->processEvents(); 1520 qApp->processEvents();
1521 CalendarLocal* calendar = new CalendarLocal(); 1521 CalendarLocal* calendar = new CalendarLocal();
1522 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1522 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1523 bool syncOK = false; 1523 bool syncOK = false;
1524 bool loadSuccess = false; 1524 bool loadSuccess = false;
1525 PhoneFormat* phoneFormat = 0; 1525 PhoneFormat* phoneFormat = 0;
1526 emit tempDisableBR(true); 1526 emit tempDisableBR(true);
1527#ifndef DESKTOP_VERSION 1527#ifndef DESKTOP_VERSION
1528 SharpFormat* sharpFormat = 0; 1528 SharpFormat* sharpFormat = 0;
1529 if ( mode == 0 ) { // sharp 1529 if ( mode == 0 ) { // sharp
1530 sharpFormat = new SharpFormat () ; 1530 sharpFormat = new SharpFormat () ;
1531 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1531 loadSuccess = sharpFormat->load( calendar, mCalendar );
1532 1532
1533 } else 1533 } else
1534#endif 1534#endif
1535 if ( mode == 1 ) { // phone 1535 if ( mode == 1 ) { // phone
1536 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1536 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1537 mSyncManager->mPhoneDevice, 1537 mSyncManager->mPhoneDevice,
1538 mSyncManager->mPhoneConnection, 1538 mSyncManager->mPhoneConnection,
1539 mSyncManager->mPhoneModel); 1539 mSyncManager->mPhoneModel);
1540 loadSuccess = phoneFormat->load( calendar,mCalendar); 1540 loadSuccess = phoneFormat->load( calendar,mCalendar);
1541 1541
1542 } else { 1542 } else {
1543 emit tempDisableBR(false); 1543 emit tempDisableBR(false);
1544 return; 1544 return;
1545 } 1545 }
1546 if ( loadSuccess ) { 1546 if ( loadSuccess ) {
1547 getEventViewerDialog()->setSyncMode( true ); 1547 getEventViewerDialog()->setSyncMode( true );
1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1549 getEventViewerDialog()->setSyncMode( false ); 1549 getEventViewerDialog()->setSyncMode( false );
1550 qApp->processEvents(); 1550 qApp->processEvents();
1551 if ( syncOK ) { 1551 if ( syncOK ) {
1552 if ( mSyncManager->mWriteBackFile ) 1552 if ( mSyncManager->mWriteBackFile )
1553 { 1553 {
1554 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1554 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1555 Incidence* inc = iL.first(); 1555 Incidence* inc = iL.first();
1556 if ( phoneFormat ) { 1556 if ( phoneFormat ) {
1557 while ( inc ) { 1557 while ( inc ) {
1558 inc->removeID(mCurrentSyncDevice); 1558 inc->removeID(mCurrentSyncDevice);
1559 inc = iL.next(); 1559 inc = iL.next();
1560 } 1560 }
1561 } 1561 }
1562#ifndef DESKTOP_VERSION 1562#ifndef DESKTOP_VERSION
1563 if ( sharpFormat ) 1563 if ( sharpFormat )
1564 sharpFormat->save(calendar); 1564 sharpFormat->save(calendar);
1565#endif 1565#endif
1566 if ( phoneFormat ) 1566 if ( phoneFormat )
1567 phoneFormat->save(calendar); 1567 phoneFormat->save(calendar);
1568 iL = calendar->rawIncidences(); 1568 iL = calendar->rawIncidences();
1569 inc = iL.first(); 1569 inc = iL.first();
1570 Incidence* loc; 1570 Incidence* loc;
1571 while ( inc ) { 1571 while ( inc ) {
1572 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1572 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1573 loc = mCalendar->incidence(inc->uid() ); 1573 loc = mCalendar->incidence(inc->uid() );
1574 if ( loc ) { 1574 if ( loc ) {
1575 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1575 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1576 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1576 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1577 } 1577 }
1578 } 1578 }
1579 inc = iL.next(); 1579 inc = iL.next();
1580 } 1580 }
1581 Incidence* lse = getLastSyncEvent(); 1581 Incidence* lse = getLastSyncEvent();
1582 if ( lse ) { 1582 if ( lse ) {
1583 lse->setReadOnly( false ); 1583 lse->setReadOnly( false );
1584 lse->setDescription( "" ); 1584 lse->setDescription( "" );
1585 lse->setReadOnly( true ); 1585 lse->setReadOnly( true );
1586 } 1586 }
1587 } 1587 }
1588 } else { 1588 } else {
1589 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1589 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1590 } 1590 }
1591 setModified( true ); 1591 setModified( true );
1592 } else { 1592 } else {
1593 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1593 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1594 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1594 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1595 question, i18n("Ok")) ; 1595 question, i18n("Ok")) ;
1596 1596
1597 } 1597 }
1598 delete calendar; 1598 delete calendar;
1599 updateView(); 1599 updateView();
1600 emit tempDisableBR(false); 1600 emit tempDisableBR(false);
1601 return ;//syncOK; 1601 return ;//syncOK;
1602 1602
1603} 1603}
1604 1604
1605bool CalendarView::importBday() 1605bool CalendarView::importBday()
1606{ 1606{
1607#ifndef KORG_NOKABC 1607#ifndef KORG_NOKABC
1608 1608
1609#ifdef DESKTOP_VERSION 1609#ifdef DESKTOP_VERSION
1610 int curCal = mCalendar->defaultCalendar(); 1610 int curCal = mCalendar->defaultCalendar();
1611 int bd = mCalEditView->getBirtdayID(); 1611 int bd = mCalEditView->getBirtdayID();
1612 if ( bd == 0 ) 1612 if ( bd == 0 )
1613 return; 1613 return false;
1614 mCalendar->setDefaultCalendar( bd ); 1614 mCalendar->setDefaultCalendar( bd );
1615 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1615 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1616 KABC::AddressBook::Iterator it; 1616 KABC::AddressBook::Iterator it;
1617 int count = 0; 1617 int count = 0;
1618 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1618 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1619 ++count; 1619 ++count;
1620 } 1620 }
1621 QProgressBar bar(count,0 ); 1621 QProgressBar bar(count,0 );
1622 int w = 300; 1622 int w = 300;
1623 if ( QApplication::desktop()->width() < 320 ) 1623 if ( QApplication::desktop()->width() < 320 )
1624 w = 220; 1624 w = 220;
1625 int h = bar.sizeHint().height() ; 1625 int h = bar.sizeHint().height() ;
1626 int dw = QApplication::desktop()->width(); 1626 int dw = QApplication::desktop()->width();
1627 int dh = QApplication::desktop()->height(); 1627 int dh = QApplication::desktop()->height();
1628 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1628 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1629 bar.show(); 1629 bar.show();
1630 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1630 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1631 qApp->processEvents(); 1631 qApp->processEvents();
1632 count = 0; 1632 count = 0;
1633 int addCount = 0; 1633 int addCount = 0;
1634 KCal::Attendee* a = 0; 1634 KCal::Attendee* a = 0;
1635 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1635 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1636 if ( ! bar.isVisible() ) 1636 if ( ! bar.isVisible() )
1637 return false; 1637 return false;
1638 bar.setProgress( count++ ); 1638 bar.setProgress( count++ );
1639 qApp->processEvents(); 1639 qApp->processEvents();
1640 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1640 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1641 if ( (*it).birthday().date().isValid() ){ 1641 if ( (*it).birthday().date().isValid() ){
1642 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1642 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1643 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1643 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1644 ++addCount; 1644 ++addCount;
1645 } 1645 }
1646 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1646 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1647 if ( anni.isValid() ){ 1647 if ( anni.isValid() ){
1648 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1648 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1649 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1649 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1650 ++addCount; 1650 ++addCount;
1651 } 1651 }
1652 } 1652 }
1653 mCalendar->setDefaultCalendar( curCal ); 1653 mCalendar->setDefaultCalendar( curCal );
1654 updateView(); 1654 updateView();
1655 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1655 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1656#else //DESKTOP_VERSION 1656#else //DESKTOP_VERSION
1657 1657
1658 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1658 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1659 // the result should now arrive through method insertBirthdays 1659 // the result should now arrive through method insertBirthdays
1660 1660
1661#endif //DESKTOP_VERSION 1661#endif //DESKTOP_VERSION
1662 1662
1663#endif //KORG_NOKABC 1663#endif //KORG_NOKABC
1664 1664
1665 1665
1666 return true; 1666 return true;
1667} 1667}
1668 1668
1669// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1669// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1670void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1670void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1671 const QStringList& anniversaryList, const QStringList& realNameList, 1671 const QStringList& anniversaryList, const QStringList& realNameList,
1672 const QStringList& emailList, const QStringList& assembledNameList, 1672 const QStringList& emailList, const QStringList& assembledNameList,
1673 const QStringList& uidList) 1673 const QStringList& uidList)
1674{ 1674{
1675 1675
1676 //qDebug("KO::CalendarView::insertBirthdays"); 1676 //qDebug("KO::CalendarView::insertBirthdays");
1677 if (uid == this->name()) 1677 if (uid == this->name())
1678 { 1678 {
1679 int curCal = mCalendar->defaultCalendar(); 1679 int curCal = mCalendar->defaultCalendar();
1680 int bd = mCalEditView->getBirtdayID(); 1680 int bd = mCalEditView->getBirtdayID();
1681 if ( bd == 0 ) 1681 if ( bd == 0 )
1682 return; 1682 return;
1683 mCalendar->setDefaultCalendar( bd ); 1683 mCalendar->setDefaultCalendar( bd );
1684 1684
1685 1685
1686 int count = birthdayList.count(); 1686 int count = birthdayList.count();
1687 int addCount = 0; 1687 int addCount = 0;
1688 KCal::Attendee* a = 0; 1688 KCal::Attendee* a = 0;
1689 1689
1690 //qDebug("CalView 1 %i", count); 1690 //qDebug("CalView 1 %i", count);
1691 1691
1692 QProgressBar bar(count,0 ); 1692 QProgressBar bar(count,0 );
1693 int w = 300; 1693 int w = 300;
1694 if ( QApplication::desktop()->width() < 320 ) 1694 if ( QApplication::desktop()->width() < 320 )
1695 w = 220; 1695 w = 220;
1696 int h = bar.sizeHint().height() ; 1696 int h = bar.sizeHint().height() ;
1697 int dw = QApplication::desktop()->width(); 1697 int dw = QApplication::desktop()->width();
1698 int dh = QApplication::desktop()->height(); 1698 int dh = QApplication::desktop()->height();
1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1700 bar.show(); 1700 bar.show();
1701 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1701 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1702 qApp->processEvents(); 1702 qApp->processEvents();
1703 1703
1704 QDate birthday; 1704 QDate birthday;
1705 QDate anniversary; 1705 QDate anniversary;
1706 QString realName; 1706 QString realName;
1707 QString email; 1707 QString email;
1708 QString assembledName; 1708 QString assembledName;
1709 QString uid; 1709 QString uid;
1710 bool ok = true; 1710 bool ok = true;
1711 for ( int i = 0; i < count; i++) 1711 for ( int i = 0; i < count; i++)
1712 { 1712 {
1713 if ( ! bar.isVisible() ) 1713 if ( ! bar.isVisible() )
1714 return; 1714 return;
1715 bar.setProgress( i ); 1715 bar.setProgress( i );
1716 qApp->processEvents(); 1716 qApp->processEvents();
1717 1717
1718 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1718 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1719 if (!ok) { 1719 if (!ok) {
1720 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1720 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1721 } 1721 }
1722 1722
1723 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1723 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1724 if (!ok) { 1724 if (!ok) {
1725 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1725 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1726 } 1726 }
1727 realName = realNameList[i]; 1727 realName = realNameList[i];
1728 email = emailList[i]; 1728 email = emailList[i];
1729 assembledName = assembledNameList[i]; 1729 assembledName = assembledNameList[i];
1730 uid = uidList[i]; 1730 uid = uidList[i];
1731 //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() ); 1731 //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() );
1732 1732
1733 if ( birthday.isValid() ){ 1733 if ( birthday.isValid() ){
1734 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1734 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1735 KCal::Attendee::ReqParticipant,uid) ; 1735 KCal::Attendee::ReqParticipant,uid) ;
1736 if ( addAnniversary( birthday, assembledName, a, true ) ) 1736 if ( addAnniversary( birthday, assembledName, a, true ) )
1737 ++addCount; 1737 ++addCount;
1738 } 1738 }
1739 1739
1740 if ( anniversary.isValid() ){ 1740 if ( anniversary.isValid() ){
1741 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1741 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1742 KCal::Attendee::ReqParticipant,uid) ; 1742 KCal::Attendee::ReqParticipant,uid) ;
1743 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1743 if ( addAnniversary( anniversary, assembledName, a, false ) )
1744 ++addCount; 1744 ++addCount;
1745 } 1745 }
1746 } 1746 }
1747 1747
1748 mCalendar->setDefaultCalendar( curCal ); 1748 mCalendar->setDefaultCalendar( curCal );
1749 updateView(); 1749 updateView();
1750 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1750 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1751 1751
1752 } 1752 }
1753 1753
1754} 1754}
1755 1755
1756 1756
1757 1757
1758bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1758bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1759{ 1759{
1760 //qDebug("addAnni "); 1760 //qDebug("addAnni ");
1761 Event * ev = new Event(); 1761 Event * ev = new Event();
1762 ev->setOrganizer(KOPrefs::instance()->email()); 1762 ev->setOrganizer(KOPrefs::instance()->email());
1763 if ( a ) { 1763 if ( a ) {
1764 ev->addAttendee( a ); 1764 ev->addAttendee( a );
1765 } 1765 }
1766 QString kind; 1766 QString kind;
1767 if ( birthday ) { 1767 if ( birthday ) {
1768 kind = i18n( "Birthday" ); 1768 kind = i18n( "Birthday" );
1769 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1769 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1770 } 1770 }
1771 else { 1771 else {
1772 kind = i18n( "Anniversary" ); 1772 kind = i18n( "Anniversary" );
1773 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1773 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1774 } 1774 }
1775 ev->setCategories( kind ); 1775 ev->setCategories( kind );
1776 ev->setDtStart( QDateTime(date) ); 1776 ev->setDtStart( QDateTime(date) );
1777 ev->setDtEnd( QDateTime(date) ); 1777 ev->setDtEnd( QDateTime(date) );
1778 ev->setFloats( true ); 1778 ev->setFloats( true );
1779 Recurrence * rec = ev->recurrence(); 1779 Recurrence * rec = ev->recurrence();
1780 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1780 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1781 rec->addYearlyNum( date.month() ); 1781 rec->addYearlyNum( date.month() );
1782 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1782 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1783 delete ev; 1783 delete ev;
1784 return false; 1784 return false;
1785 } 1785 }
1786 return true; 1786 return true;
1787 1787
1788} 1788}
1789bool CalendarView::importQtopia( const QString &categories, 1789bool CalendarView::importQtopia( const QString &categories,
1790 const QString &datebook, 1790 const QString &datebook,
1791 const QString &todolist ) 1791 const QString &todolist )
1792{ 1792{
1793 1793
1794 QtopiaFormat qtopiaFormat; 1794 QtopiaFormat qtopiaFormat;
1795 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1795 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1796 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1796 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1797 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1797 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1798 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1798 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1799 1799
1800 updateView(); 1800 updateView();
1801 return true; 1801 return true;
1802 1802
1803#if 0 1803#if 0
1804 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1804 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1805 mCurrentSyncDevice = "qtopia-XML"; 1805 mCurrentSyncDevice = "qtopia-XML";