summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 14:00:35 (UTC)
committer zautrix <zautrix>2005-06-15 14:00:35 (UTC)
commit40fa3e374fd96c0cb8925a1c3c46d40e1ea2b111 (patch) (unidiff)
treed28170ea94bbf7f1c7e90ef1fe7cf3807a847fed
parent13c00953a9d521873b03f861e54e83e33b30bc96 (diff)
downloadkdepimpi-40fa3e374fd96c0cb8925a1c3c46d40e1ea2b111.zip
kdepimpi-40fa3e374fd96c0cb8925a1c3c46d40e1ea2b111.tar.gz
kdepimpi-40fa3e374fd96c0cb8925a1c3c46d40e1ea2b111.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1338224..377a66f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1474,937 +1474,940 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1610 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1611 KABC::AddressBook::Iterator it; 1611 KABC::AddressBook::Iterator it;
1612 int count = 0; 1612 int count = 0;
1613 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1613 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1614 ++count; 1614 ++count;
1615 } 1615 }
1616 QProgressBar bar(count,0 ); 1616 QProgressBar bar(count,0 );
1617 int w = 300; 1617 int w = 300;
1618 if ( QApplication::desktop()->width() < 320 ) 1618 if ( QApplication::desktop()->width() < 320 )
1619 w = 220; 1619 w = 220;
1620 int h = bar.sizeHint().height() ; 1620 int h = bar.sizeHint().height() ;
1621 int dw = QApplication::desktop()->width(); 1621 int dw = QApplication::desktop()->width();
1622 int dh = QApplication::desktop()->height(); 1622 int dh = QApplication::desktop()->height();
1623 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1623 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1624 bar.show(); 1624 bar.show();
1625 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1625 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1626 qApp->processEvents(); 1626 qApp->processEvents();
1627 count = 0; 1627 count = 0;
1628 int addCount = 0; 1628 int addCount = 0;
1629 KCal::Attendee* a = 0; 1629 KCal::Attendee* a = 0;
1630 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1630 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1631 if ( ! bar.isVisible() ) 1631 if ( ! bar.isVisible() )
1632 return false; 1632 return false;
1633 bar.setProgress( count++ ); 1633 bar.setProgress( count++ );
1634 qApp->processEvents(); 1634 qApp->processEvents();
1635 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1635 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1636 if ( (*it).birthday().date().isValid() ){ 1636 if ( (*it).birthday().date().isValid() ){
1637 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1637 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1638 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1638 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1639 ++addCount; 1639 ++addCount;
1640 } 1640 }
1641 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1641 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1642 if ( anni.isValid() ){ 1642 if ( anni.isValid() ){
1643 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1643 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1644 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1644 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1645 ++addCount; 1645 ++addCount;
1646 } 1646 }
1647 } 1647 }
1648 updateView(); 1648 updateView();
1649 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1649 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1650#else //DESKTOP_VERSION 1650#else //DESKTOP_VERSION
1651 1651
1652 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1652 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1653 // the result should now arrive through method insertBirthdays 1653 // the result should now arrive through method insertBirthdays
1654 1654
1655#endif //DESKTOP_VERSION 1655#endif //DESKTOP_VERSION
1656 1656
1657#endif //KORG_NOKABC 1657#endif //KORG_NOKABC
1658 1658
1659 1659
1660 return true; 1660 return true;
1661} 1661}
1662 1662
1663// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1663// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1664void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1664void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1665 const QStringList& anniversaryList, const QStringList& realNameList, 1665 const QStringList& anniversaryList, const QStringList& realNameList,
1666 const QStringList& emailList, const QStringList& assembledNameList, 1666 const QStringList& emailList, const QStringList& assembledNameList,
1667 const QStringList& uidList) 1667 const QStringList& uidList)
1668{ 1668{
1669 //qDebug("KO::CalendarView::insertBirthdays"); 1669 //qDebug("KO::CalendarView::insertBirthdays");
1670 if (uid == this->name()) 1670 if (uid == this->name())
1671 { 1671 {
1672 int count = birthdayList.count(); 1672 int count = birthdayList.count();
1673 int addCount = 0; 1673 int addCount = 0;
1674 KCal::Attendee* a = 0; 1674 KCal::Attendee* a = 0;
1675 1675
1676 //qDebug("CalView 1 %i", count); 1676 //qDebug("CalView 1 %i", count);
1677 1677
1678 QProgressBar bar(count,0 ); 1678 QProgressBar bar(count,0 );
1679 int w = 300; 1679 int w = 300;
1680 if ( QApplication::desktop()->width() < 320 ) 1680 if ( QApplication::desktop()->width() < 320 )
1681 w = 220; 1681 w = 220;
1682 int h = bar.sizeHint().height() ; 1682 int h = bar.sizeHint().height() ;
1683 int dw = QApplication::desktop()->width(); 1683 int dw = QApplication::desktop()->width();
1684 int dh = QApplication::desktop()->height(); 1684 int dh = QApplication::desktop()->height();
1685 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1685 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1686 bar.show(); 1686 bar.show();
1687 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1687 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1688 qApp->processEvents(); 1688 qApp->processEvents();
1689 1689
1690 QDate birthday; 1690 QDate birthday;
1691 QDate anniversary; 1691 QDate anniversary;
1692 QString realName; 1692 QString realName;
1693 QString email; 1693 QString email;
1694 QString assembledName; 1694 QString assembledName;
1695 QString uid; 1695 QString uid;
1696 bool ok = true; 1696 bool ok = true;
1697 for ( int i = 0; i < count; i++) 1697 for ( int i = 0; i < count; i++)
1698 { 1698 {
1699 if ( ! bar.isVisible() ) 1699 if ( ! bar.isVisible() )
1700 return; 1700 return;
1701 bar.setProgress( i ); 1701 bar.setProgress( i );
1702 qApp->processEvents(); 1702 qApp->processEvents();
1703 1703
1704 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1704 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1705 if (!ok) { 1705 if (!ok) {
1706 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1706 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1707 } 1707 }
1708 1708
1709 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1709 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1710 if (!ok) { 1710 if (!ok) {
1711 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1711 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1712 } 1712 }
1713 realName = realNameList[i]; 1713 realName = realNameList[i];
1714 email = emailList[i]; 1714 email = emailList[i];
1715 assembledName = assembledNameList[i]; 1715 assembledName = assembledNameList[i];
1716 uid = uidList[i]; 1716 uid = uidList[i];
1717 //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() ); 1717 //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() );
1718 1718
1719 if ( birthday.isValid() ){ 1719 if ( birthday.isValid() ){
1720 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1720 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1721 KCal::Attendee::ReqParticipant,uid) ; 1721 KCal::Attendee::ReqParticipant,uid) ;
1722 if ( addAnniversary( birthday, assembledName, a, true ) ) 1722 if ( addAnniversary( birthday, assembledName, a, true ) )
1723 ++addCount; 1723 ++addCount;
1724 } 1724 }
1725 1725
1726 if ( anniversary.isValid() ){ 1726 if ( anniversary.isValid() ){
1727 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1727 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1728 KCal::Attendee::ReqParticipant,uid) ; 1728 KCal::Attendee::ReqParticipant,uid) ;
1729 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1729 if ( addAnniversary( anniversary, assembledName, a, false ) )
1730 ++addCount; 1730 ++addCount;
1731 } 1731 }
1732 } 1732 }
1733 1733
1734 updateView(); 1734 updateView();
1735 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1735 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1736 1736
1737 } 1737 }
1738 1738
1739} 1739}
1740 1740
1741 1741
1742 1742
1743bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1743bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1744{ 1744{
1745 //qDebug("addAnni "); 1745 //qDebug("addAnni ");
1746 Event * ev = new Event(); 1746 Event * ev = new Event();
1747 ev->setOrganizer(KOPrefs::instance()->email()); 1747 ev->setOrganizer(KOPrefs::instance()->email());
1748 if ( a ) { 1748 if ( a ) {
1749 ev->addAttendee( a ); 1749 ev->addAttendee( a );
1750 } 1750 }
1751 QString kind; 1751 QString kind;
1752 if ( birthday ) { 1752 if ( birthday ) {
1753 kind = i18n( "Birthday" ); 1753 kind = i18n( "Birthday" );
1754 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1754 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1755 } 1755 }
1756 else { 1756 else {
1757 kind = i18n( "Anniversary" ); 1757 kind = i18n( "Anniversary" );
1758 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1758 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1759 } 1759 }
1760 ev->setCategories( kind ); 1760 ev->setCategories( kind );
1761 ev->setDtStart( QDateTime(date) ); 1761 ev->setDtStart( QDateTime(date) );
1762 ev->setDtEnd( QDateTime(date) ); 1762 ev->setDtEnd( QDateTime(date) );
1763 ev->setFloats( true ); 1763 ev->setFloats( true );
1764 Recurrence * rec = ev->recurrence(); 1764 Recurrence * rec = ev->recurrence();
1765 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1765 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1766 rec->addYearlyNum( date.month() ); 1766 rec->addYearlyNum( date.month() );
1767 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1767 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1768 delete ev; 1768 delete ev;
1769 return false; 1769 return false;
1770 } 1770 }
1771 return true; 1771 return true;
1772 1772
1773} 1773}
1774bool CalendarView::importQtopia( const QString &categories, 1774bool CalendarView::importQtopia( const QString &categories,
1775 const QString &datebook, 1775 const QString &datebook,
1776 const QString &todolist ) 1776 const QString &todolist )
1777{ 1777{
1778 1778
1779 QtopiaFormat qtopiaFormat; 1779 QtopiaFormat qtopiaFormat;
1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1781 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1781 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1782 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1782 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1783 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1783 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1784 1784
1785 updateView(); 1785 updateView();
1786 return true; 1786 return true;
1787 1787
1788#if 0 1788#if 0
1789 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1789 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1790 mCurrentSyncDevice = "qtopia-XML"; 1790 mCurrentSyncDevice = "qtopia-XML";
1791 if ( mSyncManager->mAskForPreferences ) 1791 if ( mSyncManager->mAskForPreferences )
1792 edit_sync_options(); 1792 edit_sync_options();
1793 qApp->processEvents(); 1793 qApp->processEvents();
1794 CalendarLocal* calendar = new CalendarLocal(); 1794 CalendarLocal* calendar = new CalendarLocal();
1795 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1795 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1796 bool syncOK = false; 1796 bool syncOK = false;
1797 QtopiaFormat qtopiaFormat; 1797 QtopiaFormat qtopiaFormat;
1798 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1798 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1799 bool loadOk = true; 1799 bool loadOk = true;
1800 if ( !categories.isEmpty() ) 1800 if ( !categories.isEmpty() )
1801 loadOk = qtopiaFormat.load( calendar, categories ); 1801 loadOk = qtopiaFormat.load( calendar, categories );
1802 if ( loadOk && !datebook.isEmpty() ) 1802 if ( loadOk && !datebook.isEmpty() )
1803 loadOk = qtopiaFormat.load( calendar, datebook ); 1803 loadOk = qtopiaFormat.load( calendar, datebook );
1804 if ( loadOk && !todolist.isEmpty() ) 1804 if ( loadOk && !todolist.isEmpty() )
1805 loadOk = qtopiaFormat.load( calendar, todolist ); 1805 loadOk = qtopiaFormat.load( calendar, todolist );
1806 1806
1807 if ( loadOk ) { 1807 if ( loadOk ) {
1808 getEventViewerDialog()->setSyncMode( true ); 1808 getEventViewerDialog()->setSyncMode( true );
1809 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1809 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1810 getEventViewerDialog()->setSyncMode( false ); 1810 getEventViewerDialog()->setSyncMode( false );
1811 qApp->processEvents(); 1811 qApp->processEvents();
1812 if ( syncOK ) { 1812 if ( syncOK ) {
1813 if ( mSyncManager->mWriteBackFile ) 1813 if ( mSyncManager->mWriteBackFile )
1814 { 1814 {
1815 // write back XML file 1815 // write back XML file
1816 1816
1817 } 1817 }
1818 setModified( true ); 1818 setModified( true );
1819 } 1819 }
1820 } else { 1820 } else {
1821 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1821 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1822 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1822 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1823 question, i18n("Ok")) ; 1823 question, i18n("Ok")) ;
1824 } 1824 }
1825 delete calendar; 1825 delete calendar;
1826 updateView(); 1826 updateView();
1827 return syncOK; 1827 return syncOK;
1828 1828
1829 1829
1830#endif 1830#endif
1831 1831
1832} 1832}
1833 1833
1834void CalendarView::setSyncEventsReadOnly() 1834void CalendarView::setSyncEventsReadOnly()
1835{ 1835{
1836 Event * ev; 1836 Event * ev;
1837 QPtrList<Event> eL = mCalendar->rawEvents(); 1837 QPtrList<Event> eL = mCalendar->rawEvents();
1838 ev = eL.first(); 1838 ev = eL.first();
1839 while ( ev ) { 1839 while ( ev ) {
1840 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1840 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1841 ev->setReadOnly( true ); 1841 ev->setReadOnly( true );
1842 ev = eL.next(); 1842 ev = eL.next();
1843 } 1843 }
1844} 1844}
1845 1845
1846bool CalendarView::loadCalendars() 1846bool CalendarView::loadCalendars()
1847{ 1847{
1848 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1848 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1849 KopiCalendarFile * cal = calendars.first(); 1849 KopiCalendarFile * cal = calendars.first();
1850 mCalendar->setDefaultCalendar( 1 ); 1850 mCalendar->setDefaultCalendar( 1 );
1851 openCalendar( MainWindow::defaultFileName(), false ); 1851 openCalendar( MainWindow::defaultFileName(), false );
1852 cal = calendars.next(); 1852 cal = calendars.next();
1853 while ( cal ) { 1853 while ( cal ) {
1854 addCalendar( cal ); 1854 addCalendar( cal );
1855 cal = calendars.next(); 1855 cal = calendars.next();
1856 } 1856 }
1857 restoreCalendarSettings(); 1857 restoreCalendarSettings();
1858 mCalendar->reInitAlarmSettings();
1859 setSyncEventsReadOnly();
1860 updateUnmanagedViews();
1861 updateView();
1862 return true; 1858 return true;
1863} 1859}
1864bool CalendarView::restoreCalendarSettings() 1860bool CalendarView::restoreCalendarSettings()
1865{ 1861{
1866 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1862 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1867 KopiCalendarFile * cal = calendars.first(); 1863 KopiCalendarFile * cal = calendars.first();
1868 while ( cal ) { 1864 while ( cal ) {
1869 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1865 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1870 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1866 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1871 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1867 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1872 if ( cal->isStandard ) 1868 if ( cal->isStandard )
1873 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1869 mCalendar->setDefaultCalendar( cal->mCalNumber );
1874 cal = calendars.next(); 1870 cal = calendars.next();
1875 } 1871 }
1872 setSyncEventsReadOnly();
1873 mCalendar->reInitAlarmSettings();
1874 updateUnmanagedViews();
1875 updateView();
1876 return true; 1876 return true;
1877} 1877}
1878void CalendarView::addCalendarId( int id ) 1878void CalendarView::addCalendarId( int id )
1879{ 1879{
1880 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1880 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1881 addCalendar( cal ); 1881 addCalendar( cal );
1882} 1882}
1883bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1883bool CalendarView::addCalendar( KopiCalendarFile * cal )
1884{ 1884{
1885 cal->mErrorOnLoad = false; 1885 cal->mErrorOnLoad = false;
1886 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1886 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1887 cal->mLoadDt = QDateTime::currentDateTime(); 1887 cal->mLoadDt = QDateTime::currentDateTime();
1888 return true; 1888 return true;
1889 } 1889 }
1890 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1890 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1891 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1891 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1892 cal->mErrorOnLoad = true; 1892 cal->mErrorOnLoad = true;
1893 return false; 1893 return false;
1894} 1894}
1895bool CalendarView::openCalendar(QString filename, bool merge) 1895bool CalendarView::openCalendar(QString filename, bool merge)
1896{ 1896{
1897 1897
1898 if (filename.isEmpty()) { 1898 if (filename.isEmpty()) {
1899 return false; 1899 return false;
1900 } 1900 }
1901 1901
1902 if (!QFile::exists(filename)) { 1902 if (!QFile::exists(filename)) {
1903 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1903 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1904 return false; 1904 return false;
1905 } 1905 }
1906 1906
1907 globalFlagBlockAgenda = 1; 1907 globalFlagBlockAgenda = 1;
1908 clearAllViews(); 1908 clearAllViews();
1909 if (!merge) { 1909 if (!merge) {
1910 mViewManager->setDocumentId( filename ); 1910 mViewManager->setDocumentId( filename );
1911 mCalendar->close(); 1911 mCalendar->close();
1912 } 1912 }
1913 mStorage->setFileName( filename ); 1913 mStorage->setFileName( filename );
1914 1914
1915 if ( mStorage->load() ) { 1915 if ( mStorage->load() ) {
1916 if ( merge ) ;//setModified( true ); 1916 if ( merge ) ;//setModified( true );
1917 else { 1917 else {
1918 //setModified( true ); 1918 //setModified( true );
1919 mViewManager->setDocumentId( filename ); 1919 mViewManager->setDocumentId( filename );
1920 mDialogManager->setDocumentId( filename ); 1920 mDialogManager->setDocumentId( filename );
1921 mTodoList->setDocumentId( filename ); 1921 mTodoList->setDocumentId( filename );
1922 } 1922 }
1923 globalFlagBlockAgenda = 2; 1923 globalFlagBlockAgenda = 2;
1924 // if ( getLastSyncEvent() ) 1924 // if ( getLastSyncEvent() )
1925 // getLastSyncEvent()->setReadOnly( true ); 1925 // getLastSyncEvent()->setReadOnly( true );
1926 mCalendar->reInitAlarmSettings(); 1926 mCalendar->reInitAlarmSettings();
1927 setSyncEventsReadOnly(); 1927 setSyncEventsReadOnly();
1928 updateUnmanagedViews(); 1928 updateUnmanagedViews();
1929 updateView(); 1929 updateView();
1930 if ( filename != MainWindow::defaultFileName() ) { 1930 if ( filename != MainWindow::defaultFileName() ) {
1931 saveCalendar( MainWindow::defaultFileName() ); 1931 saveCalendar( MainWindow::defaultFileName() );
1932 } else { 1932 } else {
1933 QFileInfo finf ( MainWindow::defaultFileName()); 1933 QFileInfo finf ( MainWindow::defaultFileName());
1934 if ( finf.exists() ) { 1934 if ( finf.exists() ) {
1935 setLoadedFileVersion( finf.lastModified () ); 1935 setLoadedFileVersion( finf.lastModified () );
1936 } 1936 }
1937 } 1937 }
1938 return true; 1938 return true;
1939 } else { 1939 } else {
1940 // while failing to load, the calendar object could 1940 // while failing to load, the calendar object could
1941 // have become partially populated. Clear it out. 1941 // have become partially populated. Clear it out.
1942 if ( !merge ) { 1942 if ( !merge ) {
1943 mCalendar->close(); 1943 mCalendar->close();
1944 mViewManager->setDocumentId( filename ); 1944 mViewManager->setDocumentId( filename );
1945 mDialogManager->setDocumentId( filename ); 1945 mDialogManager->setDocumentId( filename );
1946 mTodoList->setDocumentId( filename ); 1946 mTodoList->setDocumentId( filename );
1947 } 1947 }
1948 1948
1949 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1949 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1950 1950
1951 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1951 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1952 globalFlagBlockAgenda = 2; 1952 globalFlagBlockAgenda = 2;
1953 mCalendar->reInitAlarmSettings(); 1953 mCalendar->reInitAlarmSettings();
1954 setSyncEventsReadOnly(); 1954 setSyncEventsReadOnly();
1955 updateUnmanagedViews(); 1955 updateUnmanagedViews();
1956 updateView(); 1956 updateView();
1957 } 1957 }
1958 return false; 1958 return false;
1959} 1959}
1960void CalendarView::showOpenError() 1960void CalendarView::showOpenError()
1961{ 1961{
1962 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1962 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1963} 1963}
1964void CalendarView::setLoadedFileVersion(QDateTime dt) 1964void CalendarView::setLoadedFileVersion(QDateTime dt)
1965{ 1965{
1966 loadedFileVersion = dt; 1966 loadedFileVersion = dt;
1967} 1967}
1968bool CalendarView::checkFileChanged(QString fn) 1968bool CalendarView::checkFileChanged(QString fn)
1969{ 1969{
1970 QFileInfo finf ( fn ); 1970 QFileInfo finf ( fn );
1971 if ( !finf.exists() ) 1971 if ( !finf.exists() )
1972 return true; 1972 return true;
1973 QDateTime dt = finf.lastModified (); 1973 QDateTime dt = finf.lastModified ();
1974 if ( dt <= loadedFileVersion ) 1974 if ( dt <= loadedFileVersion )
1975 return false; 1975 return false;
1976 return true; 1976 return true;
1977 1977
1978} 1978}
1979void CalendarView::watchSavedFile() 1979void CalendarView::watchSavedFile()
1980{ 1980{
1981 QFileInfo finf ( MainWindow::defaultFileName()); 1981 QFileInfo finf ( MainWindow::defaultFileName());
1982 if ( !finf.exists() ) 1982 if ( !finf.exists() )
1983 return; 1983 return;
1984 QDateTime dt = finf.lastModified (); 1984 QDateTime dt = finf.lastModified ();
1985 if ( dt < loadedFileVersion ) { 1985 if ( dt < loadedFileVersion ) {
1986 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1986 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1987 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1987 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1988 return; 1988 return;
1989 } 1989 }
1990 loadedFileVersion = dt; 1990 loadedFileVersion = dt;
1991} 1991}
1992bool CalendarView::checkAllFileVersions() 1992bool CalendarView::checkAllFileVersions()
1993{ 1993{
1994 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1994 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1995 KopiCalendarFile * cal = calendars.first(); 1995 KopiCalendarFile * cal = calendars.first();
1996 mCalendar->setDefaultCalendar( 1 ); 1996 mCalendar->setDefaultCalendar( 1 );
1997 mCalendar->setDefaultCalendarEnabledOnly(); 1997 mCalendar->setDefaultCalendarEnabledOnly();
1998 if ( !checkFileVersion(MainWindow::defaultFileName())) 1998 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
1999 return false; 1999 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2000 restoreCalendarSettings();
2001 return false;
2002 }
2003 }
2000 cal = calendars.next(); 2004 cal = calendars.next();
2001 QDateTime storeTemp = loadedFileVersion; 2005 QDateTime storeTemp = loadedFileVersion;
2002 while ( cal ) { 2006 while ( cal ) {
2003 if ( !cal->mErrorOnLoad ) { 2007 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2004 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2008 mCalendar->setDefaultCalendar( cal->mCalNumber );
2005 mCalendar->setDefaultCalendarEnabledOnly(); 2009 mCalendar->setDefaultCalendarEnabledOnly();
2006 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2010 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2007 if ( !checkFileVersion(cal->mFileName )) { 2011 if ( !checkFileVersion(cal->mFileName )) {
2008 loadedFileVersion = storeTemp; 2012 loadedFileVersion = storeTemp;
2009 updateView(); 2013 restoreCalendarSettings();
2010 return false; 2014 return false;
2011 } 2015 }
2012 } 2016 }
2013 cal = calendars.next(); 2017 cal = calendars.next();
2014 } 2018 }
2015 loadedFileVersion = storeTemp; 2019 loadedFileVersion = storeTemp;
2016 updateView();
2017 return true; 2020 return true;
2018} 2021}
2019bool CalendarView::checkFileVersion(QString fn) 2022bool CalendarView::checkFileVersion(QString fn)
2020{ 2023{
2021 QFileInfo finf ( fn ); 2024 QFileInfo finf ( fn );
2022 if ( !finf.exists() ) 2025 if ( !finf.exists() )
2023 return true; 2026 return true;
2024 QDateTime dt = finf.lastModified (); 2027 QDateTime dt = finf.lastModified ();
2025 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 2028 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2026 //qDebug("file on disk version %s",dt.toString().latin1()); 2029 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2027 if ( dt <= loadedFileVersion ) 2030 if ( dt <= loadedFileVersion )
2028 return true; 2031 return true;
2029 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2032 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2030 i18n("KO/Pi Warning"),i18n("Overwrite"), 2033 i18n("KO/Pi Warning"),i18n("Overwrite"),
2031 i18n("Sync+save")); 2034 i18n("Sync+save"));
2032 2035
2033 if ( km == KMessageBox::Cancel ) 2036 if ( km == KMessageBox::Cancel )
2034 return false; 2037 return false;
2035 if ( km == KMessageBox::Yes ) 2038 if ( km == KMessageBox::Yes )
2036 return true; 2039 return true;
2037 2040
2038 setSyncDevice("deleteaftersync" ); 2041 setSyncDevice("deleteaftersync" );
2039 mSyncManager->mAskForPreferences = true; 2042 mSyncManager->mAskForPreferences = true;
2040 mSyncManager->mSyncAlgoPrefs = 3; 2043 mSyncManager->mSyncAlgoPrefs = 3;
2041 mSyncManager->mWriteBackFile = false; 2044 mSyncManager->mWriteBackFile = false;
2042 mSyncManager->mWriteBackExistingOnly = false; 2045 mSyncManager->mWriteBackExistingOnly = false;
2043 mSyncManager->mShowSyncSummary = false; 2046 mSyncManager->mShowSyncSummary = false;
2044 syncCalendar( fn, 3 ); 2047 syncCalendar( fn, 3 );
2045 Event * e = getLastSyncEvent(); 2048 Event * e = getLastSyncEvent();
2046 if ( e ) 2049 if ( e )
2047 mCalendar->deleteEvent( e ); 2050 mCalendar->deleteEvent( e );
2048 return true; 2051 return true;
2049} 2052}
2050bool CalendarView::saveCalendars() 2053bool CalendarView::saveCalendars()
2051{ 2054{
2052 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2055 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2053 KopiCalendarFile * cal = calendars.first(); 2056 KopiCalendarFile * cal = calendars.first();
2054 mCalendar->setDefaultCalendar( 1 ); 2057 mCalendar->setDefaultCalendar( 1 );
2055 mCalendar->setDefaultCalendarEnabledOnly(); 2058 mCalendar->setDefaultCalendarEnabledOnly();
2056 saveCalendar( MainWindow::defaultFileName() ); 2059 saveCalendar( MainWindow::defaultFileName() );
2057 cal = calendars.next(); 2060 cal = calendars.next();
2058 while ( cal ) { 2061 while ( cal ) {
2059 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2062 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2060 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2063 mCalendar->setDefaultCalendar( cal->mCalNumber );
2061 mCalendar->setDefaultCalendarEnabledOnly(); 2064 mCalendar->setDefaultCalendarEnabledOnly();
2062 if ( saveCalendar( cal->mFileName ) ) 2065 if ( saveCalendar( cal->mFileName ) )
2063 cal->mLoadDt = QDateTime::currentDateTime(); 2066 cal->mLoadDt = QDateTime::currentDateTime();
2064 } 2067 }
2065 cal = calendars.next(); 2068 cal = calendars.next();
2066 } 2069 }
2067 restoreCalendarSettings(); 2070 restoreCalendarSettings();
2068 return true; 2071 return true;
2069} 2072}
2070bool CalendarView::saveCalendar( QString filename ) 2073bool CalendarView::saveCalendar( QString filename )
2071{ 2074{
2072 2075
2073 // Store back all unsaved data into calendar object 2076 // Store back all unsaved data into calendar object
2074 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2077 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2075 if ( mViewManager->currentView() ) 2078 if ( mViewManager->currentView() )
2076 mViewManager->currentView()->flushView(); 2079 mViewManager->currentView()->flushView();
2077 2080
2078 2081
2079 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2082 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2080 mStorage->setSaveFormat( new ICalFormat() ); 2083 mStorage->setSaveFormat( new ICalFormat() );
2081 mStorage->setFileName( filename ); 2084 mStorage->setFileName( filename );
2082 bool success; 2085 bool success;
2083 success = mStorage->save(); 2086 success = mStorage->save();
2084 if ( !success ) { 2087 if ( !success ) {
2085 return false; 2088 return false;
2086 } 2089 }
2087 if ( filename == MainWindow::defaultFileName() ) { 2090 if ( filename == MainWindow::defaultFileName() ) {
2088 setLoadedFileVersion( lfv ); 2091 setLoadedFileVersion( lfv );
2089 watchSavedFile(); 2092 watchSavedFile();
2090 } 2093 }
2091 return true; 2094 return true;
2092} 2095}
2093 2096
2094void CalendarView::closeCalendar() 2097void CalendarView::closeCalendar()
2095{ 2098{
2096 2099
2097 // child windows no longer valid 2100 // child windows no longer valid
2098 clearAllViews(); 2101 clearAllViews();
2099 emit closingDown(); 2102 emit closingDown();
2100 2103
2101 mCalendar->close(); 2104 mCalendar->close();
2102 setModified(false); 2105 setModified(false);
2103 updateView(); 2106 updateView();
2104} 2107}
2105 2108
2106void CalendarView::archiveCalendar() 2109void CalendarView::archiveCalendar()
2107{ 2110{
2108 mDialogManager->showArchiveDialog(); 2111 mDialogManager->showArchiveDialog();
2109} 2112}
2110 2113
2111 2114
2112void CalendarView::readSettings() 2115void CalendarView::readSettings()
2113{ 2116{
2114 2117
2115 2118
2116 // mViewManager->showAgendaView(); 2119 // mViewManager->showAgendaView();
2117 QString str; 2120 QString str;
2118 //qDebug("CalendarView::readSettings() "); 2121 //qDebug("CalendarView::readSettings() ");
2119 // read settings from the KConfig, supplying reasonable 2122 // read settings from the KConfig, supplying reasonable
2120 // defaults where none are to be found 2123 // defaults where none are to be found
2121 KConfig *config = KOGlobals::config(); 2124 KConfig *config = KOGlobals::config();
2122#ifndef KORG_NOSPLITTER 2125#ifndef KORG_NOSPLITTER
2123 config->setGroup("KOrganizer Geometry"); 2126 config->setGroup("KOrganizer Geometry");
2124 2127
2125 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2128 QValueList<int> sizes = config->readIntListEntry("Separator1");
2126 if (sizes.count() != 2) { 2129 if (sizes.count() != 2) {
2127 sizes << mDateNavigator->minimumSizeHint().width(); 2130 sizes << mDateNavigator->minimumSizeHint().width();
2128 sizes << 300; 2131 sizes << 300;
2129 } 2132 }
2130 mPanner->setSizes(sizes); 2133 mPanner->setSizes(sizes);
2131 2134
2132 sizes = config->readIntListEntry("Separator2"); 2135 sizes = config->readIntListEntry("Separator2");
2133 if ( ( mResourceView && sizes.count() == 4 ) || 2136 if ( ( mResourceView && sizes.count() == 4 ) ||
2134 ( !mResourceView && sizes.count() == 3 ) ) { 2137 ( !mResourceView && sizes.count() == 3 ) ) {
2135 mLeftSplitter->setSizes(sizes); 2138 mLeftSplitter->setSizes(sizes);
2136 } 2139 }
2137#endif 2140#endif
2138 globalFlagBlockAgenda = 1; 2141 globalFlagBlockAgenda = 1;
2139 mViewManager->showAgendaView(); 2142 mViewManager->showAgendaView();
2140 //mViewManager->readSettings( config ); 2143 //mViewManager->readSettings( config );
2141 mTodoList->restoreLayout(config,QString("Todo Layout")); 2144 mTodoList->restoreLayout(config,QString("Todo Layout"));
2142 readFilterSettings(config); 2145 readFilterSettings(config);
2143 2146
2144#ifdef DESKTOP_VERSION 2147#ifdef DESKTOP_VERSION
2145 config->setGroup("WidgetLayout"); 2148 config->setGroup("WidgetLayout");
2146 QStringList list; 2149 QStringList list;
2147 list = config->readListEntry("MainLayout"); 2150 list = config->readListEntry("MainLayout");
2148 int x,y,w,h; 2151 int x,y,w,h;
2149 if ( ! list.isEmpty() ) { 2152 if ( ! list.isEmpty() ) {
2150 x = list[0].toInt(); 2153 x = list[0].toInt();
2151 y = list[1].toInt(); 2154 y = list[1].toInt();
2152 w = list[2].toInt(); 2155 w = list[2].toInt();
2153 h = list[3].toInt(); 2156 h = list[3].toInt();
2154 KApplication::testCoords( &x,&y,&w,&h ); 2157 KApplication::testCoords( &x,&y,&w,&h );
2155 topLevelWidget()->setGeometry(x,y,w,h); 2158 topLevelWidget()->setGeometry(x,y,w,h);
2156 2159
2157 } else { 2160 } else {
2158 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2161 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2159 } 2162 }
2160 list = config->readListEntry("EditEventLayout"); 2163 list = config->readListEntry("EditEventLayout");
2161 if ( ! list.isEmpty() ) { 2164 if ( ! list.isEmpty() ) {
2162 x = list[0].toInt(); 2165 x = list[0].toInt();
2163 y = list[1].toInt(); 2166 y = list[1].toInt();
2164 w = list[2].toInt(); 2167 w = list[2].toInt();
2165 h = list[3].toInt(); 2168 h = list[3].toInt();
2166 KApplication::testCoords( &x,&y,&w,&h ); 2169 KApplication::testCoords( &x,&y,&w,&h );
2167 mEventEditor->setGeometry(x,y,w,h); 2170 mEventEditor->setGeometry(x,y,w,h);
2168 2171
2169 } 2172 }
2170 list = config->readListEntry("EditTodoLayout"); 2173 list = config->readListEntry("EditTodoLayout");
2171 if ( ! list.isEmpty() ) { 2174 if ( ! list.isEmpty() ) {
2172 x = list[0].toInt(); 2175 x = list[0].toInt();
2173 y = list[1].toInt(); 2176 y = list[1].toInt();
2174 w = list[2].toInt(); 2177 w = list[2].toInt();
2175 h = list[3].toInt(); 2178 h = list[3].toInt();
2176 KApplication::testCoords( &x,&y,&w,&h ); 2179 KApplication::testCoords( &x,&y,&w,&h );
2177 mTodoEditor->setGeometry(x,y,w,h); 2180 mTodoEditor->setGeometry(x,y,w,h);
2178 2181
2179 } 2182 }
2180 list = config->readListEntry("ViewerLayout"); 2183 list = config->readListEntry("ViewerLayout");
2181 if ( ! list.isEmpty() ) { 2184 if ( ! list.isEmpty() ) {
2182 x = list[0].toInt(); 2185 x = list[0].toInt();
2183 y = list[1].toInt(); 2186 y = list[1].toInt();
2184 w = list[2].toInt(); 2187 w = list[2].toInt();
2185 h = list[3].toInt(); 2188 h = list[3].toInt();
2186 KApplication::testCoords( &x,&y,&w,&h ); 2189 KApplication::testCoords( &x,&y,&w,&h );
2187 getEventViewerDialog()->setGeometry(x,y,w,h); 2190 getEventViewerDialog()->setGeometry(x,y,w,h);
2188 } 2191 }
2189#endif 2192#endif
2190 config->setGroup( "Views" ); 2193 config->setGroup( "Views" );
2191 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2194 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2192 2195
2193 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2196 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2194 2197
2195 int resetval = 0; 2198 int resetval = 0;
2196 int maxVal = 0; 2199 int maxVal = 0;
2197 if (sizes.count() != 3) { 2200 if (sizes.count() != 3) {
2198 if ( KOPrefs::instance()->mVerticalScreen ) { 2201 if ( KOPrefs::instance()->mVerticalScreen ) {
2199 resetval = mDateNavigator->sizeHint().width()+2; 2202 resetval = mDateNavigator->sizeHint().width()+2;
2200 } else { 2203 } else {
2201 resetval = mDateNavigator->sizeHint().height()+2; 2204 resetval = mDateNavigator->sizeHint().height()+2;
2202 } 2205 }
2203 } 2206 }
2204 if ( resetval ) { 2207 if ( resetval ) {
2205 sizes.clear(); 2208 sizes.clear();
2206 if ( KOPrefs::instance()->mVerticalScreen ) { 2209 if ( KOPrefs::instance()->mVerticalScreen ) {
2207 maxVal = QApplication::desktop()->width() -10; 2210 maxVal = QApplication::desktop()->width() -10;
2208 } else { 2211 } else {
2209 maxVal = QApplication::desktop()->height()-10; 2212 maxVal = QApplication::desktop()->height()-10;
2210 } 2213 }
2211 sizes << resetval; 2214 sizes << resetval;
2212 if ( maxVal < resetval + resetval) 2215 if ( maxVal < resetval + resetval)
2213 resetval = maxVal - resetval; 2216 resetval = maxVal - resetval;
2214 sizes << resetval; 2217 sizes << resetval;
2215 sizes << 100; 2218 sizes << 100;
2216 } 2219 }
2217 mLeftFrame->setSizes(sizes); 2220 mLeftFrame->setSizes(sizes);
2218 sizes = config->readIntListEntry("Main Splitter Frame"); 2221 sizes = config->readIntListEntry("Main Splitter Frame");
2219 resetval = 0; 2222 resetval = 0;
2220 maxVal = 0; 2223 maxVal = 0;
2221 if (sizes.count() != 2) { 2224 if (sizes.count() != 2) {
2222 if ( !KOPrefs::instance()->mVerticalScreen ) { 2225 if ( !KOPrefs::instance()->mVerticalScreen ) {
2223 resetval = mDateNavigator->sizeHint().width()+2; 2226 resetval = mDateNavigator->sizeHint().width()+2;
2224 } else { 2227 } else {
2225 resetval = mDateNavigator->sizeHint().height()+2; 2228 resetval = mDateNavigator->sizeHint().height()+2;
2226 } 2229 }
2227 } 2230 }
2228 if ( resetval ) { 2231 if ( resetval ) {
2229 sizes.clear(); 2232 sizes.clear();
2230 if ( !KOPrefs::instance()->mVerticalScreen ) { 2233 if ( !KOPrefs::instance()->mVerticalScreen ) {
2231 maxVal = QApplication::desktop()->width() -10; 2234 maxVal = QApplication::desktop()->width() -10;
2232 } else { 2235 } else {
2233 maxVal = QApplication::desktop()->height()-10; 2236 maxVal = QApplication::desktop()->height()-10;
2234 } 2237 }
2235 sizes << resetval; 2238 sizes << resetval;
2236 if ( maxVal < resetval + resetval) 2239 if ( maxVal < resetval + resetval)
2237 resetval = maxVal - resetval; 2240 resetval = maxVal - resetval;
2238 sizes << resetval; 2241 sizes << resetval;
2239 } 2242 }
2240 mMainFrame->setSizes(sizes); 2243 mMainFrame->setSizes(sizes);
2241 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2244 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2242 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2245 else if ( dateCount == 7 ) mNavigator->selectWeek();
2243 else mNavigator->selectDates( dateCount ); 2246 else mNavigator->selectDates( dateCount );
2244 // mViewManager->readSettings( config ); 2247 // mViewManager->readSettings( config );
2245 updateConfig(); 2248 updateConfig();
2246 globalFlagBlockAgenda = 2; 2249 globalFlagBlockAgenda = 2;
2247 mViewManager->readSettings( config ); 2250 mViewManager->readSettings( config );
2248 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2251 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2249} 2252}
2250 2253
2251 2254
2252void CalendarView::writeSettings() 2255void CalendarView::writeSettings()
2253{ 2256{
2254 // kdDebug() << "CalendarView::writeSettings" << endl; 2257 // kdDebug() << "CalendarView::writeSettings" << endl;
2255 2258
2256 KConfig *config = KOGlobals::config(); 2259 KConfig *config = KOGlobals::config();
2257 2260
2258 mViewManager->writeSettings( config ); 2261 mViewManager->writeSettings( config );
2259 mTodoList->saveLayout(config,QString("Todo Layout")); 2262 mTodoList->saveLayout(config,QString("Todo Layout"));
2260 mDialogManager->writeSettings( config ); 2263 mDialogManager->writeSettings( config );
2261 //KOPrefs::instance()->usrWriteConfig(); 2264 //KOPrefs::instance()->usrWriteConfig();
2262 KOPrefs::instance()->writeConfig(); 2265 KOPrefs::instance()->writeConfig();
2263 2266
2264 writeFilterSettings(config); 2267 writeFilterSettings(config);
2265 config->setGroup( "AppRun" ); 2268 config->setGroup( "AppRun" );
2266 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2269 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2267 int days = dt.daysTo( QDate::currentDate() ); 2270 int days = dt.daysTo( QDate::currentDate() );
2268 dt = dt.addDays( days ); 2271 dt = dt.addDays( days );
2269 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2272 int secs = dt.secsTo( QDateTime::currentDateTime() );
2270 config->writeEntry( "LatestProgramStopDays", days ); 2273 config->writeEntry( "LatestProgramStopDays", days );
2271 config->writeEntry( "LatestProgramStopSecs", secs ); 2274 config->writeEntry( "LatestProgramStopSecs", secs );
2272 //qDebug("KO: Writing stop time: %d ", secs); 2275 //qDebug("KO: Writing stop time: %d ", secs);
2273 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2276 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2274 //QDateTime latest = dt.addSecs ( secs ); 2277 //QDateTime latest = dt.addSecs ( secs );
2275 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2278 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2276 config->setGroup( "Views" ); 2279 config->setGroup( "Views" );
2277 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2280 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2278 2281
2279#if 0 2282#if 0
2280 qDebug("********************* "); 2283 qDebug("********************* ");
2281 qDebug("Testcode secsto "); 2284 qDebug("Testcode secsto ");
2282 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2285 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2283 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2286 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2284 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2287 int secsto = dt_nodaylight.secsTo( dt_daylight );
2285 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2288 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2286 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2289 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2287 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2290 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2288 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2291 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2289 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2292 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2290 qDebug("********************* testcode end"); 2293 qDebug("********************* testcode end");
2291 2294
2292#endif 2295#endif
2293 2296
2294 QValueList<int> listINT = mLeftFrame->sizes(); 2297 QValueList<int> listINT = mLeftFrame->sizes();
2295 config->writeEntry("Left Splitter Frame",listINT); 2298 config->writeEntry("Left Splitter Frame",listINT);
2296 QValueList<int> listINT2 = mMainFrame->sizes(); 2299 QValueList<int> listINT2 = mMainFrame->sizes();
2297 config->writeEntry("Main Splitter Frame",listINT2); 2300 config->writeEntry("Main Splitter Frame",listINT2);
2298#ifdef DESKTOP_VERSION 2301#ifdef DESKTOP_VERSION
2299 config->setGroup("WidgetLayout"); 2302 config->setGroup("WidgetLayout");
2300 QStringList list ;//= config->readListEntry("MainLayout"); 2303 QStringList list ;//= config->readListEntry("MainLayout");
2301 int x,y,w,h; 2304 int x,y,w,h;
2302 QWidget* wid; 2305 QWidget* wid;
2303 wid = topLevelWidget(); 2306 wid = topLevelWidget();
2304 x = wid->geometry().x(); 2307 x = wid->geometry().x();
2305 y = wid->geometry().y(); 2308 y = wid->geometry().y();
2306 w = wid->width(); 2309 w = wid->width();
2307 h = wid->height(); 2310 h = wid->height();
2308 list.clear(); 2311 list.clear();
2309 list << QString::number( x ); 2312 list << QString::number( x );
2310 list << QString::number( y ); 2313 list << QString::number( y );
2311 list << QString::number( w ); 2314 list << QString::number( w );
2312 list << QString::number( h ); 2315 list << QString::number( h );
2313 config->writeEntry("MainLayout",list ); 2316 config->writeEntry("MainLayout",list );
2314 2317
2315 wid = mEventEditor; 2318 wid = mEventEditor;
2316 x = wid->geometry().x(); 2319 x = wid->geometry().x();
2317 y = wid->geometry().y(); 2320 y = wid->geometry().y();
2318 w = wid->width(); 2321 w = wid->width();
2319 h = wid->height(); 2322 h = wid->height();
2320 list.clear(); 2323 list.clear();
2321 list << QString::number( x ); 2324 list << QString::number( x );
2322 list << QString::number( y ); 2325 list << QString::number( y );
2323 list << QString::number( w ); 2326 list << QString::number( w );
2324 list << QString::number( h ); 2327 list << QString::number( h );
2325 config->writeEntry("EditEventLayout",list ); 2328 config->writeEntry("EditEventLayout",list );
2326 2329
2327 wid = mTodoEditor; 2330 wid = mTodoEditor;
2328 x = wid->geometry().x(); 2331 x = wid->geometry().x();
2329 y = wid->geometry().y(); 2332 y = wid->geometry().y();
2330 w = wid->width(); 2333 w = wid->width();
2331 h = wid->height(); 2334 h = wid->height();
2332 list.clear(); 2335 list.clear();
2333 list << QString::number( x ); 2336 list << QString::number( x );
2334 list << QString::number( y ); 2337 list << QString::number( y );
2335 list << QString::number( w ); 2338 list << QString::number( w );
2336 list << QString::number( h ); 2339 list << QString::number( h );
2337 config->writeEntry("EditTodoLayout",list ); 2340 config->writeEntry("EditTodoLayout",list );
2338 wid = getEventViewerDialog(); 2341 wid = getEventViewerDialog();
2339 x = wid->geometry().x(); 2342 x = wid->geometry().x();
2340 y = wid->geometry().y(); 2343 y = wid->geometry().y();
2341 w = wid->width(); 2344 w = wid->width();
2342 h = wid->height(); 2345 h = wid->height();
2343 list.clear(); 2346 list.clear();
2344 list << QString::number( x ); 2347 list << QString::number( x );
2345 list << QString::number( y ); 2348 list << QString::number( y );
2346 list << QString::number( w ); 2349 list << QString::number( w );
2347 list << QString::number( h ); 2350 list << QString::number( h );
2348 config->writeEntry("ViewerLayout",list ); 2351 config->writeEntry("ViewerLayout",list );
2349 wid = mDialogManager->getSearchDialog(); 2352 wid = mDialogManager->getSearchDialog();
2350 if ( wid ) { 2353 if ( wid ) {
2351 x = wid->geometry().x(); 2354 x = wid->geometry().x();
2352 y = wid->geometry().y(); 2355 y = wid->geometry().y();
2353 w = wid->width(); 2356 w = wid->width();
2354 h = wid->height(); 2357 h = wid->height();
2355 list.clear(); 2358 list.clear();
2356 list << QString::number( x ); 2359 list << QString::number( x );
2357 list << QString::number( y ); 2360 list << QString::number( y );
2358 list << QString::number( w ); 2361 list << QString::number( w );
2359 list << QString::number( h ); 2362 list << QString::number( h );
2360 config->writeEntry("SearchLayout",list ); 2363 config->writeEntry("SearchLayout",list );
2361 } 2364 }
2362#endif 2365#endif
2363 2366
2364 2367
2365 config->sync(); 2368 config->sync();
2366} 2369}
2367 2370
2368void CalendarView::readFilterSettings(KConfig *config) 2371void CalendarView::readFilterSettings(KConfig *config)
2369{ 2372{
2370 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2373 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2371 2374
2372 mFilters.clear(); 2375 mFilters.clear();
2373 2376
2374 config->setGroup("General"); 2377 config->setGroup("General");
2375 QStringList filterList = config->readListEntry("CalendarFilters"); 2378 QStringList filterList = config->readListEntry("CalendarFilters");
2376 2379
2377 QStringList::ConstIterator it = filterList.begin(); 2380 QStringList::ConstIterator it = filterList.begin();
2378 QStringList::ConstIterator end = filterList.end(); 2381 QStringList::ConstIterator end = filterList.end();
2379 while(it != end) { 2382 while(it != end) {
2380 // kdDebug() << " filter: " << (*it) << endl; 2383 // kdDebug() << " filter: " << (*it) << endl;
2381 2384
2382 CalFilter *filter; 2385 CalFilter *filter;
2383 filter = new CalFilter(*it); 2386 filter = new CalFilter(*it);
2384 config->setGroup("Filter_" + (*it).utf8()); 2387 config->setGroup("Filter_" + (*it).utf8());
2385 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2388 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2386 filter->setCriteria(config->readNumEntry("Criteria",0)); 2389 filter->setCriteria(config->readNumEntry("Criteria",0));
2387 filter->setCategoryList(config->readListEntry("CategoryList")); 2390 filter->setCategoryList(config->readListEntry("CategoryList"));
2388 mFilters.append(filter); 2391 mFilters.append(filter);
2389 2392
2390 ++it; 2393 ++it;
2391 } 2394 }
2392 2395
2393 if (mFilters.count() == 0) { 2396 if (mFilters.count() == 0) {
2394 CalFilter *filter = new CalFilter(i18n("Default")); 2397 CalFilter *filter = new CalFilter(i18n("Default"));
2395 mFilters.append(filter); 2398 mFilters.append(filter);
2396 } 2399 }
2397 mFilterView->updateFilters(); 2400 mFilterView->updateFilters();
2398 config->setGroup("FilterView"); 2401 config->setGroup("FilterView");
2399 2402
2400 mFilterView->blockSignals(true); 2403 mFilterView->blockSignals(true);
2401 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2404 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2402 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2405 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2403 mFilterView->blockSignals(false); 2406 mFilterView->blockSignals(false);
2404 // We do it manually to avoid it being done twice by the above calls 2407 // We do it manually to avoid it being done twice by the above calls
2405 updateFilter(); 2408 updateFilter();
2406} 2409}
2407 2410
2408void CalendarView::writeFilterSettings(KConfig *config) 2411void CalendarView::writeFilterSettings(KConfig *config)
2409{ 2412{
2410 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2413 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;