summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 18:23:08 (UTC)
committer zautrix <zautrix>2005-06-15 18:23:08 (UTC)
commitccfe3f97afd65c75ee6c7c931cb3694919a4e29b (patch) (unidiff)
tree117d3467ef1d9678f31dea1b506390707f88d94a
parentcba0ac17d3d505805be6aa4b4fea6f63473a1e00 (diff)
downloadkdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.zip
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.gz
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.bz2
fixess
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/kolistview.cpp68
-rw-r--r--korganizer/kolistview.h5
-rw-r--r--korganizer/koprefs.cpp4
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp10
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/incidencebase.cpp2
10 files changed, 87 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 377a66f..2012e92 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1644,392 +1644,385 @@ bool CalendarView::importBday()
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 mCalendar->setSyncEventsReadOnly();
1837 QPtrList<Event> eL = mCalendar->rawEvents();
1838 ev = eL.first();
1839 while ( ev ) {
1840 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1841 ev->setReadOnly( true );
1842 ev = eL.next();
1843 }
1844} 1837}
1845 1838
1846bool CalendarView::loadCalendars() 1839bool CalendarView::loadCalendars()
1847{ 1840{
1848 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1841 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1849 KopiCalendarFile * cal = calendars.first(); 1842 KopiCalendarFile * cal = calendars.first();
1850 mCalendar->setDefaultCalendar( 1 ); 1843 mCalendar->setDefaultCalendar( 1 );
1851 openCalendar( MainWindow::defaultFileName(), false ); 1844 openCalendar( MainWindow::defaultFileName(), false );
1852 cal = calendars.next(); 1845 cal = calendars.next();
1853 while ( cal ) { 1846 while ( cal ) {
1854 addCalendar( cal ); 1847 addCalendar( cal );
1855 cal = calendars.next(); 1848 cal = calendars.next();
1856 } 1849 }
1857 restoreCalendarSettings(); 1850 restoreCalendarSettings();
1858 return true; 1851 return true;
1859} 1852}
1860bool CalendarView::restoreCalendarSettings() 1853bool CalendarView::restoreCalendarSettings()
1861{ 1854{
1862 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1855 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1863 KopiCalendarFile * cal = calendars.first(); 1856 KopiCalendarFile * cal = calendars.first();
1864 while ( cal ) { 1857 while ( cal ) {
1865 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1858 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1866 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1859 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1867 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1860 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1868 if ( cal->isStandard ) 1861 if ( cal->isStandard )
1869 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1862 mCalendar->setDefaultCalendar( cal->mCalNumber );
1870 cal = calendars.next(); 1863 cal = calendars.next();
1871 } 1864 }
1872 setSyncEventsReadOnly(); 1865 setSyncEventsReadOnly();
1873 mCalendar->reInitAlarmSettings(); 1866 mCalendar->reInitAlarmSettings();
1874 updateUnmanagedViews(); 1867 updateUnmanagedViews();
1875 updateView(); 1868 updateView();
1876 return true; 1869 return true;
1877} 1870}
1878void CalendarView::addCalendarId( int id ) 1871void CalendarView::addCalendarId( int id )
1879{ 1872{
1880 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1873 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1881 addCalendar( cal ); 1874 addCalendar( cal );
1882} 1875}
1883bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1876bool CalendarView::addCalendar( KopiCalendarFile * cal )
1884{ 1877{
1885 cal->mErrorOnLoad = false; 1878 cal->mErrorOnLoad = false;
1886 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1879 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1887 cal->mLoadDt = QDateTime::currentDateTime(); 1880 cal->mLoadDt = QDateTime::currentDateTime();
1888 return true; 1881 return true;
1889 } 1882 }
1890 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1883 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1891 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1884 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1892 cal->mErrorOnLoad = true; 1885 cal->mErrorOnLoad = true;
1893 return false; 1886 return false;
1894} 1887}
1895bool CalendarView::openCalendar(QString filename, bool merge) 1888bool CalendarView::openCalendar(QString filename, bool merge)
1896{ 1889{
1897 1890
1898 if (filename.isEmpty()) { 1891 if (filename.isEmpty()) {
1899 return false; 1892 return false;
1900 } 1893 }
1901 1894
1902 if (!QFile::exists(filename)) { 1895 if (!QFile::exists(filename)) {
1903 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1896 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1904 return false; 1897 return false;
1905 } 1898 }
1906 1899
1907 globalFlagBlockAgenda = 1; 1900 globalFlagBlockAgenda = 1;
1908 clearAllViews(); 1901 clearAllViews();
1909 if (!merge) { 1902 if (!merge) {
1910 mViewManager->setDocumentId( filename ); 1903 mViewManager->setDocumentId( filename );
1911 mCalendar->close(); 1904 mCalendar->close();
1912 } 1905 }
1913 mStorage->setFileName( filename ); 1906 mStorage->setFileName( filename );
1914 1907
1915 if ( mStorage->load() ) { 1908 if ( mStorage->load() ) {
1916 if ( merge ) ;//setModified( true ); 1909 if ( merge ) ;//setModified( true );
1917 else { 1910 else {
1918 //setModified( true ); 1911 //setModified( true );
1919 mViewManager->setDocumentId( filename ); 1912 mViewManager->setDocumentId( filename );
1920 mDialogManager->setDocumentId( filename ); 1913 mDialogManager->setDocumentId( filename );
1921 mTodoList->setDocumentId( filename ); 1914 mTodoList->setDocumentId( filename );
1922 } 1915 }
1923 globalFlagBlockAgenda = 2; 1916 globalFlagBlockAgenda = 2;
1924 // if ( getLastSyncEvent() ) 1917 // if ( getLastSyncEvent() )
1925 // getLastSyncEvent()->setReadOnly( true ); 1918 // getLastSyncEvent()->setReadOnly( true );
1926 mCalendar->reInitAlarmSettings(); 1919 mCalendar->reInitAlarmSettings();
1927 setSyncEventsReadOnly(); 1920 setSyncEventsReadOnly();
1928 updateUnmanagedViews(); 1921 updateUnmanagedViews();
1929 updateView(); 1922 updateView();
1930 if ( filename != MainWindow::defaultFileName() ) { 1923 if ( filename != MainWindow::defaultFileName() ) {
1931 saveCalendar( MainWindow::defaultFileName() ); 1924 saveCalendar( MainWindow::defaultFileName() );
1932 } else { 1925 } else {
1933 QFileInfo finf ( MainWindow::defaultFileName()); 1926 QFileInfo finf ( MainWindow::defaultFileName());
1934 if ( finf.exists() ) { 1927 if ( finf.exists() ) {
1935 setLoadedFileVersion( finf.lastModified () ); 1928 setLoadedFileVersion( finf.lastModified () );
1936 } 1929 }
1937 } 1930 }
1938 return true; 1931 return true;
1939 } else { 1932 } else {
1940 // while failing to load, the calendar object could 1933 // while failing to load, the calendar object could
1941 // have become partially populated. Clear it out. 1934 // have become partially populated. Clear it out.
1942 if ( !merge ) { 1935 if ( !merge ) {
1943 mCalendar->close(); 1936 mCalendar->close();
1944 mViewManager->setDocumentId( filename ); 1937 mViewManager->setDocumentId( filename );
1945 mDialogManager->setDocumentId( filename ); 1938 mDialogManager->setDocumentId( filename );
1946 mTodoList->setDocumentId( filename ); 1939 mTodoList->setDocumentId( filename );
1947 } 1940 }
1948 1941
1949 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1942 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1950 1943
1951 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1944 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1952 globalFlagBlockAgenda = 2; 1945 globalFlagBlockAgenda = 2;
1953 mCalendar->reInitAlarmSettings(); 1946 mCalendar->reInitAlarmSettings();
1954 setSyncEventsReadOnly(); 1947 setSyncEventsReadOnly();
1955 updateUnmanagedViews(); 1948 updateUnmanagedViews();
1956 updateView(); 1949 updateView();
1957 } 1950 }
1958 return false; 1951 return false;
1959} 1952}
1960void CalendarView::showOpenError() 1953void CalendarView::showOpenError()
1961{ 1954{
1962 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1955 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1963} 1956}
1964void CalendarView::setLoadedFileVersion(QDateTime dt) 1957void CalendarView::setLoadedFileVersion(QDateTime dt)
1965{ 1958{
1966 loadedFileVersion = dt; 1959 loadedFileVersion = dt;
1967} 1960}
1968bool CalendarView::checkFileChanged(QString fn) 1961bool CalendarView::checkFileChanged(QString fn)
1969{ 1962{
1970 QFileInfo finf ( fn ); 1963 QFileInfo finf ( fn );
1971 if ( !finf.exists() ) 1964 if ( !finf.exists() )
1972 return true; 1965 return true;
1973 QDateTime dt = finf.lastModified (); 1966 QDateTime dt = finf.lastModified ();
1974 if ( dt <= loadedFileVersion ) 1967 if ( dt <= loadedFileVersion )
1975 return false; 1968 return false;
1976 return true; 1969 return true;
1977 1970
1978} 1971}
1979void CalendarView::watchSavedFile() 1972void CalendarView::watchSavedFile()
1980{ 1973{
1981 QFileInfo finf ( MainWindow::defaultFileName()); 1974 QFileInfo finf ( MainWindow::defaultFileName());
1982 if ( !finf.exists() ) 1975 if ( !finf.exists() )
1983 return; 1976 return;
1984 QDateTime dt = finf.lastModified (); 1977 QDateTime dt = finf.lastModified ();
1985 if ( dt < loadedFileVersion ) { 1978 if ( dt < loadedFileVersion ) {
1986 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1979 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1987 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1980 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1988 return; 1981 return;
1989 } 1982 }
1990 loadedFileVersion = dt; 1983 loadedFileVersion = dt;
1991} 1984}
1992bool CalendarView::checkAllFileVersions() 1985bool CalendarView::checkAllFileVersions()
1993{ 1986{
1994 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1987 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1995 KopiCalendarFile * cal = calendars.first(); 1988 KopiCalendarFile * cal = calendars.first();
1996 mCalendar->setDefaultCalendar( 1 ); 1989 mCalendar->setDefaultCalendar( 1 );
1997 mCalendar->setDefaultCalendarEnabledOnly(); 1990 mCalendar->setDefaultCalendarEnabledOnly();
1998 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 1991 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
1999 if ( !checkFileVersion(MainWindow::defaultFileName())) { 1992 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2000 restoreCalendarSettings(); 1993 restoreCalendarSettings();
2001 return false; 1994 return false;
2002 } 1995 }
2003 } 1996 }
2004 cal = calendars.next(); 1997 cal = calendars.next();
2005 QDateTime storeTemp = loadedFileVersion; 1998 QDateTime storeTemp = loadedFileVersion;
2006 while ( cal ) { 1999 while ( cal ) {
2007 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2000 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2008 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2001 mCalendar->setDefaultCalendar( cal->mCalNumber );
2009 mCalendar->setDefaultCalendarEnabledOnly(); 2002 mCalendar->setDefaultCalendarEnabledOnly();
2010 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2003 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2011 if ( !checkFileVersion(cal->mFileName )) { 2004 if ( !checkFileVersion(cal->mFileName )) {
2012 loadedFileVersion = storeTemp; 2005 loadedFileVersion = storeTemp;
2013 restoreCalendarSettings(); 2006 restoreCalendarSettings();
2014 return false; 2007 return false;
2015 } 2008 }
2016 } 2009 }
2017 cal = calendars.next(); 2010 cal = calendars.next();
2018 } 2011 }
2019 loadedFileVersion = storeTemp; 2012 loadedFileVersion = storeTemp;
2020 return true; 2013 return true;
2021} 2014}
2022bool CalendarView::checkFileVersion(QString fn) 2015bool CalendarView::checkFileVersion(QString fn)
2023{ 2016{
2024 QFileInfo finf ( fn ); 2017 QFileInfo finf ( fn );
2025 if ( !finf.exists() ) 2018 if ( !finf.exists() )
2026 return true; 2019 return true;
2027 QDateTime dt = finf.lastModified (); 2020 QDateTime dt = finf.lastModified ();
2028 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2021 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2029 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2022 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2030 if ( dt <= loadedFileVersion ) 2023 if ( dt <= loadedFileVersion )
2031 return true; 2024 return 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)) , 2025 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)) ,
2033 i18n("KO/Pi Warning"),i18n("Overwrite"), 2026 i18n("KO/Pi Warning"),i18n("Overwrite"),
2034 i18n("Sync+save")); 2027 i18n("Sync+save"));
2035 2028
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b2b136a..93ff55e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -473,385 +473,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 479 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
481 481
482 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
483 // updateConfig(); 483 // updateConfig();
484 484
485 // createDayLabels(); 485 // createDayLabels();
486 486
487 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 491
492 // Scrolling 492 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
497 497
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 500
501 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 520
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 533
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
538 538
539 // event indicator update 539 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 544 // drag signals
545 /* 545 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
550 */ 550 */
551 // synchronize selections 551 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 568
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 571
572} 572}
573 573
574void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
575{ 575{
576 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
578} 578}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 580{
581 calendar()->addIncidence( inc ); 581 calendar()->addIncidence( inc );
582 582
583 if ( incOld ) { 583 if ( incOld ) {
584 if ( incOld->typeID() == todoID ) 584 if ( incOld->typeID() == todoID )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 586 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 588 }
589 589
590} 590}
591 591
592KOAgendaView::~KOAgendaView() 592KOAgendaView::~KOAgendaView()
593{ 593{
594 delete mAllAgendaPopup; 594 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 595 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 596 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 597 delete KOAgendaItem::paintPixSel();
598} 598}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 600{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 602 bool uc = false;
603 int ow = e->oldSize().width(); 603 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 604 int oh = e->oldSize().height();
605 int w = e->size().width(); 605 int w = e->size().width();
606 int h = e->size().height(); 606 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 609 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 611 }
612 mUpcomingWidth = e->size().width() ; 612 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 613 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 614 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 615 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 616 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 617 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 618 //qDebug("KOAgendaView::Updating now possible ");
619 } else 619 } else
620 createDayLabels(); 620 createDayLabels();
621 //qDebug("resizeEvent end "); 621 //qDebug("resizeEvent end ");
622 622
623} 623}
624void KOAgendaView::slotDaylabelClicked( int num ) 624void KOAgendaView::slotDaylabelClicked( int num )
625{ 625{
626 626
627 QDate firstDate = mSelectedDates.first(); 627 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 628 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 629 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 630 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 631 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 632 emit showDateView( 9, firstDate.addDays( num ) );
633 else 633 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 634 emit showDateView( 3, firstDate.addDays( num ) );
635 } 635 }
636 else 636 else
637 showDateView( 10, firstDate.addDays(1) ); 637 showDateView( 10, firstDate.addDays(1) );
638} 638}
639 639
640KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 641{
642 642
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 647 return dayLabel ;
648} 648}
649 649
650void KOAgendaView::createDayLabels() 650void KOAgendaView::createDayLabels()
651{ 651{
652 652
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 653 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 654 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 655 return;
656 656
657 } 657 }
658 int newHight; 658 int newHight;
659 if ( !mSelectedDates.count()) 659 if ( !mSelectedDates.count())
660 return; 660 return;
661 661
662 // ### Before deleting and recreating we could check if mSelectedDates changed... 662 // ### Before deleting and recreating we could check if mSelectedDates changed...
663 // It would remove some flickering and gain speed (since this is called by 663 // It would remove some flickering and gain speed (since this is called by
664 // each updateView() call) 664 // each updateView() call)
665 665
666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
668 if ( maxWid < 20 ) 668 if ( maxWid < 20 )
669 maxWid = 20; 669 maxWid = 20;
670 670
671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
672 QFontMetrics fm ( dlf ); 672 QFontMetrics fm ( dlf );
673 int selCount = mSelectedDates.count(); 673 int selCount = mSelectedDates.count();
674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
675 QString dayTest = "Mon 20"; 675 QString dayTest = "Mon 20";
676 //QString dayTest = "Mon 20"; 676 //QString dayTest = "Mon 20";
677 int wid = fm.width( dayTest ); 677 int wid = fm.width( dayTest );
678 //maxWid -= ( selCount * 3 ); //working for QLabels 678 //maxWid -= ( selCount * 3 ); //working for QLabels
679 if ( QApplication::desktop()->width() <= 320 ) 679 if ( QApplication::desktop()->width() <= 320 )
680 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
681 else 681 else
682 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
683 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
684 maxWid = 20; 684 maxWid = 20;
685 int needWid = wid * selCount; 685 int needWid = wid * selCount;
686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
687 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
688 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
689 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
690 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
691 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
692 needWid = wid * selCount; 692 needWid = wid * selCount;
693 } 693 }
694 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
695 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
696 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
697 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
698 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
699 --fontPoint; 699 --fontPoint;
700 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
701 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
702 wid = f.width( "30" ); 702 wid = f.width( "30" );
703 needWid = wid * selCount; 703 needWid = wid * selCount;
704 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
705 break; 705 break;
706 } 706 }
707 maxLen = 2; 707 maxLen = 2;
708 } 708 }
709 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
710 710
711 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
712 newHight = tempF.height(); 712 newHight = tempF.height();
713 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
715 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
716 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
717 // QFont lFont = dlf; 717 // QFont lFont = dlf;
718 bool appendLabels = false; 718 bool appendLabels = false;
719 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
720 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
721 if ( !dayLabel ) { 721 if ( !dayLabel ) {
722 appendLabels = true; 722 appendLabels = true;
723 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
724 } 724 }
725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
726 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
727 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
728 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
729 729
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
731 dayLabel->show(); 731 dayLabel->show();
732 DateList::ConstIterator dit; 732 DateList::ConstIterator dit;
733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
734 int counter = -1; 734 int counter = -1;
735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
736 ++counter; 736 ++counter;
737 QDate date = *dit; 737 QDate date = *dit;
738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
739 if ( ! appendLabels ) { 739 if ( ! appendLabels ) {
740 dayLabel = mDayLabelsList.next(); 740 dayLabel = mDayLabelsList.next();
741 if ( !dayLabel ) 741 if ( !dayLabel )
742 appendLabels = true; 742 appendLabels = true;
743 } 743 }
744 if ( appendLabels ) { 744 if ( appendLabels ) {
745 dayLabel = getNewDaylabel(); 745 dayLabel = getNewDaylabel();
746 } 746 }
747 dayLabel->setMinimumWidth( 1 ); 747 dayLabel->setMinimumWidth( 1 );
748 dayLabel->setMaximumWidth( 10240 ); 748 dayLabel->setMaximumWidth( 10240 );
749 dayLabel->setFont( dlf ); 749 dayLabel->setFont( dlf );
750 dayLabel->show(); 750 dayLabel->show();
751 dayLabel->setAutoRepeat( false ); 751 dayLabel->setAutoRepeat( false );
752 dayLabel->setNum( counter ); 752 dayLabel->setNum( counter );
753 QString str; 753 QString str;
754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
756 switch ( maxLen ) { 756 switch ( maxLen ) {
757 case 2: 757 case 2:
758 str = QString::number( date.day() ); 758 str = QString::number( date.day() );
759 break; 759 break;
760 760
761 case 3: 761 case 3:
762 str = dayName.left( 1 ) +QString::number( date.day()); 762 str = dayName.left( 1 ) +QString::number( date.day());
763 763
764 break; 764 break;
765 case 4: 765 case 4:
766 str = dayName.left( 1 ) + " " +QString::number( date.day()); 766 str = dayName.left( 1 ) + " " +QString::number( date.day());
767 767
768 break; 768 break;
769 case 5: 769 case 5:
770 str = dayName.left( 2 ) + " " +QString::number( date.day()); 770 str = dayName.left( 2 ) + " " +QString::number( date.day());
771 771
772 break; 772 break;
773 case 6: 773 case 6:
774 str = dayName.left( 3 ) + " " +QString::number( date.day()); 774 str = dayName.left( 3 ) + " " +QString::number( date.day());
775 break; 775 break;
776 776
777 default: 777 default:
778 break; 778 break;
779 } 779 }
780 if ( oneday ) { 780 if ( oneday ) {
781 QString addString; 781 QString addString;
782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
783 addString = i18n("Today"); 783 addString = i18n("Today");
784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
785 addString = i18n("Tomorrow"); 785 addString = i18n("Tomorrow");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
787 addString = i18n("Yesterday"); 787 addString = i18n("Yesterday");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
789 addString = i18n("Day before yesterday"); 789 addString = i18n("Day before yesterday");
790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
791 addString = i18n("Day after tomorrow"); 791 addString = i18n("Day after tomorrow");
792 if ( !addString.isEmpty() ) { 792 if ( !addString.isEmpty() ) {
793 str = addString+", " + str; 793 str = addString+", " + str;
794 } else { 794 } else {
795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
796 } 796 }
797 } 797 }
798 dayLabel->setText(str); 798 dayLabel->setText(str);
799 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
800 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
801 QFont bFont = dlf; 801 QFont bFont = dlf;
802 bFont.setBold( true ); 802 bFont.setBold( true );
803 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
804 } 804 }
805 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
806 806
807#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
809 CalendarDecoration *it; 809 CalendarDecoration *it;
810 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
811 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
812 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
813 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
814 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
815 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
816 } 816 }
817 } 817 }
818 818
819 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
820 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
821 if ( wid ) { 821 if ( wid ) {
822 // wid->setHeight(20); 822 // wid->setHeight(20);
823 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
824 } 824 }
825 } 825 }
826#endif 826#endif
827 } 827 }
828 if ( ! appendLabels ) { 828 if ( ! appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 if ( !dayLabel ) 830 if ( !dayLabel )
831 appendLabels = true; 831 appendLabels = true;
832 } 832 }
833 if ( appendLabels ) { 833 if ( appendLabels ) {
834 dayLabel = getNewDaylabel(); 834 dayLabel = getNewDaylabel();
835 } 835 }
836 //dayLabel->hide();//test only 836 //dayLabel->hide();//test only
837 837
838 dayLabel->setText(">"); 838 dayLabel->setText(">");
839 dayLabel->setFont( dlf ); 839 dayLabel->setFont( dlf );
840 dayLabel->setAutoRepeat( true ); 840 dayLabel->setAutoRepeat( true );
841 dayLabel->show(); 841 dayLabel->show();
842 dayLabel->setNum( -2 ); 842 dayLabel->setNum( -2 );
843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
844 844
845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
846 if ( !appendLabels ) { 846 if ( !appendLabels ) {
847 dayLabel = mDayLabelsList.next(); 847 dayLabel = mDayLabelsList.next();
848 while ( dayLabel ) { 848 while ( dayLabel ) {
849 //qDebug("!dayLabel %d",dayLabel ); 849 //qDebug("!dayLabel %d",dayLabel );
850 dayLabel->hide(); 850 dayLabel->hide();
851 dayLabel = mDayLabelsList.next(); 851 dayLabel = mDayLabelsList.next();
852 } 852 }
853 } 853 }
854 854
855 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 855 mDayLabelsFrame->setFixedHeight( newHight + 4 );
856} 856}
857 857
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 1f3b4c6..c705c73 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,565 +1,621 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70
71
72
73class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
74{ 71{
75public: 72public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 74
78protected: 75protected:
79 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
80 { 77 {
81 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
82 } 79 }
83private: 80private:
84 QWidget* _wid; 81 QWidget* _wid;
85 KOListView * _view; 82 KOListView * _view;
86}; 83};
87 84
88 85
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 87{
91 mItem = item; 88 mItem = item;
92 mDate = date; 89 mDate = date;
93} 90}
94 91
95ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
96{ 93{
97} 94}
98 95
99bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
100{ 97{
101 bool ok = false; 98 bool ok = false;
102 QString start, end; 99 QString start, end;
103 QDate ds, de; 100 QDate ds, de;
104 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 103 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 106 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
111 } 108 }
112 109
113 } 110 }
114 if ( ! ok ) { 111 if ( ! ok ) {
115 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
119 } 116 }
120 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 118 mItem->setText(1,start);
122 if ( e->doesFloat() ) 119 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 120 mItem->setText(2,"---");
124 else 121 else
125 mItem->setText(2,e->dtStartTimeStr()); 122 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 123 mItem->setText(3,end);
127 if ( e->doesFloat() ) 124 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 125 mItem->setText(4,"---");
129 else 126 else
130 mItem->setText(4,e->dtEndTimeStr()); 127 mItem->setText(4,e->dtEndTimeStr());
131 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
132 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
133 } else { 130 } else {
134 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
135 } 132 }
136 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
137 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
138 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
139 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
140 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
142 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
140 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 141
144 QString key; 142 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 143 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 144 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 145 mItem->setSortKey(1,key);
148 146
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 147 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 148 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 149 mItem->setSortKey(3,key);
152 return true; 150 return true;
153} 151}
154 152
155bool ListItemVisitor::visit(Todo *t) 153bool ListItemVisitor::visit(Todo *t)
156{ 154{
157 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 155 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
158 if (t->hasStartDate()) { 156 if (t->hasStartDate()) {
159 mItem->setText(1,t->dtStartDateStr()); 157 mItem->setText(1,t->dtStartDateStr());
160 if (t->doesFloat()) { 158 if (t->doesFloat()) {
161 mItem->setText(2,"---"); 159 mItem->setText(2,"---");
162 } else { 160 } else {
163 mItem->setText(2,t->dtStartTimeStr()); 161 mItem->setText(2,t->dtStartTimeStr());
164 } 162 }
165 } else { 163 } else {
166 mItem->setText(1,"---"); 164 mItem->setText(1,"---");
167 mItem->setText(2,"---"); 165 mItem->setText(2,"---");
168 } 166 }
169 mItem->setText(3,"---"); 167 mItem->setText(3,"---");
170 mItem->setText(4,"---"); 168 mItem->setText(4,"---");
171 if ( t->isAlarmEnabled() ) { 169 if ( t->isAlarmEnabled() ) {
172 mItem->setText(5,t->alarms().first()->offsetText() ); 170 mItem->setText(5,t->alarms().first()->offsetText() );
173 } else { 171 } else {
174 mItem->setText(5, i18n("No")); 172 mItem->setText(5, i18n("No"));
175 } 173 }
176 mItem->setText(6, t->recurrence()->recurrenceText()); 174 mItem->setText(6, t->recurrence()->recurrenceText());
177 if( ! t->doesRecur() ) 175 if( ! t->doesRecur() )
178 mItem->setSortKey( 6, "-" ); 176 mItem->setSortKey( 6, "-" );
179 if (t->hasDueDate()) { 177 if (t->hasDueDate()) {
180 mItem->setText(7,t->dtDueDateStr()); 178 mItem->setText(7,t->dtDueDateStr());
181 if (t->doesFloat()) { 179 if (t->doesFloat()) {
182 mItem->setText(8,"---"); 180 mItem->setText(8,"---");
183 } else { 181 } else {
184 mItem->setText(8,t->dtDueTimeStr()); 182 mItem->setText(8,t->dtDueTimeStr());
185 } 183 }
186 } else { 184 } else {
187 mItem->setText(7,"---"); 185 mItem->setText(7,"---");
188 mItem->setText(8,"---"); 186 mItem->setText(8,"---");
189 } 187 }
190 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 188 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
191 mItem->setText(10,t->categoriesStr()); 189 mItem->setText(10,t->categoriesStr());
190 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
192 191
193 QString key; 192 QString key;
194 QDate d; 193 QDate d;
195 if (t->hasDueDate()) { 194 if (t->hasDueDate()) {
196 d = t->dtDue().date(); 195 d = t->dtDue().date();
197 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 196 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
198 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 197 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
199 mItem->setSortKey(7,key); 198 mItem->setSortKey(7,key);
200 } 199 }
201 if ( t->hasStartDate() ) { 200 if ( t->hasStartDate() ) {
202 d = t->dtStart().date(); 201 d = t->dtStart().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 202 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 203 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(1,key); 204 mItem->setSortKey(1,key);
206 } 205 }
207 return true; 206 return true;
208} 207}
209 208
210bool ListItemVisitor::visit(Journal * j) 209bool ListItemVisitor::visit(Journal * j)
211{ 210{
212 QString des = j->description().left(30); 211 QString des = j->description().left(30);
213 des = des.simplifyWhiteSpace (); 212 des = des.simplifyWhiteSpace ();
214 des.replace (QRegExp ("\\n"),"" ); 213 des.replace (QRegExp ("\\n"),"" );
215 des.replace (QRegExp ("\\r"),"" ); 214 des.replace (QRegExp ("\\r"),"" );
216 mItem->setText(0,i18n("Journal: ")+des.left(25)); 215 mItem->setText(0,i18n("Journal: ")+des.left(25));
217 mItem->setText(1,j->dtStartDateStr()); 216 mItem->setText(1,j->dtStartDateStr());
218 mItem->setText(2,"---"); 217 mItem->setText(2,"---");
219 mItem->setText(3,"---"); 218 mItem->setText(3,"---");
220 mItem->setText(4,"---"); 219 mItem->setText(4,"---");
221 mItem->setText(5,"---"); 220 mItem->setText(5,"---");
222 mItem->setText(6,"---"); 221 mItem->setText(6,"---");
223 mItem->setText(7,j->dtStartDateStr()); 222 mItem->setText(7,j->dtStartDateStr());
224 mItem->setText(8,"---"); 223 mItem->setText(8,"---");
225 mItem->setText(9,"---"); 224 mItem->setText(9,"---");
226 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 225 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
226 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
227 227
228 QString key; 228 QString key;
229 QDate d = j->dtStart().date(); 229 QDate d = j->dtStart().date();
230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
231 mItem->setSortKey(1,key); 231 mItem->setSortKey(1,key);
232 mItem->setSortKey(7,key); 232 mItem->setSortKey(7,key);
233 233
234 return true; 234 return true;
235} 235}
236 236
237KOListView::KOListView(Calendar *calendar, QWidget *parent, 237KOListView::KOListView(Calendar *calendar, QWidget *parent,
238 const char *name) 238 const char *name)
239 : KOEventView(calendar, parent, name) 239 : KOEventView(calendar, parent, name)
240{ 240{
241 mActiveItem = 0; 241 mActiveItem = 0;
242 mListView = new KOListViewListView(this); 242 mListView = new KOListViewListView(this);
243 mListView->addColumn(i18n("Summary")); 243 mListView->addColumn(i18n("Summary"));
244 mListView->addColumn(i18n("Start Date")); 244 mListView->addColumn(i18n("Start Date"));
245 mListView->addColumn(i18n("Start Time")); 245 mListView->addColumn(i18n("Start Time"));
246 mListView->addColumn(i18n("End Date")); 246 mListView->addColumn(i18n("End Date"));
247 mListView->addColumn(i18n("End Time")); 247 mListView->addColumn(i18n("End Time"));
248 mListView->addColumn(i18n("Alarm")); // alarm set? 248 mListView->addColumn(i18n("Alarm")); // alarm set?
249 mListView->addColumn(i18n("Recurs")); // recurs? 249 mListView->addColumn(i18n("Recurs")); // recurs?
250 mListView->addColumn(i18n("Due Date")); 250 mListView->addColumn(i18n("Due Date"));
251 mListView->addColumn(i18n("Due Time")); 251 mListView->addColumn(i18n("Due Time"));
252 mListView->addColumn(i18n("Cancelled")); 252 mListView->addColumn(i18n("Cancelled"));
253 mListView->addColumn(i18n("Categories")); 253 mListView->addColumn(i18n("Categories"));
254 mListView->addColumn(i18n("Calendar"));
254 255
255 mListView->setColumnAlignment(0,AlignLeft); 256 mListView->setColumnAlignment(0,AlignLeft);
256 mListView->setColumnAlignment(1,AlignLeft); 257 mListView->setColumnAlignment(1,AlignLeft);
257 mListView->setColumnAlignment(2,AlignHCenter); 258 mListView->setColumnAlignment(2,AlignHCenter);
258 mListView->setColumnAlignment(3,AlignLeft); 259 mListView->setColumnAlignment(3,AlignLeft);
259 mListView->setColumnAlignment(4,AlignHCenter); 260 mListView->setColumnAlignment(4,AlignHCenter);
260 mListView->setColumnAlignment(5,AlignLeft); 261 mListView->setColumnAlignment(5,AlignLeft);
261 mListView->setColumnAlignment(6,AlignLeft); 262 mListView->setColumnAlignment(6,AlignLeft);
262 mListView->setColumnAlignment(7,AlignLeft); 263 mListView->setColumnAlignment(7,AlignLeft);
263 mListView->setColumnAlignment(8,AlignLeft); 264 mListView->setColumnAlignment(8,AlignLeft);
264 mListView->setColumnAlignment(9,AlignLeft); 265 mListView->setColumnAlignment(9,AlignLeft);
265 mListView->setColumnAlignment(10,AlignLeft); 266 mListView->setColumnAlignment(10,AlignLeft);
266 mListView->setColumnWidthMode(10, QListView::Manual); 267 mListView->setColumnAlignment(11,AlignLeft);
267 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 268 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
268 269
269 int iii = 0; 270 int iii = 0;
270 for ( iii = 0; iii< 10 ; ++iii ) 271 for ( iii = 0; iii< 12 ; ++iii )
271 mListView->setColumnWidthMode( iii, QListView::Manual ); 272 mListView->setColumnWidthMode( iii, QListView::Manual );
272 273
273 QBoxLayout *layoutTop = new QVBoxLayout(this); 274 QBoxLayout *layoutTop = new QVBoxLayout(this);
274 layoutTop->addWidget(mListView); 275 layoutTop->addWidget(mListView);
275 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 276 mListView->setFont ( KOPrefs::instance()->mListViewFont );
276 mPopupMenu = eventPopup(); 277 mPopupMenu = eventPopup();
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 278 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Select all"),this, 279 i18n("Select all"),this,
279 SLOT(allSelection()),true); 280 SLOT(allSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 281 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Deselect all"),this, 282 i18n("Deselect all"),this,
282 SLOT(clearSelection()),true); 283 SLOT(clearSelection()),true);
283 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 284 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
284 i18n("Delete all selected"),this, 285 i18n("Delete all selected"),this,
285 SLOT(deleteAll()),true); 286 SLOT(deleteAll()),true);
286 287
287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 288 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
288 i18n("Hide all selected"),this, 289 i18n("Hide all selected"),this,
289 SLOT(hideAll()),true); 290 SLOT(hideAll()),true);
290 291
291 mPopupMenu->insertSeparator(); 292 mPopupMenu->insertSeparator();
292#ifdef DESKTOP_VERSION 293#ifdef DESKTOP_VERSION
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 294 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Print complete list"),this, 295 i18n("Print complete list"),this,
295 SLOT(printList()),true); 296 SLOT(printList()),true);
296 mPopupMenu->insertSeparator(); 297 mPopupMenu->insertSeparator();
297#endif 298#endif
299 mCalPopup = new QPopupMenu ( this );
300 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
301
302 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
303 SLOT( populateCalPopup() ));
304 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
305 SLOT( setCalendar( int ) ));
298 QPopupMenu * exportPO = new QPopupMenu ( this ); 306 QPopupMenu * exportPO = new QPopupMenu ( this );
299 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 307 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
300 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 308 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
301 SLOT(saveToFile())); 309 SLOT(saveToFile()));
302 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 310 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
303 SLOT(saveToFileVCS())); 311 SLOT(saveToFileVCS()));
304 exportPO->insertItem( i18n("Journal/Details..."),this, 312 exportPO->insertItem( i18n("Journal/Details..."),this,
305 SLOT(saveDescriptionToFile())); 313 SLOT(saveDescriptionToFile()));
306 // mPopupMenu->insertSeparator(); 314 // mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 315 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Add Categ. to selected..."),this, 316 i18n("Add Categ. to selected..."),this,
309 SLOT(addCat()),true); 317 SLOT(addCat()),true);
310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 318 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
311 i18n("Set Categ. for selected..."),this, 319 i18n("Set Categ. for selected..."),this,
312 SLOT(setCat()),true); 320 SLOT(setCat()),true);
313 //mPopupMenu->insertSeparator(); 321 //mPopupMenu->insertSeparator();
314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 322 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
315 i18n("Set alarm for selected..."),this, 323 i18n("Set alarm for selected..."),this,
316 SLOT(setAlarm()),true); 324 SLOT(setAlarm()),true);
317 325
318 326
327
319#ifndef DESKTOP_VERSION 328#ifndef DESKTOP_VERSION
320 mPopupMenu->insertSeparator(); 329 mPopupMenu->insertSeparator();
321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
322 i18n("Beam selected via IR"),this, 331 i18n("Beam selected via IR"),this,
323 SLOT(beamSelected()),true); 332 SLOT(beamSelected()),true);
324#endif 333#endif
325 /* 334 /*
326 mPopupMenu = new QPopupMenu; 335 mPopupMenu = new QPopupMenu;
327 mPopupMenu->insertItem(i18n("Edit Event"), this, 336 mPopupMenu->insertItem(i18n("Edit Event"), this,
328 SLOT (editEvent())); 337 SLOT (editEvent()));
329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 338 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
330 SLOT (deleteEvent())); 339 SLOT (deleteEvent()));
331 mPopupMenu->insertSeparator(); 340 mPopupMenu->insertSeparator();
332 mPopupMenu->insertItem(i18n("Show Dates"), this, 341 mPopupMenu->insertItem(i18n("Show Dates"), this,
333 SLOT(showDates())); 342 SLOT(showDates()));
334 mPopupMenu->insertItem(i18n("Hide Dates"), this, 343 mPopupMenu->insertItem(i18n("Hide Dates"), this,
335 SLOT(hideDates())); 344 SLOT(hideDates()));
336 */ 345 */
337 QObject::connect(mListView,SIGNAL( newEvent()), 346 QObject::connect(mListView,SIGNAL( newEvent()),
338 this,SIGNAL(signalNewEvent())); 347 this,SIGNAL(signalNewEvent()));
339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 348 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
340 this,SLOT(defaultItemAction(QListViewItem *))); 349 this,SLOT(defaultItemAction(QListViewItem *)));
341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 350 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
342 const QPoint &, int )), 351 const QPoint &, int )),
343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 352 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 353 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
345 SLOT(processSelectionChange(QListViewItem *))); 354 SLOT(processSelectionChange(QListViewItem *)));
346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 355 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
347 SIGNAL(showIncidenceSignal(Incidence *)) ); 356 SIGNAL(showIncidenceSignal(Incidence *)) );
348 357
349 readSettings(KOGlobals::config(),"KOListView Layout"); 358 readSettings(KOGlobals::config(),"KOListView Layout");
350} 359}
351 360
352KOListView::~KOListView() 361KOListView::~KOListView()
353{ 362{
354 delete mPopupMenu; 363 delete mPopupMenu;
355#if QT_VERSION >= 0x030000 364#if QT_VERSION >= 0x030000
356 365
357#else 366#else
358 delete mKOListViewWhatsThis; 367 delete mKOListViewWhatsThis;
359#endif 368#endif
360} 369}
361 370
362QString KOListView::getWhatsThisText(QPoint p) 371QString KOListView::getWhatsThisText(QPoint p)
363{ 372{
364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 373 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
365 if ( item ) 374 if ( item )
366 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 375 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
367 KOPrefs::instance()->mWTshowDetails, 376 KOPrefs::instance()->mWTshowDetails,
368 KOPrefs::instance()->mWTshowCreated, 377 KOPrefs::instance()->mWTshowCreated,
369 KOPrefs::instance()->mWTshowChanged); 378 KOPrefs::instance()->mWTshowChanged);
370 return i18n("That is the list view" ); 379 return i18n("That is the list view" );
371 380
372} 381}
373 382
383void KOListView::setCalendar( int c )
384{
385 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
386 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
387 i18n("Continue"), i18n("Cancel"), 0,
388 0, 1 );
389 if ( result != 0 ) {
390 return;
391 }
392
393 QPtrList<Incidence> delSel = getSelectedIncidences() ;
394 int icount = delSel.count();
395 if ( icount ) {
396 Incidence *incidence = delSel.first();
397 while ( incidence ) {
398 incidence->setCalID( c );
399 KOListViewItem * item = getItemForEvent( incidence );
400 if ( item ) {
401 ListItemVisitor v(item, mStartDate );
402 incidence->accept(v);
403 }
404 incidence = delSel.next();
405 }
406 }
407 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
408 KopiCalendarFile * cal = calendars.first();
409 while ( cal ) {
410 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
411 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
412 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
413 if ( cal->isStandard )
414 mCalendar->setDefaultCalendar( cal->mCalNumber );
415 cal = calendars.next();
416 }
417 mCalendar->setSyncEventsReadOnly();
418 mCalendar->reInitAlarmSettings();
419
420}
421void KOListView::populateCalPopup()
422{
423 mCalPopup->clear();
424 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
425 while ( kkf ) {
426 mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
427 kkf = KOPrefs::instance()->mCalendars.next();
428 }
429}
374void KOListView::updateList() 430void KOListView::updateList()
375{ 431{
376 // qDebug(" KOListView::updateList() "); 432 // qDebug(" KOListView::updateList() ");
377 433
378} 434}
379 435
380void KOListView::clearList() 436void KOListView::clearList()
381{ 437{
382 clear (); 438 clear ();
383} 439}
384void KOListView::addCat( ) 440void KOListView::addCat( )
385{ 441{
386 setCategories( false ); 442 setCategories( false );
387} 443}
388void KOListView::setCat() 444void KOListView::setCat()
389{ 445{
390 setCategories( true ); 446 setCategories( true );
391} 447}
392 448
393void KOListView::setAlarm() 449void KOListView::setAlarm()
394{ 450{
395 KOAlarmPrefs kap( this); 451 KOAlarmPrefs kap( this);
396 if ( !kap.exec() ) 452 if ( !kap.exec() )
397 return; 453 return;
398 QStringList itemList; 454 QStringList itemList;
399 QPtrList<KOListViewItem> sel ; 455 QPtrList<KOListViewItem> sel ;
400 QListViewItem *qitem = mListView->firstChild (); 456 QListViewItem *qitem = mListView->firstChild ();
401 while ( qitem ) { 457 while ( qitem ) {
402 if ( qitem->isSelected() ) { 458 if ( qitem->isSelected() ) {
403 Incidence* inc = ((KOListViewItem *) qitem)->data(); 459 Incidence* inc = ((KOListViewItem *) qitem)->data();
404 if ( inc->typeID() != journalID ) { 460 if ( inc->typeID() != journalID ) {
405 if ( inc->typeID() == todoID ) { 461 if ( inc->typeID() == todoID ) {
406 if ( ((Todo*)inc)->hasDueDate() ) 462 if ( ((Todo*)inc)->hasDueDate() )
407 sel.append(((KOListViewItem *)qitem)); 463 sel.append(((KOListViewItem *)qitem));
408 } else 464 } else
409 sel.append(((KOListViewItem *)qitem)); 465 sel.append(((KOListViewItem *)qitem));
410 } 466 }
411 } 467 }
412 qitem = qitem->nextSibling(); 468 qitem = qitem->nextSibling();
413 } 469 }
414 int count = 0; 470 int count = 0;
415 KOListViewItem * item, *temp; 471 KOListViewItem * item, *temp;
416 item = sel.first(); 472 item = sel.first();
417 Incidence* inc; 473 Incidence* inc;
418 while ( item ) { 474 while ( item ) {
419 inc = item->data(); 475 inc = item->data();
420 ++count; 476 ++count;
421 if (kap.mAlarmButton->isChecked()) { 477 if (kap.mAlarmButton->isChecked()) {
422 if (inc->alarms().count() == 0) 478 if (inc->alarms().count() == 0)
423 inc->newAlarm(); 479 inc->newAlarm();
424 QPtrList<Alarm> alarms = inc->alarms(); 480 QPtrList<Alarm> alarms = inc->alarms();
425 Alarm *alarm; 481 Alarm *alarm;
426 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 482 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
427 alarm->setEnabled(true); 483 alarm->setEnabled(true);
428 int j = kap.mAlarmTimeEdit->value()* -60; 484 int j = kap.mAlarmTimeEdit->value()* -60;
429 if (kap.mAlarmIncrCombo->currentItem() == 1) 485 if (kap.mAlarmIncrCombo->currentItem() == 1)
430 j = j * 60; 486 j = j * 60;
431 else if (kap.mAlarmIncrCombo->currentItem() == 2) 487 else if (kap.mAlarmIncrCombo->currentItem() == 2)
432 j = j * (60 * 24); 488 j = j * (60 * 24);
433 alarm->setStartOffset( j ); 489 alarm->setStartOffset( j );
434 490
435 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 491 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
436 alarm->setProcedureAlarm(kap.mAlarmProgram); 492 alarm->setProcedureAlarm(kap.mAlarmProgram);
437 } 493 }
438 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 494 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
439 alarm->setAudioAlarm(kap.mAlarmSound); 495 alarm->setAudioAlarm(kap.mAlarmSound);
440 else 496 else
441 alarm->setType(Alarm::Invalid); 497 alarm->setType(Alarm::Invalid);
442 //alarm->setAudioAlarm("default"); 498 //alarm->setAudioAlarm("default");
443 // TODO: Deal with multiple alarms 499 // TODO: Deal with multiple alarms
444 break; // For now, stop after the first alarm 500 break; // For now, stop after the first alarm
445 } 501 }
446 } else { 502 } else {
447 Alarm* alarm = inc->alarms().first(); 503 Alarm* alarm = inc->alarms().first();
448 if ( alarm ) { 504 if ( alarm ) {
449 alarm->setEnabled(false); 505 alarm->setEnabled(false);
450 alarm->setType(Alarm::Invalid); 506 alarm->setType(Alarm::Invalid);
451 } 507 }
452 } 508 }
453 ListItemVisitor v(item, mStartDate ); 509 ListItemVisitor v(item, mStartDate );
454 inc->accept(v); 510 inc->accept(v);
455 item = sel.next(); 511 item = sel.next();
456 } 512 }
457 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 513 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
458 qDebug("KO: Set alarm for %d items", count); 514 qDebug("KO: Set alarm for %d items", count);
459 calendar()->reInitAlarmSettings(); 515 calendar()->reInitAlarmSettings();
460 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 516 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
461} 517}
462void KOListView::setCategories( bool removeOld ) 518void KOListView::setCategories( bool removeOld )
463{ 519{
464 520
465 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 521 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
466 csd->setColorEnabled(); 522 csd->setColorEnabled();
467 if (! csd->exec()) { 523 if (! csd->exec()) {
468 delete csd; 524 delete csd;
469 return; 525 return;
470 } 526 }
471 QStringList catList = csd->selectedCategories(); 527 QStringList catList = csd->selectedCategories();
472 delete csd; 528 delete csd;
473 // if ( catList.count() == 0 ) 529 // if ( catList.count() == 0 )
474 // return; 530 // return;
475 //catList.sort(); 531 //catList.sort();
476 QString categoriesStr = catList.join(","); 532 QString categoriesStr = catList.join(",");
477 int i; 533 int i;
478 QStringList itemList; 534 QStringList itemList;
479 QPtrList<KOListViewItem> sel ; 535 QPtrList<KOListViewItem> sel ;
480 QListViewItem *qitem = mListView->firstChild (); 536 QListViewItem *qitem = mListView->firstChild ();
481 while ( qitem ) { 537 while ( qitem ) {
482 if ( qitem->isSelected() ) { 538 if ( qitem->isSelected() ) {
483 sel.append(((KOListViewItem *)qitem)); 539 sel.append(((KOListViewItem *)qitem));
484 } 540 }
485 qitem = qitem->nextSibling(); 541 qitem = qitem->nextSibling();
486 } 542 }
487 KOListViewItem * item, *temp; 543 KOListViewItem * item, *temp;
488 item = sel.first(); 544 item = sel.first();
489 if( item ) { 545 if( item ) {
490 Incidence* inc = item->data() ; 546 Incidence* inc = item->data() ;
491 bool setSub = false; 547 bool setSub = false;
492 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { 548 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
493 int result = KMessageBox::warningYesNoCancel(this, 549 int result = KMessageBox::warningYesNoCancel(this,
494 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 550 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
495 i18n("Todo has subtodos"), 551 i18n("Todo has subtodos"),
496 i18n("Yes"), 552 i18n("Yes"),
497 i18n("No")); 553 i18n("No"));
498 if (result == KMessageBox::Cancel) item = 0; 554 if (result == KMessageBox::Cancel) item = 0;
499 if (result == KMessageBox::Yes) setSub = true; 555 if (result == KMessageBox::Yes) setSub = true;
500 } 556 }
501 while ( item ) { 557 while ( item ) {
502 inc = item->data(); 558 inc = item->data();
503 if ( removeOld ) { 559 if ( removeOld ) {
504 inc->setCategories( catList, setSub ); 560 inc->setCategories( catList, setSub );
505 } else { 561 } else {
506 inc->addCategories( catList, setSub ); 562 inc->addCategories( catList, setSub );
507 } 563 }
508 ListItemVisitor v(item, mStartDate ); 564 ListItemVisitor v(item, mStartDate );
509 inc->accept(v); 565 inc->accept(v);
510 item = sel.next(); 566 item = sel.next();
511 } 567 }
512 } 568 }
513 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 569 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
514} 570}
515 571
516void KOListView::beamSelected() 572void KOListView::beamSelected()
517{ 573{
518 QPtrList<Incidence> delSel = getSelectedIncidences() ; 574 QPtrList<Incidence> delSel = getSelectedIncidences() ;
519 int icount = delSel.count(); 575 int icount = delSel.count();
520 if ( icount ) { 576 if ( icount ) {
521 emit beamIncidenceList( delSel ); 577 emit beamIncidenceList( delSel );
522 return; 578 return;
523 QString fn ; 579 QString fn ;
524 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 580 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
525 QString mes; 581 QString mes;
526 bool createbup = true; 582 bool createbup = true;
527 if ( createbup ) { 583 if ( createbup ) {
528 QString description = "\n"; 584 QString description = "\n";
529 CalendarLocal* cal = new CalendarLocal(); 585 CalendarLocal* cal = new CalendarLocal();
530 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 586 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
531 Incidence *incidence = delSel.first(); 587 Incidence *incidence = delSel.first();
532 while ( incidence ) { 588 while ( incidence ) {
533 Incidence *in = incidence->clone(); 589 Incidence *in = incidence->clone();
534 description += in->summary() + "\n"; 590 description += in->summary() + "\n";
535 cal->addIncidence( in ); 591 cal->addIncidence( in );
536 incidence = delSel.next(); 592 incidence = delSel.next();
537 } 593 }
538 FileStorage storage( cal, fn, new VCalFormat ); 594 FileStorage storage( cal, fn, new VCalFormat );
539 storage.save(); 595 storage.save();
540 delete cal; 596 delete cal;
541 mes = i18n("KO/Pi: Ready for beaming"); 597 mes = i18n("KO/Pi: Ready for beaming");
542 topLevelWidget()->setCaption(mes); 598 topLevelWidget()->setCaption(mes);
543 599
544#ifndef DESKTOP_VERSION 600#ifndef DESKTOP_VERSION
545 Ir *ir = new Ir( this ); 601 Ir *ir = new Ir( this );
546 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 602 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
547 ir->send( fn, description, "text/x-vCalendar" ); 603 ir->send( fn, description, "text/x-vCalendar" );
548#endif 604#endif
549 } 605 }
550 } 606 }
551} 607}
552void KOListView::beamDone( Ir *ir ) 608void KOListView::beamDone( Ir *ir )
553{ 609{
554#ifndef DESKTOP_VERSION 610#ifndef DESKTOP_VERSION
555 delete ir; 611 delete ir;
556#endif 612#endif
557 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 613 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
558} 614}
559 615
560void KOListView::saveDescriptionToFile() 616void KOListView::saveDescriptionToFile()
561{ 617{
562 618
563 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 619 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
564 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 620 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
565 i18n("Continue"), i18n("Cancel"), 0, 621 i18n("Continue"), i18n("Cancel"), 0,
@@ -850,385 +906,385 @@ QPtrList<Incidence> KOListView::selectedIncidences()
850 QPtrList<Incidence> eventList; 906 QPtrList<Incidence> eventList;
851 QListViewItem *item = mListView->firstChild (); 907 QListViewItem *item = mListView->firstChild ();
852 while ( item ) { 908 while ( item ) {
853 if ( item->isSelected() ) { 909 if ( item->isSelected() ) {
854 eventList.append(((KOListViewItem *)item)->data()); 910 eventList.append(((KOListViewItem *)item)->data());
855 } 911 }
856 912
857 item = item->nextSibling(); 913 item = item->nextSibling();
858 } 914 }
859 915
860 // // QListViewItem *item = mListView->selectedItem(); 916 // // QListViewItem *item = mListView->selectedItem();
861 //if (item) eventList.append(((KOListViewItem *)item)->data()); 917 //if (item) eventList.append(((KOListViewItem *)item)->data());
862 918
863 return eventList; 919 return eventList;
864} 920}
865 921
866DateList KOListView::selectedDates() 922DateList KOListView::selectedDates()
867{ 923{
868 DateList eventList; 924 DateList eventList;
869 return eventList; 925 return eventList;
870} 926}
871 927
872void KOListView::showDates(bool show) 928void KOListView::showDates(bool show)
873{ 929{
874 // Shouldn't we set it to a value greater 0? When showDates is called with 930 // Shouldn't we set it to a value greater 0? When showDates is called with
875 // show == true at first, then the columnwidths are set to zero. 931 // show == true at first, then the columnwidths are set to zero.
876 static int oldColWidth1 = 0; 932 static int oldColWidth1 = 0;
877 static int oldColWidth3 = 0; 933 static int oldColWidth3 = 0;
878 934
879 if (!show) { 935 if (!show) {
880 oldColWidth1 = mListView->columnWidth(1); 936 oldColWidth1 = mListView->columnWidth(1);
881 oldColWidth3 = mListView->columnWidth(3); 937 oldColWidth3 = mListView->columnWidth(3);
882 mListView->setColumnWidth(1, 0); 938 mListView->setColumnWidth(1, 0);
883 mListView->setColumnWidth(3, 0); 939 mListView->setColumnWidth(3, 0);
884 } else { 940 } else {
885 mListView->setColumnWidth(1, oldColWidth1); 941 mListView->setColumnWidth(1, oldColWidth1);
886 mListView->setColumnWidth(3, oldColWidth3); 942 mListView->setColumnWidth(3, oldColWidth3);
887 } 943 }
888 mListView->repaint(); 944 mListView->repaint();
889} 945}
890 946
891void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
892 const QDate &td) 948 const QDate &td)
893{ 949{
894#ifndef KORG_NOPRINTER 950#ifndef KORG_NOPRINTER
895 calPrinter->preview(CalPrinter::Day, fd, td); 951 calPrinter->preview(CalPrinter::Day, fd, td);
896#endif 952#endif
897} 953}
898 954
899void KOListView::showDates() 955void KOListView::showDates()
900{ 956{
901 showDates(true); 957 showDates(true);
902} 958}
903 959
904void KOListView::hideDates() 960void KOListView::hideDates()
905{ 961{
906 showDates(false); 962 showDates(false);
907} 963}
908 964
909void KOListView::resetFocus() 965void KOListView::resetFocus()
910{ 966{
911 topLevelWidget()->setActiveWindow(); 967 topLevelWidget()->setActiveWindow();
912 topLevelWidget()->raise(); 968 topLevelWidget()->raise();
913 mListView->setFocus(); 969 mListView->setFocus();
914} 970}
915void KOListView::updateView() 971void KOListView::updateView()
916{ 972{
917 mListView->setFocus(); 973 mListView->setFocus();
918 if ( mListView->firstChild () ) 974 if ( mListView->firstChild () )
919 mListView->setCurrentItem( mListView->firstChild () ); 975 mListView->setCurrentItem( mListView->firstChild () );
920} 976}
921void KOListView::updateConfig() 977void KOListView::updateConfig()
922{ 978{
923 979
924 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 980 mListView->setFont ( KOPrefs::instance()->mListViewFont );
925 updateView(); 981 updateView();
926 982
927} 983}
928void KOListView::setStartDate(const QDate &start) 984void KOListView::setStartDate(const QDate &start)
929{ 985{
930 mStartDate = start; 986 mStartDate = start;
931} 987}
932 988
933void KOListView::showDates(const QDate &start, const QDate &end) 989void KOListView::showDates(const QDate &start, const QDate &end)
934{ 990{
935 clear(); 991 clear();
936 mStartDate = start; 992 mStartDate = start;
937 QDate date = start; 993 QDate date = start;
938 QPtrList<Journal> j_list; 994 QPtrList<Journal> j_list;
939 while( date <= end ) { 995 while( date <= end ) {
940 addEvents(calendar()->events(date)); 996 addEvents(calendar()->events(date));
941 addTodos(calendar()->todos(date)); 997 addTodos(calendar()->todos(date));
942 Journal* jo = calendar()->journal(date); 998 Journal* jo = calendar()->journal(date);
943 if ( jo ) 999 if ( jo )
944 j_list.append( jo ); 1000 j_list.append( jo );
945 date = date.addDays( 1 ); 1001 date = date.addDays( 1 );
946 } 1002 }
947 addJournals(j_list); 1003 addJournals(j_list);
948 emit incidenceSelected( 0 ); 1004 emit incidenceSelected( 0 );
949 updateView(); 1005 updateView();
950 1006
951} 1007}
952 1008
953void KOListView::addEvents(QPtrList<Event> eventList) 1009void KOListView::addEvents(QPtrList<Event> eventList)
954{ 1010{
955 1011
956 Event *ev; 1012 Event *ev;
957 for(ev = eventList.first(); ev; ev = eventList.next()) { 1013 for(ev = eventList.first(); ev; ev = eventList.next()) {
958 addIncidence(ev); 1014 addIncidence(ev);
959 } 1015 }
960 if ( !mListView->currentItem() ){ 1016 if ( !mListView->currentItem() ){
961 updateView(); 1017 updateView();
962 } 1018 }
963} 1019}
964 1020
965void KOListView::addTodos(QPtrList<Todo> eventList) 1021void KOListView::addTodos(QPtrList<Todo> eventList)
966{ 1022{
967 Todo *ev; 1023 Todo *ev;
968 for(ev = eventList.first(); ev; ev = eventList.next()) { 1024 for(ev = eventList.first(); ev; ev = eventList.next()) {
969 addIncidence(ev); 1025 addIncidence(ev);
970 } 1026 }
971 if ( !mListView->currentItem() ){ 1027 if ( !mListView->currentItem() ){
972 updateView(); 1028 updateView();
973 } 1029 }
974} 1030}
975void KOListView::addJournals(QPtrList<Journal> eventList) 1031void KOListView::addJournals(QPtrList<Journal> eventList)
976{ 1032{
977 Journal *ev; 1033 Journal *ev;
978 for(ev = eventList.first(); ev; ev = eventList.next()) { 1034 for(ev = eventList.first(); ev; ev = eventList.next()) {
979 addIncidence(ev); 1035 addIncidence(ev);
980 } 1036 }
981 if ( !mListView->currentItem() ){ 1037 if ( !mListView->currentItem() ){
982 updateView(); 1038 updateView();
983 } 1039 }
984} 1040}
985 1041
986void KOListView::addIncidence(Incidence *incidence) 1042void KOListView::addIncidence(Incidence *incidence)
987{ 1043{
988 if ( mUidDict.find( incidence->uid() ) ) return; 1044 if ( mUidDict.find( incidence->uid() ) ) return;
989 1045
990 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1046 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
991 mUidDict.insert( incidence->uid(), incidence ); 1047 mUidDict.insert( incidence->uid(), incidence );
992 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1048 KOListViewItem *item = new KOListViewItem( incidence, mListView );
993 ListItemVisitor v(item, mStartDate ); 1049 ListItemVisitor v(item, mStartDate );
994 if (incidence->accept(v)) { 1050 if (incidence->accept(v)) {
995 return; 1051 return;
996 } 1052 }
997 else delete item; 1053 else delete item;
998} 1054}
999 1055
1000void KOListView::showEvents(QPtrList<Event> eventList) 1056void KOListView::showEvents(QPtrList<Event> eventList)
1001{ 1057{
1002 clear(); 1058 clear();
1003 1059
1004 addEvents(eventList); 1060 addEvents(eventList);
1005 1061
1006 // After new creation of list view no events are selected. 1062 // After new creation of list view no events are selected.
1007 emit incidenceSelected( 0 ); 1063 emit incidenceSelected( 0 );
1008} 1064}
1009int KOListView::count() 1065int KOListView::count()
1010{ 1066{
1011 return mListView->childCount(); 1067 return mListView->childCount();
1012} 1068}
1013 1069
1014void KOListView::changeEventDisplay(Event *event, int action) 1070void KOListView::changeEventDisplay(Event *event, int action)
1015{ 1071{
1016 KOListViewItem *item; 1072 KOListViewItem *item;
1017 1073
1018 switch(action) { 1074 switch(action) {
1019 case KOGlobals::EVENTADDED: 1075 case KOGlobals::EVENTADDED:
1020 addIncidence( event ); 1076 addIncidence( event );
1021 break; 1077 break;
1022 case KOGlobals::EVENTEDITED: 1078 case KOGlobals::EVENTEDITED:
1023 item = getItemForEvent(event); 1079 item = getItemForEvent(event);
1024 if (item) { 1080 if (item) {
1025 mUidDict.remove( event->uid() ); 1081 mUidDict.remove( event->uid() );
1026 delete item; 1082 delete item;
1027 addIncidence( event ); 1083 addIncidence( event );
1028 } 1084 }
1029 break; 1085 break;
1030 case KOGlobals::EVENTDELETED: 1086 case KOGlobals::EVENTDELETED:
1031 item = getItemForEvent(event); 1087 item = getItemForEvent(event);
1032 if (item) { 1088 if (item) {
1033 mUidDict.remove( event->uid() ); 1089 mUidDict.remove( event->uid() );
1034 delete item; 1090 delete item;
1035 } 1091 }
1036 break; 1092 break;
1037 default: 1093 default:
1038 ; 1094 ;
1039 } 1095 }
1040} 1096}
1041 1097
1042KOListViewItem *KOListView::getItemForEvent(Event *event) 1098KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1043{ 1099{
1044 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1100 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1045 while (item) { 1101 while (item) {
1046 if (item->data() == event) return item; 1102 if (item->data() == event) return item;
1047 item = (KOListViewItem *)item->nextSibling(); 1103 item = (KOListViewItem *)item->nextSibling();
1048 } 1104 }
1049 return 0; 1105 return 0;
1050} 1106}
1051 1107
1052void KOListView::defaultItemAction(QListViewItem *i) 1108void KOListView::defaultItemAction(QListViewItem *i)
1053{ 1109{
1054 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1110 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1055 if ( item ) defaultAction( item->data() ); 1111 if ( item ) defaultAction( item->data() );
1056 1112
1057} 1113}
1058 1114
1059void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1115void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1060{ 1116{
1061 mActiveItem = (KOListViewItem *)item; 1117 mActiveItem = (KOListViewItem *)item;
1062 if (mActiveItem) { 1118 if (mActiveItem) {
1063 Incidence *incidence = mActiveItem->data(); 1119 Incidence *incidence = mActiveItem->data();
1064 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1120 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1065 mPopupMenu->showIncidencePopup(incidence); 1121 mPopupMenu->showIncidencePopup(incidence);
1066 1122
1067 /* 1123 /*
1068 if ( incidence && incidence->type() == "Event" ) { 1124 if ( incidence && incidence->type() == "Event" ) {
1069 Event *event = static_cast<Event *>( incidence ); 1125 Event *event = static_cast<Event *>( incidence );
1070 mPopupMenu->showEventPopup(event); 1126 mPopupMenu->showEventPopup(event);
1071 } 1127 }
1072 */ 1128 */
1073 } 1129 }
1074} 1130}
1075 1131
1076void KOListView::readSettings(KConfig *config, QString setting) 1132void KOListView::readSettings(KConfig *config, QString setting)
1077{ 1133{
1078 // qDebug("KOListView::readSettings "); 1134 // qDebug("KOListView::readSettings ");
1079 mListView->restoreLayout(config,setting); 1135 mListView->restoreLayout(config,setting);
1080} 1136}
1081 1137
1082void KOListView::writeSettings(KConfig *config, QString setting) 1138void KOListView::writeSettings(KConfig *config, QString setting)
1083{ 1139{
1084 // qDebug("KOListView::writeSettings "); 1140 // qDebug("KOListView::writeSettings ");
1085 mListView->saveLayout(config, setting); 1141 mListView->saveLayout(config, setting);
1086} 1142}
1087 1143
1088void KOListView::processSelectionChange(QListViewItem *) 1144void KOListView::processSelectionChange(QListViewItem *)
1089{ 1145{
1090 1146
1091 KOListViewItem *item = 1147 KOListViewItem *item =
1092 static_cast<KOListViewItem *>( mListView->currentItem() ); 1148 static_cast<KOListViewItem *>( mListView->currentItem() );
1093 1149
1094 if ( !item ) { 1150 if ( !item ) {
1095 emit incidenceSelected( 0 ); 1151 emit incidenceSelected( 0 );
1096 } else { 1152 } else {
1097 emit incidenceSelected( item->data() ); 1153 emit incidenceSelected( item->data() );
1098 } 1154 }
1099} 1155}
1100 1156
1101void KOListView::clearSelection() 1157void KOListView::clearSelection()
1102{ 1158{
1103 mListView->selectAll( false ); 1159 mListView->selectAll( false );
1104} 1160}
1105void KOListView::allSelection() 1161void KOListView::allSelection()
1106{ 1162{
1107 mListView->selectAll( true ); 1163 mListView->selectAll( true );
1108} 1164}
1109 1165
1110void KOListView::clear() 1166void KOListView::clear()
1111{ 1167{
1112 mListView->clear(); 1168 mListView->clear();
1113 mUidDict.clear(); 1169 mUidDict.clear();
1114} 1170}
1115 1171
1116Incidence* KOListView::currentItem() 1172Incidence* KOListView::currentItem()
1117{ 1173{
1118 if ( mListView->currentItem() ) 1174 if ( mListView->currentItem() )
1119 return ((KOListViewItem*) mListView->currentItem())->data(); 1175 return ((KOListViewItem*) mListView->currentItem())->data();
1120 return 0; 1176 return 0;
1121} 1177}
1122void KOListView::keyPressEvent ( QKeyEvent *e) 1178void KOListView::keyPressEvent ( QKeyEvent *e)
1123{ 1179{
1124 1180
1125 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1181 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1126 deleteAll(); 1182 deleteAll();
1127 return; 1183 return;
1128 } 1184 }
1129 1185
1130 e->ignore(); 1186 e->ignore();
1131} 1187}
1132void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1188void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1133{ 1189{
1134 1190
1135 switch ( e->key() ) { 1191 switch ( e->key() ) {
1136 case Qt::Key_Down: 1192 case Qt::Key_Down:
1137 if ( e->state() == ShiftButton ) { 1193 if ( e->state() == ShiftButton ) {
1138 QListViewItem* cn = currentItem(); 1194 QListViewItem* cn = currentItem();
1139 if ( !cn ) 1195 if ( !cn )
1140 cn = firstChild(); 1196 cn = firstChild();
1141 if ( !cn ) 1197 if ( !cn )
1142 return; 1198 return;
1143 while ( cn->nextSibling() ) 1199 while ( cn->nextSibling() )
1144 cn = cn->nextSibling(); 1200 cn = cn->nextSibling();
1145 setCurrentItem ( cn ); 1201 setCurrentItem ( cn );
1146 ensureItemVisible ( cn ); 1202 ensureItemVisible ( cn );
1147 1203
1148 e->accept(); 1204 e->accept();
1149 return; 1205 return;
1150 } 1206 }
1151 if ( e->state() == ControlButton ) { 1207 if ( e->state() == ControlButton ) {
1152 int count = childCount (); 1208 int count = childCount ();
1153 int jump = count / 5; 1209 int jump = count / 5;
1154 QListViewItem* cn; 1210 QListViewItem* cn;
1155 cn = currentItem(); 1211 cn = currentItem();
1156 if ( ! cn ) 1212 if ( ! cn )
1157 return; 1213 return;
1158 if ( jump == 0 ) 1214 if ( jump == 0 )
1159 jump = 1; 1215 jump = 1;
1160 while ( jump && cn->nextSibling() ) { 1216 while ( jump && cn->nextSibling() ) {
1161 cn = cn->nextSibling(); 1217 cn = cn->nextSibling();
1162 --jump; 1218 --jump;
1163 } 1219 }
1164 setCurrentItem ( cn ); 1220 setCurrentItem ( cn );
1165 ensureItemVisible ( cn ); 1221 ensureItemVisible ( cn );
1166 1222
1167 } else 1223 } else
1168 QListView::keyPressEvent ( e ) ; 1224 QListView::keyPressEvent ( e ) ;
1169 e->accept(); 1225 e->accept();
1170 break; 1226 break;
1171 1227
1172 case Qt::Key_Up: 1228 case Qt::Key_Up:
1173 if ( e->state() == ShiftButton ) { 1229 if ( e->state() == ShiftButton ) {
1174 QListViewItem* cn = firstChild(); 1230 QListViewItem* cn = firstChild();
1175 if ( cn ) { 1231 if ( cn ) {
1176 setCurrentItem ( cn ); 1232 setCurrentItem ( cn );
1177 ensureItemVisible ( cn ); 1233 ensureItemVisible ( cn );
1178 } 1234 }
1179 e->accept(); 1235 e->accept();
1180 return; 1236 return;
1181 } 1237 }
1182 if ( e->state() == ControlButton ) { 1238 if ( e->state() == ControlButton ) {
1183 int count = childCount (); 1239 int count = childCount ();
1184 int jump = count / 5; 1240 int jump = count / 5;
1185 QListViewItem* cn; 1241 QListViewItem* cn;
1186 cn = currentItem(); 1242 cn = currentItem();
1187 if ( ! cn ) 1243 if ( ! cn )
1188 return; 1244 return;
1189 if ( jump == 0 ) 1245 if ( jump == 0 )
1190 jump = 1; 1246 jump = 1;
1191 while ( jump && cn->itemAbove ()) { 1247 while ( jump && cn->itemAbove ()) {
1192 cn = cn->itemAbove (); 1248 cn = cn->itemAbove ();
1193 --jump; 1249 --jump;
1194 } 1250 }
1195 setCurrentItem ( cn ); 1251 setCurrentItem ( cn );
1196 ensureItemVisible ( cn ); 1252 ensureItemVisible ( cn );
1197 } else 1253 } else
1198 QListView::keyPressEvent ( e ) ; 1254 QListView::keyPressEvent ( e ) ;
1199 e->accept(); 1255 e->accept();
1200 break; 1256 break;
1201 case Qt::Key_I: { 1257 case Qt::Key_I: {
1202 QListViewItem* cn; 1258 QListViewItem* cn;
1203 cn = currentItem(); 1259 cn = currentItem();
1204 if ( cn ) { 1260 if ( cn ) {
1205 KOListViewItem* ci = (KOListViewItem*)( cn ); 1261 KOListViewItem* ci = (KOListViewItem*)( cn );
1206 if ( ci ){ 1262 if ( ci ){
1207 //emit showIncidence( ci->data()); 1263 //emit showIncidence( ci->data());
1208 cn = cn->nextSibling(); 1264 cn = cn->nextSibling();
1209 if ( cn ) { 1265 if ( cn ) {
1210 setCurrentItem ( cn ); 1266 setCurrentItem ( cn );
1211 ensureItemVisible ( cn ); 1267 ensureItemVisible ( cn );
1212 } 1268 }
1213 emit showIncidence( ci->data()); 1269 emit showIncidence( ci->data());
1214 } 1270 }
1215 } 1271 }
1216 e->accept(); 1272 e->accept();
1217 } 1273 }
1218 break; 1274 break;
1219 case Qt::Key_Return: 1275 case Qt::Key_Return:
1220 case Qt::Key_Enter: 1276 case Qt::Key_Enter:
1221 { 1277 {
1222 QListViewItem* cn; 1278 QListViewItem* cn;
1223 cn = currentItem(); 1279 cn = currentItem();
1224 if ( cn ) { 1280 if ( cn ) {
1225 KOListViewItem* ci = (KOListViewItem*)( cn ); 1281 KOListViewItem* ci = (KOListViewItem*)( cn );
1226 if ( ci ){ 1282 if ( ci ){
1227 if ( e->state() == ShiftButton ) 1283 if ( e->state() == ShiftButton )
1228 ci->setSelected( false ); 1284 ci->setSelected( false );
1229 else 1285 else
1230 ci->setSelected( true ); 1286 ci->setSelected( true );
1231 cn = cn->nextSibling(); 1287 cn = cn->nextSibling();
1232 if ( cn ) { 1288 if ( cn ) {
1233 setCurrentItem ( cn ); 1289 setCurrentItem ( cn );
1234 ensureItemVisible ( cn ); 1290 ensureItemVisible ( cn );
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 9da5497..d384af0 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -106,213 +106,216 @@ class KOAlarmPrefs : public QDialog
106 106
107 } 107 }
108 108
109 109
110 110
111 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
112 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
113 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
114 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
115 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
117private slots: 117private slots:
118 118
119void pickAlarmSound() 119void pickAlarmSound()
120{ 120{
121 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
122 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
123 //mAlarmSound = ""; 123 //mAlarmSound = "";
124 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
125 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
126 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
127 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
128 } else { 128 } else {
129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
130 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
131 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 bool hasMultiSelection(QListViewItem*); 218 bool hasMultiSelection(QListViewItem*);
219 void printList(); 219 void printList();
220 signals: 220 signals:
221 void newEvent(); 221 void newEvent();
222 void showIncidence( Incidence* ); 222 void showIncidence( Incidence* );
223 public slots: 223 public slots:
224 void popupMenu(); 224 void popupMenu();
225 private: 225 private:
226 QPoint mEventPos; 226 QPoint mEventPos;
227 QPoint mEventGlobalPos; 227 QPoint mEventGlobalPos;
228 QTimer* mPopupTimer; 228 QTimer* mPopupTimer;
229 int mYMousePos; 229 int mYMousePos;
230 void keyPressEvent ( QKeyEvent * ) ; 230 void keyPressEvent ( QKeyEvent * ) ;
231 void contentsMouseDoubleClickEvent(QMouseEvent *e); 231 void contentsMouseDoubleClickEvent(QMouseEvent *e);
232 void contentsMousePressEvent(QMouseEvent *e); 232 void contentsMousePressEvent(QMouseEvent *e);
233 void contentsMouseReleaseEvent(QMouseEvent *e); 233 void contentsMouseReleaseEvent(QMouseEvent *e);
234 void contentsMouseMoveEvent(QMouseEvent *e); 234 void contentsMouseMoveEvent(QMouseEvent *e);
235 bool mMouseDown; 235 bool mMouseDown;
236}; 236};
237 237
238class KOListView : public KOEventView 238class KOListView : public KOEventView
239{ 239{
240 Q_OBJECT 240 Q_OBJECT
241 public: 241 public:
242 KOListView(Calendar *calendar, QWidget *parent = 0, 242 KOListView(Calendar *calendar, QWidget *parent = 0,
243 const char *name = 0); 243 const char *name = 0);
244 ~KOListView(); 244 ~KOListView();
245 245
246 virtual int maxDatesHint(); 246 virtual int maxDatesHint();
247 virtual int currentDateCount(); 247 virtual int currentDateCount();
248 virtual QPtrList<Incidence> selectedIncidences(); 248 virtual QPtrList<Incidence> selectedIncidences();
249 virtual DateList selectedDates(); 249 virtual DateList selectedDates();
250 250
251 void showDates(bool show); 251 void showDates(bool show);
252 Incidence* currentItem(); 252 Incidence* currentItem();
253 void addTodos(QPtrList<Todo> eventList); 253 void addTodos(QPtrList<Todo> eventList);
254 void addJournals(QPtrList<Journal> eventList); 254 void addJournals(QPtrList<Journal> eventList);
255 virtual void printPreview(CalPrinter *calPrinter, 255 virtual void printPreview(CalPrinter *calPrinter,
256 const QDate &, const QDate &); 256 const QDate &, const QDate &);
257 257
258 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void readSettings(KConfig *config, QString setting = "KOListView Layout");
259 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 259 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
260 void updateList(); 260 void updateList();
261 void clearList(); 261 void clearList();
262 void setStartDate(const QDate &start); 262 void setStartDate(const QDate &start);
263 int count(); 263 int count();
264 QString getWhatsThisText(QPoint p); 264 QString getWhatsThisText(QPoint p);
265 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); 265 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
266 signals: 266 signals:
267 void signalNewEvent(); 267 void signalNewEvent();
268 void beamIncidenceList(QPtrList<Incidence>); 268 void beamIncidenceList(QPtrList<Incidence>);
269 269
270 public slots: 270 public slots:
271 void hideAll(); 271 void hideAll();
272 void printList(); 272 void printList();
273 void resetFocus(); 273 void resetFocus();
274 virtual void updateView(); 274 virtual void updateView();
275 virtual void showDates(const QDate &start, const QDate &end); 275 virtual void showDates(const QDate &start, const QDate &end);
276 virtual void showEvents(QPtrList<Event> eventList); 276 virtual void showEvents(QPtrList<Event> eventList);
277 void clearSelection(); 277 void clearSelection();
278 void allSelection(); 278 void allSelection();
279 279
280 void clear(); 280 void clear();
281 void beamDone( Ir *ir ); 281 void beamDone( Ir *ir );
282 void showDates(); 282 void showDates();
283 void hideDates(); 283 void hideDates();
284 void deleteAll(); 284 void deleteAll();
285 void saveToFile(); 285 void saveToFile();
286 void saveToFileVCS(); 286 void saveToFileVCS();
287 void saveDescriptionToFile(); 287 void saveDescriptionToFile();
288 void beamSelected(); 288 void beamSelected();
289 void updateConfig(); 289 void updateConfig();
290 void addCat(); 290 void addCat();
291 void setCat(); 291 void setCat();
292 void setAlarm(); 292 void setAlarm();
293 void setCategories( bool removeOld ); 293 void setCategories( bool removeOld );
294 void changeEventDisplay(Event *, int); 294 void changeEventDisplay(Event *, int);
295 295
296 void defaultItemAction(QListViewItem *item); 296 void defaultItemAction(QListViewItem *item);
297 void popupMenu(QListViewItem *item,const QPoint &,int); 297 void popupMenu(QListViewItem *item,const QPoint &,int);
298 void setCalendar( int c );
299 void populateCalPopup();
298 300
299 protected slots: 301 protected slots:
300 void processSelectionChange(QListViewItem *); 302 void processSelectionChange(QListViewItem *);
301 303
302 protected: 304 protected:
303 void writeToFile( bool iCal ); 305 void writeToFile( bool iCal );
304 void addEvents(QPtrList<Event> eventList); 306 void addEvents(QPtrList<Event> eventList);
305 void addIncidence(Incidence *); 307 void addIncidence(Incidence *);
306 KOListViewItem *getItemForEvent(Event *event); 308 KOListViewItem *getItemForEvent(Incidence *event);
307 309
308 private: 310 private:
311 QPopupMenu* mCalPopup;
309 KOListViewWhatsThis *mKOListViewWhatsThis; 312 KOListViewWhatsThis *mKOListViewWhatsThis;
310 KOListViewListView *mListView; 313 KOListViewListView *mListView;
311 KOEventPopupMenu *mPopupMenu; 314 KOEventPopupMenu *mPopupMenu;
312 KOListViewItem *mActiveItem; 315 KOListViewItem *mActiveItem;
313 QDict<Incidence> mUidDict; 316 QDict<Incidence> mUidDict;
314 QDate mStartDate; 317 QDate mStartDate;
315 void keyPressEvent ( QKeyEvent * ) ; 318 void keyPressEvent ( QKeyEvent * ) ;
316}; 319};
317 320
318#endif 321#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 65f0342..a4ea3d3 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -306,290 +306,294 @@ KOPrefs::KOPrefs() :
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406 406
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 KConfig fc (locateLocal("config","kopicalendarrc")); 439 KConfig fc (locateLocal("config","kopicalendarrc"));
440 fc.setGroup("CC"); 440 fc.setGroup("CC");
441 int numCals = fc.readNumEntry("NumberCalendars",0 ); 441 int numCals = fc.readNumEntry("NumberCalendars",0 );
442 mNextAvailableCalendar = 1; 442 mNextAvailableCalendar = 1;
443 if ( numCals == 0 ) { 443 if ( numCals == 0 ) {
444 KopiCalendarFile *kkf = getNewCalendar(); 444 KopiCalendarFile *kkf = getNewCalendar();
445 kkf->isStandard = true; 445 kkf->isStandard = true;
446 kkf->mName = i18n("Standard"); 446 kkf->mName = i18n("Standard");
447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
448 } 448 }
449 while ( mNextAvailableCalendar <= numCals ) { 449 while ( mNextAvailableCalendar <= numCals ) {
450 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 450 //qDebug("Read cal #%d ", mNextAvailableCalendar );
451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
452 KopiCalendarFile *kkf = getNewCalendar(); 452 KopiCalendarFile *kkf = getNewCalendar();
453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
460 if ( kkf->mCalNumber == 1 ) { 460 if ( kkf->mCalNumber == 1 ) {
461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
462 } 462 }
463 } 463 }
464 464
465 KPimPrefs::usrReadConfig(); 465 KPimPrefs::usrReadConfig();
466} 466}
467 467
468KopiCalendarFile * KOPrefs::getCalendar( int num ) 468KopiCalendarFile * KOPrefs::getCalendar( int num )
469{ 469{
470 return mDefCalColors[num-1]; 470 return mDefCalColors[num-1];
471} 471}
472 472
473KopiCalendarFile * KOPrefs::getNewCalendar() 473KopiCalendarFile * KOPrefs::getNewCalendar()
474{ 474{
475 KopiCalendarFile * kkf = new KopiCalendarFile(); 475 KopiCalendarFile * kkf = new KopiCalendarFile();
476 kkf->mCalNumber = mNextAvailableCalendar; 476 kkf->mCalNumber = mNextAvailableCalendar;
477 mDefCalColors.resize( mNextAvailableCalendar ); 477 mDefCalColors.resize( mNextAvailableCalendar );
478 mDefCalColors[mNextAvailableCalendar-1] = kkf; 478 mDefCalColors[mNextAvailableCalendar-1] = kkf;
479 ++mNextAvailableCalendar; 479 ++mNextAvailableCalendar;
480 kkf->mDefaultColor = mEventColor; 480 kkf->mDefaultColor = mEventColor;
481 kkf->mName = i18n("New Calendar"); 481 kkf->mName = i18n("New Calendar");
482 mCalendars.append( kkf ); 482 mCalendars.append( kkf );
483 return kkf; 483 return kkf;
484} 484}
485void KOPrefs::deleteCalendar( int num ) 485void KOPrefs::deleteCalendar( int num )
486{ 486{
487 KopiCalendarFile * kkf = mCalendars.first(); 487 KopiCalendarFile * kkf = mCalendars.first();
488 while ( kkf ) { 488 while ( kkf ) {
489 if ( kkf->mCalNumber == num ) { 489 if ( kkf->mCalNumber == num ) {
490 qDebug("KOPrefs::deleteCalendar %d ", num ); 490 qDebug("KOPrefs::deleteCalendar %d ", num );
491 mCalendars.remove( kkf ); 491 mCalendars.remove( kkf );
492 delete kkf; 492 delete kkf;
493 return; 493 return;
494 } 494 }
495 kkf = mCalendars.next(); 495 kkf = mCalendars.next();
496 } 496 }
497} 497}
498QString KOPrefs::calName( int calNum) const
499{
500 return (mDefCalColors[calNum-1])->mName;
501}
498QColor KOPrefs::defaultColor( int calNum ) const 502QColor KOPrefs::defaultColor( int calNum ) const
499{ 503{
500 if ( calNum == 1 ) return mEventColor; 504 if ( calNum == 1 ) return mEventColor;
501 return (mDefCalColors[calNum-1])->mDefaultColor; 505 return (mDefCalColors[calNum-1])->mDefaultColor;
502} 506}
503void KOPrefs::usrWriteConfig() 507void KOPrefs::usrWriteConfig()
504{ 508{
505 config()->setGroup("General"); 509 config()->setGroup("General");
506 config()->writeEntry("Custom Categories",mCustomCategories); 510 config()->writeEntry("Custom Categories",mCustomCategories);
507 511
508 config()->setGroup("Personal Settings"); 512 config()->setGroup("Personal Settings");
509 config()->writeEntry("user_name",mName); 513 config()->writeEntry("user_name",mName);
510 config()->writeEntry("user_email",mEmail); 514 config()->writeEntry("user_email",mEmail);
511 515
512 config()->setGroup("Category Colors"); 516 config()->setGroup("Category Colors");
513 QDictIterator<QColor> it(mCategoryColors); 517 QDictIterator<QColor> it(mCategoryColors);
514 while (it.current()) { 518 while (it.current()) {
515 config()->writeEntry(it.currentKey(),*(it.current())); 519 config()->writeEntry(it.currentKey(),*(it.current()));
516 ++it; 520 ++it;
517 } 521 }
518 KConfig fc (locateLocal("config","kopicalendarrc")); 522 KConfig fc (locateLocal("config","kopicalendarrc"));
519 fc.setGroup("CC"); 523 fc.setGroup("CC");
520 fc.writeEntry("NumberCalendars",mCalendars.count()); 524 fc.writeEntry("NumberCalendars",mCalendars.count());
521 int numCal = 1; 525 int numCal = 1;
522 int writeCal = 0; 526 int writeCal = 0;
523 while ( numCal < mNextAvailableCalendar ) { 527 while ( numCal < mNextAvailableCalendar ) {
524 KopiCalendarFile * kkf = mCalendars.first(); 528 KopiCalendarFile * kkf = mCalendars.first();
525 while ( kkf ) { 529 while ( kkf ) {
526 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 530 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
527 if ( kkf->mCalNumber == numCal ) { 531 if ( kkf->mCalNumber == numCal ) {
528 ++writeCal; 532 ++writeCal;
529 //qDebug("Write calendar %d %d ", numCal , writeCal); 533 //qDebug("Write calendar %d %d ", numCal , writeCal);
530 QString prefix = "Cal_" + QString::number( writeCal ); 534 QString prefix = "Cal_" + QString::number( writeCal );
531 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 535 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
532 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 536 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
533 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 537 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
534 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 538 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
535 fc.writeEntry( prefix+"_Name", kkf->mName); 539 fc.writeEntry( prefix+"_Name", kkf->mName);
536 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 540 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
537 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 541 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
538 } 542 }
539 kkf = mCalendars.next(); 543 kkf = mCalendars.next();
540 } 544 }
541 ++numCal; 545 ++numCal;
542 } 546 }
543 fc.sync(); 547 fc.sync();
544 KPimPrefs::usrWriteConfig(); 548 KPimPrefs::usrWriteConfig();
545} 549}
546 550
547void KOPrefs::setCategoryColor(QString cat,const QColor & color) 551void KOPrefs::setCategoryColor(QString cat,const QColor & color)
548{ 552{
549 mCategoryColors.replace(cat,new QColor(color)); 553 mCategoryColors.replace(cat,new QColor(color));
550} 554}
551 555
552QColor *KOPrefs::categoryColor(QString cat) 556QColor *KOPrefs::categoryColor(QString cat)
553{ 557{
554 QColor *color = 0; 558 QColor *color = 0;
555 559
556 if (!cat.isEmpty()) color = mCategoryColors[cat]; 560 if (!cat.isEmpty()) color = mCategoryColors[cat];
557 561
558 if (color) return color; 562 if (color) return color;
559 else return &mDefaultCategoryColor; 563 else return &mDefaultCategoryColor;
560} 564}
561 565
562void KOPrefs::setFullName(const QString &name) 566void KOPrefs::setFullName(const QString &name)
563{ 567{
564 mName = name; 568 mName = name;
565} 569}
566 570
567void KOPrefs::setEmail(const QString &email) 571void KOPrefs::setEmail(const QString &email)
568{ 572{
569 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 573 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
570 mEmail = email; 574 mEmail = email;
571} 575}
572 576
573QString KOPrefs::fullName() 577QString KOPrefs::fullName()
574{ 578{
575 if (mEmailControlCenter) { 579 if (mEmailControlCenter) {
576 KEMailSettings settings; 580 KEMailSettings settings;
577 return settings.getSetting(KEMailSettings::RealName); 581 return settings.getSetting(KEMailSettings::RealName);
578 } else { 582 } else {
579 return mName; 583 return mName;
580 } 584 }
581} 585}
582 586
583QString KOPrefs::email() 587QString KOPrefs::email()
584{ 588{
585 if (mEmailControlCenter) { 589 if (mEmailControlCenter) {
586 KEMailSettings settings; 590 KEMailSettings settings;
587 return settings.getSetting(KEMailSettings::EmailAddress); 591 return settings.getSetting(KEMailSettings::EmailAddress);
588 } else { 592 } else {
589 return mEmail; 593 return mEmail;
590 } 594 }
591} 595}
592KConfig* KOPrefs::getConfig() 596KConfig* KOPrefs::getConfig()
593{ 597{
594 return config(); 598 return config();
595} 599}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 463fc33..5cc9bfa 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,293 +1,294 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mCalNumber = 0; 57 mCalNumber = 0;
58 mDefaultColor = Qt::red; 58 mDefaultColor = Qt::red;
59 mErrorOnLoad = false; 59 mErrorOnLoad = false;
60 } 60 }
61 bool isStandard; 61 bool isStandard;
62 bool isEnabled; 62 bool isEnabled;
63 bool isAlarmEnabled; 63 bool isAlarmEnabled;
64 bool isReadOnly; 64 bool isReadOnly;
65 bool mErrorOnLoad; 65 bool mErrorOnLoad;
66 QString mName; 66 QString mName;
67 QString mFileName; 67 QString mFileName;
68 int mCalNumber; 68 int mCalNumber;
69 QColor mDefaultColor; 69 QColor mDefaultColor;
70 QDateTime mLoadDt; 70 QDateTime mLoadDt;
71}; 71};
72class KOPrefs : public KPimPrefs 72class KOPrefs : public KPimPrefs
73{ 73{
74 public: 74 public:
75 enum { FormatVCalendar, FormatICalendar }; 75 enum { FormatVCalendar, FormatICalendar };
76 enum { MailClientKMail, MailClientSendmail }; 76 enum { MailClientKMail, MailClientSendmail };
77 enum { IMIPDummy, IMIPKMail }; 77 enum { IMIPDummy, IMIPKMail };
78 enum { IMIPOutbox, IMIPdirectsend }; 78 enum { IMIPOutbox, IMIPdirectsend };
79 enum { neverAuto, addressbookAuto, selectedAuto }; 79 enum { neverAuto, addressbookAuto, selectedAuto };
80 enum { standardDestination, askDestination }; 80 enum { standardDestination, askDestination };
81 81
82 virtual ~KOPrefs(); 82 virtual ~KOPrefs();
83 83
84 /** Get instance of KOPrefs. It is made sure that there is only one 84 /** Get instance of KOPrefs. It is made sure that there is only one
85 instance. */ 85 instance. */
86 static KOPrefs *instance(); 86 static KOPrefs *instance();
87 87
88 /** Set preferences to default values */ 88 /** Set preferences to default values */
89 void usrSetDefaults(); 89 void usrSetDefaults();
90 90
91 /** Read preferences from config file */ 91 /** Read preferences from config file */
92 void usrReadConfig(); 92 void usrReadConfig();
93 93
94 /** Write preferences to config file */ 94 /** Write preferences to config file */
95 void usrWriteConfig(); 95 void usrWriteConfig();
96 void setCategoryDefaults(); 96 void setCategoryDefaults();
97 void setAllDefaults(); 97 void setAllDefaults();
98 KopiCalendarFile * getNewCalendar(); 98 KopiCalendarFile * getNewCalendar();
99 KopiCalendarFile * getCalendar( int ); 99 KopiCalendarFile * getCalendar( int );
100 void deleteCalendar( int ); 100 void deleteCalendar( int );
101 QColor defaultColor( int ) const; 101 QColor defaultColor( int ) const;
102 QString calName( int ) const;
102 protected: 103 protected:
103 void setTimeZoneIdDefault(); 104 void setTimeZoneIdDefault();
104 105
105 /** Fill empty mail fields with default values. */ 106 /** Fill empty mail fields with default values. */
106 void fillMailDefaults(); 107 void fillMailDefaults();
107 108
108 private: 109 private:
109 /** Constructor disabled for public. Use instance() to create a KOPrefs 110 /** Constructor disabled for public. Use instance() to create a KOPrefs
110 object. */ 111 object. */
111 KOPrefs(); 112 KOPrefs();
112 113
113 static KOPrefs *mInstance; 114 static KOPrefs *mInstance;
114 QStringList getDefaultList(); 115 QStringList getDefaultList();
115 QStringList getLocationDefaultList(); 116 QStringList getLocationDefaultList();
116 public: 117 public:
117 // preferences data 118 // preferences data
118 KConfig* getConfig(); 119 KConfig* getConfig();
119 void setFullName(const QString &); 120 void setFullName(const QString &);
120 QString fullName(); 121 QString fullName();
121 void setEmail(const QString &); 122 void setEmail(const QString &);
122 QString email(); 123 QString email();
123 124
124 QString mAdditional; 125 QString mAdditional;
125 126
126 bool mEmailControlCenter; 127 bool mEmailControlCenter;
127 128
128 bool mBcc; 129 bool mBcc;
129 bool mAutoSave; 130 bool mAutoSave;
130 int mAutoSaveInterval; 131 int mAutoSaveInterval;
131 bool mConfirm; 132 bool mConfirm;
132 133
133 bool mEnableGroupScheduling; 134 bool mEnableGroupScheduling;
134 bool mEnableProjectView; 135 bool mEnableProjectView;
135 136
136 int mDefaultFormat; 137 int mDefaultFormat;
137 int mMailClient; 138 int mMailClient;
138 139
139 int mStartTime; 140 int mStartTime;
140 int mDefaultDuration; 141 int mDefaultDuration;
141 int mAlarmTime; 142 int mAlarmTime;
142 143
143 int mWorkingHoursStart; 144 int mWorkingHoursStart;
144 int mWorkingHoursEnd; 145 int mWorkingHoursEnd;
145 bool mExcludeHolidays; 146 bool mExcludeHolidays;
146 bool mExcludeSaturdays; 147 bool mExcludeSaturdays;
147 bool mMarcusBainsShowSeconds; 148 bool mMarcusBainsShowSeconds;
148 149
149 QFont mTimeBarFont; 150 QFont mTimeBarFont;
150 QFont mMonthViewFont; 151 QFont mMonthViewFont;
151 QFont mAgendaViewFont; 152 QFont mAgendaViewFont;
152 QFont mMarcusBainsFont; 153 QFont mMarcusBainsFont;
153 QFont mTimeLabelsFont; 154 QFont mTimeLabelsFont;
154 QFont mTodoViewFont; 155 QFont mTodoViewFont;
155 QFont mListViewFont; 156 QFont mListViewFont;
156 QFont mDateNavigatorFont; 157 QFont mDateNavigatorFont;
157 QFont mEditBoxFont; 158 QFont mEditBoxFont;
158 QFont mJornalViewFont; 159 QFont mJornalViewFont;
159 QFont mWhatsNextFont; 160 QFont mWhatsNextFont;
160 QFont mEventViewFont; 161 QFont mEventViewFont;
161 162
162 163
163 164
164 165
165 QColor mHolidayColor; 166 QColor mHolidayColor;
166 QColor mHighlightColor; 167 QColor mHighlightColor;
167 QColor mEventColor; 168 QColor mEventColor;
168 QColor mTodoDoneColor; 169 QColor mTodoDoneColor;
169 QColor mAgendaBgColor; 170 QColor mAgendaBgColor;
170 QColor mWorkingHoursColor; 171 QColor mWorkingHoursColor;
171 QColor mTodoDueTodayColor; 172 QColor mTodoDueTodayColor;
172 QColor mTodoOverdueColor; 173 QColor mTodoOverdueColor;
173 QColor mTodoRunColor; 174 QColor mTodoRunColor;
174 QColor mMonthViewEvenColor; 175 QColor mMonthViewEvenColor;
175 QColor mMonthViewOddColor; 176 QColor mMonthViewOddColor;
176 QColor mMonthViewHolidayColor; 177 QColor mMonthViewHolidayColor;
177 bool mMonthViewUsesDayColors; 178 bool mMonthViewUsesDayColors;
178 bool mMonthViewSatSunTog; 179 bool mMonthViewSatSunTog;
179 bool mMonthViewWeek; 180 bool mMonthViewWeek;
180 QColor mAppColor1; 181 QColor mAppColor1;
181 QColor mAppColor2; 182 QColor mAppColor2;
182 bool mUseAppColors; 183 bool mUseAppColors;
183 184
184 int mDayBegins; 185 int mDayBegins;
185 int mHourSize; 186 int mHourSize;
186 int mAllDaySize; 187 int mAllDaySize;
187 bool mShowFullMenu; 188 bool mShowFullMenu;
188 bool mDailyRecur; 189 bool mDailyRecur;
189 bool mWeeklyRecur; 190 bool mWeeklyRecur;
190 bool mMonthDailyRecur; 191 bool mMonthDailyRecur;
191 bool mMonthWeeklyRecur; 192 bool mMonthWeeklyRecur;
192 bool mMonthShowIcons; 193 bool mMonthShowIcons;
193 bool mMonthShowTimes; 194 bool mMonthShowTimes;
194 bool mMonthShowShort; 195 bool mMonthShowShort;
195 bool mEnableToolTips; 196 bool mEnableToolTips;
196 bool mEnableMonthScroll; 197 bool mEnableMonthScroll;
197 bool mFullViewMonth; 198 bool mFullViewMonth;
198 bool mMonthViewUsesCategoryColor; 199 bool mMonthViewUsesCategoryColor;
199 bool mFullViewTodo; 200 bool mFullViewTodo;
200 bool mShowCompletedTodo; 201 bool mShowCompletedTodo;
201 bool mMarcusBainsEnabled; 202 bool mMarcusBainsEnabled;
202 int mNextXDays; 203 int mNextXDays;
203 int mWhatsNextDays; 204 int mWhatsNextDays;
204 int mWhatsNextPrios; 205 int mWhatsNextPrios;
205 bool mEnableQuickTodo; 206 bool mEnableQuickTodo;
206 207
207 bool mCompactDialogs; 208 bool mCompactDialogs;
208 bool mVerticalScreen; 209 bool mVerticalScreen;
209 210
210 bool mShowIconNewTodo; 211 bool mShowIconNewTodo;
211 bool mShowIconNewEvent; 212 bool mShowIconNewEvent;
212 bool mShowIconSearch; 213 bool mShowIconSearch;
213 bool mShowIconList; 214 bool mShowIconList;
214 bool mShowIconDay1; 215 bool mShowIconDay1;
215 bool mShowIconDay5; 216 bool mShowIconDay5;
216 bool mShowIconDay6; 217 bool mShowIconDay6;
217 bool mShowIconDay7; 218 bool mShowIconDay7;
218 bool mShowIconMonth; 219 bool mShowIconMonth;
219 bool mShowIconTodoview; 220 bool mShowIconTodoview;
220 bool mShowIconBackFast; 221 bool mShowIconBackFast;
221 bool mShowIconBack; 222 bool mShowIconBack;
222 bool mShowIconToday; 223 bool mShowIconToday;
223 bool mShowIconForward; 224 bool mShowIconForward;
224 bool mShowIconForwardFast; 225 bool mShowIconForwardFast;
225 bool mShowIconWhatsThis; 226 bool mShowIconWhatsThis;
226 bool mShowIconWeekNum; 227 bool mShowIconWeekNum;
227 bool mShowIconNextDays; 228 bool mShowIconNextDays;
228 bool mShowIconNext; 229 bool mShowIconNext;
229 bool mShowIconJournal; 230 bool mShowIconJournal;
230 bool mShowIconFilter; 231 bool mShowIconFilter;
231 bool mShowIconOnetoolbar; 232 bool mShowIconOnetoolbar;
232 bool mShowIconNavigator; 233 bool mShowIconNavigator;
233 bool mShowIconAllday; 234 bool mShowIconAllday;
234 bool mShowIconFilterview; 235 bool mShowIconFilterview;
235 bool mShowIconToggleFull; 236 bool mShowIconToggleFull;
236 237
237 bool mShowIconStretch; 238 bool mShowIconStretch;
238 239
239 bool mToolBarHor; 240 bool mToolBarHor;
240 bool mToolBarUp; 241 bool mToolBarUp;
241 bool mToolBarHorV; 242 bool mToolBarHorV;
242 bool mToolBarUpV; 243 bool mToolBarUpV;
243 bool mToolBarHorN; 244 bool mToolBarHorN;
244 bool mToolBarUpN; 245 bool mToolBarUpN;
245 bool mToolBarHorF; 246 bool mToolBarHorF;
246 bool mToolBarUpF; 247 bool mToolBarUpF;
247 bool mToolBarMiniIcons; 248 bool mToolBarMiniIcons;
248 249
249 bool mAskForQuit; 250 bool mAskForQuit;
250 bool mUsePassWd; 251 bool mUsePassWd;
251 bool mShowSyncEvents; 252 bool mShowSyncEvents;
252 bool mShowTodoInAgenda; 253 bool mShowTodoInAgenda;
253 bool mShowCompletedTodoInAgenda; 254 bool mShowCompletedTodoInAgenda;
254 bool mShowTimeInAgenda; 255 bool mShowTimeInAgenda;
255 bool mHideNonStartedTodos; 256 bool mHideNonStartedTodos;
256 257
257 bool mBlockPopupMenu; 258 bool mBlockPopupMenu;
258 259
259 int mLastSyncTime; 260 int mLastSyncTime;
260 void setCategoryColor(QString cat,const QColor & color); 261 void setCategoryColor(QString cat,const QColor & color);
261 QColor *categoryColor(QString cat); 262 QColor *categoryColor(QString cat);
262 263
263 QString mArchiveFile; 264 QString mArchiveFile;
264 QString mHtmlExportFile; 265 QString mHtmlExportFile;
265 bool mHtmlWithSave; 266 bool mHtmlWithSave;
266 267
267 QStringList mSelectedPlugins; 268 QStringList mSelectedPlugins;
268 269
269 QString mLastImportFile; 270 QString mLastImportFile;
270 QString mLastVcalFile; 271 QString mLastVcalFile;
271 QString mLastSaveFile; 272 QString mLastSaveFile;
272 QString mLastLoadFile; 273 QString mLastLoadFile;
273 274
274 275
275 QString mDefaultAlarmFile; 276 QString mDefaultAlarmFile;
276 int mIMIPScheduler; 277 int mIMIPScheduler;
277 int mIMIPSend; 278 int mIMIPSend;
278 QStringList mAdditionalMails; 279 QStringList mAdditionalMails;
279 int mIMIPAutoRefresh; 280 int mIMIPAutoRefresh;
280 int mIMIPAutoInsertReply; 281 int mIMIPAutoInsertReply;
281 int mIMIPAutoInsertRequest; 282 int mIMIPAutoInsertRequest;
282 int mIMIPAutoFreeBusy; 283 int mIMIPAutoFreeBusy;
283 int mIMIPAutoFreeBusyReply; 284 int mIMIPAutoFreeBusyReply;
284 285
285 QStringList mTodoTemplates; 286 QStringList mTodoTemplates;
286 QStringList mEventTemplates; 287 QStringList mEventTemplates;
287 288
288 int mDestination; 289 int mDestination;
289 290
290 291
291 bool mEditOnDoubleClick; 292 bool mEditOnDoubleClick;
292 bool mViewChangeHoldFullscreen; 293 bool mViewChangeHoldFullscreen;
293 bool mViewChangeHoldNonFullscreen; 294 bool mViewChangeHoldNonFullscreen;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2243e28..3b7b183 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,270 +1,271 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual void setSyncEventsReadOnly() = 0;
79 80
80 /** 81 /**
81 Sync changes in memory to persistant storage. 82 Sync changes in memory to persistant storage.
82 */ 83 */
83 virtual void save() = 0; 84 virtual void save() = 0;
84 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 85 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
85 virtual void removeSyncInfo( QString syncProfile) = 0; 86 virtual void removeSyncInfo( QString syncProfile) = 0;
86 virtual bool isSaving() { return false; } 87 virtual bool isSaving() { return false; }
87 88
88 /** 89 /**
89 Return the owner of the calendar's full name. 90 Return the owner of the calendar's full name.
90 */ 91 */
91 const QString &getOwner() const; 92 const QString &getOwner() const;
92 /** 93 /**
93 Set the owner of the calendar. Should be owner's full name. 94 Set the owner of the calendar. Should be owner's full name.
94 */ 95 */
95 void setOwner( const QString &os ); 96 void setOwner( const QString &os );
96 /** 97 /**
97 Return the email address of the calendar owner. 98 Return the email address of the calendar owner.
98 */ 99 */
99 const QString &getEmail(); 100 const QString &getEmail();
100 /** 101 /**
101 Set the email address of the calendar owner. 102 Set the email address of the calendar owner.
102 */ 103 */
103 void setEmail( const QString & ); 104 void setEmail( const QString & );
104 105
105 /** 106 /**
106 Set time zone from a timezone string (e.g. -2:00) 107 Set time zone from a timezone string (e.g. -2:00)
107 */ 108 */
108 void setTimeZone( const QString &tz ); 109 void setTimeZone( const QString &tz );
109 /** 110 /**
110 Set time zone from a minutes value (e.g. -60) 111 Set time zone from a minutes value (e.g. -60)
111 */ 112 */
112 void setTimeZone( int tz ); 113 void setTimeZone( int tz );
113 /** 114 /**
114 Return time zone as offest in minutes. 115 Return time zone as offest in minutes.
115 */ 116 */
116 int getTimeZone() const; 117 int getTimeZone() const;
117 /** 118 /**
118 Compute an ISO 8601 format string from the time zone. 119 Compute an ISO 8601 format string from the time zone.
119 */ 120 */
120 QString getTimeZoneStr() const; 121 QString getTimeZoneStr() const;
121 /** 122 /**
122 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 123 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
123 values). 124 values).
124 */ 125 */
125 void setTimeZoneId( const QString & ); 126 void setTimeZoneId( const QString & );
126 /** 127 /**
127 Return time zone id. 128 Return time zone id.
128 */ 129 */
129 QString timeZoneId() const; 130 QString timeZoneId() const;
130 /** 131 /**
131 Use local time, not UTC or a time zone. 132 Use local time, not UTC or a time zone.
132 */ 133 */
133 void setLocalTime(); 134 void setLocalTime();
134 /** 135 /**
135 Return whether local time is being used. 136 Return whether local time is being used.
136 */ 137 */
137 bool isLocalTime() const; 138 bool isLocalTime() const;
138 139
139 /** 140 /**
140 Add an incidence to calendar. 141 Add an incidence to calendar.
141 142
142 @return true on success, false on error. 143 @return true on success, false on error.
143 */ 144 */
144 virtual bool addIncidence( Incidence * ); 145 virtual bool addIncidence( Incidence * );
145 146
146 // Adds an incidence and all relatedto incidences to the cal 147 // Adds an incidence and all relatedto incidences to the cal
147 void addIncidenceBranch( Incidence * ); 148 void addIncidenceBranch( Incidence * );
148 /** 149 /**
149 Return filtered list of all incidences of this calendar. 150 Return filtered list of all incidences of this calendar.
150 */ 151 */
151 virtual QPtrList<Incidence> incidences(); 152 virtual QPtrList<Incidence> incidences();
152 153
153 /** 154 /**
154 Return unfiltered list of all incidences of this calendar. 155 Return unfiltered list of all incidences of this calendar.
155 */ 156 */
156 virtual QPtrList<Incidence> rawIncidences(); 157 virtual QPtrList<Incidence> rawIncidences();
157 158
158 /** 159 /**
159 Adds a Event to this calendar object. 160 Adds a Event to this calendar object.
160 @param anEvent a pointer to the event to add 161 @param anEvent a pointer to the event to add
161 162
162 @return true on success, false on error. 163 @return true on success, false on error.
163 */ 164 */
164 virtual bool addEventNoDup( Event *event ) = 0; 165 virtual bool addEventNoDup( Event *event ) = 0;
165 virtual bool addAnniversaryNoDup( Event *event ) = 0; 166 virtual bool addAnniversaryNoDup( Event *event ) = 0;
166 virtual bool addEvent( Event *anEvent ) = 0; 167 virtual bool addEvent( Event *anEvent ) = 0;
167 /** 168 /**
168 Delete event from calendar. 169 Delete event from calendar.
169 */ 170 */
170 virtual void deleteEvent( Event * ) = 0; 171 virtual void deleteEvent( Event * ) = 0;
171 /** 172 /**
172 Retrieves an event on the basis of the unique string ID. 173 Retrieves an event on the basis of the unique string ID.
173 */ 174 */
174 virtual Event *event( const QString &UniqueStr ) = 0; 175 virtual Event *event( const QString &UniqueStr ) = 0;
175 virtual Event *event( QString, QString ) = 0; 176 virtual Event *event( QString, QString ) = 0;
176 /** 177 /**
177 Builds and then returns a list of all events that match for the 178 Builds and then returns a list of all events that match for the
178 date specified. useful for dayView, etc. etc. 179 date specified. useful for dayView, etc. etc.
179 The calendar filter is applied. 180 The calendar filter is applied.
180 */ 181 */
181 QPtrList<Event> events( const QDate &date, bool sorted = false); 182 QPtrList<Event> events( const QDate &date, bool sorted = false);
182 /** 183 /**
183 Get events, which occur on the given date. 184 Get events, which occur on the given date.
184 The calendar filter is applied. 185 The calendar filter is applied.
185 */ 186 */
186 QPtrList<Event> events( const QDateTime &qdt ); 187 QPtrList<Event> events( const QDateTime &qdt );
187 /** 188 /**
188 Get events in a range of dates. If inclusive is set to true, only events 189 Get events in a range of dates. If inclusive is set to true, only events
189 are returned, which are completely included in the range. 190 are returned, which are completely included in the range.
190 The calendar filter is applied. 191 The calendar filter is applied.
191 */ 192 */
192 QPtrList<Event> events( const QDate &start, const QDate &end, 193 QPtrList<Event> events( const QDate &start, const QDate &end,
193 bool inclusive = false); 194 bool inclusive = false);
194 /** 195 /**
195 Return filtered list of all events in calendar. 196 Return filtered list of all events in calendar.
196 */ 197 */
197 virtual QPtrList<Event> events(); 198 virtual QPtrList<Event> events();
198 /** 199 /**
199 Return unfiltered list of all events in calendar. 200 Return unfiltered list of all events in calendar.
200 */ 201 */
201 virtual QPtrList<Event> rawEvents() = 0; 202 virtual QPtrList<Event> rawEvents() = 0;
202 203
203 /** 204 /**
204 Add a todo to the todolist. 205 Add a todo to the todolist.
205 206
206 @return true on success, false on error. 207 @return true on success, false on error.
207 */ 208 */
208 virtual bool addTodo( Todo *todo ) = 0; 209 virtual bool addTodo( Todo *todo ) = 0;
209 virtual bool addTodoNoDup( Todo *todo ) = 0; 210 virtual bool addTodoNoDup( Todo *todo ) = 0;
210 /** 211 /**
211 Remove a todo from the todolist. 212 Remove a todo from the todolist.
212 */ 213 */
213 virtual void deleteTodo( Todo * ) = 0; 214 virtual void deleteTodo( Todo * ) = 0;
214 virtual void deleteJournal( Journal * ) = 0; 215 virtual void deleteJournal( Journal * ) = 0;
215 /** 216 /**
216 Return filterd list of todos. 217 Return filterd list of todos.
217 */ 218 */
218 virtual QPtrList<Todo> todos(); 219 virtual QPtrList<Todo> todos();
219 /** 220 /**
220 Searches todolist for an event with this unique string identifier, 221 Searches todolist for an event with this unique string identifier,
221 returns a pointer or null. 222 returns a pointer or null.
222 */ 223 */
223 virtual Todo *todo( const QString &uid ) = 0; 224 virtual Todo *todo( const QString &uid ) = 0;
224 virtual Todo *todo( QString, QString ) = 0; 225 virtual Todo *todo( QString, QString ) = 0;
225 /** 226 /**
226 Returns list of todos due on the specified date. 227 Returns list of todos due on the specified date.
227 */ 228 */
228 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 229 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
229 /** 230 /**
230 Return unfiltered list of todos. 231 Return unfiltered list of todos.
231 */ 232 */
232 virtual QPtrList<Todo> rawTodos() = 0; 233 virtual QPtrList<Todo> rawTodos() = 0;
233 234
234 /** 235 /**
235 Add a Journal entry to calendar. 236 Add a Journal entry to calendar.
236 237
237 @return true on success, false on error. 238 @return true on success, false on error.
238 */ 239 */
239 virtual bool addJournal( Journal * ) = 0; 240 virtual bool addJournal( Journal * ) = 0;
240 /** 241 /**
241 Return Journal for given date. 242 Return Journal for given date.
242 */ 243 */
243 virtual Journal *journal( const QDate & ) = 0; 244 virtual Journal *journal( const QDate & ) = 0;
244 /** 245 /**
245 Return Journal with given UID. 246 Return Journal with given UID.
246 */ 247 */
247 virtual Journal *journal( const QString &UID ) = 0; 248 virtual Journal *journal( const QString &UID ) = 0;
248 /** 249 /**
249 Return list of all Journal entries. 250 Return list of all Journal entries.
250 */ 251 */
251 virtual QPtrList<Journal> journals() = 0; 252 virtual QPtrList<Journal> journals() = 0;
252 253
253 /** 254 /**
254 Searches all incidence types for an incidence with this unique 255 Searches all incidence types for an incidence with this unique
255 string identifier, returns a pointer or null. 256 string identifier, returns a pointer or null.
256 */ 257 */
257 Incidence* incidence( const QString&UID ); 258 Incidence* incidence( const QString&UID );
258 259
259 /** 260 /**
260 Setup relations for an incidence. 261 Setup relations for an incidence.
261 */ 262 */
262 virtual void setupRelations( Incidence * ); 263 virtual void setupRelations( Incidence * );
263 /** 264 /**
264 Remove all relations to an incidence 265 Remove all relations to an incidence
265 */ 266 */
266 virtual void removeRelations( Incidence * ); 267 virtual void removeRelations( Incidence * );
267 268
268 /** 269 /**
269 Set calendar filter, which filters events for the events() functions. 270 Set calendar filter, which filters events for the events() functions.
270 The Filter object is owned by the caller. 271 The Filter object is owned by the caller.
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 336c3e8..8c4dde1 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -1,272 +1,282 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 if ( mDeleteIncidencesOnClose ) 68 if ( mDeleteIncidencesOnClose )
69 close(); 69 close();
70} 70}
71bool CalendarLocal::addCalendarFile( QString name, int id ) 71bool CalendarLocal::addCalendarFile( QString name, int id )
72{ 72{
73 CalendarLocal calendar( timeZoneId() ); 73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id ); 74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) { 75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar ); 76 addCalendar( &calendar );
77 return true; 77 return true;
78 } 78 }
79 return false; 79 return false;
80} 80}
81void CalendarLocal::setSyncEventsReadOnly()
82{
83 Event * ev;
84 ev = mEventList.first();
85 while ( ev ) {
86 if ( ev->uid().left(15) == QString("last-syncEvent-") )
87 ev->setReadOnly( true );
88 ev = mEventList.next();
89 }
90}
81void CalendarLocal::addCalendar( Calendar* cal ) 91void CalendarLocal::addCalendar( Calendar* cal )
82{ 92{
83 cal->setDontDeleteIncidencesOnClose(); 93 cal->setDontDeleteIncidencesOnClose();
84 { 94 {
85 QPtrList<Event> EventList = cal->rawEvents(); 95 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first(); 96 Event * ev = EventList.first();
87 while ( ev ) { 97 while ( ev ) {
88 ev->unRegisterObserver( cal ); 98 ev->unRegisterObserver( cal );
89 ev->registerObserver( this ); 99 ev->registerObserver( this );
90 mEventList.append( ev ); 100 mEventList.append( ev );
91 ev = EventList.next(); 101 ev = EventList.next();
92 } 102 }
93 } 103 }
94 { 104 {
95 105
96 QPtrList<Todo> TodoList = cal->rawTodos(); 106 QPtrList<Todo> TodoList = cal->rawTodos();
97 Todo * ev = TodoList.first(); 107 Todo * ev = TodoList.first();
98 while ( ev ) { 108 while ( ev ) {
99 QString rel = ev->relatedToUid(); 109 QString rel = ev->relatedToUid();
100 if ( !rel.isEmpty() ){ 110 if ( !rel.isEmpty() ){
101 ev->setRelatedTo ( 0 ); 111 ev->setRelatedTo ( 0 );
102 ev->setRelatedToUid( rel ); 112 ev->setRelatedToUid( rel );
103 } 113 }
104 ev = TodoList.next(); 114 ev = TodoList.next();
105 } 115 }
106 //TodoList = cal->rawTodos(); 116 //TodoList = cal->rawTodos();
107 ev = TodoList.first(); 117 ev = TodoList.first();
108 while ( ev ) { 118 while ( ev ) {
109 ev->unRegisterObserver( cal ); 119 ev->unRegisterObserver( cal );
110 ev->registerObserver( this ); 120 ev->registerObserver( this );
111 mTodoList.append( ev ); 121 mTodoList.append( ev );
112 setupRelations( ev ); 122 setupRelations( ev );
113 ev = TodoList.next(); 123 ev = TodoList.next();
114 } 124 }
115 } 125 }
116 { 126 {
117 QPtrList<Journal> JournalList = cal->journals(); 127 QPtrList<Journal> JournalList = cal->journals();
118 Journal * ev = JournalList.first(); 128 Journal * ev = JournalList.first();
119 while ( ev ) { 129 while ( ev ) {
120 ev->unRegisterObserver( cal ); 130 ev->unRegisterObserver( cal );
121 ev->registerObserver( this ); 131 ev->registerObserver( this );
122 mJournalList.append( ev ); 132 mJournalList.append( ev );
123 ev = JournalList.next(); 133 ev = JournalList.next();
124 } 134 }
125 } 135 }
126 setModified( true ); 136 setModified( true );
127} 137}
128bool CalendarLocal::load( const QString &fileName ) 138bool CalendarLocal::load( const QString &fileName )
129{ 139{
130 FileStorage storage( this, fileName ); 140 FileStorage storage( this, fileName );
131 return storage.load(); 141 return storage.load();
132} 142}
133 143
134bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 144bool CalendarLocal::save( const QString &fileName, CalFormat *format )
135{ 145{
136 FileStorage storage( this, fileName, format ); 146 FileStorage storage( this, fileName, format );
137 return storage.save(); 147 return storage.save();
138} 148}
139 149
140void CalendarLocal::close() 150void CalendarLocal::close()
141{ 151{
142 152
143 Todo * i; 153 Todo * i;
144 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 154 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
145 155
146 mEventList.setAutoDelete( true ); 156 mEventList.setAutoDelete( true );
147 mTodoList.setAutoDelete( true ); 157 mTodoList.setAutoDelete( true );
148 mJournalList.setAutoDelete( false ); 158 mJournalList.setAutoDelete( false );
149 159
150 mEventList.clear(); 160 mEventList.clear();
151 mTodoList.clear(); 161 mTodoList.clear();
152 mJournalList.clear(); 162 mJournalList.clear();
153 163
154 mEventList.setAutoDelete( false ); 164 mEventList.setAutoDelete( false );
155 mTodoList.setAutoDelete( false ); 165 mTodoList.setAutoDelete( false );
156 mJournalList.setAutoDelete( false ); 166 mJournalList.setAutoDelete( false );
157 167
158 setModified( false ); 168 setModified( false );
159} 169}
160 170
161bool CalendarLocal::addAnniversaryNoDup( Event *event ) 171bool CalendarLocal::addAnniversaryNoDup( Event *event )
162{ 172{
163 QString cat; 173 QString cat;
164 bool isBirthday = true; 174 bool isBirthday = true;
165 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 175 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
166 isBirthday = false; 176 isBirthday = false;
167 cat = i18n( "Anniversary" ); 177 cat = i18n( "Anniversary" );
168 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 178 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
169 isBirthday = true; 179 isBirthday = true;
170 cat = i18n( "Birthday" ); 180 cat = i18n( "Birthday" );
171 } else { 181 } else {
172 qDebug("addAnniversaryNoDup called without fitting category! "); 182 qDebug("addAnniversaryNoDup called without fitting category! ");
173 return false; 183 return false;
174 } 184 }
175 Event * eve; 185 Event * eve;
176 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 186 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
177 if ( !(eve->categories().contains( cat ) )) 187 if ( !(eve->categories().contains( cat ) ))
178 continue; 188 continue;
179 // now we have an event with fitting category 189 // now we have an event with fitting category
180 if ( eve->dtStart().date() != event->dtStart().date() ) 190 if ( eve->dtStart().date() != event->dtStart().date() )
181 continue; 191 continue;
182 // now we have an event with fitting category+date 192 // now we have an event with fitting category+date
183 if ( eve->summary() != event->summary() ) 193 if ( eve->summary() != event->summary() )
184 continue; 194 continue;
185 // now we have an event with fitting category+date+summary 195 // now we have an event with fitting category+date+summary
186 return false; 196 return false;
187 } 197 }
188 return addEvent( event ); 198 return addEvent( event );
189 199
190} 200}
191bool CalendarLocal::addEventNoDup( Event *event ) 201bool CalendarLocal::addEventNoDup( Event *event )
192{ 202{
193 Event * eve; 203 Event * eve;
194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 204 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
195 if ( *eve == *event ) { 205 if ( *eve == *event ) {
196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 206 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
197 return false; 207 return false;
198 } 208 }
199 } 209 }
200 return addEvent( event ); 210 return addEvent( event );
201} 211}
202 212
203bool CalendarLocal::addEvent( Event *event ) 213bool CalendarLocal::addEvent( Event *event )
204{ 214{
205 insertEvent( event ); 215 insertEvent( event );
206 216
207 event->registerObserver( this ); 217 event->registerObserver( this );
208 218
209 setModified( true ); 219 setModified( true );
210 event->setCalID( mDefaultCalendar ); 220 event->setCalID( mDefaultCalendar );
211 event->setCalEnabled( true ); 221 event->setCalEnabled( true );
212 222
213 return true; 223 return true;
214} 224}
215 225
216void CalendarLocal::deleteEvent( Event *event ) 226void CalendarLocal::deleteEvent( Event *event )
217{ 227{
218 if ( mUndoIncidence ) delete mUndoIncidence; 228 if ( mUndoIncidence ) delete mUndoIncidence;
219 mUndoIncidence = event->clone(); 229 mUndoIncidence = event->clone();
220 if ( mEventList.removeRef( event ) ) { 230 if ( mEventList.removeRef( event ) ) {
221 setModified( true ); 231 setModified( true );
222 } 232 }
223} 233}
224 234
225 235
226Event *CalendarLocal::event( const QString &uid ) 236Event *CalendarLocal::event( const QString &uid )
227{ 237{
228 Event *event; 238 Event *event;
229 Event *retVal = 0; 239 Event *retVal = 0;
230 for ( event = mEventList.first(); event; event = mEventList.next() ) { 240 for ( event = mEventList.first(); event; event = mEventList.next() ) {
231 if ( event->calEnabled() && event->uid() == uid ) { 241 if ( event->calEnabled() && event->uid() == uid ) {
232 if ( retVal ) { 242 if ( retVal ) {
233 if ( retVal->calID() > event->calID() ) { 243 if ( retVal->calID() > event->calID() ) {
234 retVal = event; 244 retVal = event;
235 } 245 }
236 } else { 246 } else {
237 retVal = event; 247 retVal = event;
238 } 248 }
239 } 249 }
240 } 250 }
241 return retVal; 251 return retVal;
242} 252}
243bool CalendarLocal::addTodoNoDup( Todo *todo ) 253bool CalendarLocal::addTodoNoDup( Todo *todo )
244{ 254{
245 Todo * eve; 255 Todo * eve;
246 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 256 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
247 if ( *eve == *todo ) { 257 if ( *eve == *todo ) {
248 //qDebug("duplicate todo found! not inserted! "); 258 //qDebug("duplicate todo found! not inserted! ");
249 return false; 259 return false;
250 } 260 }
251 } 261 }
252 return addTodo( todo ); 262 return addTodo( todo );
253} 263}
254bool CalendarLocal::addTodo( Todo *todo ) 264bool CalendarLocal::addTodo( Todo *todo )
255{ 265{
256 mTodoList.append( todo ); 266 mTodoList.append( todo );
257 267
258 todo->registerObserver( this ); 268 todo->registerObserver( this );
259 269
260 // Set up subtask relations 270 // Set up subtask relations
261 setupRelations( todo ); 271 setupRelations( todo );
262 272
263 setModified( true ); 273 setModified( true );
264 todo->setCalID( mDefaultCalendar ); 274 todo->setCalID( mDefaultCalendar );
265 todo->setCalEnabled( true ); 275 todo->setCalEnabled( true );
266 return true; 276 return true;
267} 277}
268 278
269void CalendarLocal::deleteTodo( Todo *todo ) 279void CalendarLocal::deleteTodo( Todo *todo )
270{ 280{
271 // Handle orphaned children 281 // Handle orphaned children
272 if ( mUndoIncidence ) delete mUndoIncidence; 282 if ( mUndoIncidence ) delete mUndoIncidence;
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 5bbe55f..0286b48 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,224 +1,225 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 void setSyncEventsReadOnly();
48 /** 49 /**
49 Loads a calendar on disk in vCalendar or iCalendar format into the current 50 Loads a calendar on disk in vCalendar or iCalendar format into the current
50 calendar. Any information already present is lost. 51 calendar. Any information already present is lost.
51 @return true, if successfull, false on error. 52 @return true, if successfull, false on error.
52 @param fileName the name of the calendar on disk. 53 @param fileName the name of the calendar on disk.
53 */ 54 */
54 bool load( const QString &fileName ); 55 bool load( const QString &fileName );
55 /** 56 /**
56 Writes out the calendar to disk in the specified \a format. 57 Writes out the calendar to disk in the specified \a format.
57 CalendarLocal takes ownership of the CalFormat object. 58 CalendarLocal takes ownership of the CalFormat object.
58 @return true, if successfull, false on error. 59 @return true, if successfull, false on error.
59 @param fileName the name of the file 60 @param fileName the name of the file
60 */ 61 */
61 bool save( const QString &fileName, CalFormat *format = 0 ); 62 bool save( const QString &fileName, CalFormat *format = 0 );
62 63
63 /** 64 /**
64 Clears out the current calendar, freeing all used memory etc. etc. 65 Clears out the current calendar, freeing all used memory etc. etc.
65 */ 66 */
66 void close(); 67 void close();
67 68
68 void save() {} 69 void save() {}
69 70
70 /** 71 /**
71 Add Event to calendar. 72 Add Event to calendar.
72 */ 73 */
73 void removeSyncInfo( QString syncProfile); 74 void removeSyncInfo( QString syncProfile);
74 bool addAnniversaryNoDup( Event *event ); 75 bool addAnniversaryNoDup( Event *event );
75 bool addEventNoDup( Event *event ); 76 bool addEventNoDup( Event *event );
76 bool addEvent( Event *event ); 77 bool addEvent( Event *event );
77 /** 78 /**
78 Deletes an event from this calendar. 79 Deletes an event from this calendar.
79 */ 80 */
80 void deleteEvent( Event *event ); 81 void deleteEvent( Event *event );
81 82
82 /** 83 /**
83 Retrieves an event on the basis of the unique string ID. 84 Retrieves an event on the basis of the unique string ID.
84 */ 85 */
85 Event *event( const QString &uid ); 86 Event *event( const QString &uid );
86 /** 87 /**
87 Return unfiltered list of all events in calendar. 88 Return unfiltered list of all events in calendar.
88 */ 89 */
89 QPtrList<Event> rawEvents(); 90 QPtrList<Event> rawEvents();
90 QPtrList<Event> getExternLastSyncEvents(); 91 QPtrList<Event> getExternLastSyncEvents();
91 /** 92 /**
92 Add a todo to the todolist. 93 Add a todo to the todolist.
93 */ 94 */
94 bool addTodo( Todo *todo ); 95 bool addTodo( Todo *todo );
95 bool addTodoNoDup( Todo *todo ); 96 bool addTodoNoDup( Todo *todo );
96 /** 97 /**
97 Remove a todo from the todolist. 98 Remove a todo from the todolist.
98 */ 99 */
99 void deleteTodo( Todo * ); 100 void deleteTodo( Todo * );
100 /** 101 /**
101 Searches todolist for an event with this unique string identifier, 102 Searches todolist for an event with this unique string identifier,
102 returns a pointer or null. 103 returns a pointer or null.
103 */ 104 */
104 Todo *todo( const QString &uid ); 105 Todo *todo( const QString &uid );
105 /** 106 /**
106 Return list of all todos. 107 Return list of all todos.
107 */ 108 */
108 QPtrList<Todo> rawTodos(); 109 QPtrList<Todo> rawTodos();
109 /** 110 /**
110 Returns list of todos due on the specified date. 111 Returns list of todos due on the specified date.
111 */ 112 */
112 QPtrList<Todo> todos( const QDate &date ); 113 QPtrList<Todo> todos( const QDate &date );
113 /** 114 /**
114 Return list of all todos. 115 Return list of all todos.
115 116
116 Workaround because compiler does not recognize function of base class. 117 Workaround because compiler does not recognize function of base class.
117 */ 118 */
118 QPtrList<Todo> todos() { return Calendar::todos(); } 119 QPtrList<Todo> todos() { return Calendar::todos(); }
119 120
120 /** 121 /**
121 Add a Journal entry to calendar. 122 Add a Journal entry to calendar.
122 */ 123 */
123 bool addJournal( Journal * ); 124 bool addJournal( Journal * );
124 /** 125 /**
125 Remove a Journal from the calendar. 126 Remove a Journal from the calendar.
126 */ 127 */
127 void deleteJournal( Journal * ); 128 void deleteJournal( Journal * );
128 /** 129 /**
129 Return Journal for given date. 130 Return Journal for given date.
130 */ 131 */
131 Journal *journal( const QDate & ); 132 Journal *journal( const QDate & );
132 /** 133 /**
133 Return Journal with given UID. 134 Return Journal with given UID.
134 */ 135 */
135 Journal *journal( const QString &uid ); 136 Journal *journal( const QString &uid );
136 /** 137 /**
137 Return list of all Journals stored in calendar. 138 Return list of all Journals stored in calendar.
138 */ 139 */
139 QPtrList<Journal> journals(); 140 QPtrList<Journal> journals();
140 141
141 /** 142 /**
142 Return all alarms, which ocur in the given time interval. 143 Return all alarms, which ocur in the given time interval.
143 */ 144 */
144 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 145 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
145 146
146 /** 147 /**
147 Return all alarms, which ocur before given date. 148 Return all alarms, which ocur before given date.
148 */ 149 */
149 Alarm::List alarmsTo( const QDateTime &to ); 150 Alarm::List alarmsTo( const QDateTime &to );
150 151
151 QDateTime nextAlarm( int daysTo ) ; 152 QDateTime nextAlarm( int daysTo ) ;
152 QDateTime nextAlarmEventDateTime() const; 153 QDateTime nextAlarmEventDateTime() const;
153 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 154 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
154 void registerAlarm(); 155 void registerAlarm();
155 void deRegisterAlarm(); 156 void deRegisterAlarm();
156 QString getAlarmNotification(); 157 QString getAlarmNotification();
157 QString nextSummary() const ; 158 QString nextSummary() const ;
158 /** 159 /**
159 This method should be called whenever a Event is modified directly 160 This method should be called whenever a Event is modified directly
160 via it's pointer. It makes sure that the calendar is internally 161 via it's pointer. It makes sure that the calendar is internally
161 consistent. 162 consistent.
162 */ 163 */
163 void update( IncidenceBase *incidence ); 164 void update( IncidenceBase *incidence );
164 165
165 /** 166 /**
166 Builds and then returns a list of all events that match for the 167 Builds and then returns a list of all events that match for the
167 date specified. useful for dayView, etc. etc. 168 date specified. useful for dayView, etc. etc.
168 */ 169 */
169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 170 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
170 /** 171 /**
171 Get unfiltered events for date \a qdt. 172 Get unfiltered events for date \a qdt.
172 */ 173 */
173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 174 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
174 /** 175 /**
175 Get unfiltered events in a range of dates. If inclusive is set to true, 176 Get unfiltered events in a range of dates. If inclusive is set to true,
176 only events are returned, which are completely included in the range. 177 only events are returned, which are completely included in the range.
177 */ 178 */
178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 179 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
179 bool inclusive = false ); 180 bool inclusive = false );
180 Todo *todo( QString, QString ); 181 Todo *todo( QString, QString );
181 Event *event( QString, QString ); 182 Event *event( QString, QString );
182 183
183public slots: 184public slots:
184 void setCalendarEnabled( int id, bool enable ); 185 void setCalendarEnabled( int id, bool enable );
185 void setAlarmEnabled( int id, bool enable ); 186 void setAlarmEnabled( int id, bool enable );
186 void setReadOnly( int id, bool enable ); 187 void setReadOnly( int id, bool enable );
187 void setDefaultCalendarEnabledOnly(); 188 void setDefaultCalendarEnabledOnly();
188 void setCalendarRemove( int id ); 189 void setCalendarRemove( int id );
189 190
190 protected: 191 protected:
191 192
192 // Event* mNextAlarmEvent; 193 // Event* mNextAlarmEvent;
193 QString mNextSummary; 194 QString mNextSummary;
194 QString mNextAlarmEventDateTimeString; 195 QString mNextAlarmEventDateTimeString;
195 QString mLastAlarmNotificationString; 196 QString mLastAlarmNotificationString;
196 QDateTime mNextAlarmEventDateTime; 197 QDateTime mNextAlarmEventDateTime;
197 QDateTime mNextAlarmDateTime; 198 QDateTime mNextAlarmDateTime;
198 void reInitAlarmSettings(); 199 void reInitAlarmSettings();
199 200
200 /** Notification function of IncidenceBase::Observer. */ 201 /** Notification function of IncidenceBase::Observer. */
201 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 202 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
202 203
203 /** inserts an event into its "proper place" in the calendar. */ 204 /** inserts an event into its "proper place" in the calendar. */
204 void insertEvent( Event *event ); 205 void insertEvent( Event *event );
205 206
206 /** Append alarms of incidence in interval to list of alarms. */ 207 /** Append alarms of incidence in interval to list of alarms. */
207 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 208 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
208 const QDateTime &from, const QDateTime &to ); 209 const QDateTime &from, const QDateTime &to );
209 210
210 /** Append alarms of recurring events in interval to list of alarms. */ 211 /** Append alarms of recurring events in interval to list of alarms. */
211 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 212 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
212 const QDateTime &from, const QDateTime &to ); 213 const QDateTime &from, const QDateTime &to );
213 214
214 private: 215 private:
215 void init(); 216 void init();
216 217
217 QPtrList<Event> mEventList; 218 QPtrList<Event> mEventList;
218 QPtrList<Todo> mTodoList; 219 QPtrList<Todo> mTodoList;
219 QPtrList<Journal> mJournalList; 220 QPtrList<Journal> mJournalList;
220}; 221};
221 222
222} 223}
223 224
224#endif 225#endif
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 2ddbb01..96039df 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,335 +1,337 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 setUid(CalFormat::createUniqueId()); 37 setUid(CalFormat::createUniqueId());
38 mOrganizer = ""; 38 mOrganizer = "";
39 mFloats = false; 39 mFloats = false;
40 mDuration = 0; 40 mDuration = 0;
41 mHasDuration = false; 41 mHasDuration = false;
42 mPilotId = 0; 42 mPilotId = 0;
43 mExternalId = ":"; 43 mExternalId = ":";
44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
45 mSyncStatus = 0; 45 mSyncStatus = 0;
46 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
47 mCalEnabled = true; 47 mCalEnabled = true;
48 mAlarmEnabled = true; 48 mAlarmEnabled = true;
49 mCalID = 0; 49 mCalID = 0;
50} 50}
51 51
52IncidenceBase::IncidenceBase(const IncidenceBase &i) : 52IncidenceBase::IncidenceBase(const IncidenceBase &i) :
53 CustomProperties( i ) 53 CustomProperties( i )
54{ 54{
55 55
56 mReadOnly = i.mReadOnly; 56 mReadOnly = i.mReadOnly;
57 mDtStart = i.mDtStart; 57 mDtStart = i.mDtStart;
58 mDuration = i.mDuration; 58 mDuration = i.mDuration;
59 mHasDuration = i.mHasDuration; 59 mHasDuration = i.mHasDuration;
60 mOrganizer = i.mOrganizer; 60 mOrganizer = i.mOrganizer;
61 mUid = i.mUid; 61 mUid = i.mUid;
62 mCalEnabled = i.mCalEnabled; 62 mCalEnabled = i.mCalEnabled;
63 mAlarmEnabled = i.mAlarmEnabled; 63 mAlarmEnabled = i.mAlarmEnabled;
64 mCalID = i.mCalID; 64 mCalID = i.mCalID;
65 QPtrList<Attendee> attendees = i.attendees(); 65 QPtrList<Attendee> attendees = i.attendees();
66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
67 mAttendees.append( new Attendee( *a ) ); 67 mAttendees.append( new Attendee( *a ) );
68 } 68 }
69 mFloats = i.mFloats; 69 mFloats = i.mFloats;
70 mLastModified = i.mLastModified; 70 mLastModified = i.mLastModified;
71 mPilotId = i.mPilotId; 71 mPilotId = i.mPilotId;
72 mTempSyncStat = i.mTempSyncStat; 72 mTempSyncStat = i.mTempSyncStat;
73 mSyncStatus = i.mSyncStatus; 73 mSyncStatus = i.mSyncStatus;
74 mExternalId = i.mExternalId; 74 mExternalId = i.mExternalId;
75 // The copied object is a new one, so it isn't observed by the observer 75 // The copied object is a new one, so it isn't observed by the observer
76 // of the original object. 76 // of the original object.
77 mObservers.clear(); 77 mObservers.clear();
78 78
79 mAttendees.setAutoDelete( true ); 79 mAttendees.setAutoDelete( true );
80} 80}
81 81
82IncidenceBase::~IncidenceBase() 82IncidenceBase::~IncidenceBase()
83{ 83{
84} 84}
85 85
86 86
87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
88{ 88{
89 // do not compare mSyncStatus and mExternalId 89 // do not compare mSyncStatus and mExternalId
90 if( i1.attendees().count() != i2.attendees().count() ) { 90 if( i1.attendees().count() != i2.attendees().count() ) {
91 return false; // no need to check further 91 return false; // no need to check further
92 } 92 }
93 if ( i1.attendees().count() > 0 ) { 93 if ( i1.attendees().count() > 0 ) {
94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
95 while ( a1 ) { 95 while ( a1 ) {
96 if ( !( (*a1) == (*a2)) ) 96 if ( !( (*a1) == (*a2)) )
97 { 97 {
98 //qDebug("Attendee not equal "); 98 //qDebug("Attendee not equal ");
99 return false; 99 return false;
100 } 100 }
101 a1 = i1.attendees().next(); 101 a1 = i1.attendees().next();
102 a2 = i2.attendees().next(); 102 a2 = i2.attendees().next();
103 } 103 }
104 } 104 }
105 //if ( i1.dtStart() != i2.dtStart() ) 105 //if ( i1.dtStart() != i2.dtStart() )
106 // return false; 106 // return false;
107#if 0 107#if 0
108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
109 qDebug("1 %d ",i1.duration() == i2.duration() ); 109 qDebug("1 %d ",i1.duration() == i2.duration() );
110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
113 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 113 qDebug("6 %d ",i1.organizer() == i2.organizer() );
114 114
115#endif 115#endif
116 if ( i1.hasDuration() == i2.hasDuration() ) { 116 if ( i1.hasDuration() == i2.hasDuration() ) {
117 if ( i1.hasDuration() ) { 117 if ( i1.hasDuration() ) {
118 if ( i1.duration() != i2.duration() ) 118 if ( i1.duration() != i2.duration() )
119 return false; 119 return false;
120 } 120 }
121 } else { 121 } else {
122 return false; 122 return false;
123 } 123 }
124 124
125 return ( i1.organizer() == i2.organizer() && 125 return ( i1.organizer() == i2.organizer() &&
126 // i1.uid() == i2.uid() && 126 // i1.uid() == i2.uid() &&
127 // Don't compare lastModified, otherwise the operator is not 127 // Don't compare lastModified, otherwise the operator is not
128 // of much use. We are not comparing for identity, after all. 128 // of much use. We are not comparing for identity, after all.
129 i1.doesFloat() == i2.doesFloat() && 129 i1.doesFloat() == i2.doesFloat() &&
130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
131 // no need to compare mObserver 131 // no need to compare mObserver
132} 132}
133 133
134 134
135QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 135QDateTime IncidenceBase::getEvenTime( QDateTime dt )
136{ 136{
137 QTime t = dt.time(); 137 QTime t = dt.time();
138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
139 return dt; 139 return dt;
140} 140}
141 141
142void IncidenceBase::setCalID( int id ) 142void IncidenceBase::setCalID( int id )
143{ 143{
144 if ( mCalID > 0 )
145 updated();
144 mCalID = id; 146 mCalID = id;
145} 147}
146int IncidenceBase::calID() const 148int IncidenceBase::calID() const
147{ 149{
148 return mCalID; 150 return mCalID;
149} 151}
150void IncidenceBase::setCalEnabled( bool b ) 152void IncidenceBase::setCalEnabled( bool b )
151{ 153{
152 mCalEnabled = b; 154 mCalEnabled = b;
153} 155}
154bool IncidenceBase::calEnabled() const 156bool IncidenceBase::calEnabled() const
155{ 157{
156 return mCalEnabled; 158 return mCalEnabled;
157} 159}
158 160
159void IncidenceBase::setAlarmEnabled( bool b ) 161void IncidenceBase::setAlarmEnabled( bool b )
160{ 162{
161 mAlarmEnabled = b; 163 mAlarmEnabled = b;
162} 164}
163bool IncidenceBase::alarmEnabled() const 165bool IncidenceBase::alarmEnabled() const
164{ 166{
165 return mAlarmEnabled; 167 return mAlarmEnabled;
166} 168}
167 169
168 170
169void IncidenceBase::setUid(const QString &uid) 171void IncidenceBase::setUid(const QString &uid)
170{ 172{
171 mUid = uid; 173 mUid = uid;
172 updated(); 174 updated();
173} 175}
174 176
175QString IncidenceBase::uid() const 177QString IncidenceBase::uid() const
176{ 178{
177 return mUid; 179 return mUid;
178} 180}
179 181
180void IncidenceBase::setLastModified(const QDateTime &lm) 182void IncidenceBase::setLastModified(const QDateTime &lm)
181{ 183{
182 // DON'T! updated() because we call this from 184 // DON'T! updated() because we call this from
183 // Calendar::updateEvent(). 185 // Calendar::updateEvent().
184 mLastModified = getEvenTime(lm); 186 mLastModified = getEvenTime(lm);
185 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 187 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
186} 188}
187 189
188QDateTime IncidenceBase::lastModified() const 190QDateTime IncidenceBase::lastModified() const
189{ 191{
190 return mLastModified; 192 return mLastModified;
191} 193}
192 194
193void IncidenceBase::setOrganizer(const QString &o) 195void IncidenceBase::setOrganizer(const QString &o)
194{ 196{
195 // we don't check for readonly here, because it is 197 // we don't check for readonly here, because it is
196 // possible that by setting the organizer we are changing 198 // possible that by setting the organizer we are changing
197 // the event's readonly status... 199 // the event's readonly status...
198 mOrganizer = o; 200 mOrganizer = o;
199 if (mOrganizer.left(7).upper() == "MAILTO:") 201 if (mOrganizer.left(7).upper() == "MAILTO:")
200 mOrganizer = mOrganizer.remove(0,7); 202 mOrganizer = mOrganizer.remove(0,7);
201 203
202 updated(); 204 updated();
203} 205}
204 206
205QString IncidenceBase::organizer() const 207QString IncidenceBase::organizer() const
206{ 208{
207 return mOrganizer; 209 return mOrganizer;
208} 210}
209 211
210void IncidenceBase::setReadOnly( bool readOnly ) 212void IncidenceBase::setReadOnly( bool readOnly )
211{ 213{
212 mReadOnly = readOnly; 214 mReadOnly = readOnly;
213} 215}
214 216
215void IncidenceBase::setDtStart(const QDateTime &dtStart) 217void IncidenceBase::setDtStart(const QDateTime &dtStart)
216{ 218{
217// if (mReadOnly) return; 219// if (mReadOnly) return;
218 mDtStart = getEvenTime(dtStart); 220 mDtStart = getEvenTime(dtStart);
219 updated(); 221 updated();
220} 222}
221 223
222 224
223QDateTime IncidenceBase::dtStart() const 225QDateTime IncidenceBase::dtStart() const
224{ 226{
225 return mDtStart; 227 return mDtStart;
226} 228}
227 229
228QString IncidenceBase::dtStartTimeStr() const 230QString IncidenceBase::dtStartTimeStr() const
229{ 231{
230 return KGlobal::locale()->formatTime(dtStart().time()); 232 return KGlobal::locale()->formatTime(dtStart().time());
231} 233}
232 234
233QString IncidenceBase::dtStartDateStr(bool shortfmt) const 235QString IncidenceBase::dtStartDateStr(bool shortfmt) const
234{ 236{
235 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 237 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
236} 238}
237 239
238QString IncidenceBase::dtStartStr(bool shortfmt) const 240QString IncidenceBase::dtStartStr(bool shortfmt) const
239{ 241{
240 if ( doesFloat() ) 242 if ( doesFloat() )
241 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 243 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
242 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 244 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
243} 245}
244 246
245 247
246bool IncidenceBase::doesFloat() const 248bool IncidenceBase::doesFloat() const
247{ 249{
248 return mFloats; 250 return mFloats;
249} 251}
250 252
251void IncidenceBase::setFloats(bool f) 253void IncidenceBase::setFloats(bool f)
252{ 254{
253 if (mReadOnly) return; 255 if (mReadOnly) return;
254 mFloats = f; 256 mFloats = f;
255 updated(); 257 updated();
256} 258}
257 259
258 260
259bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 261bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
260{ 262{
261 if (mReadOnly) return false; 263 if (mReadOnly) return false;
262 if (a->name().left(7).upper() == "MAILTO:") 264 if (a->name().left(7).upper() == "MAILTO:")
263 a->setName(a->name().remove(0,7)); 265 a->setName(a->name().remove(0,7));
264 266
265 QPtrListIterator<Attendee> qli(mAttendees); 267 QPtrListIterator<Attendee> qli(mAttendees);
266 268
267 qli.toFirst(); 269 qli.toFirst();
268 while (qli) { 270 while (qli) {
269 if (*qli.current() == *a) 271 if (*qli.current() == *a)
270 return false; 272 return false;
271 ++qli; 273 ++qli;
272 } 274 }
273 mAttendees.append(a); 275 mAttendees.append(a);
274 if (doupdate) updated(); 276 if (doupdate) updated();
275 return true; 277 return true;
276} 278}
277 279
278#if 0 280#if 0
279void IncidenceBase::removeAttendee(Attendee *a) 281void IncidenceBase::removeAttendee(Attendee *a)
280{ 282{
281 if (mReadOnly) return; 283 if (mReadOnly) return;
282 mAttendees.removeRef(a); 284 mAttendees.removeRef(a);
283 updated(); 285 updated();
284} 286}
285 287
286void IncidenceBase::removeAttendee(const char *n) 288void IncidenceBase::removeAttendee(const char *n)
287{ 289{
288 Attendee *a; 290 Attendee *a;
289 291
290 if (mReadOnly) return; 292 if (mReadOnly) return;
291 for (a = mAttendees.first(); a; a = mAttendees.next()) 293 for (a = mAttendees.first(); a; a = mAttendees.next())
292 if (a->getName() == n) { 294 if (a->getName() == n) {
293 mAttendees.remove(); 295 mAttendees.remove();
294 break; 296 break;
295 } 297 }
296} 298}
297#endif 299#endif
298 300
299void IncidenceBase::clearAttendees() 301void IncidenceBase::clearAttendees()
300{ 302{
301 if (mReadOnly) return; 303 if (mReadOnly) return;
302 mAttendees.clear(); 304 mAttendees.clear();
303} 305}
304 306
305#if 0 307#if 0
306Attendee *IncidenceBase::getAttendee(const char *n) const 308Attendee *IncidenceBase::getAttendee(const char *n) const
307{ 309{
308 QPtrListIterator<Attendee> qli(mAttendees); 310 QPtrListIterator<Attendee> qli(mAttendees);
309 311
310 qli.toFirst(); 312 qli.toFirst();
311 while (qli) { 313 while (qli) {
312 if (qli.current()->getName() == n) 314 if (qli.current()->getName() == n)
313 return qli.current(); 315 return qli.current();
314 ++qli; 316 ++qli;
315 } 317 }
316 return 0L; 318 return 0L;
317} 319}
318#endif 320#endif
319 321
320Attendee *IncidenceBase::attendeeByMail(const QString &email) 322Attendee *IncidenceBase::attendeeByMail(const QString &email)
321{ 323{
322 QPtrListIterator<Attendee> qli(mAttendees); 324 QPtrListIterator<Attendee> qli(mAttendees);
323 325
324 qli.toFirst(); 326 qli.toFirst();
325 while (qli) { 327 while (qli) {
326 if (qli.current()->email().lower() == email.lower()) 328 if (qli.current()->email().lower() == email.lower())
327 return qli.current(); 329 return qli.current();
328 ++qli; 330 ++qli;
329 } 331 }
330 return 0L; 332 return 0L;
331} 333}
332 334
333Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 335Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
334{ 336{
335 QPtrListIterator<Attendee> qli(mAttendees); 337 QPtrListIterator<Attendee> qli(mAttendees);