summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-07 00:03:44 (UTC)
committer zautrix <zautrix>2005-07-07 00:03:44 (UTC)
commitcb350dbe9151db2ded62942d29d11d6c8b88eabd (patch) (unidiff)
tree3ba8d483461e10afddb67f17cd038118d99513ef /korganizer
parent93bc4dbbef774e28672c947281291b12d5971803 (diff)
downloadkdepimpi-cb350dbe9151db2ded62942d29d11d6c8b88eabd.zip
kdepimpi-cb350dbe9151db2ded62942d29d11d6c8b88eabd.tar.gz
kdepimpi-cb350dbe9151db2ded62942d29d11d6c8b88eabd.tar.bz2
fixessss
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp27
-rw-r--r--korganizer/kolistview.cpp6
2 files changed, 26 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 98e0ac1..bc1c0c7 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1798,2759 +1798,2776 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1798 QString realName; 1798 QString realName;
1799 QString email; 1799 QString email;
1800 QString assembledName; 1800 QString assembledName;
1801 QString uid; 1801 QString uid;
1802 bool ok = true; 1802 bool ok = true;
1803 for ( int i = 0; i < count; i++) 1803 for ( int i = 0; i < count; i++)
1804 { 1804 {
1805 if ( ! bar.isVisible() ) 1805 if ( ! bar.isVisible() )
1806 return; 1806 return;
1807 bar.setProgress( i ); 1807 bar.setProgress( i );
1808 qApp->processEvents(); 1808 qApp->processEvents();
1809 1809
1810 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1810 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1811 if (!ok) { 1811 if (!ok) {
1812 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1812 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1813 } 1813 }
1814 1814
1815 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1815 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1816 if (!ok) { 1816 if (!ok) {
1817 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1817 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1818 } 1818 }
1819 realName = realNameList[i]; 1819 realName = realNameList[i];
1820 email = emailList[i]; 1820 email = emailList[i];
1821 assembledName = assembledNameList[i]; 1821 assembledName = assembledNameList[i];
1822 uid = uidList[i]; 1822 uid = uidList[i];
1823 //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() ); 1823 //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() );
1824 1824
1825 if ( birthday.isValid() ){ 1825 if ( birthday.isValid() ){
1826 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1826 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1827 KCal::Attendee::ReqParticipant,uid) ; 1827 KCal::Attendee::ReqParticipant,uid) ;
1828 if ( addAnniversary( birthday, assembledName, a, true ) ) 1828 if ( addAnniversary( birthday, assembledName, a, true ) )
1829 ++addCount; 1829 ++addCount;
1830 } 1830 }
1831 1831
1832 if ( anniversary.isValid() ){ 1832 if ( anniversary.isValid() ){
1833 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1833 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1834 KCal::Attendee::ReqParticipant,uid) ; 1834 KCal::Attendee::ReqParticipant,uid) ;
1835 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1835 if ( addAnniversary( anniversary, assembledName, a, false ) )
1836 ++addCount; 1836 ++addCount;
1837 } 1837 }
1838 } 1838 }
1839 1839
1840 mCalendar->setDefaultCalendar( curCal ); 1840 mCalendar->setDefaultCalendar( curCal );
1841 updateView(); 1841 updateView();
1842 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1842 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1843 1843
1844 } 1844 }
1845 1845
1846} 1846}
1847 1847
1848 1848
1849 1849
1850bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1850bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1851{ 1851{
1852 //qDebug("addAnni "); 1852 //qDebug("addAnni ");
1853 Event * ev = new Event(); 1853 Event * ev = new Event();
1854 ev->setOrganizer(KOPrefs::instance()->email()); 1854 ev->setOrganizer(KOPrefs::instance()->email());
1855 if ( a ) { 1855 if ( a ) {
1856 ev->addAttendee( a ); 1856 ev->addAttendee( a );
1857 } 1857 }
1858 QString kind; 1858 QString kind;
1859 if ( birthday ) { 1859 if ( birthday ) {
1860 kind = i18n( "Birthday" ); 1860 kind = i18n( "Birthday" );
1861 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1861 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1862 } 1862 }
1863 else { 1863 else {
1864 kind = i18n( "Anniversary" ); 1864 kind = i18n( "Anniversary" );
1865 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1865 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1866 } 1866 }
1867 ev->setCategories( kind ); 1867 ev->setCategories( kind );
1868 ev->setDtStart( QDateTime(date) ); 1868 ev->setDtStart( QDateTime(date) );
1869 ev->setDtEnd( QDateTime(date) ); 1869 ev->setDtEnd( QDateTime(date) );
1870 ev->setFloats( true ); 1870 ev->setFloats( true );
1871 Recurrence * rec = ev->recurrence(); 1871 Recurrence * rec = ev->recurrence();
1872 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1872 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1873 rec->addYearlyNum( date.month() ); 1873 rec->addYearlyNum( date.month() );
1874 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1874 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1875 delete ev; 1875 delete ev;
1876 return false; 1876 return false;
1877 } 1877 }
1878 return true; 1878 return true;
1879 1879
1880} 1880}
1881bool CalendarView::importQtopia( const QString &categories, 1881bool CalendarView::importQtopia( const QString &categories,
1882 const QString &datebook, 1882 const QString &datebook,
1883 const QString &todolist ) 1883 const QString &todolist )
1884{ 1884{
1885 1885
1886 QtopiaFormat qtopiaFormat; 1886 QtopiaFormat qtopiaFormat;
1887 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1887 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1888 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1888 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1889 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1889 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1890 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1890 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1891 1891
1892 updateView(); 1892 updateView();
1893 return true; 1893 return true;
1894 1894
1895#if 0 1895#if 0
1896 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1896 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1897 mCurrentSyncDevice = "qtopia-XML"; 1897 mCurrentSyncDevice = "qtopia-XML";
1898 if ( mSyncManager->mAskForPreferences ) 1898 if ( mSyncManager->mAskForPreferences )
1899 edit_sync_options(); 1899 edit_sync_options();
1900 qApp->processEvents(); 1900 qApp->processEvents();
1901 CalendarLocal* calendar = new CalendarLocal(); 1901 CalendarLocal* calendar = new CalendarLocal();
1902 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1902 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1903 bool syncOK = false; 1903 bool syncOK = false;
1904 QtopiaFormat qtopiaFormat; 1904 QtopiaFormat qtopiaFormat;
1905 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1905 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1906 bool loadOk = true; 1906 bool loadOk = true;
1907 if ( !categories.isEmpty() ) 1907 if ( !categories.isEmpty() )
1908 loadOk = qtopiaFormat.load( calendar, categories ); 1908 loadOk = qtopiaFormat.load( calendar, categories );
1909 if ( loadOk && !datebook.isEmpty() ) 1909 if ( loadOk && !datebook.isEmpty() )
1910 loadOk = qtopiaFormat.load( calendar, datebook ); 1910 loadOk = qtopiaFormat.load( calendar, datebook );
1911 if ( loadOk && !todolist.isEmpty() ) 1911 if ( loadOk && !todolist.isEmpty() )
1912 loadOk = qtopiaFormat.load( calendar, todolist ); 1912 loadOk = qtopiaFormat.load( calendar, todolist );
1913 1913
1914 if ( loadOk ) { 1914 if ( loadOk ) {
1915 getEventViewerDialog()->setSyncMode( true ); 1915 getEventViewerDialog()->setSyncMode( true );
1916 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1916 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1917 getEventViewerDialog()->setSyncMode( false ); 1917 getEventViewerDialog()->setSyncMode( false );
1918 qApp->processEvents(); 1918 qApp->processEvents();
1919 if ( syncOK ) { 1919 if ( syncOK ) {
1920 if ( mSyncManager->mWriteBackFile ) 1920 if ( mSyncManager->mWriteBackFile )
1921 { 1921 {
1922 // write back XML file 1922 // write back XML file
1923 1923
1924 } 1924 }
1925 setModified( true ); 1925 setModified( true );
1926 } 1926 }
1927 } else { 1927 } else {
1928 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1928 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1929 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1929 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1930 question, i18n("Ok")) ; 1930 question, i18n("Ok")) ;
1931 } 1931 }
1932 delete calendar; 1932 delete calendar;
1933 updateView(); 1933 updateView();
1934 return syncOK; 1934 return syncOK;
1935 1935
1936 1936
1937#endif 1937#endif
1938 1938
1939} 1939}
1940 1940
1941void CalendarView::setSyncEventsReadOnly() 1941void CalendarView::setSyncEventsReadOnly()
1942{ 1942{
1943 mCalendar->setSyncEventsReadOnly(); 1943 mCalendar->setSyncEventsReadOnly();
1944} 1944}
1945 1945
1946bool CalendarView::loadCalendars() 1946bool CalendarView::loadCalendars()
1947{ 1947{
1948 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1948 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1949 KopiCalendarFile * cal = calendars.first(); 1949 KopiCalendarFile * cal = calendars.first();
1950 mCalendar->setDefaultCalendar( 1 ); 1950 mCalendar->setDefaultCalendar( 1 );
1951 openCalendar( MainWindow::defaultFileName(), false ); 1951 openCalendar( MainWindow::defaultFileName(), false );
1952 cal = calendars.next(); 1952 cal = calendars.next();
1953 while ( cal ) { 1953 while ( cal ) {
1954 addCalendar( cal ); 1954 addCalendar( cal );
1955 cal = calendars.next(); 1955 cal = calendars.next();
1956 } 1956 }
1957 restoreCalendarSettings(); 1957 restoreCalendarSettings();
1958 return true; 1958 return true;
1959} 1959}
1960bool CalendarView::restoreCalendarSettings() 1960bool CalendarView::restoreCalendarSettings()
1961{ 1961{
1962 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1962 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1963 KopiCalendarFile * cal = calendars.first(); 1963 KopiCalendarFile * cal = calendars.first();
1964 while ( cal ) { 1964 while ( cal ) {
1965 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1965 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1966 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1966 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1967 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1967 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1968 if ( cal->isStandard ) 1968 if ( cal->isStandard )
1969 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1969 mCalendar->setDefaultCalendar( cal->mCalNumber );
1970 cal = calendars.next(); 1970 cal = calendars.next();
1971 } 1971 }
1972 setSyncEventsReadOnly(); 1972 setSyncEventsReadOnly();
1973 mCalendar->reInitAlarmSettings(); 1973 mCalendar->reInitAlarmSettings();
1974 updateUnmanagedViews(); 1974 updateUnmanagedViews();
1975 updateView(); 1975 updateView();
1976 return true; 1976 return true;
1977} 1977}
1978void CalendarView::addCalendarId( int id ) 1978void CalendarView::addCalendarId( int id )
1979{ 1979{
1980 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1980 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1981 if ( cal ) 1981 if ( cal )
1982 addCalendar( cal ); 1982 addCalendar( cal );
1983} 1983}
1984bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1984bool CalendarView::addCalendar( KopiCalendarFile * cal )
1985{ 1985{
1986 cal->mErrorOnLoad = false; 1986 cal->mErrorOnLoad = false;
1987 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1987 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1988 cal->mLoadDt = QDateTime::currentDateTime(); 1988 cal->mLoadDt = QDateTime::currentDateTime();
1989 return true; 1989 return true;
1990 } 1990 }
1991 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 1991 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
1992 cal->mErrorOnLoad = true; 1992 cal->mErrorOnLoad = true;
1993 return false; 1993 return false;
1994} 1994}
1995bool CalendarView::openCalendar(QString filename, bool merge) 1995bool CalendarView::openCalendar(QString filename, bool merge)
1996{ 1996{
1997 1997
1998 if (filename.isEmpty()) { 1998 if (filename.isEmpty()) {
1999 return false; 1999 return false;
2000 } 2000 }
2001 2001
2002 if (!QFile::exists(filename)) { 2002 if (!QFile::exists(filename)) {
2003 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2003 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2004 return false; 2004 return false;
2005 } 2005 }
2006 2006
2007 globalFlagBlockAgenda = 1; 2007 globalFlagBlockAgenda = 1;
2008 clearAllViews(); 2008 clearAllViews();
2009 if (!merge) { 2009 if (!merge) {
2010 mViewManager->setDocumentId( filename ); 2010 mViewManager->setDocumentId( filename );
2011 mCalendar->close(); 2011 mCalendar->close();
2012 } 2012 }
2013 mStorage->setFileName( filename ); 2013 mStorage->setFileName( filename );
2014 2014
2015 if ( mStorage->load() ) { 2015 if ( mStorage->load() ) {
2016 if ( merge ) ;//setModified( true ); 2016 if ( merge ) ;//setModified( true );
2017 else { 2017 else {
2018 //setModified( true ); 2018 //setModified( true );
2019 mViewManager->setDocumentId( filename ); 2019 mViewManager->setDocumentId( filename );
2020 mDialogManager->setDocumentId( filename ); 2020 mDialogManager->setDocumentId( filename );
2021 mTodoList->setDocumentId( filename ); 2021 mTodoList->setDocumentId( filename );
2022 } 2022 }
2023 globalFlagBlockAgenda = 2; 2023 globalFlagBlockAgenda = 2;
2024 // if ( getLastSyncEvent() ) 2024 // if ( getLastSyncEvent() )
2025 // getLastSyncEvent()->setReadOnly( true ); 2025 // getLastSyncEvent()->setReadOnly( true );
2026 mCalendar->reInitAlarmSettings(); 2026 mCalendar->reInitAlarmSettings();
2027 setSyncEventsReadOnly(); 2027 setSyncEventsReadOnly();
2028 updateUnmanagedViews(); 2028 updateUnmanagedViews();
2029 updateView(); 2029 updateView();
2030 if ( filename != MainWindow::defaultFileName() ) { 2030 if ( filename != MainWindow::defaultFileName() ) {
2031 saveCalendar( MainWindow::defaultFileName() ); 2031 saveCalendar( MainWindow::defaultFileName() );
2032 } else { 2032 } else {
2033 QFileInfo finf ( MainWindow::defaultFileName()); 2033 QFileInfo finf ( MainWindow::defaultFileName());
2034 if ( finf.exists() ) { 2034 if ( finf.exists() ) {
2035 setLoadedFileVersion( finf.lastModified () ); 2035 setLoadedFileVersion( finf.lastModified () );
2036 } 2036 }
2037 } 2037 }
2038 return true; 2038 return true;
2039 } else { 2039 } else {
2040 // while failing to load, the calendar object could 2040 // while failing to load, the calendar object could
2041 // have become partially populated. Clear it out. 2041 // have become partially populated. Clear it out.
2042 if ( !merge ) { 2042 if ( !merge ) {
2043 mCalendar->close(); 2043 mCalendar->close();
2044 mViewManager->setDocumentId( filename ); 2044 mViewManager->setDocumentId( filename );
2045 mDialogManager->setDocumentId( filename ); 2045 mDialogManager->setDocumentId( filename );
2046 mTodoList->setDocumentId( filename ); 2046 mTodoList->setDocumentId( filename );
2047 } 2047 }
2048 2048
2049 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2049 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2050 2050
2051 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2051 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2052 globalFlagBlockAgenda = 2; 2052 globalFlagBlockAgenda = 2;
2053 mCalendar->reInitAlarmSettings(); 2053 mCalendar->reInitAlarmSettings();
2054 setSyncEventsReadOnly(); 2054 setSyncEventsReadOnly();
2055 updateUnmanagedViews(); 2055 updateUnmanagedViews();
2056 updateView(); 2056 updateView();
2057 } 2057 }
2058 return false; 2058 return false;
2059} 2059}
2060void CalendarView::showOpenError() 2060void CalendarView::showOpenError()
2061{ 2061{
2062 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2062 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2063} 2063}
2064void CalendarView::setLoadedFileVersion(QDateTime dt) 2064void CalendarView::setLoadedFileVersion(QDateTime dt)
2065{ 2065{
2066 loadedFileVersion = dt; 2066 loadedFileVersion = dt;
2067} 2067}
2068bool CalendarView::checkFileChanged(QString fn) 2068bool CalendarView::checkFileChanged(QString fn)
2069{ 2069{
2070 QFileInfo finf ( fn ); 2070 QFileInfo finf ( fn );
2071 if ( !finf.exists() ) 2071 if ( !finf.exists() )
2072 return true; 2072 return true;
2073 QDateTime dt = finf.lastModified (); 2073 QDateTime dt = finf.lastModified ();
2074 if ( dt <= loadedFileVersion ) 2074 if ( dt <= loadedFileVersion )
2075 return false; 2075 return false;
2076 return true; 2076 return true;
2077 2077
2078} 2078}
2079void CalendarView::watchSavedFile() 2079void CalendarView::watchSavedFile()
2080{ 2080{
2081 QFileInfo finf ( MainWindow::defaultFileName()); 2081 QFileInfo finf ( MainWindow::defaultFileName());
2082 if ( !finf.exists() ) 2082 if ( !finf.exists() )
2083 return; 2083 return;
2084 QDateTime dt = finf.lastModified (); 2084 QDateTime dt = finf.lastModified ();
2085 if ( dt < loadedFileVersion ) { 2085 if ( dt < loadedFileVersion ) {
2086 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2086 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2087 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2087 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2088 return; 2088 return;
2089 } 2089 }
2090 loadedFileVersion = dt; 2090 loadedFileVersion = dt;
2091} 2091}
2092bool CalendarView::checkAllFileVersions() 2092bool CalendarView::checkAllFileVersions()
2093{ 2093{
2094 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2094 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2095 KopiCalendarFile * cal = calendars.first(); 2095 KopiCalendarFile * cal = calendars.first();
2096 mCalendar->setDefaultCalendar( 1 ); 2096 mCalendar->setDefaultCalendar( 1 );
2097 mCalendar->setDefaultCalendarEnabledOnly(); 2097 mCalendar->setDefaultCalendarEnabledOnly();
2098 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2098 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2099 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2099 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2100 restoreCalendarSettings(); 2100 restoreCalendarSettings();
2101 return false; 2101 return false;
2102 } 2102 }
2103 } 2103 }
2104 cal = calendars.next(); 2104 cal = calendars.next();
2105 QDateTime storeTemp = loadedFileVersion; 2105 QDateTime storeTemp = loadedFileVersion;
2106 while ( cal ) { 2106 while ( cal ) {
2107 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2107 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2108 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2108 mCalendar->setDefaultCalendar( cal->mCalNumber );
2109 mCalendar->setDefaultCalendarEnabledOnly(); 2109 mCalendar->setDefaultCalendarEnabledOnly();
2110 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2110 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2111 if ( !checkFileVersion(cal->mFileName )) { 2111 if ( !checkFileVersion(cal->mFileName )) {
2112 loadedFileVersion = storeTemp; 2112 loadedFileVersion = storeTemp;
2113 restoreCalendarSettings(); 2113 restoreCalendarSettings();
2114 return false; 2114 return false;
2115 } 2115 }
2116 } 2116 }
2117 cal = calendars.next(); 2117 cal = calendars.next();
2118 } 2118 }
2119 loadedFileVersion = storeTemp; 2119 loadedFileVersion = storeTemp;
2120 return true; 2120 return true;
2121} 2121}
2122bool CalendarView::checkFileVersion(QString fn) 2122bool CalendarView::checkFileVersion(QString fn)
2123{ 2123{
2124 QFileInfo finf ( fn ); 2124 QFileInfo finf ( fn );
2125 if ( !finf.exists() ) 2125 if ( !finf.exists() )
2126 return true; 2126 return true;
2127 QDateTime dt = finf.lastModified (); 2127 QDateTime dt = finf.lastModified ();
2128 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2128 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2129 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2129 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2130 if ( dt <= loadedFileVersion ) 2130 if ( dt <= loadedFileVersion )
2131 return true; 2131 return true;
2132 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2132 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2133 i18n("KO/Pi Warning"),i18n("Overwrite"), 2133 i18n("KO/Pi Warning"),i18n("Overwrite"),
2134 i18n("Sync+save")); 2134 i18n("Sync+save"));
2135 2135
2136 if ( km == KMessageBox::Cancel ) 2136 if ( km == KMessageBox::Cancel )
2137 return false; 2137 return false;
2138 if ( km == KMessageBox::Yes ) 2138 if ( km == KMessageBox::Yes )
2139 return true; 2139 return true;
2140 2140
2141 setSyncDevice("deleteaftersync" ); 2141 setSyncDevice("deleteaftersync" );
2142 mSyncManager->mAskForPreferences = true; 2142 mSyncManager->mAskForPreferences = true;
2143 mSyncManager->mSyncAlgoPrefs = 3; 2143 mSyncManager->mSyncAlgoPrefs = 3;
2144 mSyncManager->mWriteBackFile = false; 2144 mSyncManager->mWriteBackFile = false;
2145 mSyncManager->mWriteBackExistingOnly = false; 2145 mSyncManager->mWriteBackExistingOnly = false;
2146 mSyncManager->mShowSyncSummary = false; 2146 mSyncManager->mShowSyncSummary = false;
2147 syncCalendar( fn, 3 ); 2147 syncCalendar( fn, 3 );
2148 Event * e = getLastSyncEvent(); 2148 Event * e = getLastSyncEvent();
2149 if ( e ) 2149 if ( e )
2150 mCalendar->deleteEvent( e ); 2150 mCalendar->deleteEvent( e );
2151 return true; 2151 return true;
2152} 2152}
2153bool CalendarView::saveCalendars() 2153bool CalendarView::saveCalendars()
2154{ 2154{
2155 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2155 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2156 KopiCalendarFile * cal = calendars.first(); 2156 KopiCalendarFile * cal = calendars.first();
2157 mCalendar->setDefaultCalendar( 1 ); 2157 mCalendar->setDefaultCalendar( 1 );
2158 mCalendar->setDefaultCalendarEnabledOnly(); 2158 mCalendar->setDefaultCalendarEnabledOnly();
2159 saveCalendar( MainWindow::defaultFileName() ); 2159 saveCalendar( MainWindow::defaultFileName() );
2160 cal = calendars.next(); 2160 cal = calendars.next();
2161 while ( cal ) { 2161 while ( cal ) {
2162 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2162 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2163 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2163 mCalendar->setDefaultCalendar( cal->mCalNumber );
2164 mCalendar->setDefaultCalendarEnabledOnly(); 2164 mCalendar->setDefaultCalendarEnabledOnly();
2165 if ( saveCalendar( cal->mFileName ) ) 2165 if ( saveCalendar( cal->mFileName ) )
2166 cal->mLoadDt = QDateTime::currentDateTime(); 2166 cal->mLoadDt = QDateTime::currentDateTime();
2167 } 2167 }
2168 cal = calendars.next(); 2168 cal = calendars.next();
2169 } 2169 }
2170 restoreCalendarSettings(); 2170 restoreCalendarSettings();
2171 return true; 2171 return true;
2172} 2172}
2173bool CalendarView::saveCalendar( QString filename ) 2173bool CalendarView::saveCalendar( QString filename )
2174{ 2174{
2175 2175
2176 // Store back all unsaved data into calendar object 2176 // Store back all unsaved data into calendar object
2177 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2177 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2178 if ( mViewManager->currentView() ) 2178 if ( mViewManager->currentView() )
2179 mViewManager->currentView()->flushView(); 2179 mViewManager->currentView()->flushView();
2180 2180
2181 2181
2182 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2182 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2183 mStorage->setSaveFormat( new ICalFormat() ); 2183 mStorage->setSaveFormat( new ICalFormat() );
2184 mStorage->setFileName( filename ); 2184 mStorage->setFileName( filename );
2185 bool success; 2185 bool success;
2186 success = mStorage->save(); 2186 success = mStorage->save();
2187 if ( !success ) { 2187 if ( !success ) {
2188 return false; 2188 return false;
2189 } 2189 }
2190 if ( filename == MainWindow::defaultFileName() ) { 2190 if ( filename == MainWindow::defaultFileName() ) {
2191 setLoadedFileVersion( lfv ); 2191 setLoadedFileVersion( lfv );
2192 watchSavedFile(); 2192 watchSavedFile();
2193 } 2193 }
2194 return true; 2194 return true;
2195} 2195}
2196 2196
2197void CalendarView::closeCalendar() 2197void CalendarView::closeCalendar()
2198{ 2198{
2199 2199
2200 // child windows no longer valid 2200 // child windows no longer valid
2201 clearAllViews(); 2201 clearAllViews();
2202 emit closingDown(); 2202 emit closingDown();
2203 2203
2204 mCalendar->close(); 2204 mCalendar->close();
2205 setModified(false); 2205 setModified(false);
2206 updateView(); 2206 updateView();
2207} 2207}
2208 2208
2209void CalendarView::archiveCalendar() 2209void CalendarView::archiveCalendar()
2210{ 2210{
2211 mDialogManager->showArchiveDialog(); 2211 mDialogManager->showArchiveDialog();
2212} 2212}
2213 2213
2214 2214
2215void CalendarView::readSettings() 2215void CalendarView::readSettings()
2216{ 2216{
2217 2217
2218 2218
2219 // mViewManager->showAgendaView(); 2219 // mViewManager->showAgendaView();
2220 QString str; 2220 QString str;
2221 //qDebug("CalendarView::readSettings() "); 2221 //qDebug("CalendarView::readSettings() ");
2222 // read settings from the KConfig, supplying reasonable 2222 // read settings from the KConfig, supplying reasonable
2223 // defaults where none are to be found 2223 // defaults where none are to be found
2224 KConfig *config = KOGlobals::config(); 2224 KConfig *config = KOGlobals::config();
2225#ifndef KORG_NOSPLITTER 2225#ifndef KORG_NOSPLITTER
2226 config->setGroup("KOrganizer Geometry"); 2226 config->setGroup("KOrganizer Geometry");
2227 2227
2228 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2228 QValueList<int> sizes = config->readIntListEntry("Separator1");
2229 if (sizes.count() != 2) { 2229 if (sizes.count() != 2) {
2230 sizes << mDateNavigator->minimumSizeHint().width(); 2230 sizes << mDateNavigator->minimumSizeHint().width();
2231 sizes << 300; 2231 sizes << 300;
2232 } 2232 }
2233 mPanner->setSizes(sizes); 2233 mPanner->setSizes(sizes);
2234 2234
2235 sizes = config->readIntListEntry("Separator2"); 2235 sizes = config->readIntListEntry("Separator2");
2236 if ( ( mResourceView && sizes.count() == 4 ) || 2236 if ( ( mResourceView && sizes.count() == 4 ) ||
2237 ( !mResourceView && sizes.count() == 3 ) ) { 2237 ( !mResourceView && sizes.count() == 3 ) ) {
2238 mLeftSplitter->setSizes(sizes); 2238 mLeftSplitter->setSizes(sizes);
2239 } 2239 }
2240#endif 2240#endif
2241 globalFlagBlockAgenda = 1; 2241 globalFlagBlockAgenda = 1;
2242 mViewManager->showAgendaView(); 2242 mViewManager->showAgendaView();
2243 //mViewManager->readSettings( config ); 2243 //mViewManager->readSettings( config );
2244 mTodoList->restoreLayout(config,QString("Todo Layout")); 2244 mTodoList->restoreLayout(config,QString("Todo Layout"));
2245 readFilterSettings(config); 2245 readFilterSettings(config);
2246 2246
2247#ifdef DESKTOP_VERSION 2247#ifdef DESKTOP_VERSION
2248 config->setGroup("WidgetLayout"); 2248 config->setGroup("WidgetLayout");
2249 QStringList list; 2249 QStringList list;
2250 list = config->readListEntry("MainLayout"); 2250 list = config->readListEntry("MainLayout");
2251 int x,y,w,h; 2251 int x,y,w,h;
2252 if ( ! list.isEmpty() ) { 2252 if ( ! list.isEmpty() ) {
2253 x = list[0].toInt(); 2253 x = list[0].toInt();
2254 y = list[1].toInt(); 2254 y = list[1].toInt();
2255 w = list[2].toInt(); 2255 w = list[2].toInt();
2256 h = list[3].toInt(); 2256 h = list[3].toInt();
2257 KApplication::testCoords( &x,&y,&w,&h ); 2257 KApplication::testCoords( &x,&y,&w,&h );
2258 topLevelWidget()->setGeometry(x,y,w,h); 2258 topLevelWidget()->setGeometry(x,y,w,h);
2259 2259
2260 } else { 2260 } else {
2261 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2261 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2262 } 2262 }
2263 list = config->readListEntry("EditEventLayout"); 2263 list = config->readListEntry("EditEventLayout");
2264 if ( ! list.isEmpty() ) { 2264 if ( ! list.isEmpty() ) {
2265 x = list[0].toInt(); 2265 x = list[0].toInt();
2266 y = list[1].toInt(); 2266 y = list[1].toInt();
2267 w = list[2].toInt(); 2267 w = list[2].toInt();
2268 h = list[3].toInt(); 2268 h = list[3].toInt();
2269 KApplication::testCoords( &x,&y,&w,&h ); 2269 KApplication::testCoords( &x,&y,&w,&h );
2270 mEventEditor->setGeometry(x,y,w,h); 2270 mEventEditor->setGeometry(x,y,w,h);
2271 2271
2272 } 2272 }
2273 list = config->readListEntry("EditTodoLayout"); 2273 list = config->readListEntry("EditTodoLayout");
2274 if ( ! list.isEmpty() ) { 2274 if ( ! list.isEmpty() ) {
2275 x = list[0].toInt(); 2275 x = list[0].toInt();
2276 y = list[1].toInt(); 2276 y = list[1].toInt();
2277 w = list[2].toInt(); 2277 w = list[2].toInt();
2278 h = list[3].toInt(); 2278 h = list[3].toInt();
2279 KApplication::testCoords( &x,&y,&w,&h ); 2279 KApplication::testCoords( &x,&y,&w,&h );
2280 mTodoEditor->setGeometry(x,y,w,h); 2280 mTodoEditor->setGeometry(x,y,w,h);
2281 2281
2282 } 2282 }
2283 list = config->readListEntry("ViewerLayout"); 2283 list = config->readListEntry("ViewerLayout");
2284 if ( ! list.isEmpty() ) { 2284 if ( ! list.isEmpty() ) {
2285 x = list[0].toInt(); 2285 x = list[0].toInt();
2286 y = list[1].toInt(); 2286 y = list[1].toInt();
2287 w = list[2].toInt(); 2287 w = list[2].toInt();
2288 h = list[3].toInt(); 2288 h = list[3].toInt();
2289 KApplication::testCoords( &x,&y,&w,&h ); 2289 KApplication::testCoords( &x,&y,&w,&h );
2290 getEventViewerDialog()->setGeometry(x,y,w,h); 2290 getEventViewerDialog()->setGeometry(x,y,w,h);
2291 } 2291 }
2292#endif 2292#endif
2293 config->setGroup( "Views" ); 2293 config->setGroup( "Views" );
2294 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2294 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2295 2295
2296 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2296 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2297 2297
2298 int resetval = 0; 2298 int resetval = 0;
2299 int maxVal = 0; 2299 int maxVal = 0;
2300 if (sizes.count() != 3) { 2300 if (sizes.count() != 3) {
2301 if ( KOPrefs::instance()->mVerticalScreen ) { 2301 if ( KOPrefs::instance()->mVerticalScreen ) {
2302 resetval = mDateNavigator->sizeHint().width()+2; 2302 resetval = mDateNavigator->sizeHint().width()+2;
2303 } else { 2303 } else {
2304 resetval = mDateNavigator->sizeHint().height()+2; 2304 resetval = mDateNavigator->sizeHint().height()+2;
2305 } 2305 }
2306 } 2306 }
2307 if ( resetval ) { 2307 if ( resetval ) {
2308 sizes.clear(); 2308 sizes.clear();
2309 if ( KOPrefs::instance()->mVerticalScreen ) { 2309 if ( KOPrefs::instance()->mVerticalScreen ) {
2310 maxVal = QApplication::desktop()->width() -10; 2310 maxVal = QApplication::desktop()->width() -10;
2311 } else { 2311 } else {
2312 maxVal = QApplication::desktop()->height()-10; 2312 maxVal = QApplication::desktop()->height()-10;
2313 } 2313 }
2314 sizes << resetval; 2314 sizes << resetval;
2315 if ( maxVal < resetval + resetval) 2315 if ( maxVal < resetval + resetval)
2316 resetval = maxVal - resetval; 2316 resetval = maxVal - resetval;
2317 sizes << resetval; 2317 sizes << resetval;
2318 sizes << 100; 2318 sizes << 100;
2319 } 2319 }
2320 mLeftFrame->setSizes(sizes); 2320 mLeftFrame->setSizes(sizes);
2321 sizes = config->readIntListEntry("Main Splitter Frame"); 2321 sizes = config->readIntListEntry("Main Splitter Frame");
2322 resetval = 0; 2322 resetval = 0;
2323 maxVal = 0; 2323 maxVal = 0;
2324 if (sizes.count() != 2) { 2324 if (sizes.count() != 2) {
2325 if ( !KOPrefs::instance()->mVerticalScreen ) { 2325 if ( !KOPrefs::instance()->mVerticalScreen ) {
2326 resetval = mDateNavigator->sizeHint().width()+2; 2326 resetval = mDateNavigator->sizeHint().width()+2;
2327 } else { 2327 } else {
2328 resetval = mDateNavigator->sizeHint().height()+2; 2328 resetval = mDateNavigator->sizeHint().height()+2;
2329 } 2329 }
2330 } 2330 }
2331 if ( resetval ) { 2331 if ( resetval ) {
2332 sizes.clear(); 2332 sizes.clear();
2333 if ( !KOPrefs::instance()->mVerticalScreen ) { 2333 if ( !KOPrefs::instance()->mVerticalScreen ) {
2334 maxVal = QApplication::desktop()->width() -10; 2334 maxVal = QApplication::desktop()->width() -10;
2335 } else { 2335 } else {
2336 maxVal = QApplication::desktop()->height()-10; 2336 maxVal = QApplication::desktop()->height()-10;
2337 } 2337 }
2338 sizes << resetval; 2338 sizes << resetval;
2339 if ( maxVal < resetval + resetval) 2339 if ( maxVal < resetval + resetval)
2340 resetval = maxVal - resetval; 2340 resetval = maxVal - resetval;
2341 sizes << resetval; 2341 sizes << resetval;
2342 } 2342 }
2343 mMainFrame->setSizes(sizes); 2343 mMainFrame->setSizes(sizes);
2344 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2344 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2345 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2345 else if ( dateCount == 7 ) mNavigator->selectWeek();
2346 else mNavigator->selectDates( dateCount ); 2346 else mNavigator->selectDates( dateCount );
2347 // mViewManager->readSettings( config ); 2347 // mViewManager->readSettings( config );
2348 updateConfig(); 2348 updateConfig();
2349 globalFlagBlockAgenda = 2; 2349 globalFlagBlockAgenda = 2;
2350 mViewManager->readSettings( config ); 2350 mViewManager->readSettings( config );
2351 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2351 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2352} 2352}
2353 2353
2354void CalendarView::checkSuspendAlarm() 2354void CalendarView::checkSuspendAlarm()
2355{ 2355{
2356 if ( mSuspendTimer->isActive() ) { 2356 if ( mSuspendTimer->isActive() ) {
2357 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2357 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2358 } 2358 }
2359} 2359}
2360void CalendarView::writeSettings() 2360void CalendarView::writeSettings()
2361{ 2361{
2362 // kdDebug() << "CalendarView::writeSettings" << endl; 2362 // kdDebug() << "CalendarView::writeSettings" << endl;
2363 2363
2364 KConfig *config = KOGlobals::config(); 2364 KConfig *config = KOGlobals::config();
2365 2365
2366 mViewManager->writeSettings( config ); 2366 mViewManager->writeSettings( config );
2367 mTodoList->saveLayout(config,QString("Todo Layout")); 2367 mTodoList->saveLayout(config,QString("Todo Layout"));
2368 mDialogManager->writeSettings( config ); 2368 mDialogManager->writeSettings( config );
2369 //KOPrefs::instance()->usrWriteConfig(); 2369 //KOPrefs::instance()->usrWriteConfig();
2370 KOPrefs::instance()->writeConfig(); 2370 KOPrefs::instance()->writeConfig();
2371 2371
2372 writeFilterSettings(config); 2372 writeFilterSettings(config);
2373 config->setGroup( "AppRun" ); 2373 config->setGroup( "AppRun" );
2374 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2374 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2375 int days = dt.daysTo( QDate::currentDate() ); 2375 int days = dt.daysTo( QDate::currentDate() );
2376 dt = dt.addDays( days ); 2376 dt = dt.addDays( days );
2377 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2377 int secs = dt.secsTo( QDateTime::currentDateTime() );
2378 config->writeEntry( "LatestProgramStopDays", days ); 2378 config->writeEntry( "LatestProgramStopDays", days );
2379 config->writeEntry( "LatestProgramStopSecs", secs ); 2379 config->writeEntry( "LatestProgramStopSecs", secs );
2380 //qDebug("KO: Writing stop time: %d ", secs); 2380 //qDebug("KO: Writing stop time: %d ", secs);
2381 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2381 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2382 //QDateTime latest = dt.addSecs ( secs ); 2382 //QDateTime latest = dt.addSecs ( secs );
2383 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2383 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2384 config->setGroup( "Views" ); 2384 config->setGroup( "Views" );
2385 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2385 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2386 2386
2387#if 0 2387#if 0
2388 qDebug("********************* "); 2388 qDebug("********************* ");
2389 qDebug("Testcode secsto "); 2389 qDebug("Testcode secsto ");
2390 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2390 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2391 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2391 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2392 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2392 int secsto = dt_nodaylight.secsTo( dt_daylight );
2393 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2393 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2394 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2394 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2395 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2395 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2396 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2396 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2397 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2397 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2398 qDebug("********************* testcode end"); 2398 qDebug("********************* testcode end");
2399 2399
2400#endif 2400#endif
2401 2401
2402 QValueList<int> listINT = mLeftFrame->sizes(); 2402 QValueList<int> listINT = mLeftFrame->sizes();
2403 config->writeEntry("Left Splitter Frame",listINT); 2403 config->writeEntry("Left Splitter Frame",listINT);
2404 QValueList<int> listINT2 = mMainFrame->sizes(); 2404 QValueList<int> listINT2 = mMainFrame->sizes();
2405 config->writeEntry("Main Splitter Frame",listINT2); 2405 config->writeEntry("Main Splitter Frame",listINT2);
2406#ifdef DESKTOP_VERSION 2406#ifdef DESKTOP_VERSION
2407 config->setGroup("WidgetLayout"); 2407 config->setGroup("WidgetLayout");
2408 QStringList list ;//= config->readListEntry("MainLayout"); 2408 QStringList list ;//= config->readListEntry("MainLayout");
2409 int x,y,w,h; 2409 int x,y,w,h;
2410 QWidget* wid; 2410 QWidget* wid;
2411 wid = topLevelWidget(); 2411 wid = topLevelWidget();
2412 x = wid->geometry().x(); 2412 x = wid->geometry().x();
2413 y = wid->geometry().y(); 2413 y = wid->geometry().y();
2414 w = wid->width(); 2414 w = wid->width();
2415 h = wid->height(); 2415 h = wid->height();
2416 list.clear(); 2416 list.clear();
2417 list << QString::number( x ); 2417 list << QString::number( x );
2418 list << QString::number( y ); 2418 list << QString::number( y );
2419 list << QString::number( w ); 2419 list << QString::number( w );
2420 list << QString::number( h ); 2420 list << QString::number( h );
2421 config->writeEntry("MainLayout",list ); 2421 config->writeEntry("MainLayout",list );
2422 2422
2423 wid = mEventEditor; 2423 wid = mEventEditor;
2424 x = wid->geometry().x(); 2424 x = wid->geometry().x();
2425 y = wid->geometry().y(); 2425 y = wid->geometry().y();
2426 w = wid->width(); 2426 w = wid->width();
2427 h = wid->height(); 2427 h = wid->height();
2428 list.clear(); 2428 list.clear();
2429 list << QString::number( x ); 2429 list << QString::number( x );
2430 list << QString::number( y ); 2430 list << QString::number( y );
2431 list << QString::number( w ); 2431 list << QString::number( w );
2432 list << QString::number( h ); 2432 list << QString::number( h );
2433 config->writeEntry("EditEventLayout",list ); 2433 config->writeEntry("EditEventLayout",list );
2434 2434
2435 wid = mTodoEditor; 2435 wid = mTodoEditor;
2436 x = wid->geometry().x(); 2436 x = wid->geometry().x();
2437 y = wid->geometry().y(); 2437 y = wid->geometry().y();
2438 w = wid->width(); 2438 w = wid->width();
2439 h = wid->height(); 2439 h = wid->height();
2440 list.clear(); 2440 list.clear();
2441 list << QString::number( x ); 2441 list << QString::number( x );
2442 list << QString::number( y ); 2442 list << QString::number( y );
2443 list << QString::number( w ); 2443 list << QString::number( w );
2444 list << QString::number( h ); 2444 list << QString::number( h );
2445 config->writeEntry("EditTodoLayout",list ); 2445 config->writeEntry("EditTodoLayout",list );
2446 wid = getEventViewerDialog(); 2446 wid = getEventViewerDialog();
2447 x = wid->geometry().x(); 2447 x = wid->geometry().x();
2448 y = wid->geometry().y(); 2448 y = wid->geometry().y();
2449 w = wid->width(); 2449 w = wid->width();
2450 h = wid->height(); 2450 h = wid->height();
2451 list.clear(); 2451 list.clear();
2452 list << QString::number( x ); 2452 list << QString::number( x );
2453 list << QString::number( y ); 2453 list << QString::number( y );
2454 list << QString::number( w ); 2454 list << QString::number( w );
2455 list << QString::number( h ); 2455 list << QString::number( h );
2456 config->writeEntry("ViewerLayout",list ); 2456 config->writeEntry("ViewerLayout",list );
2457 wid = mDialogManager->getSearchDialog(); 2457 wid = mDialogManager->getSearchDialog();
2458 if ( wid ) { 2458 if ( wid ) {
2459 x = wid->geometry().x(); 2459 x = wid->geometry().x();
2460 y = wid->geometry().y(); 2460 y = wid->geometry().y();
2461 w = wid->width(); 2461 w = wid->width();
2462 h = wid->height(); 2462 h = wid->height();
2463 list.clear(); 2463 list.clear();
2464 list << QString::number( x ); 2464 list << QString::number( x );
2465 list << QString::number( y ); 2465 list << QString::number( y );
2466 list << QString::number( w ); 2466 list << QString::number( w );
2467 list << QString::number( h ); 2467 list << QString::number( h );
2468 config->writeEntry("SearchLayout",list ); 2468 config->writeEntry("SearchLayout",list );
2469 } 2469 }
2470#endif 2470#endif
2471 2471
2472 2472
2473 config->sync(); 2473 config->sync();
2474} 2474}
2475 2475
2476void CalendarView::readFilterSettings(KConfig *config) 2476void CalendarView::readFilterSettings(KConfig *config)
2477{ 2477{
2478 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2478 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2479 2479
2480 mFilters.clear(); 2480 mFilters.clear();
2481 2481
2482 config->setGroup("General"); 2482 config->setGroup("General");
2483 QStringList filterList = config->readListEntry("CalendarFilters"); 2483 QStringList filterList = config->readListEntry("CalendarFilters");
2484 2484
2485 QStringList::ConstIterator it = filterList.begin(); 2485 QStringList::ConstIterator it = filterList.begin();
2486 QStringList::ConstIterator end = filterList.end(); 2486 QStringList::ConstIterator end = filterList.end();
2487 while(it != end) { 2487 while(it != end) {
2488 // kdDebug() << " filter: " << (*it) << endl; 2488 // kdDebug() << " filter: " << (*it) << endl;
2489 2489
2490 CalFilter *filter; 2490 CalFilter *filter;
2491 filter = new CalFilter(*it); 2491 filter = new CalFilter(*it);
2492 config->setGroup("Filter_" + (*it).utf8()); 2492 config->setGroup("Filter_" + (*it).utf8());
2493 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2493 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2494 filter->setCriteria(config->readNumEntry("Criteria",0)); 2494 filter->setCriteria(config->readNumEntry("Criteria",0));
2495 filter->setCategoryList(config->readListEntry("CategoryList")); 2495 filter->setCategoryList(config->readListEntry("CategoryList"));
2496 mFilters.append(filter); 2496 mFilters.append(filter);
2497 2497
2498 ++it; 2498 ++it;
2499 } 2499 }
2500 2500
2501 if (mFilters.count() == 0) { 2501 if (mFilters.count() == 0) {
2502 CalFilter *filter = new CalFilter(i18n("Default")); 2502 CalFilter *filter = new CalFilter(i18n("Default"));
2503 mFilters.append(filter); 2503 mFilters.append(filter);
2504 } 2504 }
2505 mFilterView->updateFilters(); 2505 mFilterView->updateFilters();
2506 config->setGroup("FilterView"); 2506 config->setGroup("FilterView");
2507 2507
2508 mFilterView->blockSignals(true); 2508 mFilterView->blockSignals(true);
2509 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2509 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2510 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2510 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2511 mFilterView->blockSignals(false); 2511 mFilterView->blockSignals(false);
2512 // We do it manually to avoid it being done twice by the above calls 2512 // We do it manually to avoid it being done twice by the above calls
2513 updateFilter(); 2513 updateFilter();
2514} 2514}
2515 2515
2516void CalendarView::writeFilterSettings(KConfig *config) 2516void CalendarView::writeFilterSettings(KConfig *config)
2517{ 2517{
2518 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2518 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2519 2519
2520 QStringList filterList; 2520 QStringList filterList;
2521 2521
2522 CalFilter *filter = mFilters.first(); 2522 CalFilter *filter = mFilters.first();
2523 while(filter) { 2523 while(filter) {
2524 // kdDebug() << " fn: " << filter->name() << endl; 2524 // kdDebug() << " fn: " << filter->name() << endl;
2525 filterList << filter->name(); 2525 filterList << filter->name();
2526 config->setGroup("Filter_" + filter->name().utf8()); 2526 config->setGroup("Filter_" + filter->name().utf8());
2527 config->writeEntry("Criteria",filter->criteria()); 2527 config->writeEntry("Criteria",filter->criteria());
2528 config->writeEntry("CategoryList",filter->categoryList()); 2528 config->writeEntry("CategoryList",filter->categoryList());
2529 filter = mFilters.next(); 2529 filter = mFilters.next();
2530 } 2530 }
2531 config->setGroup("General"); 2531 config->setGroup("General");
2532 config->writeEntry("CalendarFilters",filterList); 2532 config->writeEntry("CalendarFilters",filterList);
2533 2533
2534 config->setGroup("FilterView"); 2534 config->setGroup("FilterView");
2535 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2535 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2536 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2536 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2537} 2537}
2538 2538
2539 2539
2540void CalendarView::goToday() 2540void CalendarView::goToday()
2541{ 2541{
2542 if ( mViewManager->currentView()->isMonthView() ) 2542 if ( mViewManager->currentView()->isMonthView() )
2543 mNavigator->selectTodayMonth(); 2543 mNavigator->selectTodayMonth();
2544 else 2544 else
2545 mNavigator->selectToday(); 2545 mNavigator->selectToday();
2546} 2546}
2547 2547
2548void CalendarView::goNext() 2548void CalendarView::goNext()
2549{ 2549{
2550 mNavigator->selectNext(); 2550 mNavigator->selectNext();
2551} 2551}
2552 2552
2553void CalendarView::goPrevious() 2553void CalendarView::goPrevious()
2554{ 2554{
2555 mNavigator->selectPrevious(); 2555 mNavigator->selectPrevious();
2556} 2556}
2557void CalendarView::goNextMonth() 2557void CalendarView::goNextMonth()
2558{ 2558{
2559 mNavigator->selectNextMonth(); 2559 mNavigator->selectNextMonth();
2560} 2560}
2561 2561
2562void CalendarView::goPreviousMonth() 2562void CalendarView::goPreviousMonth()
2563{ 2563{
2564 mNavigator->selectPreviousMonth(); 2564 mNavigator->selectPreviousMonth();
2565} 2565}
2566 2566
2567void CalendarView::updateConfig() 2567void CalendarView::updateConfig()
2568{ 2568{
2569 if ( KOPrefs::instance()->mUseAppColors ) 2569 if ( KOPrefs::instance()->mUseAppColors )
2570 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2570 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2571 emit configChanged(); 2571 emit configChanged();
2572 mTodoList->updateConfig(); 2572 mTodoList->updateConfig();
2573 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2573 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2574 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2574 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2575 // To make the "fill window" configurations work 2575 // To make the "fill window" configurations work
2576 //mViewManager->raiseCurrentView(); 2576 //mViewManager->raiseCurrentView();
2577} 2577}
2578 2578
2579 2579
2580void CalendarView::eventChanged(Event *event) 2580void CalendarView::eventChanged(Event *event)
2581{ 2581{
2582 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2582 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2583 //updateUnmanagedViews(); 2583 //updateUnmanagedViews();
2584} 2584}
2585 2585
2586void CalendarView::eventAdded(Event *event) 2586void CalendarView::eventAdded(Event *event)
2587{ 2587{
2588 changeEventDisplay(event,KOGlobals::EVENTADDED); 2588 changeEventDisplay(event,KOGlobals::EVENTADDED);
2589} 2589}
2590 2590
2591void CalendarView::eventToBeDeleted(Event *) 2591void CalendarView::eventToBeDeleted(Event *)
2592{ 2592{
2593 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2593 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2594} 2594}
2595 2595
2596void CalendarView::eventDeleted() 2596void CalendarView::eventDeleted()
2597{ 2597{
2598 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2598 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2599} 2599}
2600void CalendarView::changeTodoDisplay(Todo *which, int action) 2600void CalendarView::changeTodoDisplay(Todo *which, int action)
2601{ 2601{
2602 changeIncidenceDisplay((Incidence *)which, action); 2602 changeIncidenceDisplay((Incidence *)which, action);
2603 mDateNavigator->updateView(); //LR 2603 mDateNavigator->updateView(); //LR
2604 //mDialogManager->updateSearchDialog(); 2604 //mDialogManager->updateSearchDialog();
2605 2605
2606 if (which) { 2606 if (which) {
2607 mViewManager->updateWNview(); 2607 mViewManager->updateWNview();
2608 //mTodoList->updateView(); 2608 //mTodoList->updateView();
2609 } 2609 }
2610 2610
2611} 2611}
2612 2612
2613void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2613void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2614{ 2614{
2615 updateUnmanagedViews(); 2615 updateUnmanagedViews();
2616 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2616 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2617 if ( action == KOGlobals::EVENTDELETED ) { //delete 2617 if ( action == KOGlobals::EVENTDELETED ) { //delete
2618 mCalendar->checkAlarmForIncidence( 0, true ); 2618 mCalendar->checkAlarmForIncidence( 0, true );
2619 if ( mEventViewerDialog ) 2619 if ( mEventViewerDialog )
2620 mEventViewerDialog->hide(); 2620 mEventViewerDialog->hide();
2621 } 2621 }
2622 else 2622 else
2623 mCalendar->checkAlarmForIncidence( which , false ); 2623 mCalendar->checkAlarmForIncidence( which , false );
2624} 2624}
2625 2625
2626// most of the changeEventDisplays() right now just call the view's 2626// most of the changeEventDisplays() right now just call the view's
2627// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2627// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2628void CalendarView::changeEventDisplay(Event *which, int action) 2628void CalendarView::changeEventDisplay(Event *which, int action)
2629{ 2629{
2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2631 changeIncidenceDisplay((Incidence *)which, action); 2631 changeIncidenceDisplay((Incidence *)which, action);
2632 2632
2633 2633
2634 static bool clearallviews = false; 2634 static bool clearallviews = false;
2635 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2635 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2636 if ( clearallviews ) { 2636 if ( clearallviews ) {
2637 clearAllViews(); 2637 clearAllViews();
2638 clearallviews = false; 2638 clearallviews = false;
2639 } 2639 }
2640 return; 2640 return;
2641 } 2641 }
2642 clearallviews = true; 2642 clearallviews = true;
2643 2643
2644 2644
2645 2645
2646 mDateNavigator->updateView(); 2646 mDateNavigator->updateView();
2647 //mDialogManager->updateSearchDialog(); 2647 //mDialogManager->updateSearchDialog();
2648 2648
2649 if (which) { 2649 if (which) {
2650 // If there is an event view visible update the display 2650 // If there is an event view visible update the display
2651 mViewManager->currentView()->changeEventDisplay(which,action); 2651 mViewManager->currentView()->changeEventDisplay(which,action);
2652 // TODO: check, if update needed 2652 // TODO: check, if update needed
2653 // if (which->getTodoStatus()) { 2653 // if (which->getTodoStatus()) {
2654 mTodoList->updateView(); 2654 mTodoList->updateView();
2655 // } 2655 // }
2656 } else { 2656 } else {
2657 mViewManager->currentView()->updateView(); 2657 mViewManager->currentView()->updateView();
2658 } 2658 }
2659} 2659}
2660 2660
2661 2661
2662void CalendarView::updateTodoViews() 2662void CalendarView::updateTodoViews()
2663{ 2663{
2664 mTodoList->updateView(); 2664 mTodoList->updateView();
2665 mViewManager->currentView()->updateView(); 2665 mViewManager->currentView()->updateView();
2666 2666
2667} 2667}
2668 2668
2669 2669
2670 2670
2671void CalendarView::clearAllViews() 2671void CalendarView::clearAllViews()
2672{ 2672{
2673 mTodoList->clearList(); 2673 mTodoList->clearList();
2674 mViewManager->clearAllViews(); 2674 mViewManager->clearAllViews();
2675 SearchDialog * sd = mDialogManager->getSearchDialog(); 2675 SearchDialog * sd = mDialogManager->getSearchDialog();
2676 if ( sd ) { 2676 if ( sd ) {
2677 KOListView* kol = sd->listview(); 2677 KOListView* kol = sd->listview();
2678 if ( kol ) 2678 if ( kol )
2679 kol->clearList(); 2679 kol->clearList();
2680 } 2680 }
2681} 2681}
2682void CalendarView::updateView() 2682void CalendarView::updateView()
2683{ 2683{
2684 static bool clearallviews = false; 2684 static bool clearallviews = false;
2685 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2685 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2686 if ( clearallviews ) { 2686 if ( clearallviews ) {
2687 clearAllViews(); 2687 clearAllViews();
2688 clearallviews = false; 2688 clearallviews = false;
2689 } 2689 }
2690 return; 2690 return;
2691 } 2691 }
2692 clearallviews = true; 2692 clearallviews = true;
2693 DateList tmpList = mNavigator->selectedDates(); 2693 DateList tmpList = mNavigator->selectedDates();
2694 2694
2695 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2695 if ( KOPrefs::instance()->mHideNonStartedTodos )
2696 mTodoList->updateView(); 2696 mTodoList->updateView();
2697 // We assume that the navigator only selects consecutive days. 2697 // We assume that the navigator only selects consecutive days.
2698 updateView( tmpList.first(), tmpList.last() ); 2698 updateView( tmpList.first(), tmpList.last() );
2699} 2699}
2700 2700
2701void CalendarView::updateUnmanagedViews() 2701void CalendarView::updateUnmanagedViews()
2702{ 2702{
2703 mDateNavigator->updateDayMatrix(); 2703 mDateNavigator->updateDayMatrix();
2704} 2704}
2705 2705
2706int CalendarView::msgItemDelete(const QString name) 2706int CalendarView::msgItemDelete(const QString name)
2707{ 2707{
2708 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2708 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2709 i18n("This item will be\npermanently deleted."), 2709 i18n("This item will be\npermanently deleted."),
2710 i18n("KO/Pi Confirmation"),i18n("Delete")); 2710 i18n("KO/Pi Confirmation"),i18n("Delete"));
2711} 2711}
2712 2712
2713 2713
2714void CalendarView::edit_cut() 2714void CalendarView::edit_cut()
2715{ 2715{
2716 Event *anEvent=0; 2716 Event *anEvent=0;
2717 2717
2718 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2718 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2719 2719
2720 if (mViewManager->currentView()->isEventView()) { 2720 if (mViewManager->currentView()->isEventView()) {
2721 if ( incidence && incidence->typeID() == eventID ) { 2721 if ( incidence && incidence->typeID() == eventID ) {
2722 anEvent = static_cast<Event *>(incidence); 2722 anEvent = static_cast<Event *>(incidence);
2723 } 2723 }
2724 } 2724 }
2725 2725
2726 if (!anEvent) { 2726 if (!anEvent) {
2727 KNotifyClient::beep(); 2727 KNotifyClient::beep();
2728 return; 2728 return;
2729 } 2729 }
2730 DndFactory factory( mCalendar ); 2730 DndFactory factory( mCalendar );
2731 factory.cutIncidence(anEvent); 2731 factory.cutIncidence(anEvent);
2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2733} 2733}
2734 2734
2735void CalendarView::edit_copy() 2735void CalendarView::edit_copy()
2736{ 2736{
2737 Event *anEvent=0; 2737 Event *anEvent=0;
2738 2738
2739 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2739 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2740 2740
2741 if (mViewManager->currentView()->isEventView()) { 2741 if (mViewManager->currentView()->isEventView()) {
2742 if ( incidence && incidence->typeID() == eventID ) { 2742 if ( incidence && incidence->typeID() == eventID ) {
2743 anEvent = static_cast<Event *>(incidence); 2743 anEvent = static_cast<Event *>(incidence);
2744 } 2744 }
2745 } 2745 }
2746 2746
2747 if (!anEvent) { 2747 if (!anEvent) {
2748 KNotifyClient::beep(); 2748 KNotifyClient::beep();
2749 return; 2749 return;
2750 } 2750 }
2751 DndFactory factory( mCalendar ); 2751 DndFactory factory( mCalendar );
2752 factory.copyIncidence(anEvent); 2752 factory.copyIncidence(anEvent);
2753} 2753}
2754 2754
2755void CalendarView::edit_paste() 2755void CalendarView::edit_paste()
2756{ 2756{
2757 QDate date = mNavigator->selectedDates().first(); 2757 QDate date = mNavigator->selectedDates().first();
2758 2758
2759 DndFactory factory( mCalendar ); 2759 DndFactory factory( mCalendar );
2760 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2760 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2761 2761
2762 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2762 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2763} 2763}
2764void CalendarView::edit_global_options() 2764void CalendarView::edit_global_options()
2765{ 2765{
2766 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2766 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2767 emit save(); 2767 emit save();
2768 emit saveStopTimer(); 2768 emit saveStopTimer();
2769 mDialogManager->showGlobalOptionsDialog(); 2769 mDialogManager->showGlobalOptionsDialog();
2770 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2770 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2771 emit saveStopTimer(); 2771 emit saveStopTimer();
2772 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2772 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2773 i18n("Timezone settings"),i18n("Reload"))) { 2773 i18n("Timezone settings"),i18n("Reload"))) {
2774 qDebug("KO: TZ reload cancelled "); 2774 qDebug("KO: TZ reload cancelled ");
2775 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2775 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2776 return; 2776 return;
2777 } 2777 }
2778 qDebug("KO: Timezone change "); 2778 qDebug("KO: Timezone change ");
2779 loadCalendars(); 2779 loadCalendars();
2780 setModified(true); 2780 setModified(true);
2781 } 2781 }
2782 else 2782 else
2783 qDebug("KO: No tz change "); 2783 qDebug("KO: No tz change ");
2784} 2784}
2785void CalendarView::edit_options() 2785void CalendarView::edit_options()
2786{ 2786{
2787 mDialogManager->showOptionsDialog(); 2787 mDialogManager->showOptionsDialog();
2788} 2788}
2789 2789
2790 2790
2791void CalendarView::slotSelectPickerDate( QDate d) 2791void CalendarView::slotSelectPickerDate( QDate d)
2792{ 2792{
2793 mDateFrame->hide(); 2793 mDateFrame->hide();
2794 if ( mDatePickerMode == 1 ) { 2794 if ( mDatePickerMode == 1 ) {
2795 mNavigator->slotDaySelect( d ); 2795 mNavigator->slotDaySelect( d );
2796 } else if ( mDatePickerMode == 2 ) { 2796 } else if ( mDatePickerMode == 2 ) {
2797 if ( mMoveIncidence->typeID() == todoID ) { 2797 if ( mMoveIncidence->typeID() == todoID ) {
2798 Todo * to = (Todo *) mMoveIncidence; 2798 Todo * to = (Todo *) mMoveIncidence;
2799 QTime tim; 2799 QTime tim;
2800 int len = 0; 2800 int len = 0;
2801 if ( to->hasStartDate() && to->hasDueDate() ) 2801 if ( to->hasStartDate() && to->hasDueDate() )
2802 len = to->dtStart().secsTo( to->dtDue()); 2802 len = to->dtStart().secsTo( to->dtDue());
2803 if ( to->hasDueDate() ) 2803 if ( to->hasDueDate() )
2804 tim = to->dtDue().time(); 2804 tim = to->dtDue().time();
2805 else { 2805 else {
2806 tim = QTime ( 0,0,0 ); 2806 tim = QTime ( 0,0,0 );
2807 to->setFloats( true ); 2807 to->setFloats( true );
2808 to->setHasDueDate( true ); 2808 to->setHasDueDate( true );
2809 } 2809 }
2810 QDateTime dt ( d,tim ); 2810 QDateTime dt ( d,tim );
2811 to->setDtDue( dt ); 2811 to->setDtDue( dt );
2812 2812
2813 if ( to->hasStartDate() ) { 2813 if ( to->hasStartDate() ) {
2814 if ( len>0 ) 2814 if ( len>0 )
2815 to->setDtStart(to->dtDue().addSecs( -len )); 2815 to->setDtStart(to->dtDue().addSecs( -len ));
2816 else 2816 else
2817 if (to->dtStart() > to->dtDue() ) 2817 if (to->dtStart() > to->dtDue() )
2818 to->setDtStart(to->dtDue().addDays( -3 )); 2818 to->setDtStart(to->dtDue().addDays( -3 ));
2819 } 2819 }
2820 2820
2821 todoChanged( to ); 2821 todoChanged( to );
2822 } else { 2822 } else if ( mMoveIncidence->typeID() == eventID ) {
2823 if ( mMoveIncidence->doesRecur() ) { 2823 if ( mMoveIncidence->doesRecur() ) {
2824#if 0 2824#if 0
2825 // PENDING implement this 2825 // PENDING implement this
2826 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2826 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2827 mCalendar()->addIncidence( newInc ); 2827 mCalendar()->addIncidence( newInc );
2828 if ( mMoveIncidence->typeID() == todoID ) 2828 if ( mMoveIncidence->typeID() == todoID )
2829 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2829 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2830 else 2830 else
2831 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2831 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2832 mMoveIncidence = newInc; 2832 mMoveIncidence = newInc;
2833 2833
2834#endif 2834#endif
2835 } 2835 }
2836 QTime tim = mMoveIncidence->dtStart().time(); 2836 QTime tim = mMoveIncidence->dtStart().time();
2837 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2837 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2838 QDateTime dt ( d,tim ); 2838 QDateTime dt ( d,tim );
2839 mMoveIncidence->setDtStart( dt ); 2839 mMoveIncidence->setDtStart( dt );
2840 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2840 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2841 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2841 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2842 } else if ( mMoveIncidence->typeID() == journalID ) {
2843 QTime tim = mMoveIncidence->dtStart().time();
2844 QDateTime dt ( d,tim );
2845 mMoveIncidence->setDtStart( dt );
2846 updateView();
2842 } 2847 }
2843
2844 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2848 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2845 } 2849 }
2846} 2850}
2847 2851
2848void CalendarView::removeCategories() 2852void CalendarView::removeCategories()
2849{ 2853{
2850 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2854 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2851 QStringList catList = KOPrefs::instance()->mCustomCategories; 2855 QStringList catList = KOPrefs::instance()->mCustomCategories;
2852 QStringList catIncList; 2856 QStringList catIncList;
2853 QStringList newCatList; 2857 QStringList newCatList;
2854 Incidence* inc = incList.first(); 2858 Incidence* inc = incList.first();
2855 uint i; 2859 uint i;
2856 while ( inc ) { 2860 while ( inc ) {
2857 newCatList.clear(); 2861 newCatList.clear();
2858 catIncList = inc->categories() ; 2862 catIncList = inc->categories() ;
2859 for( i = 0; i< catIncList.count(); ++i ) { 2863 for( i = 0; i< catIncList.count(); ++i ) {
2860 if ( catList.contains (catIncList[i])) 2864 if ( catList.contains (catIncList[i]))
2861 newCatList.append( catIncList[i] ); 2865 newCatList.append( catIncList[i] );
2862 } 2866 }
2863 newCatList.sort(); 2867 newCatList.sort();
2864 inc->setCategories( newCatList.join(",") ); 2868 inc->setCategories( newCatList.join(",") );
2865 inc = incList.next(); 2869 inc = incList.next();
2866 } 2870 }
2867} 2871}
2868 2872
2869int CalendarView::addCategories() 2873int CalendarView::addCategories()
2870{ 2874{
2871 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2875 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2872 QStringList catList = KOPrefs::instance()->mCustomCategories; 2876 QStringList catList = KOPrefs::instance()->mCustomCategories;
2873 QStringList catIncList; 2877 QStringList catIncList;
2874 Incidence* inc = incList.first(); 2878 Incidence* inc = incList.first();
2875 uint i; 2879 uint i;
2876 int count = 0; 2880 int count = 0;
2877 while ( inc ) { 2881 while ( inc ) {
2878 catIncList = inc->categories() ; 2882 catIncList = inc->categories() ;
2879 for( i = 0; i< catIncList.count(); ++i ) { 2883 for( i = 0; i< catIncList.count(); ++i ) {
2880 if ( !catList.contains (catIncList[i])) { 2884 if ( !catList.contains (catIncList[i])) {
2881 catList.append( catIncList[i] ); 2885 catList.append( catIncList[i] );
2882 //qDebug("add cat %s ", catIncList[i].latin1()); 2886 //qDebug("add cat %s ", catIncList[i].latin1());
2883 ++count; 2887 ++count;
2884 } 2888 }
2885 } 2889 }
2886 inc = incList.next(); 2890 inc = incList.next();
2887 } 2891 }
2888 catList.sort(); 2892 catList.sort();
2889 KOPrefs::instance()->mCustomCategories = catList; 2893 KOPrefs::instance()->mCustomCategories = catList;
2890 return count; 2894 return count;
2891} 2895}
2892 2896
2893void CalendarView::editCategories() 2897void CalendarView::editCategories()
2894{ 2898{
2895 qDebug("CalendarView::editCategories() "); 2899 qDebug("CalendarView::editCategories() ");
2896 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 2900 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
2897 ced.exec(); 2901 ced.exec();
2898} 2902}
2899void CalendarView::manageCategories() 2903void CalendarView::manageCategories()
2900{ 2904{
2901 KOCatPrefs* cp = new KOCatPrefs(); 2905 KOCatPrefs* cp = new KOCatPrefs();
2902 cp->show(); 2906 cp->show();
2903 int w =cp->sizeHint().width() ; 2907 int w =cp->sizeHint().width() ;
2904 int h = cp->sizeHint().height() ; 2908 int h = cp->sizeHint().height() ;
2905 int dw = QApplication::desktop()->width(); 2909 int dw = QApplication::desktop()->width();
2906 int dh = QApplication::desktop()->height(); 2910 int dh = QApplication::desktop()->height();
2907 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2911 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2908 if ( !cp->exec() ) { 2912 if ( !cp->exec() ) {
2909 delete cp; 2913 delete cp;
2910 return; 2914 return;
2911 } 2915 }
2912 int count = 0; 2916 int count = 0;
2913 if ( cp->addCat() ) { 2917 if ( cp->addCat() ) {
2914 count = addCategories(); 2918 count = addCategories();
2915 if ( count ) { 2919 if ( count ) {
2916 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2920 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2917 writeSettings(); 2921 writeSettings();
2918 } else 2922 } else
2919 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2923 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2920 } else { 2924 } else {
2921 removeCategories(); 2925 removeCategories();
2922 updateView(); 2926 updateView();
2923 } 2927 }
2924 delete cp; 2928 delete cp;
2925} 2929}
2926 2930
2927void CalendarView::beamIncidence(Incidence * Inc) 2931void CalendarView::beamIncidence(Incidence * Inc)
2928{ 2932{
2929 QPtrList<Incidence> delSel ; 2933 QPtrList<Incidence> delSel ;
2930 delSel.append(Inc); 2934 delSel.append(Inc);
2931 beamIncidenceList( delSel ); 2935 beamIncidenceList( delSel );
2932} 2936}
2933void CalendarView::beamCalendar() 2937void CalendarView::beamCalendar()
2934{ 2938{
2935 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2939 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2936 //qDebug("beamCalendar() "); 2940 //qDebug("beamCalendar() ");
2937 beamIncidenceList( delSel ); 2941 beamIncidenceList( delSel );
2938} 2942}
2939void CalendarView::beamFilteredCalendar() 2943void CalendarView::beamFilteredCalendar()
2940{ 2944{
2941 QPtrList<Incidence> delSel = mCalendar->incidences(); 2945 QPtrList<Incidence> delSel = mCalendar->incidences();
2942 //qDebug("beamFilteredCalendar() "); 2946 //qDebug("beamFilteredCalendar() ");
2943 beamIncidenceList( delSel ); 2947 beamIncidenceList( delSel );
2944} 2948}
2945void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2949void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2946{ 2950{
2947 2951
2948 KOBeamPrefs beamDialog; 2952 KOBeamPrefs beamDialog;
2949 if ( beamDialog.exec () == QDialog::Rejected ) 2953 if ( beamDialog.exec () == QDialog::Rejected )
2950 return; 2954 return;
2951#ifdef DESKTOP_VERSION 2955#ifdef DESKTOP_VERSION
2952 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2956 QString fn = locateLocal( "tmp", "kopibeamfile" );
2953#else 2957#else
2954 QString fn = "/tmp/kopibeamfile"; 2958 QString fn = "/tmp/kopibeamfile";
2955#endif 2959#endif
2956 QString mes; 2960 QString mes;
2957 bool createbup = true; 2961 bool createbup = true;
2958 if ( createbup ) { 2962 if ( createbup ) {
2959 QString description = "\n"; 2963 QString description = "\n";
2960 CalendarLocal* cal = new CalendarLocal(); 2964 CalendarLocal* cal = new CalendarLocal();
2961 if ( beamDialog.beamLocal() ) 2965 if ( beamDialog.beamLocal() )
2962 cal->setLocalTime(); 2966 cal->setLocalTime();
2963 else 2967 else
2964 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2968 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2965 Incidence *incidence = delSel.first(); 2969 Incidence *incidence = delSel.first();
2966 bool addText = false; 2970 bool addText = false;
2967 if ( delSel.count() < 10 ) 2971 if ( delSel.count() < 10 )
2968 addText = true; 2972 addText = true;
2969 else { 2973 else {
2970 description.sprintf(i18n(" %d items?"),delSel.count() ); 2974 description.sprintf(i18n(" %d items?"),delSel.count() );
2971 } 2975 }
2972 while ( incidence ) { 2976 while ( incidence ) {
2973 Incidence *in = incidence->clone(); 2977 Incidence *in = incidence->clone();
2974 if ( ! in->summary().isEmpty() ) { 2978 if ( ! in->summary().isEmpty() ) {
2975 in->setDescription(""); 2979 in->setDescription("");
2976 } else { 2980 } else {
2977 in->setSummary( in->description().left(20)); 2981 in->setSummary( in->description().left(20));
2978 in->setDescription(""); 2982 in->setDescription("");
2979 } 2983 }
2980 if ( addText ) 2984 if ( addText )
2981 description += in->summary() + "\n"; 2985 description += in->summary() + "\n";
2982 cal->addIncidence( in ); 2986 cal->addIncidence( in );
2983 incidence = delSel.next(); 2987 incidence = delSel.next();
2984 } 2988 }
2985 if ( beamDialog.beamVcal() ) { 2989 if ( beamDialog.beamVcal() ) {
2986 fn += ".vcs"; 2990 fn += ".vcs";
2987 FileStorage storage( cal, fn, new VCalFormat ); 2991 FileStorage storage( cal, fn, new VCalFormat );
2988 storage.save(); 2992 storage.save();
2989 } else { 2993 } else {
2990 fn += ".ics"; 2994 fn += ".ics";
2991 FileStorage storage( cal, fn, new ICalFormat( ) ); 2995 FileStorage storage( cal, fn, new ICalFormat( ) );
2992 storage.save(); 2996 storage.save();
2993 } 2997 }
2994 delete cal; 2998 delete cal;
2995 mes = i18n("KO/Pi: Ready for beaming"); 2999 mes = i18n("KO/Pi: Ready for beaming");
2996 topLevelWidget()->setCaption(mes); 3000 topLevelWidget()->setCaption(mes);
2997 KApplication::convert2latin1( fn ); 3001 KApplication::convert2latin1( fn );
2998#ifndef DESKTOP_VERSION 3002#ifndef DESKTOP_VERSION
2999 Ir *ir = new Ir( this ); 3003 Ir *ir = new Ir( this );
3000 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3004 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3001 ir->send( fn, description, "text/x-vCalendar" ); 3005 ir->send( fn, description, "text/x-vCalendar" );
3002#endif 3006#endif
3003 } 3007 }
3004} 3008}
3005 3009
3006#ifndef DESKTOP_VERSION 3010#ifndef DESKTOP_VERSION
3007void CalendarView::beamDone( Ir *ir ) 3011void CalendarView::beamDone( Ir *ir )
3008{ 3012{
3009 delete ir; 3013 delete ir;
3010 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3014 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3011 topLevelWidget()->raise(); 3015 topLevelWidget()->raise();
3012} 3016}
3013#else 3017#else
3014void CalendarView::beamDone( Ir *){;} 3018void CalendarView::beamDone( Ir *){;}
3015#endif 3019#endif
3016void CalendarView::moveIncidence(Incidence * inc ) 3020void CalendarView::moveIncidence(Incidence * inc )
3017{ 3021{
3018 if ( !inc ) return; 3022 if ( !inc ) return;
3019 showDatePickerPopup(); 3023 showDatePickerPopup();
3020 mDatePickerMode = 2; 3024 mDatePickerMode = 2;
3021 mMoveIncidence = inc ; 3025 mMoveIncidence = inc ;
3022 QDate da; 3026 QDate da;
3023 if ( mMoveIncidence->typeID() == todoID ) { 3027 if ( mMoveIncidence->typeID() == todoID ) {
3024 Todo * to = (Todo *) mMoveIncidence; 3028 Todo * to = (Todo *) mMoveIncidence;
3025 if ( to->hasDueDate() ) 3029 if ( to->hasDueDate() )
3026 da = to->dtDue().date(); 3030 da = to->dtDue().date();
3027 else 3031 else
3028 da = QDate::currentDate(); 3032 da = QDate::currentDate();
3029 } else { 3033 } else {
3030 da = mMoveIncidence->dtStart().date(); 3034 da = mMoveIncidence->dtStart().date();
3031 } 3035 }
3032 //PENDING set date for recurring incidence to date of recurrence 3036 //PENDING set date for recurring incidence to date of recurrence
3033 //mMoveIncidenceOldDate; 3037 //mMoveIncidenceOldDate;
3034 mDatePicker->setDate( da ); 3038 mDatePicker->setDate( da );
3035} 3039}
3036void CalendarView::showDatePickerPopup() 3040void CalendarView::showDatePickerPopup()
3037{ 3041{
3038 if ( mDateFrame->isVisible() ) 3042 if ( mDateFrame->isVisible() )
3039 mDateFrame->hide(); 3043 mDateFrame->hide();
3040 else { 3044 else {
3041 int offX = 0, offY = 0; 3045 int offX = 0, offY = 0;
3042#ifdef DESKTOP_VERSION 3046#ifdef DESKTOP_VERSION
3043 int w =mDatePicker->sizeHint().width() ; 3047 int w =mDatePicker->sizeHint().width() ;
3044 int h = mDatePicker->sizeHint().height() ; 3048 int h = mDatePicker->sizeHint().height() ;
3045 int dw = topLevelWidget()->width(); 3049 int dw = topLevelWidget()->width();
3046 int dh = topLevelWidget()->height(); 3050 int dh = topLevelWidget()->height();
3047 offX = topLevelWidget()->x(); 3051 offX = topLevelWidget()->x();
3048 offY = topLevelWidget()->y(); 3052 offY = topLevelWidget()->y();
3049#else 3053#else
3050 int w =mDatePicker->sizeHint().width() ; 3054 int w =mDatePicker->sizeHint().width() ;
3051 int h = mDatePicker->sizeHint().height() ; 3055 int h = mDatePicker->sizeHint().height() ;
3052 int dw = QApplication::desktop()->width(); 3056 int dw = QApplication::desktop()->width();
3053 int dh = QApplication::desktop()->height(); 3057 int dh = QApplication::desktop()->height();
3054#endif 3058#endif
3055 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3059 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3056 mDateFrame->show(); 3060 mDateFrame->show();
3057 } 3061 }
3058} 3062}
3059void CalendarView::showDatePicker( ) 3063void CalendarView::showDatePicker( )
3060{ 3064{
3061 showDatePickerPopup(); 3065 showDatePickerPopup();
3062 mDatePickerMode = 1; 3066 mDatePickerMode = 1;
3063 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3067 mDatePicker->setDate( mNavigator->selectedDates().first() );
3064} 3068}
3065 3069
3066void CalendarView::showEventEditor() 3070void CalendarView::showEventEditor()
3067{ 3071{
3068#ifdef DESKTOP_VERSION 3072#ifdef DESKTOP_VERSION
3069 int x,y,w,h; 3073 int x,y,w,h;
3070 x = mEventEditor->geometry().x(); 3074 x = mEventEditor->geometry().x();
3071 y = mEventEditor->geometry().y(); 3075 y = mEventEditor->geometry().y();
3072 w = mEventEditor->width(); 3076 w = mEventEditor->width();
3073 h = mEventEditor->height(); 3077 h = mEventEditor->height();
3074 mEventEditor->show(); 3078 mEventEditor->show();
3075 mEventEditor->setGeometry(x,y,w,h); 3079 mEventEditor->setGeometry(x,y,w,h);
3076#else 3080#else
3077 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3081 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3078 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3082 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3079 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3083 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3080 qApp->processEvents(); 3084 qApp->processEvents();
3081 delete mEventEditor; 3085 delete mEventEditor;
3082 mEventEditor = mDialogManager->getEventEditor(); 3086 mEventEditor = mDialogManager->getEventEditor();
3083 topLevelWidget()->setCaption( i18n("") ); 3087 topLevelWidget()->setCaption( i18n("") );
3084 } 3088 }
3085 mEventEditor->showMaximized(); 3089 mEventEditor->showMaximized();
3086#endif 3090#endif
3087} 3091}
3088void CalendarView::showTodoEditor() 3092void CalendarView::showTodoEditor()
3089{ 3093{
3090#ifdef DESKTOP_VERSION 3094#ifdef DESKTOP_VERSION
3091 int x,y,w,h; 3095 int x,y,w,h;
3092 x = mTodoEditor->geometry().x(); 3096 x = mTodoEditor->geometry().x();
3093 y = mTodoEditor->geometry().y(); 3097 y = mTodoEditor->geometry().y();
3094 w = mTodoEditor->width(); 3098 w = mTodoEditor->width();
3095 h = mTodoEditor->height(); 3099 h = mTodoEditor->height();
3096 mTodoEditor->show(); 3100 mTodoEditor->show();
3097 mTodoEditor->setGeometry(x,y,w,h); 3101 mTodoEditor->setGeometry(x,y,w,h);
3098#else 3102#else
3099 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3103 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3100 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3104 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3101 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3105 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3102 qApp->processEvents(); 3106 qApp->processEvents();
3103 delete mTodoEditor; 3107 delete mTodoEditor;
3104 mTodoEditor = mDialogManager->getTodoEditor(); 3108 mTodoEditor = mDialogManager->getTodoEditor();
3105 topLevelWidget()->setCaption( i18n("") ); 3109 topLevelWidget()->setCaption( i18n("") );
3106 } 3110 }
3107 mTodoEditor->showMaximized(); 3111 mTodoEditor->showMaximized();
3108#endif 3112#endif
3109} 3113}
3110 3114
3111void CalendarView::cloneIncidence() 3115void CalendarView::cloneIncidence()
3112{ 3116{
3113 Incidence *incidence = currentSelection(); 3117 Incidence *incidence = currentSelection();
3114 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3118 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3115 if ( incidence ) { 3119 if ( incidence ) {
3116 cloneIncidence(incidence); 3120 cloneIncidence(incidence);
3117 } 3121 }
3118} 3122}
3119void CalendarView::moveIncidence() 3123void CalendarView::moveIncidence()
3120{ 3124{
3121 Incidence *incidence = currentSelection(); 3125 Incidence *incidence = currentSelection();
3122 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3126 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3123 if ( incidence ) { 3127 if ( incidence ) {
3124 moveIncidence(incidence); 3128 moveIncidence(incidence);
3125 } 3129 }
3126} 3130}
3127void CalendarView::beamIncidence() 3131void CalendarView::beamIncidence()
3128{ 3132{
3129 Incidence *incidence = currentSelection(); 3133 Incidence *incidence = currentSelection();
3130 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3134 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3131 if ( incidence ) { 3135 if ( incidence ) {
3132 beamIncidence(incidence); 3136 beamIncidence(incidence);
3133 } 3137 }
3134} 3138}
3135void CalendarView::toggleCancelIncidence() 3139void CalendarView::toggleCancelIncidence()
3136{ 3140{
3137 Incidence *incidence = currentSelection(); 3141 Incidence *incidence = currentSelection();
3138 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3142 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3139 if ( incidence ) { 3143 if ( incidence ) {
3140 cancelIncidence(incidence); 3144 cancelIncidence(incidence);
3141 } 3145 }
3142} 3146}
3143 3147
3144 3148
3145void CalendarView::cancelIncidence(Incidence * inc ) 3149void CalendarView::cancelIncidence(Incidence * inc )
3146{ 3150{
3147 inc->setCancelled( ! inc->cancelled() ); 3151 inc->setCancelled( ! inc->cancelled() );
3148 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3152 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3149 updateView(); 3153 updateView();
3150} 3154}
3151void CalendarView::cloneIncidence(Incidence * orgInc ) 3155void CalendarView::cloneIncidence(Incidence * orgInc )
3152{ 3156{
3153 Incidence * newInc = orgInc->clone(); 3157 Incidence * newInc = orgInc->clone();
3154 newInc->recreate(); 3158 newInc->recreate();
3155 3159
3156 if ( newInc->typeID() == todoID ) { 3160 if ( newInc->typeID() == todoID ) {
3157 Todo* t = (Todo*) newInc; 3161 Todo* t = (Todo*) newInc;
3158 bool cloneSub = false; 3162 bool cloneSub = false;
3159 if ( orgInc->relations().count() ) { 3163 if ( orgInc->relations().count() ) {
3160 int result = KMessageBox::warningYesNoCancel(this, 3164 int result = KMessageBox::warningYesNoCancel(this,
3161 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 3165 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
3162 i18n("Todo has subtodos"), 3166 i18n("Todo has subtodos"),
3163 i18n("Yes"), 3167 i18n("Yes"),
3164 i18n("No")); 3168 i18n("No"));
3165 3169
3166 if ( result == KMessageBox::Cancel ) { 3170 if ( result == KMessageBox::Cancel ) {
3167 delete t; 3171 delete t;
3168 return; 3172 return;
3169 } 3173 }
3170 if (result == KMessageBox::Yes) cloneSub = true; 3174 if (result == KMessageBox::Yes) cloneSub = true;
3171 } 3175 }
3172 showTodoEditor(); 3176 showTodoEditor();
3173 mTodoEditor->editTodo( t ); 3177 mTodoEditor->editTodo( t );
3174 if ( mTodoEditor->exec() ) { 3178 if ( mTodoEditor->exec() ) {
3175 if ( cloneSub ) { 3179 if ( cloneSub ) {
3176 orgInc->cloneRelations( t ); 3180 orgInc->cloneRelations( t );
3177 mCalendar->addIncidenceBranch( t ); 3181 mCalendar->addIncidenceBranch( t );
3178 updateView(); 3182 updateView();
3179 3183
3180 } else { 3184 } else {
3181 mCalendar->addTodo( t ); 3185 mCalendar->addTodo( t );
3182 updateView(); 3186 updateView();
3183 } 3187 }
3184 } else { 3188 } else {
3185 delete t; 3189 delete t;
3186 } 3190 }
3187 } 3191 }
3188 else { 3192 else if ( newInc->typeID() == eventID ) {
3189 Event* e = (Event*) newInc; 3193 Event* e = (Event*) newInc;
3190 showEventEditor(); 3194 showEventEditor();
3191 mEventEditor->editEvent( e ); 3195 mEventEditor->editEvent( e );
3192 if ( mEventEditor->exec() ) { 3196 if ( mEventEditor->exec() ) {
3193 mCalendar->addEvent( e ); 3197 mCalendar->addEvent( e );
3194 updateView(); 3198 updateView();
3195 } else { 3199 } else {
3196 delete e; 3200 delete e;
3197 } 3201 }
3202 } if ( newInc->typeID() == journalID ) {
3203 mCalendar->addJournal( (Journal*) newInc );
3204 editJournal( (Journal*) newInc );
3198 } 3205 }
3199 setActiveWindow(); 3206 setActiveWindow();
3200} 3207}
3201 3208
3202void CalendarView::newEvent() 3209void CalendarView::newEvent()
3203{ 3210{
3204 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3211 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3205 KOAgendaView *aView = mViewManager->agendaView(); 3212 KOAgendaView *aView = mViewManager->agendaView();
3206 if (aView) { 3213 if (aView) {
3207 if (aView->selectionStart().isValid()) { 3214 if (aView->selectionStart().isValid()) {
3208 if (aView->selectedIsAllDay()) { 3215 if (aView->selectedIsAllDay()) {
3209 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3216 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3210 } else { 3217 } else {
3211 newEvent(aView->selectionStart(),aView->selectionEnd()); 3218 newEvent(aView->selectionStart(),aView->selectionEnd());
3212 } 3219 }
3213 return; 3220 return;
3214 } 3221 }
3215 } 3222 }
3216 3223
3217 QDate date = mNavigator->selectedDates().first(); 3224 QDate date = mNavigator->selectedDates().first();
3218 QDateTime current = QDateTime::currentDateTime(); 3225 QDateTime current = QDateTime::currentDateTime();
3219 if ( date <= current.date() ) { 3226 if ( date <= current.date() ) {
3220 int hour = current.time().hour() +1; 3227 int hour = current.time().hour() +1;
3221 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3228 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3222 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3229 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3223 } else 3230 } else
3224 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3231 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3225 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3232 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3226 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3233 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3227} 3234}
3228 3235
3229void CalendarView::newEvent(QDateTime fh) 3236void CalendarView::newEvent(QDateTime fh)
3230{ 3237{
3231 newEvent(fh, 3238 newEvent(fh,
3232 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3239 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3233} 3240}
3234 3241
3235void CalendarView::newEvent(QDate dt) 3242void CalendarView::newEvent(QDate dt)
3236{ 3243{
3237 newEvent(QDateTime(dt, QTime(0,0,0)), 3244 newEvent(QDateTime(dt, QTime(0,0,0)),
3238 QDateTime(dt, QTime(0,0,0)), true); 3245 QDateTime(dt, QTime(0,0,0)), true);
3239} 3246}
3240void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3247void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3241{ 3248{
3242 newEvent(fromHint, toHint, false); 3249 newEvent(fromHint, toHint, false);
3243} 3250}
3244void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3251void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3245{ 3252{
3246 3253
3247 showEventEditor(); 3254 showEventEditor();
3248 mEventEditor->newEvent(fromHint,toHint,allDay); 3255 mEventEditor->newEvent(fromHint,toHint,allDay);
3249 if ( mFilterView->filtersEnabled() ) { 3256 if ( mFilterView->filtersEnabled() ) {
3250 CalFilter *filter = mFilterView->selectedFilter(); 3257 CalFilter *filter = mFilterView->selectedFilter();
3251 if (filter && filter->showCategories()) { 3258 if (filter && filter->showCategories()) {
3252 mEventEditor->setCategories(filter->categoryList().join(",") ); 3259 mEventEditor->setCategories(filter->categoryList().join(",") );
3253 } 3260 }
3254 if ( filter ) 3261 if ( filter )
3255 mEventEditor->setSecrecy( filter->getSecrecy() ); 3262 mEventEditor->setSecrecy( filter->getSecrecy() );
3256 } 3263 }
3257 mEventEditor->exec(); 3264 mEventEditor->exec();
3258 setActiveWindow(); 3265 setActiveWindow();
3259} 3266}
3260void CalendarView::todoAdded(Todo * t) 3267void CalendarView::todoAdded(Todo * t)
3261{ 3268{
3262 3269
3263 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3270 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3264 updateTodoViews(); 3271 updateTodoViews();
3265} 3272}
3266void CalendarView::todoChanged(Todo * t) 3273void CalendarView::todoChanged(Todo * t)
3267{ 3274{
3268 emit todoModified( t, 4 ); 3275 emit todoModified( t, 4 );
3269 // updateTodoViews(); 3276 // updateTodoViews();
3270} 3277}
3271void CalendarView::todoToBeDeleted(Todo *) 3278void CalendarView::todoToBeDeleted(Todo *)
3272{ 3279{
3273 //qDebug("todoToBeDeleted(Todo *) "); 3280 //qDebug("todoToBeDeleted(Todo *) ");
3274 updateTodoViews(); 3281 updateTodoViews();
3275} 3282}
3276void CalendarView::todoDeleted() 3283void CalendarView::todoDeleted()
3277{ 3284{
3278 //qDebug(" todoDeleted()"); 3285 //qDebug(" todoDeleted()");
3279 updateTodoViews(); 3286 updateTodoViews();
3280} 3287}
3281 3288
3282 3289
3283void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3290void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3284{ 3291{
3285 showTodoEditor(); 3292 showTodoEditor();
3286 mTodoEditor->newTodo(dt,0,allday); 3293 mTodoEditor->newTodo(dt,0,allday);
3287 if ( mFilterView->filtersEnabled() ) { 3294 if ( mFilterView->filtersEnabled() ) {
3288 CalFilter *filter = mFilterView->selectedFilter(); 3295 CalFilter *filter = mFilterView->selectedFilter();
3289 if (filter && filter->showCategories()) { 3296 if (filter && filter->showCategories()) {
3290 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3297 mTodoEditor->setCategories(filter->categoryList().join(",") );
3291 } 3298 }
3292 if ( filter ) 3299 if ( filter )
3293 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3300 mTodoEditor->setSecrecy( filter->getSecrecy() );
3294 } 3301 }
3295 mTodoEditor->exec(); 3302 mTodoEditor->exec();
3296 setActiveWindow(); 3303 setActiveWindow();
3297} 3304}
3298 3305
3299void CalendarView::newTodo() 3306void CalendarView::newTodo()
3300{ 3307{
3301 newTodoDateTime( QDateTime(),true ); 3308 newTodoDateTime( QDateTime(),true );
3302} 3309}
3303 3310
3304void CalendarView::newSubTodo() 3311void CalendarView::newSubTodo()
3305{ 3312{
3306 Todo *todo = selectedTodo(); 3313 Todo *todo = selectedTodo();
3307 if ( todo ) newSubTodo( todo ); 3314 if ( todo ) newSubTodo( todo );
3308} 3315}
3309 3316
3310void CalendarView::newSubTodo(Todo *parentEvent) 3317void CalendarView::newSubTodo(Todo *parentEvent)
3311{ 3318{
3312 3319
3313 showTodoEditor(); 3320 showTodoEditor();
3314 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3321 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3315 mTodoEditor->exec(); 3322 mTodoEditor->exec();
3316 setActiveWindow(); 3323 setActiveWindow();
3317} 3324}
3318 3325
3319void CalendarView::newFloatingEvent() 3326void CalendarView::newFloatingEvent()
3320{ 3327{
3321 DateList tmpList = mNavigator->selectedDates(); 3328 DateList tmpList = mNavigator->selectedDates();
3322 QDate date = tmpList.first(); 3329 QDate date = tmpList.first();
3323 3330
3324 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3331 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3325 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3332 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3326} 3333}
3327 3334
3328 3335
3329void CalendarView::editEvent( Event *event ) 3336void CalendarView::editEvent( Event *event )
3330{ 3337{
3331 3338
3332 if ( !event ) return; 3339 if ( !event ) return;
3333 if ( event->isReadOnly() ) { 3340 if ( event->isReadOnly() ) {
3334 showEvent( event ); 3341 showEvent( event );
3335 return; 3342 return;
3336 } 3343 }
3337 showEventEditor(); 3344 showEventEditor();
3338 mEventEditor->editEvent( event , mFlagEditDescription); 3345 mEventEditor->editEvent( event , mFlagEditDescription);
3339 mEventEditor->exec(); 3346 mEventEditor->exec();
3340 setActiveWindow(); 3347 setActiveWindow();
3341 3348
3342} 3349}
3343void CalendarView::editJournal( Journal *jour ) 3350void CalendarView::editJournal( Journal *jour )
3344{ 3351{
3345 if ( !jour ) return; 3352 if ( !jour ) return;
3346 mDialogManager->hideSearchDialog(); 3353 mDialogManager->hideSearchDialog();
3347 mViewManager->showJournalView(); 3354 mViewManager->showJournalView();
3348 mNavigator->slotDaySelect( jour->dtStart().date() ); 3355 mNavigator->slotDaySelect( jour->dtStart().date() );
3349} 3356}
3350void CalendarView::editTodo( Todo *todo ) 3357void CalendarView::editTodo( Todo *todo )
3351{ 3358{
3352 if ( !todo ) return; 3359 if ( !todo ) return;
3353 3360
3354 if ( todo->isReadOnly() ) { 3361 if ( todo->isReadOnly() ) {
3355 showTodo( todo ); 3362 showTodo( todo );
3356 return; 3363 return;
3357 } 3364 }
3358 showTodoEditor(); 3365 showTodoEditor();
3359 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3366 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3360 mTodoEditor->exec(); 3367 mTodoEditor->exec();
3361 setActiveWindow(); 3368 setActiveWindow();
3362 3369
3363} 3370}
3364 3371
3365KOEventViewerDialog* CalendarView::getEventViewerDialog() 3372KOEventViewerDialog* CalendarView::getEventViewerDialog()
3366{ 3373{
3367 if ( !mEventViewerDialog ) { 3374 if ( !mEventViewerDialog ) {
3368 mEventViewerDialog = new KOEventViewerDialog(0); 3375 mEventViewerDialog = new KOEventViewerDialog(0);
3369 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3376 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3370 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3377 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3371 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3378 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3372 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3379 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3373 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3380 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3374 viewManager(), SLOT( showAgendaView( bool ) ) ); 3381 viewManager(), SLOT( showAgendaView( bool ) ) );
3375 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3382 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3376 this, SLOT( slotViewerClosed() ) ); 3383 this, SLOT( slotViewerClosed() ) );
3377 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3384 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3378 this, SLOT( todoChanged(Todo *) ) ); 3385 this, SLOT( todoChanged(Todo *) ) );
3379 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3386 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3380 mEventViewerDialog->resize( 640, 480 ); 3387 mEventViewerDialog->resize( 640, 480 );
3381 3388
3382 } 3389 }
3383 return mEventViewerDialog; 3390 return mEventViewerDialog;
3384} 3391}
3385void CalendarView::showEvent(Event *event) 3392void CalendarView::showEvent(Event *event)
3386{ 3393{
3387 getEventViewerDialog()->setEvent(event); 3394 getEventViewerDialog()->setEvent(event);
3388 getEventViewerDialog()->showMe(); 3395 getEventViewerDialog()->showMe();
3389} 3396}
3390 3397
3391void CalendarView::showTodo(Todo *event) 3398void CalendarView::showTodo(Todo *event)
3392{ 3399{
3393 getEventViewerDialog()->setTodo(event); 3400 getEventViewerDialog()->setTodo(event);
3394 getEventViewerDialog()->showMe(); 3401 getEventViewerDialog()->showMe();
3395} 3402}
3396void CalendarView::showJournal( Journal *jour ) 3403void CalendarView::showJournal( Journal *jour )
3397{ 3404{
3398 getEventViewerDialog()->setJournal(jour); 3405 getEventViewerDialog()->setJournal(jour);
3399 getEventViewerDialog()->showMe(); 3406 getEventViewerDialog()->showMe();
3400 3407
3401} 3408}
3402// void CalendarView::todoModified (Todo *event, int changed) 3409// void CalendarView::todoModified (Todo *event, int changed)
3403// { 3410// {
3404// // if (mDialogList.find (event) != mDialogList.end ()) { 3411// // if (mDialogList.find (event) != mDialogList.end ()) {
3405// // kdDebug() << "Todo modified and open" << endl; 3412// // kdDebug() << "Todo modified and open" << endl;
3406// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3413// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3407// // temp->modified (changed); 3414// // temp->modified (changed);
3408 3415
3409// // } 3416// // }
3410 3417
3411// mViewManager->updateView(); 3418// mViewManager->updateView();
3412// } 3419// }
3413 3420
3414void CalendarView::appointment_show() 3421void CalendarView::appointment_show()
3415{ 3422{
3416 Event *anEvent = 0; 3423 Event *anEvent = 0;
3417 3424
3418 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3425 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3419 3426
3420 if (mViewManager->currentView()->isEventView()) { 3427 if (mViewManager->currentView()->isEventView()) {
3421 if ( incidence && incidence->typeID() == eventID ) { 3428 if ( incidence && incidence->typeID() == eventID ) {
3422 anEvent = static_cast<Event *>(incidence); 3429 anEvent = static_cast<Event *>(incidence);
3423 } 3430 }
3424 } 3431 }
3425 3432
3426 if (!anEvent) { 3433 if (!anEvent) {
3427 KNotifyClient::beep(); 3434 KNotifyClient::beep();
3428 return; 3435 return;
3429 } 3436 }
3430 3437
3431 showEvent(anEvent); 3438 showEvent(anEvent);
3432} 3439}
3433 3440
3434void CalendarView::appointment_edit() 3441void CalendarView::appointment_edit()
3435{ 3442{
3436 Event *anEvent = 0; 3443 Event *anEvent = 0;
3437 3444
3438 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3445 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3439 3446
3440 if (mViewManager->currentView()->isEventView()) { 3447 if (mViewManager->currentView()->isEventView()) {
3441 if ( incidence && incidence->typeID() == eventID ) { 3448 if ( incidence && incidence->typeID() == eventID ) {
3442 anEvent = static_cast<Event *>(incidence); 3449 anEvent = static_cast<Event *>(incidence);
3443 } 3450 }
3444 } 3451 }
3445 3452
3446 if (!anEvent) { 3453 if (!anEvent) {
3447 KNotifyClient::beep(); 3454 KNotifyClient::beep();
3448 return; 3455 return;
3449 } 3456 }
3450 3457
3451 editEvent(anEvent); 3458 editEvent(anEvent);
3452} 3459}
3453 3460
3454void CalendarView::appointment_delete() 3461void CalendarView::appointment_delete()
3455{ 3462{
3456 Event *anEvent = 0; 3463 Event *anEvent = 0;
3457 3464
3458 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3465 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3459 3466
3460 if (mViewManager->currentView()->isEventView()) { 3467 if (mViewManager->currentView()->isEventView()) {
3461 if ( incidence && incidence->typeID() == eventID ) { 3468 if ( incidence && incidence->typeID() == eventID ) {
3462 anEvent = static_cast<Event *>(incidence); 3469 anEvent = static_cast<Event *>(incidence);
3463 } 3470 }
3464 } 3471 }
3465 3472
3466 if (!anEvent) { 3473 if (!anEvent) {
3467 KNotifyClient::beep(); 3474 KNotifyClient::beep();
3468 return; 3475 return;
3469 } 3476 }
3470 3477
3471 deleteEvent(anEvent); 3478 deleteEvent(anEvent);
3472} 3479}
3473 3480
3474void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3481void CalendarView::todo_resub( Todo * parent, Todo * sub )
3475{ 3482{
3476 if (!sub) return; 3483 if (!sub) return;
3477 if ( sub->relatedTo() == parent ) 3484 if ( sub->relatedTo() == parent )
3478 return; 3485 return;
3479 sub->setRelatedTo(parent); 3486 sub->setRelatedTo(parent);
3480 sub->updated(); 3487 sub->updated();
3481 setModified(true); 3488 setModified(true);
3482 updateView(); 3489 updateView();
3483} 3490}
3484void CalendarView::todo_unsub(Todo *anTodo ) 3491void CalendarView::todo_unsub(Todo *anTodo )
3485{ 3492{
3486 todo_resub( 0, anTodo ); 3493 todo_resub( 0, anTodo );
3487} 3494}
3488 3495
3489void CalendarView::deleteTodo(Todo *todo) 3496void CalendarView::deleteTodo(Todo *todo)
3490{ 3497{
3491 if (!todo) { 3498 if (!todo) {
3492 KNotifyClient::beep(); 3499 KNotifyClient::beep();
3493 return; 3500 return;
3494 } 3501 }
3495 if (KOPrefs::instance()->mConfirm) { 3502 if (KOPrefs::instance()->mConfirm) {
3496 QString text = todo->summary().left(20); 3503 QString text = todo->summary().left(20);
3497 if (!todo->relations().isEmpty()) { 3504 if (!todo->relations().isEmpty()) {
3498 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3505 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3499 3506
3500 } 3507 }
3501 switch (msgItemDelete(text)) { 3508 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
3502 case KMessageBox::Continue: // OK 3509 case KMessageBox::Continue: // OK
3503 bool deleteT = false; 3510 bool deleteT = false;
3504 if (!todo->relations().isEmpty()) { 3511 if (!todo->relations().isEmpty()) {
3505 deleteT = removeCompletedSubTodos( todo ); 3512 deleteT = removeCompletedSubTodos( todo );
3506 } 3513 }
3507 // deleteT == true: todo already deleted in removeCompletedSubTodos 3514 // deleteT == true: todo already deleted in removeCompletedSubTodos
3508 if ( !deleteT ) { 3515 if ( !deleteT ) {
3509 checkExternalId( todo ); 3516 checkExternalId( todo );
3510 calendar()->deleteTodo(todo); 3517 calendar()->deleteTodo(todo);
3511 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3518 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3512 updateView(); 3519 updateView();
3513 } 3520 }
3514 break; 3521 break;
3515 } // switch 3522 } // switch
3516 } else { 3523 } else {
3517 checkExternalId( todo ); 3524 checkExternalId( todo );
3518 mCalendar->deleteTodo(todo); 3525 mCalendar->deleteTodo(todo);
3519 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3526 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3520 updateView(); 3527 updateView();
3521 } 3528 }
3522 3529
3523 emit updateSearchDialog(); 3530 emit updateSearchDialog();
3524} 3531}
3525void CalendarView::deleteJournal(Journal *jour) 3532void CalendarView::deleteJournal(Journal *jour)
3526{ 3533{
3527 if (!jour) { 3534 if (!jour) {
3528 KNotifyClient::beep(); 3535 KNotifyClient::beep();
3529 return; 3536 return;
3530 } 3537 }
3531 if (KOPrefs::instance()->mConfirm) { 3538 if (KOPrefs::instance()->mConfirm) {
3532 switch (msgItemDelete( jour->description().left(20))) { 3539
3540 QString des;
3541 if ( !jour->summary().isEmpty() ) {
3542 des = jour->summary();
3543 } else {
3544 des = jour->description().left(30);
3545 des = des.simplifyWhiteSpace ();
3546 des.replace (QRegExp ("\\n"),"" );
3547 des.replace (QRegExp ("\\r"),"" );
3548 }
3549 switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) {
3533 case KMessageBox::Continue: // OK 3550 case KMessageBox::Continue: // OK
3534 calendar()->deleteJournal(jour); 3551 calendar()->deleteJournal(jour);
3535 updateView(); 3552 updateView();
3536 break; 3553 break;
3537 } // switch 3554 } // switch
3538 } else { 3555 } else {
3539 calendar()->deleteJournal(jour);; 3556 calendar()->deleteJournal(jour);;
3540 updateView(); 3557 updateView();
3541 } 3558 }
3542 emit updateSearchDialog(); 3559 emit updateSearchDialog();
3543} 3560}
3544 3561
3545void CalendarView::deleteEvent(Event *anEvent) 3562void CalendarView::deleteEvent(Event *anEvent)
3546{ 3563{
3547 if (!anEvent) { 3564 if (!anEvent) {
3548 KNotifyClient::beep(); 3565 KNotifyClient::beep();
3549 return; 3566 return;
3550 } 3567 }
3551 3568
3552 if (anEvent->recurrence()->doesRecur()) { 3569 if (anEvent->recurrence()->doesRecur()) {
3553 QDate itemDate = mViewManager->currentSelectionDate(); 3570 QDate itemDate = mViewManager->currentSelectionDate();
3554 int km; 3571 int km;
3555 if (!itemDate.isValid()) { 3572 if (!itemDate.isValid()) {
3556 //kdDebug() << "Date Not Valid" << endl; 3573 //kdDebug() << "Date Not Valid" << endl;
3557 if (KOPrefs::instance()->mConfirm) { 3574 if (KOPrefs::instance()->mConfirm) {
3558 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3575 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3559 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3576 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3560 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3577 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3561 if ( km == KMessageBox::Continue ) 3578 if ( km == KMessageBox::Continue )
3562 km = KMessageBox::No; // No = all below 3579 km = KMessageBox::No; // No = all below
3563 } else 3580 } else
3564 km = KMessageBox::No; 3581 km = KMessageBox::No;
3565 } else { 3582 } else {
3566 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3583 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3567 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3584 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3568 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3585 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3569 i18n("KO/Pi Confirmation"),i18n("Current"), 3586 i18n("KO/Pi Confirmation"),i18n("Current"),
3570 i18n("All")); 3587 i18n("All"));
3571 } 3588 }
3572 switch(km) { 3589 switch(km) {
3573 3590
3574 case KMessageBox::No: // Continue // all 3591 case KMessageBox::No: // Continue // all
3575 //qDebug("KMessageBox::No "); 3592 //qDebug("KMessageBox::No ");
3576 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3593 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3577 schedule(Scheduler::Cancel,anEvent); 3594 schedule(Scheduler::Cancel,anEvent);
3578 3595
3579 checkExternalId( anEvent); 3596 checkExternalId( anEvent);
3580 mCalendar->deleteEvent(anEvent); 3597 mCalendar->deleteEvent(anEvent);
3581 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3598 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3582 break; 3599 break;
3583 3600
3584 // Disabled because it does not work 3601 // Disabled because it does not work
3585 //#if 0 3602 //#if 0
3586 case KMessageBox::Yes: // just this one 3603 case KMessageBox::Yes: // just this one
3587 //QDate qd = mNavigator->selectedDates().first(); 3604 //QDate qd = mNavigator->selectedDates().first();
3588 //if (!qd.isValid()) { 3605 //if (!qd.isValid()) {
3589 // kdDebug() << "no date selected, or invalid date" << endl; 3606 // kdDebug() << "no date selected, or invalid date" << endl;
3590 // KNotifyClient::beep(); 3607 // KNotifyClient::beep();
3591 // return; 3608 // return;
3592 //} 3609 //}
3593 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3610 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3594 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3611 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3595 anEvent->addExDate(itemDate); 3612 anEvent->addExDate(itemDate);
3596 int duration = anEvent->recurrence()->duration(); 3613 int duration = anEvent->recurrence()->duration();
3597 if ( duration > 0 ) { 3614 if ( duration > 0 ) {
3598 anEvent->recurrence()->setDuration( duration - 1 ); 3615 anEvent->recurrence()->setDuration( duration - 1 );
3599 } 3616 }
3600 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3617 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3601 } 3618 }
3602 break; 3619 break;
3603 //#endif 3620 //#endif
3604 } // switch 3621 } // switch
3605 } else { 3622 } else {
3606 if (KOPrefs::instance()->mConfirm) { 3623 if (KOPrefs::instance()->mConfirm) {
3607 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3624 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3608 i18n("\nAre you sure you want\nto delete this event?"), 3625 i18n("\nAre you sure you want\nto delete this event?"),
3609 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3626 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3610 case KMessageBox::Continue: // OK 3627 case KMessageBox::Continue: // OK
3611 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3628 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3612 schedule(Scheduler::Cancel,anEvent); 3629 schedule(Scheduler::Cancel,anEvent);
3613 checkExternalId( anEvent); 3630 checkExternalId( anEvent);
3614 mCalendar->deleteEvent(anEvent); 3631 mCalendar->deleteEvent(anEvent);
3615 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3632 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3616 break; 3633 break;
3617 } // switch 3634 } // switch
3618 } else { 3635 } else {
3619 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3636 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3620 schedule(Scheduler::Cancel,anEvent); 3637 schedule(Scheduler::Cancel,anEvent);
3621 checkExternalId( anEvent); 3638 checkExternalId( anEvent);
3622 mCalendar->deleteEvent(anEvent); 3639 mCalendar->deleteEvent(anEvent);
3623 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3640 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3624 } 3641 }
3625 } // if-else 3642 } // if-else
3626 emit updateSearchDialog(); 3643 emit updateSearchDialog();
3627} 3644}
3628 3645
3629bool CalendarView::deleteEvent(const QString &uid) 3646bool CalendarView::deleteEvent(const QString &uid)
3630{ 3647{
3631 Event *ev = mCalendar->event(uid); 3648 Event *ev = mCalendar->event(uid);
3632 if (ev) { 3649 if (ev) {
3633 deleteEvent(ev); 3650 deleteEvent(ev);
3634 return true; 3651 return true;
3635 } else { 3652 } else {
3636 return false; 3653 return false;
3637 } 3654 }
3638} 3655}
3639 3656
3640/*****************************************************************************/ 3657/*****************************************************************************/
3641 3658
3642void CalendarView::action_mail() 3659void CalendarView::action_mail()
3643{ 3660{
3644#ifndef KORG_NOMAIL 3661#ifndef KORG_NOMAIL
3645 KOMailClient mailClient; 3662 KOMailClient mailClient;
3646 3663
3647 Incidence *incidence = currentSelection(); 3664 Incidence *incidence = currentSelection();
3648 3665
3649 if (!incidence) { 3666 if (!incidence) {
3650 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3667 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3651 return; 3668 return;
3652 } 3669 }
3653 if(incidence->attendeeCount() == 0 ) { 3670 if(incidence->attendeeCount() == 0 ) {
3654 KMessageBox::sorry(this, 3671 KMessageBox::sorry(this,
3655 i18n("Can't generate mail:\nNo attendees defined.\n")); 3672 i18n("Can't generate mail:\nNo attendees defined.\n"));
3656 return; 3673 return;
3657 } 3674 }
3658 3675
3659 CalendarLocal cal_tmp; 3676 CalendarLocal cal_tmp;
3660 Event *event = 0; 3677 Event *event = 0;
3661 Event *ev = 0; 3678 Event *ev = 0;
3662 if ( incidence && incidence->typeID() == eventID ) { 3679 if ( incidence && incidence->typeID() == eventID ) {
3663 event = static_cast<Event *>(incidence); 3680 event = static_cast<Event *>(incidence);
3664 ev = new Event(*event); 3681 ev = new Event(*event);
3665 cal_tmp.addEvent(ev); 3682 cal_tmp.addEvent(ev);
3666 } 3683 }
3667 ICalFormat mForm(); 3684 ICalFormat mForm();
3668 QString attachment = mForm.toString( &cal_tmp ); 3685 QString attachment = mForm.toString( &cal_tmp );
3669 if (ev) delete(ev); 3686 if (ev) delete(ev);
3670 3687
3671 mailClient.mailAttendees(currentSelection(), attachment); 3688 mailClient.mailAttendees(currentSelection(), attachment);
3672 3689
3673#endif 3690#endif
3674 3691
3675#if 0 3692#if 0
3676 Event *anEvent = 0; 3693 Event *anEvent = 0;
3677 if (mViewManager->currentView()->isEventView()) { 3694 if (mViewManager->currentView()->isEventView()) {
3678 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3695 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3679 } 3696 }
3680 3697
3681 if (!anEvent) { 3698 if (!anEvent) {
3682 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3699 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3683 return; 3700 return;
3684 } 3701 }
3685 if(anEvent->attendeeCount() == 0 ) { 3702 if(anEvent->attendeeCount() == 0 ) {
3686 KMessageBox::sorry(this, 3703 KMessageBox::sorry(this,
3687 i18n("Can't generate mail:\nNo attendees defined.\n")); 3704 i18n("Can't generate mail:\nNo attendees defined.\n"));
3688 return; 3705 return;
3689 } 3706 }
3690 3707
3691 mailobject.emailEvent(anEvent); 3708 mailobject.emailEvent(anEvent);
3692#endif 3709#endif
3693} 3710}
3694 3711
3695 3712
3696void CalendarView::schedule_publish(Incidence *incidence) 3713void CalendarView::schedule_publish(Incidence *incidence)
3697{ 3714{
3698 Event *event = 0; 3715 Event *event = 0;
3699 Todo *todo = 0; 3716 Todo *todo = 0;
3700 3717
3701 if (incidence == 0) { 3718 if (incidence == 0) {
3702 incidence = mViewManager->currentView()->selectedIncidences().first(); 3719 incidence = mViewManager->currentView()->selectedIncidences().first();
3703 if (incidence == 0) { 3720 if (incidence == 0) {
3704 incidence = mTodoList->selectedIncidences().first(); 3721 incidence = mTodoList->selectedIncidences().first();
3705 } 3722 }
3706 } 3723 }
3707 if ( incidence && incidence->typeID() == eventID ) { 3724 if ( incidence && incidence->typeID() == eventID ) {
3708 event = static_cast<Event *>(incidence); 3725 event = static_cast<Event *>(incidence);
3709 } else { 3726 } else {
3710 if ( incidence && incidence->typeID() == todoID ) { 3727 if ( incidence && incidence->typeID() == todoID ) {
3711 todo = static_cast<Todo *>(incidence); 3728 todo = static_cast<Todo *>(incidence);
3712 } 3729 }
3713 } 3730 }
3714 3731
3715 if (!event && !todo) { 3732 if (!event && !todo) {
3716 KMessageBox::sorry(this,i18n("No event selected.")); 3733 KMessageBox::sorry(this,i18n("No event selected."));
3717 return; 3734 return;
3718 } 3735 }
3719 3736
3720 PublishDialog *publishdlg = new PublishDialog(); 3737 PublishDialog *publishdlg = new PublishDialog();
3721 if (incidence->attendeeCount()>0) { 3738 if (incidence->attendeeCount()>0) {
3722 QPtrList<Attendee> attendees = incidence->attendees(); 3739 QPtrList<Attendee> attendees = incidence->attendees();
3723 attendees.first(); 3740 attendees.first();
3724 while ( attendees.current()!=0 ) { 3741 while ( attendees.current()!=0 ) {
3725 publishdlg->addAttendee(attendees.current()); 3742 publishdlg->addAttendee(attendees.current());
3726 attendees.next(); 3743 attendees.next();
3727 } 3744 }
3728 } 3745 }
3729 bool send = true; 3746 bool send = true;
3730 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3747 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3731 if ( publishdlg->exec() != QDialog::Accepted ) 3748 if ( publishdlg->exec() != QDialog::Accepted )
3732 send = false; 3749 send = false;
3733 } 3750 }
3734 if ( send ) { 3751 if ( send ) {
3735 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3752 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3736 if ( event ) { 3753 if ( event ) {
3737 Event *ev = new Event(*event); 3754 Event *ev = new Event(*event);
3738 ev->registerObserver(0); 3755 ev->registerObserver(0);
3739 ev->clearAttendees(); 3756 ev->clearAttendees();
3740 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3757 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3741 delete(ev); 3758 delete(ev);
3742 } 3759 }
3743 } else { 3760 } else {
3744 if ( todo ) { 3761 if ( todo ) {
3745 Todo *ev = new Todo(*todo); 3762 Todo *ev = new Todo(*todo);
3746 ev->registerObserver(0); 3763 ev->registerObserver(0);
3747 ev->clearAttendees(); 3764 ev->clearAttendees();
3748 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3765 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3749 delete(ev); 3766 delete(ev);
3750 } 3767 }
3751 } 3768 }
3752 } 3769 }
3753 } 3770 }
3754 delete publishdlg; 3771 delete publishdlg;
3755} 3772}
3756 3773
3757void CalendarView::schedule_request(Incidence *incidence) 3774void CalendarView::schedule_request(Incidence *incidence)
3758{ 3775{
3759 schedule(Scheduler::Request,incidence); 3776 schedule(Scheduler::Request,incidence);
3760} 3777}
3761 3778
3762void CalendarView::schedule_refresh(Incidence *incidence) 3779void CalendarView::schedule_refresh(Incidence *incidence)
3763{ 3780{
3764 schedule(Scheduler::Refresh,incidence); 3781 schedule(Scheduler::Refresh,incidence);
3765} 3782}
3766 3783
3767void CalendarView::schedule_cancel(Incidence *incidence) 3784void CalendarView::schedule_cancel(Incidence *incidence)
3768{ 3785{
3769 schedule(Scheduler::Cancel,incidence); 3786 schedule(Scheduler::Cancel,incidence);
3770} 3787}
3771 3788
3772void CalendarView::schedule_add(Incidence *incidence) 3789void CalendarView::schedule_add(Incidence *incidence)
3773{ 3790{
3774 schedule(Scheduler::Add,incidence); 3791 schedule(Scheduler::Add,incidence);
3775} 3792}
3776 3793
3777void CalendarView::schedule_reply(Incidence *incidence) 3794void CalendarView::schedule_reply(Incidence *incidence)
3778{ 3795{
3779 schedule(Scheduler::Reply,incidence); 3796 schedule(Scheduler::Reply,incidence);
3780} 3797}
3781 3798
3782void CalendarView::schedule_counter(Incidence *incidence) 3799void CalendarView::schedule_counter(Incidence *incidence)
3783{ 3800{
3784 schedule(Scheduler::Counter,incidence); 3801 schedule(Scheduler::Counter,incidence);
3785} 3802}
3786 3803
3787void CalendarView::schedule_declinecounter(Incidence *incidence) 3804void CalendarView::schedule_declinecounter(Incidence *incidence)
3788{ 3805{
3789 schedule(Scheduler::Declinecounter,incidence); 3806 schedule(Scheduler::Declinecounter,incidence);
3790} 3807}
3791 3808
3792void CalendarView::schedule_publish_freebusy(int daysToPublish) 3809void CalendarView::schedule_publish_freebusy(int daysToPublish)
3793{ 3810{
3794 QDateTime start = QDateTime::currentDateTime(); 3811 QDateTime start = QDateTime::currentDateTime();
3795 QDateTime end = start.addDays(daysToPublish); 3812 QDateTime end = start.addDays(daysToPublish);
3796 3813
3797 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3814 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3798 freebusy->setOrganizer(KOPrefs::instance()->email()); 3815 freebusy->setOrganizer(KOPrefs::instance()->email());
3799 3816
3800 3817
3801 PublishDialog *publishdlg = new PublishDialog(); 3818 PublishDialog *publishdlg = new PublishDialog();
3802 if ( publishdlg->exec() == QDialog::Accepted ) { 3819 if ( publishdlg->exec() == QDialog::Accepted ) {
3803 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3820 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3804 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3821 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3805 delete(freebusy); 3822 delete(freebusy);
3806 } 3823 }
3807 } 3824 }
3808 delete publishdlg; 3825 delete publishdlg;
3809} 3826}
3810 3827
3811void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3828void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3812{ 3829{
3813 Event *event = 0; 3830 Event *event = 0;
3814 Todo *todo = 0; 3831 Todo *todo = 0;
3815 3832
3816 if (incidence == 0) { 3833 if (incidence == 0) {
3817 incidence = mViewManager->currentView()->selectedIncidences().first(); 3834 incidence = mViewManager->currentView()->selectedIncidences().first();
3818 if (incidence == 0) { 3835 if (incidence == 0) {
3819 incidence = mTodoList->selectedIncidences().first(); 3836 incidence = mTodoList->selectedIncidences().first();
3820 } 3837 }
3821 } 3838 }
3822 if ( incidence && incidence->typeID() == eventID ) { 3839 if ( incidence && incidence->typeID() == eventID ) {
3823 event = static_cast<Event *>(incidence); 3840 event = static_cast<Event *>(incidence);
3824 } 3841 }
3825 if ( incidence && incidence->typeID() == todoID ) { 3842 if ( incidence && incidence->typeID() == todoID ) {
3826 todo = static_cast<Todo *>(incidence); 3843 todo = static_cast<Todo *>(incidence);
3827 } 3844 }
3828 3845
3829 if (!event && !todo) { 3846 if (!event && !todo) {
3830 KMessageBox::sorry(this,i18n("No event selected.")); 3847 KMessageBox::sorry(this,i18n("No event selected."));
3831 return; 3848 return;
3832 } 3849 }
3833 3850
3834 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3851 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3835 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3852 KMessageBox::sorry(this,i18n("The event has no attendees."));
3836 return; 3853 return;
3837 } 3854 }
3838 3855
3839 Event *ev = 0; 3856 Event *ev = 0;
3840 if (event) ev = new Event(*event); 3857 if (event) ev = new Event(*event);
3841 Todo *to = 0; 3858 Todo *to = 0;
3842 if (todo) to = new Todo(*todo); 3859 if (todo) to = new Todo(*todo);
3843 3860
3844 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3861 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3845 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3862 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3846 if (!me) { 3863 if (!me) {
3847 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3864 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3848 return; 3865 return;
3849 } 3866 }
3850 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3867 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3851 StatusDialog *statdlg = new StatusDialog(this); 3868 StatusDialog *statdlg = new StatusDialog(this);
3852 if (!statdlg->exec()==QDialog::Accepted) return; 3869 if (!statdlg->exec()==QDialog::Accepted) return;
3853 me->setStatus( statdlg->status() ); 3870 me->setStatus( statdlg->status() );
3854 delete(statdlg); 3871 delete(statdlg);
3855 } 3872 }
3856 Attendee *menew = new Attendee(*me); 3873 Attendee *menew = new Attendee(*me);
3857 if (ev) { 3874 if (ev) {
3858 ev->clearAttendees(); 3875 ev->clearAttendees();
3859 ev->addAttendee(menew,false); 3876 ev->addAttendee(menew,false);
3860 } else { 3877 } else {
3861 if (to) { 3878 if (to) {
3862 todo->clearAttendees(); 3879 todo->clearAttendees();
3863 todo->addAttendee(menew,false); 3880 todo->addAttendee(menew,false);
3864 } 3881 }
3865 } 3882 }
3866 } 3883 }
3867 3884
3868 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3885 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3869 if (ev) { 3886 if (ev) {
3870 if ( !dlg->addMessage(ev,method) ) delete(ev); 3887 if ( !dlg->addMessage(ev,method) ) delete(ev);
3871 } else { 3888 } else {
3872 if (to) { 3889 if (to) {
3873 if ( !dlg->addMessage(to,method) ) delete(to); 3890 if ( !dlg->addMessage(to,method) ) delete(to);
3874 } 3891 }
3875 } 3892 }
3876} 3893}
3877 3894
3878void CalendarView::openAddressbook() 3895void CalendarView::openAddressbook()
3879{ 3896{
3880 KRun::runCommand("kaddressbook"); 3897 KRun::runCommand("kaddressbook");
3881} 3898}
3882 3899
3883void CalendarView::setModified(bool modified) 3900void CalendarView::setModified(bool modified)
3884{ 3901{
3885 if ( modified ) 3902 if ( modified )
3886 emit signalmodified(); 3903 emit signalmodified();
3887 if (mModified != modified) { 3904 if (mModified != modified) {
3888 mModified = modified; 3905 mModified = modified;
3889 emit modifiedChanged(mModified); 3906 emit modifiedChanged(mModified);
3890 } 3907 }
3891} 3908}
3892 3909
3893bool CalendarView::isReadOnly() 3910bool CalendarView::isReadOnly()
3894{ 3911{
3895 return mReadOnly; 3912 return mReadOnly;
3896} 3913}
3897 3914
3898void CalendarView::setReadOnly(bool readOnly) 3915void CalendarView::setReadOnly(bool readOnly)
3899{ 3916{
3900 if (mReadOnly != readOnly) { 3917 if (mReadOnly != readOnly) {
3901 mReadOnly = readOnly; 3918 mReadOnly = readOnly;
3902 emit readOnlyChanged(mReadOnly); 3919 emit readOnlyChanged(mReadOnly);
3903 } 3920 }
3904} 3921}
3905 3922
3906bool CalendarView::isModified() 3923bool CalendarView::isModified()
3907{ 3924{
3908 return mModified; 3925 return mModified;
3909} 3926}
3910void CalendarView::slotprintSelInc() 3927void CalendarView::slotprintSelInc()
3911{ 3928{
3912 if ( currentSelection() == 0 ) { 3929 if ( currentSelection() == 0 ) {
3913 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3930 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3914 return; 3931 return;
3915 } 3932 }
3916 showIncidence(); 3933 showIncidence();
3917 getEventViewerDialog()->print(); 3934 getEventViewerDialog()->print();
3918 3935
3919} 3936}
3920void CalendarView::printSetup() 3937void CalendarView::printSetup()
3921{ 3938{
3922#ifndef KORG_NOPRINTER 3939#ifndef KORG_NOPRINTER
3923 createPrinter(); 3940 createPrinter();
3924 3941
3925 mCalPrinter->setupPrinter(); 3942 mCalPrinter->setupPrinter();
3926#endif 3943#endif
3927} 3944}
3928 3945
3929void CalendarView::print() 3946void CalendarView::print()
3930{ 3947{
3931#ifndef KORG_NOPRINTER 3948#ifndef KORG_NOPRINTER
3932 createPrinter(); 3949 createPrinter();
3933 3950
3934 DateList tmpDateList = mNavigator->selectedDates(); 3951 DateList tmpDateList = mNavigator->selectedDates();
3935 mCalPrinter->print(CalPrinter::Month, 3952 mCalPrinter->print(CalPrinter::Month,
3936 tmpDateList.first(), tmpDateList.last()); 3953 tmpDateList.first(), tmpDateList.last());
3937#endif 3954#endif
3938} 3955}
3939 3956
3940void CalendarView::printPreview() 3957void CalendarView::printPreview()
3941{ 3958{
3942#ifndef KORG_NOPRINTER 3959#ifndef KORG_NOPRINTER
3943 kdDebug() << "CalendarView::printPreview()" << endl; 3960 kdDebug() << "CalendarView::printPreview()" << endl;
3944 3961
3945 createPrinter(); 3962 createPrinter();
3946 3963
3947 DateList tmpDateList = mNavigator->selectedDates(); 3964 DateList tmpDateList = mNavigator->selectedDates();
3948 3965
3949 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3966 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3950 tmpDateList.last()); 3967 tmpDateList.last());
3951#endif 3968#endif
3952} 3969}
3953 3970
3954void CalendarView::exportICalendar() 3971void CalendarView::exportICalendar()
3955{ 3972{
3956 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3973 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3957 3974
3958 // Force correct extension 3975 // Force correct extension
3959 if (filename.right(4) != ".ics") filename += ".ics"; 3976 if (filename.right(4) != ".ics") filename += ".ics";
3960 3977
3961 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3978 FileStorage storage( mCalendar, filename, new ICalFormat() );
3962 storage.save(); 3979 storage.save();
3963} 3980}
3964 3981
3965bool CalendarView::exportVCalendar( QString filename ) 3982bool CalendarView::exportVCalendar( QString filename )
3966{ 3983{
3967 if (mCalendar->journals().count() > 0) { 3984 if (mCalendar->journals().count() > 0) {
3968 int result = KMessageBox::warningContinueCancel(this, 3985 int result = KMessageBox::warningContinueCancel(this,
3969 i18n("The journal entries can not be\nexported to a vCalendar file."), 3986 i18n("The journal entries can not be\nexported to a vCalendar file."),
3970 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3987 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3971 true); 3988 true);
3972 if (result != KMessageBox::Continue) return false; 3989 if (result != KMessageBox::Continue) return false;
3973 } 3990 }
3974 3991
3975 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3992 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3976 3993
3977 // Force correct extension 3994 // Force correct extension
3978 if (filename.right(4) != ".vcs") filename += ".vcs"; 3995 if (filename.right(4) != ".vcs") filename += ".vcs";
3979 3996
3980 FileStorage storage( mCalendar, filename, new VCalFormat ); 3997 FileStorage storage( mCalendar, filename, new VCalFormat );
3981 return storage.save(); 3998 return storage.save();
3982 3999
3983} 4000}
3984 4001
3985void CalendarView::eventUpdated(Incidence *) 4002void CalendarView::eventUpdated(Incidence *)
3986{ 4003{
3987 setModified(); 4004 setModified();
3988 // Don't call updateView here. The code, which has caused the update of the 4005 // Don't call updateView here. The code, which has caused the update of the
3989 // event is responsible for updating the view. 4006 // event is responsible for updating the view.
3990 // updateView(); 4007 // updateView();
3991} 4008}
3992 4009
3993void CalendarView::adaptNavigationUnits() 4010void CalendarView::adaptNavigationUnits()
3994{ 4011{
3995 if (mViewManager->currentView()->isEventView()) { 4012 if (mViewManager->currentView()->isEventView()) {
3996 int days = mViewManager->currentView()->currentDateCount(); 4013 int days = mViewManager->currentView()->currentDateCount();
3997 if (days == 1) { 4014 if (days == 1) {
3998 emit changeNavStringPrev(i18n("&Previous Day")); 4015 emit changeNavStringPrev(i18n("&Previous Day"));
3999 emit changeNavStringNext(i18n("&Next Day")); 4016 emit changeNavStringNext(i18n("&Next Day"));
4000 } else { 4017 } else {
4001 emit changeNavStringPrev(i18n("&Previous Week")); 4018 emit changeNavStringPrev(i18n("&Previous Week"));
4002 emit changeNavStringNext(i18n("&Next Week")); 4019 emit changeNavStringNext(i18n("&Next Week"));
4003 } 4020 }
4004 } 4021 }
4005} 4022}
4006 4023
4007void CalendarView::processMainViewSelection( Incidence *incidence ) 4024void CalendarView::processMainViewSelection( Incidence *incidence )
4008{ 4025{
4009 if ( incidence ) mTodoList->clearSelection(); 4026 if ( incidence ) mTodoList->clearSelection();
4010 processIncidenceSelection( incidence ); 4027 processIncidenceSelection( incidence );
4011} 4028}
4012 4029
4013void CalendarView::processTodoListSelection( Incidence *incidence ) 4030void CalendarView::processTodoListSelection( Incidence *incidence )
4014{ 4031{
4015 if ( incidence && mViewManager->currentView() ) { 4032 if ( incidence && mViewManager->currentView() ) {
4016 mViewManager->currentView()->clearSelection(); 4033 mViewManager->currentView()->clearSelection();
4017 } 4034 }
4018 processIncidenceSelection( incidence ); 4035 processIncidenceSelection( incidence );
4019} 4036}
4020 4037
4021void CalendarView::processIncidenceSelection( Incidence *incidence ) 4038void CalendarView::processIncidenceSelection( Incidence *incidence )
4022{ 4039{
4023 emit incidenceSelected( incidence ); 4040 emit incidenceSelected( incidence );
4024 if ( incidence == mSelectedIncidence ) return; 4041 if ( incidence == mSelectedIncidence ) return;
4025 mSelectedIncidence = incidence; 4042 mSelectedIncidence = incidence;
4026 4043
4027 if ( incidence && incidence->typeID() == eventID ) { 4044 if ( incidence && incidence->typeID() == eventID ) {
4028 Event *event = static_cast<Event *>( incidence ); 4045 Event *event = static_cast<Event *>( incidence );
4029 if ( event->organizer() == KOPrefs::instance()->email() ) { 4046 if ( event->organizer() == KOPrefs::instance()->email() ) {
4030 emit organizerEventsSelected( true ); 4047 emit organizerEventsSelected( true );
4031 } else { 4048 } else {
4032 emit organizerEventsSelected(false); 4049 emit organizerEventsSelected(false);
4033 } 4050 }
4034 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4051 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4035 KOPrefs::instance()->email() ) ) { 4052 KOPrefs::instance()->email() ) ) {
4036 emit groupEventsSelected( true ); 4053 emit groupEventsSelected( true );
4037 } else { 4054 } else {
4038 emit groupEventsSelected(false); 4055 emit groupEventsSelected(false);
4039 } 4056 }
4040 return; 4057 return;
4041 } else { 4058 } else {
4042 if ( incidence && incidence->typeID() == todoID ) { 4059 if ( incidence && incidence->typeID() == todoID ) {
4043 emit todoSelected( true ); 4060 emit todoSelected( true );
4044 Todo *event = static_cast<Todo *>( incidence ); 4061 Todo *event = static_cast<Todo *>( incidence );
4045 if ( event->organizer() == KOPrefs::instance()->email() ) { 4062 if ( event->organizer() == KOPrefs::instance()->email() ) {
4046 emit organizerEventsSelected( true ); 4063 emit organizerEventsSelected( true );
4047 } else { 4064 } else {
4048 emit organizerEventsSelected(false); 4065 emit organizerEventsSelected(false);
4049 } 4066 }
4050 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4067 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4051 KOPrefs::instance()->email() ) ) { 4068 KOPrefs::instance()->email() ) ) {
4052 emit groupEventsSelected( true ); 4069 emit groupEventsSelected( true );
4053 } else { 4070 } else {
4054 emit groupEventsSelected(false); 4071 emit groupEventsSelected(false);
4055 } 4072 }
4056 return; 4073 return;
4057 } else { 4074 } else {
4058 emit todoSelected( false ); 4075 emit todoSelected( false );
4059 emit organizerEventsSelected(false); 4076 emit organizerEventsSelected(false);
4060 emit groupEventsSelected(false); 4077 emit groupEventsSelected(false);
4061 } 4078 }
4062 return; 4079 return;
4063 } 4080 }
4064 4081
4065 /* if ( incidence && incidence->typeID() == todoID ) { 4082 /* if ( incidence && incidence->typeID() == todoID ) {
4066 emit todoSelected( true ); 4083 emit todoSelected( true );
4067 } else { 4084 } else {
4068 emit todoSelected( false ); 4085 emit todoSelected( false );
4069 }*/ 4086 }*/
4070} 4087}
4071 4088
4072 4089
4073void CalendarView::checkClipboard() 4090void CalendarView::checkClipboard()
4074{ 4091{
4075#ifndef KORG_NODND 4092#ifndef KORG_NODND
4076 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4093 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4077 emit pasteEnabled(true); 4094 emit pasteEnabled(true);
4078 } else { 4095 } else {
4079 emit pasteEnabled(false); 4096 emit pasteEnabled(false);
4080 } 4097 }
4081#endif 4098#endif
4082} 4099}
4083 4100
4084void CalendarView::showDates(const DateList &selectedDates) 4101void CalendarView::showDates(const DateList &selectedDates)
4085{ 4102{
4086 // kdDebug() << "CalendarView::selectDates()" << endl; 4103 // kdDebug() << "CalendarView::selectDates()" << endl;
4087 4104
4088 4105
4089 if ( !mBlockShowDates ) { 4106 if ( !mBlockShowDates ) {
4090 if ( mViewManager->currentView() ) { 4107 if ( mViewManager->currentView() ) {
4091 updateView( selectedDates.first(), selectedDates.last() ); 4108 updateView( selectedDates.first(), selectedDates.last() );
4092 } else { 4109 } else {
4093 mViewManager->showAgendaView(); 4110 mViewManager->showAgendaView();
4094 } 4111 }
4095 } 4112 }
4096 4113
4097 QDate date = selectedDates.first(); 4114 QDate date = selectedDates.first();
4098 if ( ! date.isValid() ) { 4115 if ( ! date.isValid() ) {
4099 topLevelWidget()->setCaption(""); 4116 topLevelWidget()->setCaption("");
4100 return; 4117 return;
4101 } 4118 }
4102 4119
4103 QString selDates; 4120 QString selDates;
4104 selDates = KGlobal::locale()->formatDate( date, true); 4121 selDates = KGlobal::locale()->formatDate( date, true);
4105 if (selectedDates.first() < selectedDates.last() ) 4122 if (selectedDates.first() < selectedDates.last() )
4106 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4123 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4107 else { 4124 else {
4108 QString addString; 4125 QString addString;
4109 if ( date == QDateTime::currentDateTime().date() ) 4126 if ( date == QDateTime::currentDateTime().date() )
4110 addString = i18n("Today"); 4127 addString = i18n("Today");
4111 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4128 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4112 addString = i18n("Tomorrow"); 4129 addString = i18n("Tomorrow");
4113 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4130 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4114 addString = i18n("Yesterday"); 4131 addString = i18n("Yesterday");
4115 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4132 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4116 addString = i18n("Day before yesterday"); 4133 addString = i18n("Day before yesterday");
4117 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4134 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4118 addString = i18n("Day after tomorrow"); 4135 addString = i18n("Day after tomorrow");
4119 if ( !addString.isEmpty() ) { 4136 if ( !addString.isEmpty() ) {
4120 topLevelWidget()->setCaption( addString+", " + selDates ); 4137 topLevelWidget()->setCaption( addString+", " + selDates );
4121 return; 4138 return;
4122 } 4139 }
4123 } 4140 }
4124 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4141 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4125 4142
4126} 4143}
4127 4144
4128QPtrList<CalFilter> CalendarView::filters() 4145QPtrList<CalFilter> CalendarView::filters()
4129{ 4146{
4130 return mFilters; 4147 return mFilters;
4131 4148
4132} 4149}
4133void CalendarView::editFilters() 4150void CalendarView::editFilters()
4134{ 4151{
4135 // kdDebug() << "CalendarView::editFilters()" << endl; 4152 // kdDebug() << "CalendarView::editFilters()" << endl;
4136 4153
4137 CalFilter *filter = mFilters.first(); 4154 CalFilter *filter = mFilters.first();
4138 while(filter) { 4155 while(filter) {
4139 filter = mFilters.next(); 4156 filter = mFilters.next();
4140 } 4157 }
4141 4158
4142 mDialogManager->showFilterEditDialog(&mFilters); 4159 mDialogManager->showFilterEditDialog(&mFilters);
4143 updateFilter(); 4160 updateFilter();
4144} 4161}
4145void CalendarView::toggleFilter() 4162void CalendarView::toggleFilter()
4146{ 4163{
4147 if ( mLeftFrame->isHidden() ) { 4164 if ( mLeftFrame->isHidden() ) {
4148 toggleExpand(); 4165 toggleExpand();
4149 showFilter( true ); 4166 showFilter( true );
4150 } else 4167 } else
4151 showFilter(! mCalEditView->isVisible()); 4168 showFilter(! mCalEditView->isVisible());
4152} 4169}
4153 4170
4154KOFilterView *CalendarView::filterView() 4171KOFilterView *CalendarView::filterView()
4155{ 4172{
4156 return mFilterView; 4173 return mFilterView;
4157} 4174}
4158void CalendarView::selectFilter( int fil ) 4175void CalendarView::selectFilter( int fil )
4159{ 4176{
4160 mFilterView->setSelectedFilter( fil ); 4177 mFilterView->setSelectedFilter( fil );
4161 updateUnmanagedViews(); 4178 updateUnmanagedViews();
4162} 4179}
4163void CalendarView::showFilter(bool visible) 4180void CalendarView::showFilter(bool visible)
4164{ 4181{
4165#if 1 4182#if 1
4166 if (visible) { 4183 if (visible) {
4167 mCalEditView->readConfig(); 4184 mCalEditView->readConfig();
4168 mCalEditView->show(); 4185 mCalEditView->show();
4169 QValueList<int> sizes; 4186 QValueList<int> sizes;
4170 sizes = mLeftFrame->sizes(); 4187 sizes = mLeftFrame->sizes();
4171 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4188 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4172 sizes.clear(); 4189 sizes.clear();
4173 sizes << 100; 4190 sizes << 100;
4174 sizes << 0; 4191 sizes << 0;
4175 sizes << 0; 4192 sizes << 0;
4176 sizes << 100; 4193 sizes << 100;
4177 mLeftFrame->setSizes(sizes); 4194 mLeftFrame->setSizes(sizes);
4178 } 4195 }
4179#if 0 4196#if 0
4180 sizes = mLeftFrame->sizes(); 4197 sizes = mLeftFrame->sizes();
4181 int ccc = 0; 4198 int ccc = 0;
4182 while ( ccc < sizes.count()) { 4199 while ( ccc < sizes.count()) {
4183 qDebug("size %d %d ", ccc, sizes[ccc]); 4200 qDebug("size %d %d ", ccc, sizes[ccc]);
4184 ++ccc; 4201 ++ccc;
4185 } 4202 }
4186#endif 4203#endif
4187 4204
4188 } 4205 }
4189 else { 4206 else {
4190 mCalEditView->hide(); 4207 mCalEditView->hide();
4191 } 4208 }
4192#else 4209#else
4193 if (visible) mFilterView->show(); 4210 if (visible) mFilterView->show();
4194 else mFilterView->hide(); 4211 else mFilterView->hide();
4195#endif 4212#endif
4196} 4213}
4197void CalendarView::toggleFilerEnabled( ) 4214void CalendarView::toggleFilerEnabled( )
4198{ 4215{
4199 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4216 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4200 if ( !mFilterView->filtersEnabled() ) 4217 if ( !mFilterView->filtersEnabled() )
4201 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4218 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4202 updateUnmanagedViews(); 4219 updateUnmanagedViews();
4203 4220
4204} 4221}
4205void CalendarView::updateFilter() 4222void CalendarView::updateFilter()
4206{ 4223{
4207 CalFilter *filter = mFilterView->selectedFilter(); 4224 CalFilter *filter = mFilterView->selectedFilter();
4208 if (filter) { 4225 if (filter) {
4209 QString mess; 4226 QString mess;
4210 if (mFilterView->filtersEnabled()) { 4227 if (mFilterView->filtersEnabled()) {
4211 mess = i18n("Filter selected: ")+filter->name(); 4228 mess = i18n("Filter selected: ")+filter->name();
4212 filter->setEnabled(true); 4229 filter->setEnabled(true);
4213 } 4230 }
4214 else filter->setEnabled(false); 4231 else filter->setEnabled(false);
4215 mCalendar->setFilter(filter); 4232 mCalendar->setFilter(filter);
4216 updateView(); 4233 updateView();
4217 if ( !mess.isEmpty() ) 4234 if ( !mess.isEmpty() )
4218 topLevelWidget()->setCaption( mess ); 4235 topLevelWidget()->setCaption( mess );
4219 4236
4220 } 4237 }
4221 emit filtersUpdated(); 4238 emit filtersUpdated();
4222} 4239}
4223 4240
4224void CalendarView::filterEdited() 4241void CalendarView::filterEdited()
4225{ 4242{
4226 mFilterView->updateFilters(); 4243 mFilterView->updateFilters();
4227 updateFilter(); 4244 updateFilter();
4228 writeSettings(); 4245 writeSettings();
4229} 4246}
4230 4247
4231 4248
4232void CalendarView::takeOverEvent() 4249void CalendarView::takeOverEvent()
4233{ 4250{
4234 Incidence *incidence = currentSelection(); 4251 Incidence *incidence = currentSelection();
4235 4252
4236 if (!incidence) return; 4253 if (!incidence) return;
4237 4254
4238 incidence->setOrganizer(KOPrefs::instance()->email()); 4255 incidence->setOrganizer(KOPrefs::instance()->email());
4239 incidence->recreate(); 4256 incidence->recreate();
4240 incidence->setReadOnly(false); 4257 incidence->setReadOnly(false);
4241 4258
4242 updateView(); 4259 updateView();
4243} 4260}
4244 4261
4245void CalendarView::takeOverCalendar() 4262void CalendarView::takeOverCalendar()
4246{ 4263{
4247 // TODO: Create Calendar::allIncidences() function and use it here 4264 // TODO: Create Calendar::allIncidences() function and use it here
4248 4265
4249 clearAllViews(); 4266 clearAllViews();
4250 QPtrList<Event> events = mCalendar->events(); 4267 QPtrList<Event> events = mCalendar->events();
4251 for(uint i=0; i<events.count(); ++i) { 4268 for(uint i=0; i<events.count(); ++i) {
4252 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4269 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4253 events.at(i)->recreate(); 4270 events.at(i)->recreate();
4254 events.at(i)->setReadOnly(false); 4271 events.at(i)->setReadOnly(false);
4255 } 4272 }
4256 4273
4257 QPtrList<Todo> todos = mCalendar->todos(); 4274 QPtrList<Todo> todos = mCalendar->todos();
4258 for(uint i=0; i<todos.count(); ++i) { 4275 for(uint i=0; i<todos.count(); ++i) {
4259 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4276 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4260 todos.at(i)->recreate(); 4277 todos.at(i)->recreate();
4261 todos.at(i)->setReadOnly(false); 4278 todos.at(i)->setReadOnly(false);
4262 } 4279 }
4263 4280
4264 QPtrList<Journal> journals = mCalendar->journals(); 4281 QPtrList<Journal> journals = mCalendar->journals();
4265 for(uint i=0; i<journals.count(); ++i) { 4282 for(uint i=0; i<journals.count(); ++i) {
4266 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4283 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4267 journals.at(i)->recreate(); 4284 journals.at(i)->recreate();
4268 journals.at(i)->setReadOnly(false); 4285 journals.at(i)->setReadOnly(false);
4269 } 4286 }
4270 4287
4271 updateView(); 4288 updateView();
4272} 4289}
4273 4290
4274void CalendarView::showIntro() 4291void CalendarView::showIntro()
4275{ 4292{
4276 kdDebug() << "To be implemented." << endl; 4293 kdDebug() << "To be implemented." << endl;
4277} 4294}
4278 4295
4279QWidgetStack *CalendarView::viewStack() 4296QWidgetStack *CalendarView::viewStack()
4280{ 4297{
4281 return mRightFrame; 4298 return mRightFrame;
4282} 4299}
4283 4300
4284QWidget *CalendarView::leftFrame() 4301QWidget *CalendarView::leftFrame()
4285{ 4302{
4286 return ( QWidget *)mLeftFrame; 4303 return ( QWidget *)mLeftFrame;
4287} 4304}
4288 4305
4289DateNavigator *CalendarView::dateNavigator() 4306DateNavigator *CalendarView::dateNavigator()
4290{ 4307{
4291 return mNavigator; 4308 return mNavigator;
4292} 4309}
4293 4310
4294KDateNavigator* CalendarView::dateNavigatorWidget() 4311KDateNavigator* CalendarView::dateNavigatorWidget()
4295{ 4312{
4296 return mDateNavigator->navigatorView(); 4313 return mDateNavigator->navigatorView();
4297} 4314}
4298void CalendarView::toggleDateNavigatorWidget() 4315void CalendarView::toggleDateNavigatorWidget()
4299{ 4316{
4300 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4317 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4301 4318
4302 if (!KOPrefs::instance()->mShowDateNavigator ) 4319 if (!KOPrefs::instance()->mShowDateNavigator )
4303 mDateNavigator->hide(); 4320 mDateNavigator->hide();
4304 else 4321 else
4305 mDateNavigator->show(); 4322 mDateNavigator->show();
4306} 4323}
4307void CalendarView::addView(KOrg::BaseView *view) 4324void CalendarView::addView(KOrg::BaseView *view)
4308{ 4325{
4309 mViewManager->addView(view); 4326 mViewManager->addView(view);
4310} 4327}
4311 4328
4312void CalendarView::showView(KOrg::BaseView *view) 4329void CalendarView::showView(KOrg::BaseView *view)
4313{ 4330{
4314 mViewManager->showView(view, mLeftFrame->isVisible()); 4331 mViewManager->showView(view, mLeftFrame->isVisible());
4315} 4332}
4316 4333
4317Incidence *CalendarView::currentSelection() 4334Incidence *CalendarView::currentSelection()
4318{ 4335{
4319 return mViewManager->currentSelection(); 4336 return mViewManager->currentSelection();
4320} 4337}
4321void CalendarView::toggleAllDaySize() 4338void CalendarView::toggleAllDaySize()
4322{ 4339{
4323 /* 4340 /*
4324 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4341 if ( KOPrefs::instance()->mAllDaySize > 47 )
4325 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4342 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4326 else 4343 else
4327 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4344 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4328 */ 4345 */
4329 viewManager()->agendaView()->toggleAllDay(); 4346 viewManager()->agendaView()->toggleAllDay();
4330} 4347}
4331void CalendarView::toggleExpand() 4348void CalendarView::toggleExpand()
4332{ 4349{
4333 // if ( mLeftFrame->isHidden() ) { 4350 // if ( mLeftFrame->isHidden() ) {
4334 // mLeftFrame->show(); 4351 // mLeftFrame->show();
4335 // emit calendarViewExpanded( false ); 4352 // emit calendarViewExpanded( false );
4336 // } else { 4353 // } else {
4337 // mLeftFrame->hide(); 4354 // mLeftFrame->hide();
4338 // emit calendarViewExpanded( true ); 4355 // emit calendarViewExpanded( true );
4339 // } 4356 // }
4340 //qDebug(" CalendarView::toggleExpand()"); 4357 //qDebug(" CalendarView::toggleExpand()");
4341 globalFlagBlockAgenda = 1; 4358 globalFlagBlockAgenda = 1;
4342 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4359 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4343 globalFlagBlockAgenda = 5; 4360 globalFlagBlockAgenda = 5;
4344 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4361 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4345 //mViewManager->showView( 0, true ); 4362 //mViewManager->showView( 0, true );
4346} 4363}
4347 4364
4348void CalendarView::calendarModified( bool modified, Calendar * ) 4365void CalendarView::calendarModified( bool modified, Calendar * )
4349{ 4366{
4350 setModified( modified ); 4367 setModified( modified );
4351} 4368}
4352 4369
4353Todo *CalendarView::selectedTodo() 4370Todo *CalendarView::selectedTodo()
4354{ 4371{
4355 Incidence *incidence = currentSelection(); 4372 Incidence *incidence = currentSelection();
4356 if ( incidence && incidence->typeID() == todoID ) { 4373 if ( incidence && incidence->typeID() == todoID ) {
4357 return static_cast<Todo *>( incidence ); 4374 return static_cast<Todo *>( incidence );
4358 } 4375 }
4359 4376
4360 incidence = mTodoList->selectedIncidences().first(); 4377 incidence = mTodoList->selectedIncidences().first();
4361 if ( incidence && incidence->typeID() == todoID ) { 4378 if ( incidence && incidence->typeID() == todoID ) {
4362 return static_cast<Todo *>( incidence ); 4379 return static_cast<Todo *>( incidence );
4363 } 4380 }
4364 4381
4365 return 0; 4382 return 0;
4366} 4383}
4367 4384
4368void CalendarView::showIncidence() 4385void CalendarView::showIncidence()
4369{ 4386{
4370 mViewerCallerIsSearchDialog = false; 4387 mViewerCallerIsSearchDialog = false;
4371 Incidence *incidence = currentSelection(); 4388 Incidence *incidence = currentSelection();
4372 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4389 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4373 if ( incidence ) { 4390 if ( incidence ) {
4374 ShowIncidenceVisitor v; 4391 ShowIncidenceVisitor v;
4375 v.act( incidence, this ); 4392 v.act( incidence, this );
4376 } 4393 }
4377} 4394}
4378void CalendarView::editIncidenceDescription() 4395void CalendarView::editIncidenceDescription()
4379{ 4396{
4380 mFlagEditDescription = true; 4397 mFlagEditDescription = true;
4381 editIncidence(); 4398 editIncidence();
4382 mFlagEditDescription = false; 4399 mFlagEditDescription = false;
4383} 4400}
4384void CalendarView::editIncidence() 4401void CalendarView::editIncidence()
4385{ 4402{
4386 // qDebug("editIncidence() "); 4403 // qDebug("editIncidence() ");
4387 Incidence *incidence = currentSelection(); 4404 Incidence *incidence = currentSelection();
4388 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4405 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4389 if ( incidence ) { 4406 if ( incidence ) {
4390 EditIncidenceVisitor v; 4407 EditIncidenceVisitor v;
4391 v.act( incidence, this ); 4408 v.act( incidence, this );
4392 } 4409 }
4393} 4410}
4394 4411
4395void CalendarView::deleteIncidence() 4412void CalendarView::deleteIncidence()
4396{ 4413{
4397 Incidence *incidence = currentSelection(); 4414 Incidence *incidence = currentSelection();
4398 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4415 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4399 if ( incidence ) { 4416 if ( incidence ) {
4400 deleteIncidence(incidence); 4417 deleteIncidence(incidence);
4401 } 4418 }
4402} 4419}
4403void CalendarView::showIncidence(QString uid) 4420void CalendarView::showIncidence(QString uid)
4404{ 4421{
4405 Incidence *inc = mCalendar->incidence( uid ); 4422 Incidence *inc = mCalendar->incidence( uid );
4406 if ( inc ) 4423 if ( inc )
4407 showIncidence( inc ); 4424 showIncidence( inc );
4408} 4425}
4409void CalendarView::showIncidence(Incidence *incidence) 4426void CalendarView::showIncidence(Incidence *incidence)
4410{ 4427{
4411 mViewerCallerIsSearchDialog = false; 4428 mViewerCallerIsSearchDialog = false;
4412 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4429 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4413 if ( sender() && mDialogManager->getSearchDialog() ) { 4430 if ( sender() && mDialogManager->getSearchDialog() ) {
4414 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4431 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4415 mViewerCallerIsSearchDialog = true; 4432 mViewerCallerIsSearchDialog = true;
4416 } 4433 }
4417 } 4434 }
4418 if ( incidence ) { 4435 if ( incidence ) {
4419 ShowIncidenceVisitor v; 4436 ShowIncidenceVisitor v;
4420 v.act( incidence, this ); 4437 v.act( incidence, this );
4421 } 4438 }
4422} 4439}
4423 4440
4424void CalendarView::editIncidence(Incidence *incidence) 4441void CalendarView::editIncidence(Incidence *incidence)
4425{ 4442{
4426 if ( incidence ) { 4443 if ( incidence ) {
4427 4444
4428 EditIncidenceVisitor v; 4445 EditIncidenceVisitor v;
4429 v.act( incidence, this ); 4446 v.act( incidence, this );
4430 4447
4431 } 4448 }
4432} 4449}
4433 4450
4434void CalendarView::deleteIncidence(Incidence *incidence) 4451void CalendarView::deleteIncidence(Incidence *incidence)
4435{ 4452{
4436 //qDebug(" CalendarView::deleteIncidence "); 4453 //qDebug(" CalendarView::deleteIncidence ");
4437 if ( incidence == 0 ) { 4454 if ( incidence == 0 ) {
4438 updateView(); 4455 updateView();
4439 emit updateSearchDialog(); 4456 emit updateSearchDialog();
4440 return; 4457 return;
4441 } 4458 }
4442 if ( incidence ) { 4459 if ( incidence ) {
4443 DeleteIncidenceVisitor v; 4460 DeleteIncidenceVisitor v;
4444 v.act( incidence, this ); 4461 v.act( incidence, this );
4445 } 4462 }
4446} 4463}
4447 4464
4448 4465
4449void CalendarView::lookForOutgoingMessages() 4466void CalendarView::lookForOutgoingMessages()
4450{ 4467{
4451 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4468 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4452 ogd->loadMessages(); 4469 ogd->loadMessages();
4453} 4470}
4454 4471
4455void CalendarView::lookForIncomingMessages() 4472void CalendarView::lookForIncomingMessages()
4456{ 4473{
4457 IncomingDialog *icd = mDialogManager->incomingDialog(); 4474 IncomingDialog *icd = mDialogManager->incomingDialog();
4458 icd->retrieve(); 4475 icd->retrieve();
4459} 4476}
4460 4477
4461bool CalendarView::removeCompletedSubTodos( Todo* t ) 4478bool CalendarView::removeCompletedSubTodos( Todo* t )
4462{ 4479{
4463 bool deleteTodo = true; 4480 bool deleteTodo = true;
4464 QPtrList<Incidence> subTodos; 4481 QPtrList<Incidence> subTodos;
4465 Incidence *aTodo; 4482 Incidence *aTodo;
4466 subTodos = t->relations(); 4483 subTodos = t->relations();
4467 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4484 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4468 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4485 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4469 deleteTodo = false; 4486 deleteTodo = false;
4470 } 4487 }
4471 if ( deleteTodo ) { 4488 if ( deleteTodo ) {
4472 if ( t->isCompleted() && !t->doesRecur()) { 4489 if ( t->isCompleted() && !t->doesRecur()) {
4473 checkExternalId( t ); 4490 checkExternalId( t );
4474 mCalendar->deleteTodo( t ); 4491 mCalendar->deleteTodo( t );
4475 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4492 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4476 } 4493 }
4477 else 4494 else
4478 deleteTodo = false; 4495 deleteTodo = false;
4479 } 4496 }
4480 return deleteTodo; 4497 return deleteTodo;
4481 4498
4482} 4499}
4483void CalendarView::purgeCompleted() 4500void CalendarView::purgeCompleted()
4484{ 4501{
4485 int result = KMessageBox::warningContinueCancel(this, 4502 int result = KMessageBox::warningContinueCancel(this,
4486 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4503 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4487 4504
4488 if (result == KMessageBox::Continue) { 4505 if (result == KMessageBox::Continue) {
4489 4506
4490 QPtrList<Todo> todoCal; 4507 QPtrList<Todo> todoCal;
4491 QPtrList<Todo> rootTodos; 4508 QPtrList<Todo> rootTodos;
4492 //QPtrList<Incidence> rel; 4509 //QPtrList<Incidence> rel;
4493 Todo *aTodo; 4510 Todo *aTodo;
4494 todoCal = calendar()->todos(); 4511 todoCal = calendar()->todos();
4495 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4512 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4496 if ( !aTodo->relatedTo() ) 4513 if ( !aTodo->relatedTo() )
4497 rootTodos.append( aTodo ); 4514 rootTodos.append( aTodo );
4498 } 4515 }
4499 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4516 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4500 removeCompletedSubTodos( aTodo ); 4517 removeCompletedSubTodos( aTodo );
4501 } 4518 }
4502 4519
4503 updateView(); 4520 updateView();
4504 } 4521 }
4505} 4522}
4506 4523
4507void CalendarView::slotCalendarChanged() 4524void CalendarView::slotCalendarChanged()
4508{ 4525{
4509 ; 4526 ;
4510} 4527}
4511 4528
4512void CalendarView::keyPressEvent ( QKeyEvent *e) 4529void CalendarView::keyPressEvent ( QKeyEvent *e)
4513{ 4530{
4514 //qDebug(" alendarView::keyPressEvent "); 4531 //qDebug(" alendarView::keyPressEvent ");
4515 e->ignore(); 4532 e->ignore();
4516} 4533}
4517 4534
4518 4535
4519bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4536bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4520{ 4537{
4521 4538
4522 if ( manager != mSyncManager) 4539 if ( manager != mSyncManager)
4523 qDebug("KO: Internal error-1. SyncManager mismatch "); 4540 qDebug("KO: Internal error-1. SyncManager mismatch ");
4524 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4541 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4525 qDebug("KO: SyncKDE request detected!"); 4542 qDebug("KO: SyncKDE request detected!");
4526 } 4543 }
4527 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4544 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4528 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4545 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4529 return syncCalendar( filename, mode ); 4546 return syncCalendar( filename, mode );
4530} 4547}
4531bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4548bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4532{ 4549{
4533 //mSyncManager = manager; 4550 //mSyncManager = manager;
4534 if ( manager != mSyncManager) 4551 if ( manager != mSyncManager)
4535 qDebug("KO: Internal error-2. SyncManager mismatch "); 4552 qDebug("KO: Internal error-2. SyncManager mismatch ");
4536 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4553 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4537 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4554 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4538 if ( resource == "sharp" ) 4555 if ( resource == "sharp" )
4539 syncExternal( 0 ); 4556 syncExternal( 0 );
4540 if ( resource == "phone" ) 4557 if ( resource == "phone" )
4541 syncExternal( 1 ); 4558 syncExternal( 1 );
4542 // pending setmodified 4559 // pending setmodified
4543 return true; 4560 return true;
4544} 4561}
4545void CalendarView::setSyncManager(KSyncManager* manager) 4562void CalendarView::setSyncManager(KSyncManager* manager)
4546{ 4563{
4547 mSyncManager = manager; 4564 mSyncManager = manager;
4548} 4565}
4549 4566
4550void CalendarView::removeSyncInfo( QString syncProfile) 4567void CalendarView::removeSyncInfo( QString syncProfile)
4551{ 4568{
4552 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4569 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4553 mCalendar->removeSyncInfo( syncProfile ); 4570 mCalendar->removeSyncInfo( syncProfile );
4554 4571
4555} 4572}
4556 4573
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5f90dc6..7783dd4 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1450 +1,1452 @@
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
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71extern QPixmap* sgListViewJournalPix; 71extern QPixmap* sgListViewJournalPix;
72 72
73class KOListViewWhatsThis :public QWhatsThis 73class KOListViewWhatsThis :public QWhatsThis
74{ 74{
75public: 75public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 77
78protected: 78protected:
79 virtual QString text( const QPoint& p) 79 virtual QString text( const QPoint& p)
80 { 80 {
81 return _view->getWhatsThisText(p) ; 81 return _view->getWhatsThisText(p) ;
82 } 82 }
83private: 83private:
84 QWidget* _wid; 84 QWidget* _wid;
85 KOListView * _view; 85 KOListView * _view;
86}; 86};
87 87
88 88
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 90{
91 mItem = item; 91 mItem = item;
92 mDate = date; 92 mDate = date;
93} 93}
94 94
95ListItemVisitor::~ListItemVisitor() 95ListItemVisitor::~ListItemVisitor()
96{ 96{
97} 97}
98 98
99bool ListItemVisitor::visit(Event *e) 99bool ListItemVisitor::visit(Event *e)
100{ 100{
101 bool ok = false; 101 bool ok = false;
102 QString start, end; 102 QString start, end;
103 QDate ds, de; 103 QDate ds, de;
104 if ( e->doesRecur() ) { 104 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 106 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 107 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 108 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 109 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 110 end = KGlobal::locale()->formatDate(de,true);
111 } 111 }
112 112
113 } 113 }
114 if ( ! ok ) { 114 if ( ! ok ) {
115 start =e->dtStartDateStr(); 115 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 116 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 117 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 118 de = e->dtEnd().date();
119 } 119 }
120 mItem->setText(0,e->summary()); 120 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 121 mItem->setText(1,start);
122 if ( e->doesFloat() ) 122 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 123 mItem->setText(2,"---");
124 else 124 else
125 mItem->setText(2,e->dtStartTimeStr()); 125 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 126 mItem->setText(3,end);
127 if ( e->doesFloat() ) 127 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 128 mItem->setText(4,"---");
129 else 129 else
130 mItem->setText(4,e->dtEndTimeStr()); 130 mItem->setText(4,e->dtEndTimeStr());
131 if ( e->isAlarmEnabled() ) { 131 if ( e->isAlarmEnabled() ) {
132 mItem->setText(5,e->alarms().first()->offsetText() ); 132 mItem->setText(5,e->alarms().first()->offsetText() );
133 } else { 133 } else {
134 mItem->setText(5, i18n("No")); 134 mItem->setText(5, i18n("No"));
135 } 135 }
136 mItem->setText(6, e->recurrence()->recurrenceText()); 136 mItem->setText(6, e->recurrence()->recurrenceText());
137 if( ! e->doesRecur() ) 137 if( ! e->doesRecur() )
138 mItem->setSortKey( 6, "-" ); 138 mItem->setSortKey( 6, "-" );
139 mItem->setText(7,"---"); 139 mItem->setText(7,"---");
140 mItem->setText(8,"---"); 140 mItem->setText(8,"---");
141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
142 mItem->setText(10,e->categoriesStr()); 142 mItem->setText(10,e->categoriesStr());
143 mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); 143 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
144 mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); 144 mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true ));
145 145
146 QString key; 146 QString key;
147 QDate d = e->lastModified().date(); 147 QDate d = e->lastModified().date();
148 QTime t = e->lastModified().time(); 148 QTime t = e->lastModified().time();
149 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); 149 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
150 mItem->setSortKey(12,key); 150 mItem->setSortKey(12,key);
151 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 151 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
152 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 152 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
153 mItem->setSortKey(1,key); 153 mItem->setSortKey(1,key);
154 154
155 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 155 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
156 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 156 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
157 mItem->setSortKey(3,key); 157 mItem->setSortKey(3,key);
158 return true; 158 return true;
159} 159}
160 160
161bool ListItemVisitor::visit(Todo *t) 161bool ListItemVisitor::visit(Todo *t)
162{ 162{
163 mItem->setText(0,t->summary()); 163 mItem->setText(0,t->summary());
164 if ( t->isCompleted() ) { 164 if ( t->isCompleted() ) {
165 mItem->setSortKey(0,"99"+ t->summary().left(10)); 165 mItem->setSortKey(0,"99"+ t->summary().left(10));
166 } else 166 } else
167 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); 167 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10));
168 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 168 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
169 if (t->hasStartDate()) { 169 if (t->hasStartDate()) {
170 mItem->setText(1,t->dtStartDateStr()); 170 mItem->setText(1,t->dtStartDateStr());
171 if (t->doesFloat()) { 171 if (t->doesFloat()) {
172 mItem->setText(2,"---"); 172 mItem->setText(2,"---");
173 } else { 173 } else {
174 mItem->setText(2,t->dtStartTimeStr()); 174 mItem->setText(2,t->dtStartTimeStr());
175 } 175 }
176 } else { 176 } else {
177 mItem->setText(1,"---"); 177 mItem->setText(1,"---");
178 mItem->setText(2,"---"); 178 mItem->setText(2,"---");
179 } 179 }
180 mItem->setText(3,"---"); 180 mItem->setText(3,"---");
181 mItem->setText(4,"---"); 181 mItem->setText(4,"---");
182 if ( t->isAlarmEnabled() ) { 182 if ( t->isAlarmEnabled() ) {
183 mItem->setText(5,t->alarms().first()->offsetText() ); 183 mItem->setText(5,t->alarms().first()->offsetText() );
184 } else { 184 } else {
185 mItem->setText(5, i18n("No")); 185 mItem->setText(5, i18n("No"));
186 } 186 }
187 mItem->setText(6, t->recurrence()->recurrenceText()); 187 mItem->setText(6, t->recurrence()->recurrenceText());
188 if( ! t->doesRecur() ) 188 if( ! t->doesRecur() )
189 mItem->setSortKey( 6, "-" ); 189 mItem->setSortKey( 6, "-" );
190 if (t->hasDueDate()) { 190 if (t->hasDueDate()) {
191 mItem->setText(7,t->dtDueDateStr()); 191 mItem->setText(7,t->dtDueDateStr());
192 if (t->doesFloat()) { 192 if (t->doesFloat()) {
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } else { 194 } else {
195 mItem->setText(8,t->dtDueTimeStr()); 195 mItem->setText(8,t->dtDueTimeStr());
196 } 196 }
197 } else { 197 } else {
198 mItem->setText(7,"---"); 198 mItem->setText(7,"---");
199 mItem->setText(8,"---"); 199 mItem->setText(8,"---");
200 } 200 }
201 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 201 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
202 mItem->setText(10,t->categoriesStr()); 202 mItem->setText(10,t->categoriesStr());
203 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 203 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
204 mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); 204 mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true ));
205 QString key; 205 QString key;
206 QDate d = t->lastModified().date(); 206 QDate d = t->lastModified().date();
207 QTime tm = t->lastModified().time(); 207 QTime tm = t->lastModified().time();
208 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); 208 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
209 mItem->setSortKey(12,key); 209 mItem->setSortKey(12,key);
210 if (t->hasDueDate()) { 210 if (t->hasDueDate()) {
211 d = t->dtDue().date(); 211 d = t->dtDue().date();
212 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 212 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
213 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 213 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
214 mItem->setSortKey(7,key); 214 mItem->setSortKey(7,key);
215 } 215 }
216 if ( t->hasStartDate() ) { 216 if ( t->hasStartDate() ) {
217 d = t->dtStart().date(); 217 d = t->dtStart().date();
218 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 218 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
219 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 219 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
220 mItem->setSortKey(1,key); 220 mItem->setSortKey(1,key);
221 } 221 }
222 return true; 222 return true;
223} 223}
224 224
225bool ListItemVisitor::visit(Journal * j) 225bool ListItemVisitor::visit(Journal * j)
226{ 226{
227 227
228 QString des; 228 QString des;
229 mItem->setPixmap( 0, *sgListViewJournalPix); 229 mItem->setPixmap( 0, *sgListViewJournalPix);
230 if ( !j->summary().isEmpty() ) { 230 if ( !j->summary().isEmpty() ) {
231 des = j->summary(); 231 des = j->summary();
232 } else { 232 } else {
233 des = j->description().left(30); 233 des = j->description().left(30);
234 des = des.simplifyWhiteSpace (); 234 des = des.simplifyWhiteSpace ();
235 des.replace (QRegExp ("\\n"),"" ); 235 des.replace (QRegExp ("\\n"),"" );
236 des.replace (QRegExp ("\\r"),"" ); 236 des.replace (QRegExp ("\\r"),"" );
237 } 237 }
238 mItem->setText(0,des.left(25)); 238 mItem->setText(0,des.left(25));
239 mItem->setSortKey(0,"0"+ des.left(25)); 239 mItem->setSortKey(0,"0"+ des.left(25));
240 mItem->setText(1,j->dtStartDateStr()); 240 mItem->setText(1,j->dtStartDateStr());
241 mItem->setText(2,"---"); 241 mItem->setText(2,"---");
242 mItem->setText(3,"---"); 242 mItem->setText(3,"---");
243 mItem->setText(4,"---"); 243 mItem->setText(4,"---");
244 mItem->setText(5,"---"); 244 mItem->setText(5,"---");
245 mItem->setText(6,"---"); 245 mItem->setText(6,"---");
246 mItem->setText(7,j->dtStartDateStr()); 246 mItem->setText(7,j->dtStartDateStr());
247 mItem->setText(8,"---"); 247 mItem->setText(8,"---");
248 mItem->setText(9,"---"); 248 mItem->setText(9,"---");
249 mItem->setText(10,j->categoriesStr()); 249 mItem->setText(10,j->categoriesStr());
250 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 250 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
251 mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); 251 mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true ));
252 252
253 QString key; 253 QString key;
254 QDate d = j->lastModified().date(); 254 QDate d = j->lastModified().date();
255 QTime tm = j->lastModified().time(); 255 QTime tm = j->lastModified().time();
256 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); 256 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
257 mItem->setSortKey(12,key); 257 mItem->setSortKey(12,key);
258 d = j->dtStart().date(); 258 d = j->dtStart().date();
259 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 259 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
260 mItem->setSortKey(1,key); 260 mItem->setSortKey(1,key);
261 mItem->setSortKey(7,key); 261 mItem->setSortKey(7,key);
262 262
263 return true; 263 return true;
264} 264}
265 265
266KOListView::KOListView(Calendar *calendar, QWidget *parent, 266KOListView::KOListView(Calendar *calendar, QWidget *parent,
267 const char *name) 267 const char *name)
268 : KOEventView(calendar, parent, name) 268 : KOEventView(calendar, parent, name)
269{ 269{
270 270
271 mActiveItem = 0; 271 mActiveItem = 0;
272 mForceShowCompletedTodos = false; 272 mForceShowCompletedTodos = false;
273 mListView = new KOListViewListView(this); 273 mListView = new KOListViewListView(this);
274 mListView->addColumn(i18n("Summary")); 274 mListView->addColumn(i18n("Summary"));
275 mListView->addColumn(i18n("Start Date")); 275 mListView->addColumn(i18n("Start Date"));
276 mListView->addColumn(i18n("Start Time")); 276 mListView->addColumn(i18n("Start Time"));
277 mListView->addColumn(i18n("End Date")); 277 mListView->addColumn(i18n("End Date"));
278 mListView->addColumn(i18n("End Time")); 278 mListView->addColumn(i18n("End Time"));
279 mListView->addColumn(i18n("Alarm")); // alarm set? 279 mListView->addColumn(i18n("Alarm")); // alarm set?
280 mListView->addColumn(i18n("Recurs")); // recurs? 280 mListView->addColumn(i18n("Recurs")); // recurs?
281 mListView->addColumn(i18n("Due Date")); 281 mListView->addColumn(i18n("Due Date"));
282 mListView->addColumn(i18n("Due Time")); 282 mListView->addColumn(i18n("Due Time"));
283 mListView->addColumn(i18n("Cancelled")); 283 mListView->addColumn(i18n("Cancelled"));
284 mListView->addColumn(i18n("Categories")); 284 mListView->addColumn(i18n("Categories"));
285 mListView->addColumn(i18n("Calendar")); 285 mListView->addColumn(i18n("Calendar"));
286 mListView->addColumn(i18n("Last Modified")); 286 mListView->addColumn(i18n("Last Modified"));
287 287
288 mListView->setColumnAlignment(0,AlignLeft); 288 mListView->setColumnAlignment(0,AlignLeft);
289 mListView->setColumnAlignment(1,AlignLeft); 289 mListView->setColumnAlignment(1,AlignLeft);
290 mListView->setColumnAlignment(2,AlignHCenter); 290 mListView->setColumnAlignment(2,AlignHCenter);
291 mListView->setColumnAlignment(3,AlignLeft); 291 mListView->setColumnAlignment(3,AlignLeft);
292 mListView->setColumnAlignment(4,AlignHCenter); 292 mListView->setColumnAlignment(4,AlignHCenter);
293 mListView->setColumnAlignment(5,AlignLeft); 293 mListView->setColumnAlignment(5,AlignLeft);
294 mListView->setColumnAlignment(6,AlignLeft); 294 mListView->setColumnAlignment(6,AlignLeft);
295 mListView->setColumnAlignment(7,AlignLeft); 295 mListView->setColumnAlignment(7,AlignLeft);
296 mListView->setColumnAlignment(8,AlignLeft); 296 mListView->setColumnAlignment(8,AlignLeft);
297 mListView->setColumnAlignment(9,AlignLeft); 297 mListView->setColumnAlignment(9,AlignLeft);
298 mListView->setColumnAlignment(10,AlignLeft); 298 mListView->setColumnAlignment(10,AlignLeft);
299 mListView->setColumnAlignment(11,AlignLeft); 299 mListView->setColumnAlignment(11,AlignLeft);
300 mListView->setColumnAlignment(12,AlignLeft); 300 mListView->setColumnAlignment(12,AlignLeft);
301 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 301 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
302 302
303 int iii = 0; 303 int iii = 0;
304 for ( iii = 0; iii< 13 ; ++iii ) 304 for ( iii = 0; iii< 13 ; ++iii )
305 mListView->setColumnWidthMode( iii, QListView::Manual ); 305 mListView->setColumnWidthMode( iii, QListView::Manual );
306 306
307 QBoxLayout *layoutTop = new QVBoxLayout(this); 307 QBoxLayout *layoutTop = new QVBoxLayout(this);
308 layoutTop->addWidget(mListView); 308 layoutTop->addWidget(mListView);
309 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 309 mListView->setFont ( KOPrefs::instance()->mListViewFont );
310 mPopupMenu = eventPopup(); 310 mPopupMenu = eventPopup();
311 QPopupMenu* selPopup = new QPopupMenu ( this ); 311 QPopupMenu* selPopup = new QPopupMenu ( this );
312 mPopupMenu->insertSeparator(); 312 mPopupMenu->insertSeparator();
313 313
314 selPopup->insertItem(i18n("All"),this, 314 selPopup->insertItem(i18n("All"),this,
315 SLOT(allSelection())); 315 SLOT(allSelection()));
316 selPopup->insertItem(i18n("None"),this, 316 selPopup->insertItem(i18n("None"),this,
317 SLOT(clearSelection())); 317 SLOT(clearSelection()));
318 selPopup->insertItem(i18n("Delete selected..."),this, 318 selPopup->insertItem(i18n("Delete selected..."),this,
319 SLOT(deleteAll())); 319 SLOT(deleteAll()));
320 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 320 mPopupMenu->insertItem(i18n("Selection"), selPopup );
321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
322 i18n("Hide all selected"),this, 322 i18n("Hide all selected"),this,
323 SLOT(hideAll()),true); 323 SLOT(hideAll()),true);
324 324
325 selPopup->insertSeparator(); 325 selPopup->insertSeparator();
326 QPopupMenu * exportPO = new QPopupMenu ( this ); 326 QPopupMenu * exportPO = new QPopupMenu ( this );
327 selPopup->insertItem( i18n("Export"), exportPO ); 327 selPopup->insertItem( i18n("Export"), exportPO );
328#ifdef DESKTOP_VERSION 328#ifdef DESKTOP_VERSION
329 mPopupMenu->insertSeparator(); 329 mPopupMenu->insertSeparator();
330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
331 i18n("Print complete list..."),this, 331 i18n("Print complete list..."),this,
332 SLOT(printList()),true); 332 SLOT(printList()),true);
333#endif 333#endif
334 mCalPopup = new QPopupMenu ( this ); 334 mCalPopup = new QPopupMenu ( this );
335 selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); 335 selPopup->insertItem( i18n("Set Calendar"), mCalPopup );
336 336
337 selPopup->insertItem(i18n("Set categories")+"...",this, 337 selPopup->insertItem(i18n("Set categories")+"...",this,
338 SLOT(setCat()) ); 338 SLOT(setCat()) );
339 selPopup->insertItem( i18n("Set alarm..."),this, 339 selPopup->insertItem( i18n("Set alarm..."),this,
340 SLOT(setAlarm())); 340 SLOT(setAlarm()));
341#if 0 341#if 0
342 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 342 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
343 i18n("Set categories")+"...",this, 343 i18n("Set categories")+"...",this,
344 SLOT(setCat()),true); 344 SLOT(setCat()),true);
345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
346 i18n("Set alarm..."),this, 346 i18n("Set alarm..."),this,
347 SLOT(setAlarm()),true); 347 SLOT(setAlarm()),true);
348#endif 348#endif
349 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 349 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
350 SLOT( populateCalPopup() )); 350 SLOT( populateCalPopup() ));
351 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 351 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
352 SLOT( setCalendar( int ) )); 352 SLOT( setCalendar( int ) ));
353 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, 353 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
354 SLOT( catChanged( Incidence * ) )); 354 SLOT( catChanged( Incidence * ) ));
355 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 355 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
356 SLOT(saveToFile())); 356 SLOT(saveToFile()));
357 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 357 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
358 SLOT(saveToFileVCS())); 358 SLOT(saveToFileVCS()));
359 exportPO->insertItem( i18n("Journal/Details..."),this, 359 exportPO->insertItem( i18n("Journal/Details..."),this,
360 SLOT(saveDescriptionToFile())); 360 SLOT(saveDescriptionToFile()));
361 // mPopupMenu->insertSeparator(); 361 // mPopupMenu->insertSeparator();
362 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 362 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
363 // i18n("Add Categ. to selected..."),this, 363 // i18n("Add Categ. to selected..."),this,
364 // SLOT(addCat()),true); 364 // SLOT(addCat()),true);
365 //mPopupMenu->insertSeparator(); 365 //mPopupMenu->insertSeparator();
366#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
367 selPopup->insertSeparator(); 367 selPopup->insertSeparator();
368 selPopup->insertItem( i18n("Beam via IR..."),this, 368 selPopup->insertItem( i18n("Beam via IR..."),this,
369 SLOT(beamSelected())); 369 SLOT(beamSelected()));
370#if 0 370#if 0
371 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 371 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
372 i18n("Beam via IR"),this, 372 i18n("Beam via IR"),this,
373 SLOT(beamSelected()),true); 373 SLOT(beamSelected()),true);
374#endif 374#endif
375#endif 375#endif
376 /* 376 /*
377 mPopupMenu = new QPopupMenu; 377 mPopupMenu = new QPopupMenu;
378 mPopupMenu->insertItem(i18n("Edit Event"), this, 378 mPopupMenu->insertItem(i18n("Edit Event"), this,
379 SLOT (editEvent())); 379 SLOT (editEvent()));
380 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 380 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
381 SLOT (deleteEvent())); 381 SLOT (deleteEvent()));
382 mPopupMenu->insertSeparator(); 382 mPopupMenu->insertSeparator();
383 mPopupMenu->insertItem(i18n("Show Dates"), this, 383 mPopupMenu->insertItem(i18n("Show Dates"), this,
384 SLOT(showDates())); 384 SLOT(showDates()));
385 mPopupMenu->insertItem(i18n("Hide Dates"), this, 385 mPopupMenu->insertItem(i18n("Hide Dates"), this,
386 SLOT(hideDates())); 386 SLOT(hideDates()));
387 */ 387 */
388 QObject::connect(mListView,SIGNAL( newEvent()), 388 QObject::connect(mListView,SIGNAL( newEvent()),
389 this,SIGNAL(signalNewEvent())); 389 this,SIGNAL(signalNewEvent()));
390 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 390 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
391 this,SLOT(defaultItemAction(QListViewItem *))); 391 this,SLOT(defaultItemAction(QListViewItem *)));
392 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 392 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
393 const QPoint &, int )), 393 const QPoint &, int )),
394 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 394 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
395 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 395 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
396 SLOT(processSelectionChange(QListViewItem *))); 396 SLOT(processSelectionChange(QListViewItem *)));
397 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 397 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
398 SIGNAL(showIncidenceSignal(Incidence *)) ); 398 SIGNAL(showIncidenceSignal(Incidence *)) );
399 399
400 readSettings(KOGlobals::config(),"KOListView Layout"); 400 readSettings(KOGlobals::config(),"KOListView Layout");
401} 401}
402 402
403KOListView::~KOListView() 403KOListView::~KOListView()
404{ 404{
405 delete mPopupMenu; 405 delete mPopupMenu;
406#if QT_VERSION >= 0x030000 406#if QT_VERSION >= 0x030000
407 407
408#else 408#else
409 delete mKOListViewWhatsThis; 409 delete mKOListViewWhatsThis;
410#endif 410#endif
411} 411}
412 412
413void KOListView::catChanged( Incidence* inc) 413void KOListView::catChanged( Incidence* inc)
414{ 414{
415 KOListViewItem* item = getItemForEvent(inc); 415 KOListViewItem* item = getItemForEvent(inc);
416 if (item) { 416 if (item) {
417 ListItemVisitor v(item, mStartDate ); 417 ListItemVisitor v(item, mStartDate );
418 inc->accept(v); 418 inc->accept(v);
419 } 419 }
420} 420}
421QString KOListView::getWhatsThisText(QPoint p) 421QString KOListView::getWhatsThisText(QPoint p)
422{ 422{
423 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 423 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
424 if ( item ) 424 if ( item )
425 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 425 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
426 KOPrefs::instance()->mWTshowDetails, 426 KOPrefs::instance()->mWTshowDetails,
427 KOPrefs::instance()->mWTshowCreated, 427 KOPrefs::instance()->mWTshowCreated,
428 KOPrefs::instance()->mWTshowChanged); 428 KOPrefs::instance()->mWTshowChanged);
429 return i18n("That is the list view" ); 429 return i18n("That is the list view" );
430 430
431} 431}
432 432
433void KOListView::setCalendar( int c ) 433void KOListView::setCalendar( int c )
434{ 434{
435 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 435 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
436 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 436 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
437 i18n("Continue"), i18n("Cancel"), 0, 437 i18n("Continue"), i18n("Cancel"), 0,
438 0, 1 ); 438 0, 1 );
439 if ( result != 0 ) { 439 if ( result != 0 ) {
440 return; 440 return;
441 } 441 }
442 442
443 QPtrList<Incidence> delSel = getSelectedIncidences() ; 443 QPtrList<Incidence> delSel = getSelectedIncidences() ;
444 int icount = delSel.count(); 444 int icount = delSel.count();
445 if ( icount ) { 445 if ( icount ) {
446 Incidence *incidence = delSel.first(); 446 Incidence *incidence = delSel.first();
447 while ( incidence ) { 447 while ( incidence ) {
448 incidence->setCalID( c ); 448 incidence->setCalID( c );
449 KOListViewItem * item = getItemForEvent( incidence ); 449 KOListViewItem * item = getItemForEvent( incidence );
450 if ( item ) { 450 if ( item ) {
451 ListItemVisitor v(item, mStartDate ); 451 ListItemVisitor v(item, mStartDate );
452 incidence->accept(v); 452 incidence->accept(v);
453 } 453 }
454 incidence = delSel.next(); 454 incidence = delSel.next();
455 } 455 }
456 } 456 }
457 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 457 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
458 KopiCalendarFile * cal = calendars.first(); 458 KopiCalendarFile * cal = calendars.first();
459 while ( cal ) { 459 while ( cal ) {
460 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 460 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
461 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 461 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
462 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 462 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
463 if ( cal->isStandard ) 463 if ( cal->isStandard )
464 mCalendar->setDefaultCalendar( cal->mCalNumber ); 464 mCalendar->setDefaultCalendar( cal->mCalNumber );
465 cal = calendars.next(); 465 cal = calendars.next();
466 } 466 }
467 mCalendar->setSyncEventsReadOnly(); 467 mCalendar->setSyncEventsReadOnly();
468 mCalendar->reInitAlarmSettings(); 468 mCalendar->reInitAlarmSettings();
469 469
470} 470}
471void KOListView::populateCalPopup() 471void KOListView::populateCalPopup()
472{ 472{
473 mCalPopup->clear(); 473 mCalPopup->clear();
474 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 474 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
475 while ( kkf ) { 475 while ( kkf ) {
476 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); 476 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber);
477 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 477 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
478 mCalPopup->setItemEnabled( index, false ); 478 mCalPopup->setItemEnabled( index, false );
479 kkf = KOPrefs::instance()->mCalendars.next(); 479 kkf = KOPrefs::instance()->mCalendars.next();
480 } 480 }
481} 481}
482void KOListView::updateList() 482void KOListView::updateList()
483{ 483{
484 // qDebug(" KOListView::updateList() "); 484 // qDebug(" KOListView::updateList() ");
485 485
486} 486}
487 487
488void KOListView::clearList() 488void KOListView::clearList()
489{ 489{
490 clear (); 490 clear ();
491} 491}
492 492
493void KOListView::setCat() 493void KOListView::setCat()
494{ 494{
495 495
496 bool set = true; 496 bool set = true;
497 int result = KMessageBox::warningYesNoCancel(this, 497 int result = KMessageBox::warningYesNoCancel(this,
498 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), 498 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"),
499 i18n("Set categories"), 499 i18n("Set categories"),
500 i18n("Add"), 500 i18n("Add"),
501 i18n("Reset")); 501 i18n("Reset"));
502 if (result == KMessageBox::Cancel) return; 502 if (result == KMessageBox::Cancel) return;
503 if (result == KMessageBox::Yes) set = false; 503 if (result == KMessageBox::Yes) set = false;
504 setCategories( set ); 504 setCategories( set );
505} 505}
506 506
507void KOListView::setAlarm() 507void KOListView::setAlarm()
508{ 508{
509 KOAlarmPrefs kap( this); 509 KOAlarmPrefs kap( this);
510 if ( !kap.exec() ) 510 if ( !kap.exec() )
511 return; 511 return;
512 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos 512 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
513 Incidence* inc = delSel.first(); 513 Incidence* inc = delSel.first();
514 int count = 0; 514 int count = 0;
515 while ( inc ) { 515 while ( inc ) {
516 ++count; 516 ++count;
517 if (kap.mAlarmButton->isChecked()) { 517 if (kap.mAlarmButton->isChecked()) {
518 if (inc->alarms().count() == 0) 518 if (inc->alarms().count() == 0)
519 inc->newAlarm(); 519 inc->newAlarm();
520 QPtrList<Alarm> alarms = inc->alarms(); 520 QPtrList<Alarm> alarms = inc->alarms();
521 Alarm *alarm; 521 Alarm *alarm;
522 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 522 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
523 alarm->setEnabled(true); 523 alarm->setEnabled(true);
524 int j = kap.mAlarmTimeEdit->value()* -60; 524 int j = kap.mAlarmTimeEdit->value()* -60;
525 if (kap.mAlarmIncrCombo->currentItem() == 1) 525 if (kap.mAlarmIncrCombo->currentItem() == 1)
526 j = j * 60; 526 j = j * 60;
527 else if (kap.mAlarmIncrCombo->currentItem() == 2) 527 else if (kap.mAlarmIncrCombo->currentItem() == 2)
528 j = j * (60 * 24); 528 j = j * (60 * 24);
529 alarm->setStartOffset( j ); 529 alarm->setStartOffset( j );
530 530
531 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 531 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
532 alarm->setProcedureAlarm(kap.mAlarmProgram); 532 alarm->setProcedureAlarm(kap.mAlarmProgram);
533 } 533 }
534 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 534 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
535 alarm->setAudioAlarm(kap.mAlarmSound); 535 alarm->setAudioAlarm(kap.mAlarmSound);
536 else 536 else
537 alarm->setType(Alarm::Invalid); 537 alarm->setType(Alarm::Invalid);
538 //alarm->setAudioAlarm("default"); 538 //alarm->setAudioAlarm("default");
539 // TODO: Deal with multiple alarms 539 // TODO: Deal with multiple alarms
540 break; // For now, stop after the first alarm 540 break; // For now, stop after the first alarm
541 } 541 }
542 } else { 542 } else {
543 Alarm* alarm = inc->alarms().first(); 543 Alarm* alarm = inc->alarms().first();
544 if ( alarm ) { 544 if ( alarm ) {
545 alarm->setEnabled(false); 545 alarm->setEnabled(false);
546 alarm->setType(Alarm::Invalid); 546 alarm->setType(Alarm::Invalid);
547 } 547 }
548 } 548 }
549 KOListViewItem* item = getItemForEvent(inc); 549 KOListViewItem* item = getItemForEvent(inc);
550 if (item) { 550 if (item) {
551 ListItemVisitor v(item, mStartDate ); 551 ListItemVisitor v(item, mStartDate );
552 inc->accept(v); 552 inc->accept(v);
553 } 553 }
554 inc = delSel.next(); 554 inc = delSel.next();
555 } 555 }
556 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 556 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
557 qDebug("KO: Set alarm for %d items", count); 557 qDebug("KO: Set alarm for %d items", count);
558 calendar()->reInitAlarmSettings(); 558 calendar()->reInitAlarmSettings();
559 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 559 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
560} 560}
561void KOListView::setCategories( bool removeOld ) 561void KOListView::setCategories( bool removeOld )
562{ 562{
563 563
564 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 564 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
565 csd->setColorEnabled(); 565 csd->setColorEnabled();
566 if (! csd->exec()) { 566 if (! csd->exec()) {
567 delete csd; 567 delete csd;
568 return; 568 return;
569 } 569 }
570 QStringList catList = csd->selectedCategories(); 570 QStringList catList = csd->selectedCategories();
571 delete csd; 571 delete csd;
572 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 572 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
573 Incidence* inc = delSel.first(); 573 Incidence* inc = delSel.first();
574 while ( inc ) { 574 while ( inc ) {
575 if ( removeOld ) { 575 if ( removeOld ) {
576 inc->setCategories( catList, false ); 576 inc->setCategories( catList, false );
577 } else { 577 } else {
578 inc->addCategories( catList, false ); 578 inc->addCategories( catList, false );
579 } 579 }
580 KOListViewItem* item = getItemForEvent(inc); 580 KOListViewItem* item = getItemForEvent(inc);
581 if (item) { 581 if (item) {
582 ListItemVisitor v(item, mStartDate ); 582 ListItemVisitor v(item, mStartDate );
583 inc->accept(v); 583 inc->accept(v);
584 } 584 }
585 inc = delSel.next(); 585 inc = delSel.next();
586 } 586 }
587 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 587 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
588} 588}
589 589
590void KOListView::beamSelected() 590void KOListView::beamSelected()
591{ 591{
592 QPtrList<Incidence> delSel = getSelectedIncidences() ; 592 QPtrList<Incidence> delSel = getSelectedIncidences() ;
593 if ( delSel.count() ) 593 if ( delSel.count() )
594 emit beamIncidenceList( delSel ); 594 emit beamIncidenceList( delSel );
595} 595}
596 596
597void KOListView::saveDescriptionToFile() 597void KOListView::saveDescriptionToFile()
598{ 598{
599 599
600 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 600 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
601 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 601 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
602 i18n("Continue"), i18n("Cancel"), 0, 602 i18n("Continue"), i18n("Cancel"), 0,
603 0, 1 ); 603 0, 1 );
604 if ( result != 0 ) { 604 if ( result != 0 ) {
605 return; 605 return;
606 } 606 }
607 QPtrList<Incidence> delSel = getSelectedIncidences() ; 607 QPtrList<Incidence> delSel = getSelectedIncidences() ;
608 int icount = delSel.count(); 608 int icount = delSel.count();
609 if ( icount ) { 609 if ( icount ) {
610 QString fn = KOPrefs::instance()->mLastSaveFile; 610 QString fn = KOPrefs::instance()->mLastSaveFile;
611 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 611 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
612 612
613 if ( fn == "" ) 613 if ( fn == "" )
614 return; 614 return;
615 QFileInfo info; 615 QFileInfo info;
616 info.setFile( fn ); 616 info.setFile( fn );
617 QString mes; 617 QString mes;
618 bool createbup = true; 618 bool createbup = true;
619 if ( info. exists() ) { 619 if ( info. exists() ) {
620 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 620 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
621 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 621 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
622 i18n("Overwrite!"), i18n("Cancel"), 0, 622 i18n("Overwrite!"), i18n("Cancel"), 0,
623 0, 1 ); 623 0, 1 );
624 if ( result != 0 ) { 624 if ( result != 0 ) {
625 createbup = false; 625 createbup = false;
626 } 626 }
627 } 627 }
628 if ( createbup ) { 628 if ( createbup ) {
629 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 629 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
630 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 630 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
631 Incidence *incidence = delSel.first(); 631 Incidence *incidence = delSel.first();
632 icount = 0; 632 icount = 0;
633 while ( incidence ) { 633 while ( incidence ) {
634 if ( incidence->typeID() == journalID ) { 634 if ( incidence->typeID() == journalID ) {
635 text += "\n************************************\n"; 635 text += "\n************************************\n";
636 if ( !incidence->summary().isEmpty() ) 636 if ( !incidence->summary().isEmpty() )
637 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); 637 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false );
638 else 638 else
639 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 639 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
640 if ( !incidence->location().isEmpty() ) 640 if ( !incidence->location().isEmpty() )
641 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 641 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
642 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 642 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
643 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 643 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
644 ++icount; 644 ++icount;
645 645
646 } else { 646 } else {
647 if ( !incidence->description().isEmpty() ) { 647 if ( !incidence->description().isEmpty() ) {
648 text += "\n************************************\n"; 648 text += "\n************************************\n";
649 if ( incidence->typeID() == todoID ) 649 if ( incidence->typeID() == todoID )
650 text += i18n("To-Do: "); 650 text += i18n("To-Do: ");
651 text += incidence->summary(); 651 text += incidence->summary();
652 if ( !incidence->location().isEmpty() ) 652 if ( !incidence->location().isEmpty() )
653 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 653 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
654 if ( incidence->hasStartDate() ) 654 if ( incidence->hasStartDate() )
655 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 655 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
656 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 656 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
657 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 657 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
658 ++icount; 658 ++icount;
659 659
660 } 660 }
661 } 661 }
662 incidence = delSel.next(); 662 incidence = delSel.next();
663 } 663 }
664 QFile file( fn ); 664 QFile file( fn );
665 if (!file.open( IO_WriteOnly ) ) { 665 if (!file.open( IO_WriteOnly ) ) {
666 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 666 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
667 return; 667 return;
668 } 668 }
669 QTextStream ts( &file ); 669 QTextStream ts( &file );
670 ts << text; 670 ts << text;
671 file.close(); 671 file.close();
672 //qDebug("%s ", text.latin1()); 672 //qDebug("%s ", text.latin1());
673 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 673 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
674 KOPrefs::instance()->mLastSaveFile = fn; 674 KOPrefs::instance()->mLastSaveFile = fn;
675 topLevelWidget()->setCaption(mes); 675 topLevelWidget()->setCaption(mes);
676 } 676 }
677 } 677 }
678} 678}
679void KOListView::saveToFileVCS() 679void KOListView::saveToFileVCS()
680{ 680{
681 writeToFile( false ); 681 writeToFile( false );
682} 682}
683void KOListView::saveToFile() 683void KOListView::saveToFile()
684{ 684{
685 writeToFile( true ); 685 writeToFile( true );
686} 686}
687QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 687QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
688{ 688{
689 QPtrList<Incidence> delSel ; 689 QPtrList<Incidence> delSel ;
690 bool addSubTodos = false; 690 bool addSubTodos = false;
691 bool askSubTodos = true; 691 bool askSubTodos = true;
692 QListViewItem *item = mListView->firstChild (); 692 QListViewItem *item = mListView->firstChild ();
693 while ( item ) { 693 while ( item ) {
694 if ( item->isSelected() ) { 694 if ( item->isSelected() ) {
695 Incidence* inc = ((KOListViewItem *)item)->data(); 695 Incidence* inc = ((KOListViewItem *)item)->data();
696 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 696 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
697 if ( (inc->typeID() == todoID && includeTodos) || 697 if ( (inc->typeID() == todoID && includeTodos) ||
698 (inc->typeID() == eventID && includeEvents) || 698 (inc->typeID() == eventID && includeEvents) ||
699 (inc->typeID() == journalID && includeJournals) ) { 699 (inc->typeID() == journalID && includeJournals) ) {
700 if ( inc->typeID() == todoID && onlyDueTodos ) { 700 if ( inc->typeID() == todoID && onlyDueTodos ) {
701 if ( ((Todo*)inc)->hasDueDate() ) 701 if ( ((Todo*)inc)->hasDueDate() )
702 delSel.append( inc ); 702 delSel.append( inc );
703 } else 703 } else
704 delSel.append( inc ); 704 delSel.append( inc );
705 705
706 } 706 }
707 } 707 }
708 if ( inc->typeID() == todoID ) { 708 if ( inc->typeID() == todoID ) {
709 Todo * todo = (Todo*) inc; 709 Todo * todo = (Todo*) inc;
710 if ( todo->relations().count() ) { 710 if ( todo->relations().count() ) {
711 if ( askSubTodos ) { 711 if ( askSubTodos ) {
712 int result = KMessageBox::warningYesNoCancel(this, 712 int result = KMessageBox::warningYesNoCancel(this,
713 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), 713 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
714 i18n("Todo has subtodos"), 714 i18n("Todo has subtodos"),
715 i18n("Yes"), 715 i18n("Yes"),
716 i18n("No")); 716 i18n("No"));
717 if ( result == KMessageBox::Cancel ) { 717 if ( result == KMessageBox::Cancel ) {
718 delSel.clear(); 718 delSel.clear();
719 return delSel; 719 return delSel;
720 } 720 }
721 if (result == KMessageBox::Yes) 721 if (result == KMessageBox::Yes)
722 addSubTodos = true; 722 addSubTodos = true;
723 askSubTodos = false; 723 askSubTodos = false;
724 } 724 }
725 if ( addSubTodos ) { 725 if ( addSubTodos ) {
726 QPtrList<Incidence> tempSel ; 726 QPtrList<Incidence> tempSel ;
727 inc->addRelationsToList( &tempSel ); 727 inc->addRelationsToList( &tempSel );
728 Incidence* tempinc = tempSel.first(); 728 Incidence* tempinc = tempSel.first();
729 while ( tempinc ) { 729 while ( tempinc ) {
730 if ( delSel.findRef( tempinc ) == -1 ) { 730 if ( delSel.findRef( tempinc ) == -1 ) {
731 if ( tempinc->typeID() == todoID && onlyDueTodos ) { 731 if ( tempinc->typeID() == todoID && onlyDueTodos ) {
732 if ( ((Todo*)tempinc)->hasDueDate() ) 732 if ( ((Todo*)tempinc)->hasDueDate() )
733 delSel.append( tempinc ); 733 delSel.append( tempinc );
734 } else 734 } else
735 delSel.append( tempinc ); 735 delSel.append( tempinc );
736 } 736 }
737 tempinc = tempSel.next(); 737 tempinc = tempSel.next();
738 } 738 }
739 } 739 }
740 } 740 }
741 } 741 }
742 } 742 }
743 item = item->nextSibling(); 743 item = item->nextSibling();
744 } 744 }
745 return delSel; 745 return delSel;
746} 746}
747 747
748void KOListView::writeToFile( bool iCal ) 748void KOListView::writeToFile( bool iCal )
749{ 749{
750 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 750 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
751 if ( !iCal ) { 751 if ( !iCal ) {
752 bool journal = false; 752 bool journal = false;
753 Incidence *incidence = delSel.first(); 753 Incidence *incidence = delSel.first();
754 while ( incidence ) { 754 while ( incidence ) {
755 if ( incidence->typeID() == journalID ) { 755 if ( incidence->typeID() == journalID ) {
756 journal = true; 756 journal = true;
757 break; 757 break;
758 } 758 }
759 incidence = delSel.next(); 759 incidence = delSel.next();
760 } 760 }
761 if ( journal ) { 761 if ( journal ) {
762 int result = KMessageBox::warningContinueCancel(this, 762 int result = KMessageBox::warningContinueCancel(this,
763 i18n("The journal entries can not be\nexported to a vCalendar file."), 763 i18n("The journal entries can not be\nexported to a vCalendar file."),
764 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 764 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
765 true); 765 true);
766 if (result != KMessageBox::Continue) return; 766 if (result != KMessageBox::Continue) return;
767 } 767 }
768 } 768 }
769 if ( delSel.count() ) { 769 if ( delSel.count() ) {
770 QString fn = KOPrefs::instance()->mLastSaveFile; 770 QString fn = KOPrefs::instance()->mLastSaveFile;
771 QString extension; 771 QString extension;
772 if ( iCal ) { 772 if ( iCal ) {
773 if ( fn.right( 4 ).lower() == ".vcs" ) { 773 if ( fn.right( 4 ).lower() == ".vcs" ) {
774 fn = fn.left( fn.length() -3) + "ics"; 774 fn = fn.left( fn.length() -3) + "ics";
775 } 775 }
776 } else { 776 } else {
777 if ( fn.right( 4 ).lower() == ".ics" ) { 777 if ( fn.right( 4 ).lower() == ".ics" ) {
778 fn = fn.left( fn.length() -3) + "vcs"; 778 fn = fn.left( fn.length() -3) + "vcs";
779 } 779 }
780 } 780 }
781 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 781 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
782 782
783 if ( fn == "" ) 783 if ( fn == "" )
784 return; 784 return;
785 QFileInfo info; 785 QFileInfo info;
786 info.setFile( fn ); 786 info.setFile( fn );
787 QString mes; 787 QString mes;
788 bool createbup = true; 788 bool createbup = true;
789 if ( info. exists() ) { 789 if ( info. exists() ) {
790 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 790 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
791 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 791 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
792 i18n("Overwrite!"), i18n("Cancel"), 0, 792 i18n("Overwrite!"), i18n("Cancel"), 0,
793 0, 1 ); 793 0, 1 );
794 if ( result != 0 ) { 794 if ( result != 0 ) {
795 createbup = false; 795 createbup = false;
796 } 796 }
797 } 797 }
798 if ( createbup ) { 798 if ( createbup ) {
799 CalendarLocal cal; 799 CalendarLocal cal;
800 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 800 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
801 Incidence *incidence = delSel.first(); 801 Incidence *incidence = delSel.first();
802 while ( incidence ) { 802 while ( incidence ) {
803 cal.addIncidence( incidence->clone() ); 803 cal.addIncidence( incidence->clone() );
804 incidence = delSel.next(); 804 incidence = delSel.next();
805 } 805 }
806 if ( iCal ) { 806 if ( iCal ) {
807 ICalFormat format; 807 ICalFormat format;
808 format.save( &cal, fn ); 808 format.save( &cal, fn );
809 } else { 809 } else {
810 810
811 VCalFormat format; 811 VCalFormat format;
812 format.save( &cal, fn ); 812 format.save( &cal, fn );
813 } 813 }
814 mes = i18n("KO/Pi:Saved %1").arg(fn ); 814 mes = i18n("KO/Pi:Saved %1").arg(fn );
815 KOPrefs::instance()->mLastSaveFile = fn; 815 KOPrefs::instance()->mLastSaveFile = fn;
816 topLevelWidget()->setCaption(mes); 816 topLevelWidget()->setCaption(mes);
817 } 817 }
818 } 818 }
819 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 819 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
820} 820}
821void KOListView::hideAll() 821void KOListView::hideAll()
822{ 822{
823 QPtrList<QListViewItem> delSel ; 823 QPtrList<QListViewItem> delSel ;
824 QListViewItem *item = mListView->firstChild (); 824 QListViewItem *item = mListView->firstChild ();
825 while ( item ) { 825 while ( item ) {
826 if ( item->isSelected() ) { 826 if ( item->isSelected() ) {
827 delSel.append(item); 827 delSel.append(item);
828 } 828 }
829 item = item->nextSibling(); 829 item = item->nextSibling();
830 } 830 }
831 item = delSel.first() ; 831 item = delSel.first() ;
832 while ( item ) { 832 while ( item ) {
833 QListViewItem * del = item; 833 QListViewItem * del = item;
834 item = delSel.next(); 834 item = delSel.next();
835 delete del; 835 delete del;
836 } 836 }
837} 837}
838void KOListView::printList() 838void KOListView::printList()
839{ 839{
840 mListView->printList(); 840 mListView->printList();
841} 841}
842void KOListView::deleteAll() 842void KOListView::deleteAll()
843{ 843{
844 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 844 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
845 if ( delSel.count() ) { 845 if ( delSel.count() ) {
846 int icount = delSel.count(); 846 int icount = delSel.count();
847 Incidence *incidence = delSel.first(); 847 Incidence *incidence = delSel.first();
848 Incidence *toDelete; 848 Incidence *toDelete;
849 KOPrefs *p = KOPrefs::instance(); 849 KOPrefs *p = KOPrefs::instance();
850 bool confirm = p->mConfirm; 850 bool confirm = p->mConfirm;
851 QString mess; 851 QString mess;
852 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 852 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
853 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 853 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
854 p->mConfirm = false; 854 p->mConfirm = false;
855 int delCounter = 0; 855 int delCounter = 0;
856 QDialog dia ( this, "p-dialog", true ); 856 QDialog dia ( this, "p-dialog", true );
857 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 857 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
858 QVBoxLayout lay( &dia ); 858 QVBoxLayout lay( &dia );
859 lay.setMargin(7); 859 lay.setMargin(7);
860 lay.setSpacing(7); 860 lay.setSpacing(7);
861 lay.addWidget( &lab); 861 lay.addWidget( &lab);
862 QProgressBar bar( icount, &dia ); 862 QProgressBar bar( icount, &dia );
863 lay.addWidget( &bar); 863 lay.addWidget( &bar);
864 int w = 220; 864 int w = 220;
865 int h = 50; 865 int h = 50;
866 int dw = QApplication::desktop()->width(); 866 int dw = QApplication::desktop()->width();
867 int dh = QApplication::desktop()->height(); 867 int dh = QApplication::desktop()->height();
868 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 868 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
869 //dia.resize( 240,50 ); 869 //dia.resize( 240,50 );
870 dia.show(); 870 dia.show();
871 KOPrefs::instance()->mGlobalUpdateDisabled = true; 871 KOPrefs::instance()->mGlobalUpdateDisabled = true;
872 while ( incidence ) { 872 while ( incidence ) {
873 bar.setProgress( delCounter ); 873 bar.setProgress( delCounter );
874 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 874 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
875 dia.setCaption( mess ); 875 dia.setCaption( mess );
876 qApp->processEvents(); 876 qApp->processEvents();
877 toDelete = (incidence); 877 toDelete = (incidence);
878 incidence = delSel.next(); 878 incidence = delSel.next();
879 emit deleteIncidenceSignal(toDelete ); 879 emit deleteIncidenceSignal(toDelete );
880 if ( dia.result() != 0 ) 880 if ( dia.result() != 0 )
881 break; 881 break;
882 882
883 } 883 }
884 KOPrefs::instance()->mGlobalUpdateDisabled = false; 884 KOPrefs::instance()->mGlobalUpdateDisabled = false;
885 emit deleteIncidenceSignal( 0 ); 885 emit deleteIncidenceSignal( 0 );
886 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 886 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
887 topLevelWidget ()->setCaption( mess ); 887 topLevelWidget ()->setCaption( mess );
888 p->mConfirm = confirm; 888 p->mConfirm = confirm;
889 } 889 }
890 } 890 }
891 891
892 892
893} 893}
894int KOListView::maxDatesHint() 894int KOListView::maxDatesHint()
895{ 895{
896 return 0; 896 return 0;
897} 897}
898 898
899int KOListView::currentDateCount() 899int KOListView::currentDateCount()
900{ 900{
901 return 0; 901 return 0;
902} 902}
903 903
904QPtrList<Incidence> KOListView::selectedIncidences() 904QPtrList<Incidence> KOListView::selectedIncidences()
905{ 905{
906 QPtrList<Incidence> eventList; 906 QPtrList<Incidence> eventList;
907 QListViewItem *item = mListView->firstChild (); 907 QListViewItem *item = mListView->firstChild ();
908 while ( item ) { 908 while ( item ) {
909 if ( item->isSelected() ) { 909 if ( item->isSelected() ) {
910 eventList.append(((KOListViewItem *)item)->data()); 910 eventList.append(((KOListViewItem *)item)->data());
911 } 911 }
912 912
913 item = item->nextSibling(); 913 item = item->nextSibling();
914 } 914 }
915 915
916 // // QListViewItem *item = mListView->selectedItem(); 916 // // QListViewItem *item = mListView->selectedItem();
917 //if (item) eventList.append(((KOListViewItem *)item)->data()); 917 //if (item) eventList.append(((KOListViewItem *)item)->data());
918 918
919 return eventList; 919 return eventList;
920} 920}
921 921
922DateList KOListView::selectedDates() 922DateList KOListView::selectedDates()
923{ 923{
924 DateList eventList; 924 DateList eventList;
925 return eventList; 925 return eventList;
926} 926}
927 927
928void KOListView::showDates(bool show) 928void KOListView::showDates(bool show)
929{ 929{
930 // 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
931 // show == true at first, then the columnwidths are set to zero. 931 // show == true at first, then the columnwidths are set to zero.
932 static int oldColWidth1 = 0; 932 static int oldColWidth1 = 0;
933 static int oldColWidth3 = 0; 933 static int oldColWidth3 = 0;
934 934
935 if (!show) { 935 if (!show) {
936 oldColWidth1 = mListView->columnWidth(1); 936 oldColWidth1 = mListView->columnWidth(1);
937 oldColWidth3 = mListView->columnWidth(3); 937 oldColWidth3 = mListView->columnWidth(3);
938 mListView->setColumnWidth(1, 0); 938 mListView->setColumnWidth(1, 0);
939 mListView->setColumnWidth(3, 0); 939 mListView->setColumnWidth(3, 0);
940 } else { 940 } else {
941 mListView->setColumnWidth(1, oldColWidth1); 941 mListView->setColumnWidth(1, oldColWidth1);
942 mListView->setColumnWidth(3, oldColWidth3); 942 mListView->setColumnWidth(3, oldColWidth3);
943 } 943 }
944 mListView->repaint(); 944 mListView->repaint();
945} 945}
946 946
947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
948 const QDate &td) 948 const QDate &td)
949{ 949{
950#ifndef KORG_NOPRINTER 950#ifndef KORG_NOPRINTER
951 calPrinter->preview(CalPrinter::Day, fd, td); 951 calPrinter->preview(CalPrinter::Day, fd, td);
952#endif 952#endif
953} 953}
954 954
955void KOListView::showDates() 955void KOListView::showDates()
956{ 956{
957 showDates(true); 957 showDates(true);
958} 958}
959 959
960void KOListView::hideDates() 960void KOListView::hideDates()
961{ 961{
962 showDates(false); 962 showDates(false);
963} 963}
964 964
965void KOListView::resetFocus() 965void KOListView::resetFocus()
966{ 966{
967 topLevelWidget()->setActiveWindow(); 967 topLevelWidget()->setActiveWindow();
968 topLevelWidget()->raise(); 968 topLevelWidget()->raise();
969 mListView->setFocus(); 969 mListView->setFocus();
970} 970}
971void KOListView::updateView() 971void KOListView::updateView()
972{ 972{
973 mListView->setFocus(); 973 mListView->setFocus();
974 if ( mListView->firstChild () ) 974 if ( mListView->firstChild () ) {
975 mListView->setCurrentItem( mListView->firstChild () ); 975 mListView->setCurrentItem( mListView->firstChild () );
976 }
977 processSelectionChange( mListView->firstChild () );
976} 978}
977void KOListView::updateConfig() 979void KOListView::updateConfig()
978{ 980{
979 981
980 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 982 mListView->setFont ( KOPrefs::instance()->mListViewFont );
981 updateView(); 983 updateView();
982 984
983} 985}
984void KOListView::setStartDate(const QDate &start) 986void KOListView::setStartDate(const QDate &start)
985{ 987{
986 mStartDate = start; 988 mStartDate = start;
987} 989}
988 990
989void KOListView::showDates(const QDate &start, const QDate &end) 991void KOListView::showDates(const QDate &start, const QDate &end)
990{ 992{
991 clear(); 993 clear();
992 mStartDate = start; 994 mStartDate = start;
993 QDate date = start; 995 QDate date = start;
994 while( date <= end ) { 996 while( date <= end ) {
995 addEvents(calendar()->events(date)); 997 addEvents(calendar()->events(date));
996 addTodos(calendar()->todos(date)); 998 addTodos(calendar()->todos(date));
997 addJournals( calendar()->journals4Date(date) ); 999 addJournals( calendar()->journals4Date(date) );
998 date = date.addDays( 1 ); 1000 date = date.addDays( 1 );
999 } 1001 }
1000 emit incidenceSelected( 0 ); 1002 //emit incidenceSelected( 0 );
1001 updateView(); 1003 updateView();
1002 1004
1003} 1005}
1004 1006
1005void KOListView::addEvents(QPtrList<Event> eventList) 1007void KOListView::addEvents(QPtrList<Event> eventList)
1006{ 1008{
1007 1009
1008 Event *ev; 1010 Event *ev;
1009 for(ev = eventList.first(); ev; ev = eventList.next()) { 1011 for(ev = eventList.first(); ev; ev = eventList.next()) {
1010 addIncidence(ev); 1012 addIncidence(ev);
1011 } 1013 }
1012 if ( !mListView->currentItem() ){ 1014 if ( !mListView->currentItem() ){
1013 updateView(); 1015 updateView();
1014 } 1016 }
1015} 1017}
1016 1018
1017void KOListView::addTodos(QPtrList<Todo> eventList) 1019void KOListView::addTodos(QPtrList<Todo> eventList)
1018{ 1020{
1019 Todo *ev; 1021 Todo *ev;
1020 for(ev = eventList.first(); ev; ev = eventList.next()) { 1022 for(ev = eventList.first(); ev; ev = eventList.next()) {
1021 addIncidence(ev); 1023 addIncidence(ev);
1022 } 1024 }
1023 if ( !mListView->currentItem() ){ 1025 if ( !mListView->currentItem() ){
1024 updateView(); 1026 updateView();
1025 } 1027 }
1026} 1028}
1027void KOListView::addJournals(QPtrList<Journal> eventList) 1029void KOListView::addJournals(QPtrList<Journal> eventList)
1028{ 1030{
1029 Journal *ev; 1031 Journal *ev;
1030 for(ev = eventList.first(); ev; ev = eventList.next()) { 1032 for(ev = eventList.first(); ev; ev = eventList.next()) {
1031 addIncidence(ev); 1033 addIncidence(ev);
1032 } 1034 }
1033 if ( !mListView->currentItem() ){ 1035 if ( !mListView->currentItem() ){
1034 updateView(); 1036 updateView();
1035 } 1037 }
1036} 1038}
1037 1039
1038void KOListView::showCompletedTodos() 1040void KOListView::showCompletedTodos()
1039{ 1041{
1040 mForceShowCompletedTodos = true; 1042 mForceShowCompletedTodos = true;
1041} 1043}
1042void KOListView::addIncidence(Incidence *incidence) 1044void KOListView::addIncidence(Incidence *incidence)
1043{ 1045{
1044 if ( mUidDict.find( incidence->uid() ) ) return; 1046 if ( mUidDict.find( incidence->uid() ) ) return;
1045 1047
1046 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1048 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1047 if ( incidence->typeID() == todoID ) { 1049 if ( incidence->typeID() == todoID ) {
1048 if ( ! mForceShowCompletedTodos ) { 1050 if ( ! mForceShowCompletedTodos ) {
1049 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1051 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1050 return; 1052 return;
1051 } 1053 }
1052 } 1054 }
1053 mUidDict.insert( incidence->uid(), incidence ); 1055 mUidDict.insert( incidence->uid(), incidence );
1054 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1056 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1055 ListItemVisitor v(item, mStartDate ); 1057 ListItemVisitor v(item, mStartDate );
1056 if (incidence->accept(v)) { 1058 if (incidence->accept(v)) {
1057 return; 1059 return;
1058 } 1060 }
1059 else delete item; 1061 else delete item;
1060} 1062}
1061 1063
1062void KOListView::showEvents(QPtrList<Event> eventList) 1064void KOListView::showEvents(QPtrList<Event> eventList)
1063{ 1065{
1064 clear(); 1066 clear();
1065 1067
1066 addEvents(eventList); 1068 addEvents(eventList);
1067 1069
1068 // After new creation of list view no events are selected. 1070 // After new creation of list view no events are selected.
1069 emit incidenceSelected( 0 ); 1071 emit incidenceSelected( 0 );
1070} 1072}
1071int KOListView::count() 1073int KOListView::count()
1072{ 1074{
1073 return mListView->childCount(); 1075 return mListView->childCount();
1074} 1076}
1075 1077
1076void KOListView::changeEventDisplay(Event *event, int action) 1078void KOListView::changeEventDisplay(Event *event, int action)
1077{ 1079{
1078 KOListViewItem *item; 1080 KOListViewItem *item;
1079 1081
1080 switch(action) { 1082 switch(action) {
1081 case KOGlobals::EVENTADDED: 1083 case KOGlobals::EVENTADDED:
1082 addIncidence( event ); 1084 addIncidence( event );
1083 break; 1085 break;
1084 case KOGlobals::EVENTEDITED: 1086 case KOGlobals::EVENTEDITED:
1085 item = getItemForEvent(event); 1087 item = getItemForEvent(event);
1086 if (item) { 1088 if (item) {
1087 ListItemVisitor v(item, mStartDate ); 1089 ListItemVisitor v(item, mStartDate );
1088 ((Incidence*)event)->accept(v); 1090 ((Incidence*)event)->accept(v);
1089 } 1091 }
1090 break; 1092 break;
1091 case KOGlobals::EVENTDELETED: 1093 case KOGlobals::EVENTDELETED:
1092 item = getItemForEvent(event); 1094 item = getItemForEvent(event);
1093 if (item) { 1095 if (item) {
1094 mUidDict.remove( event->uid() ); 1096 mUidDict.remove( event->uid() );
1095 delete item; 1097 delete item;
1096 } 1098 }
1097 break; 1099 break;
1098 default: 1100 default:
1099 ; 1101 ;
1100 } 1102 }
1101} 1103}
1102 1104
1103KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1105KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1104{ 1106{
1105 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1107 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1106 while (item) { 1108 while (item) {
1107 if (item->data() == event) return item; 1109 if (item->data() == event) return item;
1108 item = (KOListViewItem *)item->nextSibling(); 1110 item = (KOListViewItem *)item->nextSibling();
1109 } 1111 }
1110 return 0; 1112 return 0;
1111} 1113}
1112 1114
1113void KOListView::defaultItemAction(QListViewItem *i) 1115void KOListView::defaultItemAction(QListViewItem *i)
1114{ 1116{
1115 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1117 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1116 if ( item ) defaultAction( item->data() ); 1118 if ( item ) defaultAction( item->data() );
1117 1119
1118} 1120}
1119 1121
1120void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1122void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1121{ 1123{
1122 mActiveItem = (KOListViewItem *)item; 1124 mActiveItem = (KOListViewItem *)item;
1123 if (mActiveItem) { 1125 if (mActiveItem) {
1124 Incidence *incidence = mActiveItem->data(); 1126 Incidence *incidence = mActiveItem->data();
1125 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1127 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1126 mPopupMenu->showIncidencePopup(incidence); 1128 mPopupMenu->showIncidencePopup(incidence);
1127 1129
1128 /* 1130 /*
1129 if ( incidence && incidence->type() == "Event" ) { 1131 if ( incidence && incidence->type() == "Event" ) {
1130 Event *event = static_cast<Event *>( incidence ); 1132 Event *event = static_cast<Event *>( incidence );
1131 mPopupMenu->showEventPopup(event); 1133 mPopupMenu->showEventPopup(event);
1132 } 1134 }
1133 */ 1135 */
1134 } 1136 }
1135} 1137}
1136 1138
1137void KOListView::readSettings(KConfig *config, QString setting) 1139void KOListView::readSettings(KConfig *config, QString setting)
1138{ 1140{
1139 // qDebug("KOListView::readSettings "); 1141 // qDebug("KOListView::readSettings ");
1140 mListView->restoreLayout(config,setting); 1142 mListView->restoreLayout(config,setting);
1141} 1143}
1142 1144
1143void KOListView::writeSettings(KConfig *config, QString setting) 1145void KOListView::writeSettings(KConfig *config, QString setting)
1144{ 1146{
1145 // qDebug("KOListView::writeSettings "); 1147 // qDebug("KOListView::writeSettings ");
1146 mListView->saveLayout(config, setting); 1148 mListView->saveLayout(config, setting);
1147} 1149}
1148 1150
1149void KOListView::processSelectionChange(QListViewItem *) 1151void KOListView::processSelectionChange(QListViewItem *)
1150{ 1152{
1151 1153
1152 KOListViewItem *item = 1154 KOListViewItem *item =
1153 static_cast<KOListViewItem *>( mListView->currentItem() ); 1155 static_cast<KOListViewItem *>( mListView->currentItem() );
1154 1156
1155 if ( !item ) { 1157 if ( !item ) {
1156 emit incidenceSelected( 0 ); 1158 emit incidenceSelected( 0 );
1157 } else { 1159 } else {
1158 emit incidenceSelected( item->data() ); 1160 emit incidenceSelected( item->data() );
1159 } 1161 }
1160} 1162}
1161 1163
1162void KOListView::clearSelection() 1164void KOListView::clearSelection()
1163{ 1165{
1164 mListView->selectAll( false ); 1166 mListView->selectAll( false );
1165} 1167}
1166void KOListView::allSelection() 1168void KOListView::allSelection()
1167{ 1169{
1168 mListView->selectAll( true ); 1170 mListView->selectAll( true );
1169} 1171}
1170 1172
1171void KOListView::clear() 1173void KOListView::clear()
1172{ 1174{
1173 mListView->clear(); 1175 mListView->clear();
1174 mUidDict.clear(); 1176 mUidDict.clear();
1175} 1177}
1176 1178
1177Incidence* KOListView::currentItem() 1179Incidence* KOListView::currentItem()
1178{ 1180{
1179 if ( mListView->currentItem() ) 1181 if ( mListView->currentItem() )
1180 return ((KOListViewItem*) mListView->currentItem())->data(); 1182 return ((KOListViewItem*) mListView->currentItem())->data();
1181 return 0; 1183 return 0;
1182} 1184}
1183void KOListView::keyPressEvent ( QKeyEvent *e) 1185void KOListView::keyPressEvent ( QKeyEvent *e)
1184{ 1186{
1185 1187
1186 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1188 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1187 deleteAll(); 1189 deleteAll();
1188 return; 1190 return;
1189 } 1191 }
1190 1192
1191 e->ignore(); 1193 e->ignore();
1192} 1194}
1193void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1195void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1194{ 1196{
1195 1197
1196 switch ( e->key() ) { 1198 switch ( e->key() ) {
1197 case Qt::Key_Down: 1199 case Qt::Key_Down:
1198 if ( e->state() == ShiftButton ) { 1200 if ( e->state() == ShiftButton ) {
1199 QListViewItem* cn = currentItem(); 1201 QListViewItem* cn = currentItem();
1200 if ( !cn ) 1202 if ( !cn )
1201 cn = firstChild(); 1203 cn = firstChild();
1202 if ( !cn ) 1204 if ( !cn )
1203 return; 1205 return;
1204 while ( cn->nextSibling() ) 1206 while ( cn->nextSibling() )
1205 cn = cn->nextSibling(); 1207 cn = cn->nextSibling();
1206 setCurrentItem ( cn ); 1208 setCurrentItem ( cn );
1207 ensureItemVisible ( cn ); 1209 ensureItemVisible ( cn );
1208 1210
1209 e->accept(); 1211 e->accept();
1210 return; 1212 return;
1211 } 1213 }
1212 if ( e->state() == ControlButton ) { 1214 if ( e->state() == ControlButton ) {
1213 int count = childCount (); 1215 int count = childCount ();
1214 int jump = count / 5; 1216 int jump = count / 5;
1215 QListViewItem* cn; 1217 QListViewItem* cn;
1216 cn = currentItem(); 1218 cn = currentItem();
1217 if ( ! cn ) 1219 if ( ! cn )
1218 return; 1220 return;
1219 if ( jump == 0 ) 1221 if ( jump == 0 )
1220 jump = 1; 1222 jump = 1;
1221 while ( jump && cn->nextSibling() ) { 1223 while ( jump && cn->nextSibling() ) {
1222 cn = cn->nextSibling(); 1224 cn = cn->nextSibling();
1223 --jump; 1225 --jump;
1224 } 1226 }
1225 setCurrentItem ( cn ); 1227 setCurrentItem ( cn );
1226 ensureItemVisible ( cn ); 1228 ensureItemVisible ( cn );
1227 1229
1228 } else 1230 } else
1229 QListView::keyPressEvent ( e ) ; 1231 QListView::keyPressEvent ( e ) ;
1230 e->accept(); 1232 e->accept();
1231 break; 1233 break;
1232 1234
1233 case Qt::Key_Up: 1235 case Qt::Key_Up:
1234 if ( e->state() == ShiftButton ) { 1236 if ( e->state() == ShiftButton ) {
1235 QListViewItem* cn = firstChild(); 1237 QListViewItem* cn = firstChild();
1236 if ( cn ) { 1238 if ( cn ) {
1237 setCurrentItem ( cn ); 1239 setCurrentItem ( cn );
1238 ensureItemVisible ( cn ); 1240 ensureItemVisible ( cn );
1239 } 1241 }
1240 e->accept(); 1242 e->accept();
1241 return; 1243 return;
1242 } 1244 }
1243 if ( e->state() == ControlButton ) { 1245 if ( e->state() == ControlButton ) {
1244 int count = childCount (); 1246 int count = childCount ();
1245 int jump = count / 5; 1247 int jump = count / 5;
1246 QListViewItem* cn; 1248 QListViewItem* cn;
1247 cn = currentItem(); 1249 cn = currentItem();
1248 if ( ! cn ) 1250 if ( ! cn )
1249 return; 1251 return;
1250 if ( jump == 0 ) 1252 if ( jump == 0 )
1251 jump = 1; 1253 jump = 1;
1252 while ( jump && cn->itemAbove ()) { 1254 while ( jump && cn->itemAbove ()) {
1253 cn = cn->itemAbove (); 1255 cn = cn->itemAbove ();
1254 --jump; 1256 --jump;
1255 } 1257 }
1256 setCurrentItem ( cn ); 1258 setCurrentItem ( cn );
1257 ensureItemVisible ( cn ); 1259 ensureItemVisible ( cn );
1258 } else 1260 } else
1259 QListView::keyPressEvent ( e ) ; 1261 QListView::keyPressEvent ( e ) ;
1260 e->accept(); 1262 e->accept();
1261 break; 1263 break;
1262 case Qt::Key_I: { 1264 case Qt::Key_I: {
1263 QListViewItem* cn; 1265 QListViewItem* cn;
1264 cn = currentItem(); 1266 cn = currentItem();
1265 if ( cn ) { 1267 if ( cn ) {
1266 KOListViewItem* ci = (KOListViewItem*)( cn ); 1268 KOListViewItem* ci = (KOListViewItem*)( cn );
1267 if ( ci ){ 1269 if ( ci ){
1268 //emit showIncidence( ci->data()); 1270 //emit showIncidence( ci->data());
1269 cn = cn->nextSibling(); 1271 cn = cn->nextSibling();
1270 if ( cn ) { 1272 if ( cn ) {
1271 setCurrentItem ( cn ); 1273 setCurrentItem ( cn );
1272 ensureItemVisible ( cn ); 1274 ensureItemVisible ( cn );
1273 } 1275 }
1274 emit showIncidence( ci->data()); 1276 emit showIncidence( ci->data());
1275 } 1277 }
1276 } 1278 }
1277 e->accept(); 1279 e->accept();
1278 } 1280 }
1279 break; 1281 break;
1280 case Qt::Key_Return: 1282 case Qt::Key_Return:
1281 case Qt::Key_Enter: 1283 case Qt::Key_Enter:
1282 { 1284 {
1283 QListViewItem* cn; 1285 QListViewItem* cn;
1284 cn = currentItem(); 1286 cn = currentItem();
1285 if ( cn ) { 1287 if ( cn ) {
1286 KOListViewItem* ci = (KOListViewItem*)( cn ); 1288 KOListViewItem* ci = (KOListViewItem*)( cn );
1287 if ( ci ){ 1289 if ( ci ){
1288 if ( e->state() == ShiftButton ) 1290 if ( e->state() == ShiftButton )
1289 ci->setSelected( false ); 1291 ci->setSelected( false );
1290 else 1292 else
1291 ci->setSelected( true ); 1293 ci->setSelected( true );
1292 cn = cn->nextSibling(); 1294 cn = cn->nextSibling();
1293 if ( cn ) { 1295 if ( cn ) {
1294 setCurrentItem ( cn ); 1296 setCurrentItem ( cn );
1295 ensureItemVisible ( cn ); 1297 ensureItemVisible ( cn );
1296 } 1298 }
1297 } 1299 }
1298 } 1300 }
1299 e->accept(); 1301 e->accept();
1300 } 1302 }
1301 break; 1303 break;
1302 default: 1304 default:
1303 e->ignore(); 1305 e->ignore();
1304 } 1306 }
1305} 1307}
1306KOListViewListView::KOListViewListView(KOListView * lv ) 1308KOListViewListView::KOListViewListView(KOListView * lv )
1307 : KListView( lv, "kolistlistview", false ) 1309 : KListView( lv, "kolistlistview", false )
1308{ 1310{
1309 mYMousePos = 0; 1311 mYMousePos = 0;
1310 mPopupTimer = new QTimer(this); 1312 mPopupTimer = new QTimer(this);
1311 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1313 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1312#ifndef DESKTOP_VERSION 1314#ifndef DESKTOP_VERSION
1313 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1315 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1314#endif 1316#endif
1315 setSelectionMode( QListView::Multi ); 1317 setSelectionMode( QListView::Multi );
1316 setMultiSelection( true); 1318 setMultiSelection( true);
1317} 1319}
1318bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1320bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1319{ 1321{
1320 QListViewItem *qitem = firstChild (); 1322 QListViewItem *qitem = firstChild ();
1321 while ( qitem ) { 1323 while ( qitem ) {
1322 if ( qitem->isSelected() && item != qitem ) 1324 if ( qitem->isSelected() && item != qitem )
1323 return true; 1325 return true;
1324 qitem = qitem->nextSibling(); 1326 qitem = qitem->nextSibling();
1325 } 1327 }
1326 return false; 1328 return false;
1327} 1329}
1328void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1330void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1329{ 1331{
1330 if (!e) return; 1332 if (!e) return;
1331 QPoint vp = contentsToViewport(e->pos()); 1333 QPoint vp = contentsToViewport(e->pos());
1332 QListViewItem *item = itemAt(vp); 1334 QListViewItem *item = itemAt(vp);
1333 if (!item) { 1335 if (!item) {
1334 emit newEvent(); 1336 emit newEvent();
1335 return; 1337 return;
1336 } 1338 }
1337 KListView::contentsMouseDoubleClickEvent(e); 1339 KListView::contentsMouseDoubleClickEvent(e);
1338} 1340}
1339#if 0 1341#if 0
1340void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1342void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1341{ 1343{
1342 //qDebug("contentsMousePressEvent++++ "); 1344 //qDebug("contentsMousePressEvent++++ ");
1343 KListView::contentsMousePressEvent( e ); 1345 KListView::contentsMousePressEvent( e );
1344 if ( e->button() == RightButton ) { 1346 if ( e->button() == RightButton ) {
1345 QListViewItem* ci = currentItem(); 1347 QListViewItem* ci = currentItem();
1346 clearSelection () ; 1348 clearSelection () ;
1347 if ( ci ) 1349 if ( ci )
1348 ci->setSelected( true ); 1350 ci->setSelected( true );
1349 } 1351 }
1350} 1352}
1351void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1353void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1352{ 1354{
1353 KListView::contentsMouseReleaseEvent(e); 1355 KListView::contentsMouseReleaseEvent(e);
1354} 1356}
1355void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1357void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1356{ 1358{
1357 KListView::contentsMouseMoveEvent(e); 1359 KListView::contentsMouseMoveEvent(e);
1358} 1360}
1359#endif 1361#endif
1360void KOListViewListView::popupMenu() 1362void KOListViewListView::popupMenu()
1361{ 1363{
1362 mPopupTimer->stop(); 1364 mPopupTimer->stop();
1363 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1365 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1364 QApplication::postEvent( this->viewport(), e ); 1366 QApplication::postEvent( this->viewport(), e );
1365 1367
1366} 1368}
1367void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1369void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1368{ 1370{
1369 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1371 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1370 mYMousePos = mapToGlobal( (e->pos())).y(); 1372 mYMousePos = mapToGlobal( (e->pos())).y();
1371 if ( e->button() == LeftButton ) { 1373 if ( e->button() == LeftButton ) {
1372 mPopupTimer->start( 600 ); 1374 mPopupTimer->start( 600 );
1373 mEventPos = contentsToViewport(e->pos()); 1375 mEventPos = contentsToViewport(e->pos());
1374 mEventGlobalPos = e->globalPos(); 1376 mEventGlobalPos = e->globalPos();
1375 } 1377 }
1376 KListView::contentsMousePressEvent( e ); 1378 KListView::contentsMousePressEvent( e );
1377 if ( e->button() == RightButton ) { 1379 if ( e->button() == RightButton ) {
1378 QListViewItem* ci = currentItem(); 1380 QListViewItem* ci = currentItem();
1379 //clearSelection(); 1381 //clearSelection();
1380 if ( ci ) 1382 if ( ci )
1381 ci->setSelected( true ); 1383 ci->setSelected( true );
1382 } 1384 }
1383} 1385}
1384void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1386void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1385{ 1387{
1386 mPopupTimer->stop(); 1388 mPopupTimer->stop();
1387 KListView::contentsMouseReleaseEvent(e); 1389 KListView::contentsMouseReleaseEvent(e);
1388} 1390}
1389void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1391void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1390{ 1392{
1391 // qDebug("contentsMouseMoveEv....... "); 1393 // qDebug("contentsMouseMoveEv....... ");
1392 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1394 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1393 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1395 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1394 if ( diff < 0 ) diff = -diff; 1396 if ( diff < 0 ) diff = -diff;
1395 if ( diff > 15 ) 1397 if ( diff > 15 )
1396 mPopupTimer->stop(); 1398 mPopupTimer->stop();
1397 else { 1399 else {
1398 mEventPos = contentsToViewport(e->pos()); 1400 mEventPos = contentsToViewport(e->pos());
1399 mEventGlobalPos = e->globalPos(); 1401 mEventGlobalPos = e->globalPos();
1400 } 1402 }
1401 KListView::contentsMouseMoveEvent(e); 1403 KListView::contentsMouseMoveEvent(e);
1402} 1404}
1403 1405
1404#define protected public 1406#define protected public
1405#include <qheader.h> 1407#include <qheader.h>
1406#undef protected 1408#undef protected
1407void KOListViewListView::printList() 1409void KOListViewListView::printList()
1408{ 1410{
1409#ifdef DESKTOP_VERSION 1411#ifdef DESKTOP_VERSION
1410 KOPrintPrefs pp ( this ); 1412 KOPrintPrefs pp ( this );
1411 if (!pp.exec() ) 1413 if (!pp.exec() )
1412 return; 1414 return;
1413 int scaleval = pp.printMode() ; 1415 int scaleval = pp.printMode() ;
1414 1416
1415 QPrinter printer; 1417 QPrinter printer;
1416 if (!printer.setup() ) 1418 if (!printer.setup() )
1417 return; 1419 return;
1418 clearSelection (); 1420 clearSelection ();
1419 QPainter p; 1421 QPainter p;
1420 p.begin ( &printer ); 1422 p.begin ( &printer );
1421 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1423 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1422 float dx, dy; 1424 float dx, dy;
1423 int wid = (m.width() * 9)/10; 1425 int wid = (m.width() * 9)/10;
1424 dx = (float) wid/(float)contentsWidth (); 1426 dx = (float) wid/(float)contentsWidth ();
1425 dy = (float)(m.height()) / (float)contentsHeight (); 1427 dy = (float)(m.height()) / (float)contentsHeight ();
1426 float scale; 1428 float scale;
1427 // scale to fit the width or height of the paper 1429 // scale to fit the width or height of the paper
1428 if ( dx < dy ) 1430 if ( dx < dy )
1429 scale = dx; 1431 scale = dx;
1430 else 1432 else
1431 scale = dy; 1433 scale = dy;
1432 1434
1433 p.translate( m.width()/10,m.width()/10 ); 1435 p.translate( m.width()/10,m.width()/10 );
1434 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1436 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1435 p.scale( scale, scale ); 1437 p.scale( scale, scale );
1436 } 1438 }
1437 1439
1438 int cou = header()->count(); 1440 int cou = header()->count();
1439 int iii; 1441 int iii;
1440 QRect rect ( 0,0,0, header()->height()); 1442 QRect rect ( 0,0,0, header()->height());
1441 for ( iii = 0; iii < cou; ++iii ) { 1443 for ( iii = 0; iii < cou; ++iii ) {
1442 rect.setLeft ( header()->sectionPos( iii ) ); 1444 rect.setLeft ( header()->sectionPos( iii ) );
1443 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1445 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1444 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1446 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1445 } 1447 }
1446 p.translate( 0, header()->height()); 1448 p.translate( 0, header()->height());
1447 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1449 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1448 p.end(); 1450 p.end();
1449#endif 1451#endif
1450} 1452}