summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-30 15:06:11 (UTC)
committer zautrix <zautrix>2005-06-30 15:06:11 (UTC)
commitd401e425af46703a89eb80802606edeea06c9538 (patch) (unidiff)
treee32a98c44e340a6af6706fa99544cba648aa19f1
parentaf48ba51eeb7a766ca7b458d2287e55c121388cf (diff)
downloadkdepimpi-d401e425af46703a89eb80802606edeea06c9538.zip
kdepimpi-d401e425af46703a89eb80802606edeea06c9538.tar.gz
kdepimpi-d401e425af46703a89eb80802606edeea06c9538.tar.bz2
desk fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/journalentry.cpp8
-rw-r--r--korganizer/kodaymatrix.cpp3
-rw-r--r--korganizer/koeditorgeneral.cpp6
-rw-r--r--korganizer/koprefs.cpp14
5 files changed, 21 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 214b829..d0de233 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1830,1537 +1830,1539 @@ bool CalendarView::importQtopia( const QString &categories,
1830 QtopiaFormat qtopiaFormat; 1830 QtopiaFormat qtopiaFormat;
1831 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1831 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1832 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1832 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1833 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1833 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1834 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1834 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1835 1835
1836 updateView(); 1836 updateView();
1837 return true; 1837 return true;
1838 1838
1839#if 0 1839#if 0
1840 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1840 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1841 mCurrentSyncDevice = "qtopia-XML"; 1841 mCurrentSyncDevice = "qtopia-XML";
1842 if ( mSyncManager->mAskForPreferences ) 1842 if ( mSyncManager->mAskForPreferences )
1843 edit_sync_options(); 1843 edit_sync_options();
1844 qApp->processEvents(); 1844 qApp->processEvents();
1845 CalendarLocal* calendar = new CalendarLocal(); 1845 CalendarLocal* calendar = new CalendarLocal();
1846 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1846 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1847 bool syncOK = false; 1847 bool syncOK = false;
1848 QtopiaFormat qtopiaFormat; 1848 QtopiaFormat qtopiaFormat;
1849 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1849 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1850 bool loadOk = true; 1850 bool loadOk = true;
1851 if ( !categories.isEmpty() ) 1851 if ( !categories.isEmpty() )
1852 loadOk = qtopiaFormat.load( calendar, categories ); 1852 loadOk = qtopiaFormat.load( calendar, categories );
1853 if ( loadOk && !datebook.isEmpty() ) 1853 if ( loadOk && !datebook.isEmpty() )
1854 loadOk = qtopiaFormat.load( calendar, datebook ); 1854 loadOk = qtopiaFormat.load( calendar, datebook );
1855 if ( loadOk && !todolist.isEmpty() ) 1855 if ( loadOk && !todolist.isEmpty() )
1856 loadOk = qtopiaFormat.load( calendar, todolist ); 1856 loadOk = qtopiaFormat.load( calendar, todolist );
1857 1857
1858 if ( loadOk ) { 1858 if ( loadOk ) {
1859 getEventViewerDialog()->setSyncMode( true ); 1859 getEventViewerDialog()->setSyncMode( true );
1860 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1860 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1861 getEventViewerDialog()->setSyncMode( false ); 1861 getEventViewerDialog()->setSyncMode( false );
1862 qApp->processEvents(); 1862 qApp->processEvents();
1863 if ( syncOK ) { 1863 if ( syncOK ) {
1864 if ( mSyncManager->mWriteBackFile ) 1864 if ( mSyncManager->mWriteBackFile )
1865 { 1865 {
1866 // write back XML file 1866 // write back XML file
1867 1867
1868 } 1868 }
1869 setModified( true ); 1869 setModified( true );
1870 } 1870 }
1871 } else { 1871 } else {
1872 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1872 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1873 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1873 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1874 question, i18n("Ok")) ; 1874 question, i18n("Ok")) ;
1875 } 1875 }
1876 delete calendar; 1876 delete calendar;
1877 updateView(); 1877 updateView();
1878 return syncOK; 1878 return syncOK;
1879 1879
1880 1880
1881#endif 1881#endif
1882 1882
1883} 1883}
1884 1884
1885void CalendarView::setSyncEventsReadOnly() 1885void CalendarView::setSyncEventsReadOnly()
1886{ 1886{
1887 mCalendar->setSyncEventsReadOnly(); 1887 mCalendar->setSyncEventsReadOnly();
1888} 1888}
1889 1889
1890bool CalendarView::loadCalendars() 1890bool CalendarView::loadCalendars()
1891{ 1891{
1892 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1892 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1893 KopiCalendarFile * cal = calendars.first(); 1893 KopiCalendarFile * cal = calendars.first();
1894 mCalendar->setDefaultCalendar( 1 ); 1894 mCalendar->setDefaultCalendar( 1 );
1895 openCalendar( MainWindow::defaultFileName(), false ); 1895 openCalendar( MainWindow::defaultFileName(), false );
1896 cal = calendars.next(); 1896 cal = calendars.next();
1897 while ( cal ) { 1897 while ( cal ) {
1898 addCalendar( cal ); 1898 addCalendar( cal );
1899 cal = calendars.next(); 1899 cal = calendars.next();
1900 } 1900 }
1901 restoreCalendarSettings(); 1901 restoreCalendarSettings();
1902 return true; 1902 return true;
1903} 1903}
1904bool CalendarView::restoreCalendarSettings() 1904bool CalendarView::restoreCalendarSettings()
1905{ 1905{
1906 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1906 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1907 KopiCalendarFile * cal = calendars.first(); 1907 KopiCalendarFile * cal = calendars.first();
1908 while ( cal ) { 1908 while ( cal ) {
1909 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1909 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1910 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1910 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1911 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1911 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1912 if ( cal->isStandard ) 1912 if ( cal->isStandard )
1913 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1913 mCalendar->setDefaultCalendar( cal->mCalNumber );
1914 cal = calendars.next(); 1914 cal = calendars.next();
1915 } 1915 }
1916 setSyncEventsReadOnly(); 1916 setSyncEventsReadOnly();
1917 mCalendar->reInitAlarmSettings(); 1917 mCalendar->reInitAlarmSettings();
1918 updateUnmanagedViews(); 1918 updateUnmanagedViews();
1919 updateView(); 1919 updateView();
1920 return true; 1920 return true;
1921} 1921}
1922void CalendarView::addCalendarId( int id ) 1922void CalendarView::addCalendarId( int id )
1923{ 1923{
1924 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1924 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1925 addCalendar( cal ); 1925 addCalendar( cal );
1926} 1926}
1927bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1927bool CalendarView::addCalendar( KopiCalendarFile * cal )
1928{ 1928{
1929 cal->mErrorOnLoad = false; 1929 cal->mErrorOnLoad = false;
1930 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1930 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1931 cal->mLoadDt = QDateTime::currentDateTime(); 1931 cal->mLoadDt = QDateTime::currentDateTime();
1932 return true; 1932 return true;
1933 } 1933 }
1934 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1934 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1935 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1935 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1936 cal->mErrorOnLoad = true; 1936 cal->mErrorOnLoad = true;
1937 return false; 1937 return false;
1938} 1938}
1939bool CalendarView::openCalendar(QString filename, bool merge) 1939bool CalendarView::openCalendar(QString filename, bool merge)
1940{ 1940{
1941 1941
1942 if (filename.isEmpty()) { 1942 if (filename.isEmpty()) {
1943 return false; 1943 return false;
1944 } 1944 }
1945 1945
1946 if (!QFile::exists(filename)) { 1946 if (!QFile::exists(filename)) {
1947 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1947 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1948 return false; 1948 return false;
1949 } 1949 }
1950 1950
1951 globalFlagBlockAgenda = 1; 1951 globalFlagBlockAgenda = 1;
1952 clearAllViews(); 1952 clearAllViews();
1953 if (!merge) { 1953 if (!merge) {
1954 mViewManager->setDocumentId( filename ); 1954 mViewManager->setDocumentId( filename );
1955 mCalendar->close(); 1955 mCalendar->close();
1956 } 1956 }
1957 mStorage->setFileName( filename ); 1957 mStorage->setFileName( filename );
1958 1958
1959 if ( mStorage->load() ) { 1959 if ( mStorage->load() ) {
1960 if ( merge ) ;//setModified( true ); 1960 if ( merge ) ;//setModified( true );
1961 else { 1961 else {
1962 //setModified( true ); 1962 //setModified( true );
1963 mViewManager->setDocumentId( filename ); 1963 mViewManager->setDocumentId( filename );
1964 mDialogManager->setDocumentId( filename ); 1964 mDialogManager->setDocumentId( filename );
1965 mTodoList->setDocumentId( filename ); 1965 mTodoList->setDocumentId( filename );
1966 } 1966 }
1967 globalFlagBlockAgenda = 2; 1967 globalFlagBlockAgenda = 2;
1968 // if ( getLastSyncEvent() ) 1968 // if ( getLastSyncEvent() )
1969 // getLastSyncEvent()->setReadOnly( true ); 1969 // getLastSyncEvent()->setReadOnly( true );
1970 mCalendar->reInitAlarmSettings(); 1970 mCalendar->reInitAlarmSettings();
1971 setSyncEventsReadOnly(); 1971 setSyncEventsReadOnly();
1972 updateUnmanagedViews(); 1972 updateUnmanagedViews();
1973 updateView(); 1973 updateView();
1974 if ( filename != MainWindow::defaultFileName() ) { 1974 if ( filename != MainWindow::defaultFileName() ) {
1975 saveCalendar( MainWindow::defaultFileName() ); 1975 saveCalendar( MainWindow::defaultFileName() );
1976 } else { 1976 } else {
1977 QFileInfo finf ( MainWindow::defaultFileName()); 1977 QFileInfo finf ( MainWindow::defaultFileName());
1978 if ( finf.exists() ) { 1978 if ( finf.exists() ) {
1979 setLoadedFileVersion( finf.lastModified () ); 1979 setLoadedFileVersion( finf.lastModified () );
1980 } 1980 }
1981 } 1981 }
1982 return true; 1982 return true;
1983 } else { 1983 } else {
1984 // while failing to load, the calendar object could 1984 // while failing to load, the calendar object could
1985 // have become partially populated. Clear it out. 1985 // have become partially populated. Clear it out.
1986 if ( !merge ) { 1986 if ( !merge ) {
1987 mCalendar->close(); 1987 mCalendar->close();
1988 mViewManager->setDocumentId( filename ); 1988 mViewManager->setDocumentId( filename );
1989 mDialogManager->setDocumentId( filename ); 1989 mDialogManager->setDocumentId( filename );
1990 mTodoList->setDocumentId( filename ); 1990 mTodoList->setDocumentId( filename );
1991 } 1991 }
1992 1992
1993 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1993 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1994 1994
1995 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1995 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1996 globalFlagBlockAgenda = 2; 1996 globalFlagBlockAgenda = 2;
1997 mCalendar->reInitAlarmSettings(); 1997 mCalendar->reInitAlarmSettings();
1998 setSyncEventsReadOnly(); 1998 setSyncEventsReadOnly();
1999 updateUnmanagedViews(); 1999 updateUnmanagedViews();
2000 updateView(); 2000 updateView();
2001 } 2001 }
2002 return false; 2002 return false;
2003} 2003}
2004void CalendarView::showOpenError() 2004void CalendarView::showOpenError()
2005{ 2005{
2006 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2006 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2007} 2007}
2008void CalendarView::setLoadedFileVersion(QDateTime dt) 2008void CalendarView::setLoadedFileVersion(QDateTime dt)
2009{ 2009{
2010 loadedFileVersion = dt; 2010 loadedFileVersion = dt;
2011} 2011}
2012bool CalendarView::checkFileChanged(QString fn) 2012bool CalendarView::checkFileChanged(QString fn)
2013{ 2013{
2014 QFileInfo finf ( fn ); 2014 QFileInfo finf ( fn );
2015 if ( !finf.exists() ) 2015 if ( !finf.exists() )
2016 return true; 2016 return true;
2017 QDateTime dt = finf.lastModified (); 2017 QDateTime dt = finf.lastModified ();
2018 if ( dt <= loadedFileVersion ) 2018 if ( dt <= loadedFileVersion )
2019 return false; 2019 return false;
2020 return true; 2020 return true;
2021 2021
2022} 2022}
2023void CalendarView::watchSavedFile() 2023void CalendarView::watchSavedFile()
2024{ 2024{
2025 QFileInfo finf ( MainWindow::defaultFileName()); 2025 QFileInfo finf ( MainWindow::defaultFileName());
2026 if ( !finf.exists() ) 2026 if ( !finf.exists() )
2027 return; 2027 return;
2028 QDateTime dt = finf.lastModified (); 2028 QDateTime dt = finf.lastModified ();
2029 if ( dt < loadedFileVersion ) { 2029 if ( dt < loadedFileVersion ) {
2030 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2030 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2031 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2031 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2032 return; 2032 return;
2033 } 2033 }
2034 loadedFileVersion = dt; 2034 loadedFileVersion = dt;
2035} 2035}
2036bool CalendarView::checkAllFileVersions() 2036bool CalendarView::checkAllFileVersions()
2037{ 2037{
2038 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2038 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2039 KopiCalendarFile * cal = calendars.first(); 2039 KopiCalendarFile * cal = calendars.first();
2040 mCalendar->setDefaultCalendar( 1 ); 2040 mCalendar->setDefaultCalendar( 1 );
2041 mCalendar->setDefaultCalendarEnabledOnly(); 2041 mCalendar->setDefaultCalendarEnabledOnly();
2042 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2042 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2043 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2043 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2044 restoreCalendarSettings(); 2044 restoreCalendarSettings();
2045 return false; 2045 return false;
2046 } 2046 }
2047 } 2047 }
2048 cal = calendars.next(); 2048 cal = calendars.next();
2049 QDateTime storeTemp = loadedFileVersion; 2049 QDateTime storeTemp = loadedFileVersion;
2050 while ( cal ) { 2050 while ( cal ) {
2051 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2051 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2052 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2052 mCalendar->setDefaultCalendar( cal->mCalNumber );
2053 mCalendar->setDefaultCalendarEnabledOnly(); 2053 mCalendar->setDefaultCalendarEnabledOnly();
2054 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2054 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2055 if ( !checkFileVersion(cal->mFileName )) { 2055 if ( !checkFileVersion(cal->mFileName )) {
2056 loadedFileVersion = storeTemp; 2056 loadedFileVersion = storeTemp;
2057 restoreCalendarSettings(); 2057 restoreCalendarSettings();
2058 return false; 2058 return false;
2059 } 2059 }
2060 } 2060 }
2061 cal = calendars.next(); 2061 cal = calendars.next();
2062 } 2062 }
2063 loadedFileVersion = storeTemp; 2063 loadedFileVersion = storeTemp;
2064 return true; 2064 return true;
2065} 2065}
2066bool CalendarView::checkFileVersion(QString fn) 2066bool CalendarView::checkFileVersion(QString fn)
2067{ 2067{
2068 QFileInfo finf ( fn ); 2068 QFileInfo finf ( fn );
2069 if ( !finf.exists() ) 2069 if ( !finf.exists() )
2070 return true; 2070 return true;
2071 QDateTime dt = finf.lastModified (); 2071 QDateTime dt = finf.lastModified ();
2072 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2072 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2073 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2073 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2074 if ( dt <= loadedFileVersion ) 2074 if ( dt <= loadedFileVersion )
2075 return true; 2075 return true;
2076 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2076 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2077 i18n("KO/Pi Warning"),i18n("Overwrite"), 2077 i18n("KO/Pi Warning"),i18n("Overwrite"),
2078 i18n("Sync+save")); 2078 i18n("Sync+save"));
2079 2079
2080 if ( km == KMessageBox::Cancel ) 2080 if ( km == KMessageBox::Cancel )
2081 return false; 2081 return false;
2082 if ( km == KMessageBox::Yes ) 2082 if ( km == KMessageBox::Yes )
2083 return true; 2083 return true;
2084 2084
2085 setSyncDevice("deleteaftersync" ); 2085 setSyncDevice("deleteaftersync" );
2086 mSyncManager->mAskForPreferences = true; 2086 mSyncManager->mAskForPreferences = true;
2087 mSyncManager->mSyncAlgoPrefs = 3; 2087 mSyncManager->mSyncAlgoPrefs = 3;
2088 mSyncManager->mWriteBackFile = false; 2088 mSyncManager->mWriteBackFile = false;
2089 mSyncManager->mWriteBackExistingOnly = false; 2089 mSyncManager->mWriteBackExistingOnly = false;
2090 mSyncManager->mShowSyncSummary = false; 2090 mSyncManager->mShowSyncSummary = false;
2091 syncCalendar( fn, 3 ); 2091 syncCalendar( fn, 3 );
2092 Event * e = getLastSyncEvent(); 2092 Event * e = getLastSyncEvent();
2093 if ( e ) 2093 if ( e )
2094 mCalendar->deleteEvent( e ); 2094 mCalendar->deleteEvent( e );
2095 return true; 2095 return true;
2096} 2096}
2097bool CalendarView::saveCalendars() 2097bool CalendarView::saveCalendars()
2098{ 2098{
2099 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2099 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2100 KopiCalendarFile * cal = calendars.first(); 2100 KopiCalendarFile * cal = calendars.first();
2101 mCalendar->setDefaultCalendar( 1 ); 2101 mCalendar->setDefaultCalendar( 1 );
2102 mCalendar->setDefaultCalendarEnabledOnly(); 2102 mCalendar->setDefaultCalendarEnabledOnly();
2103 saveCalendar( MainWindow::defaultFileName() ); 2103 saveCalendar( MainWindow::defaultFileName() );
2104 cal = calendars.next(); 2104 cal = calendars.next();
2105 while ( cal ) { 2105 while ( cal ) {
2106 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2106 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2107 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2107 mCalendar->setDefaultCalendar( cal->mCalNumber );
2108 mCalendar->setDefaultCalendarEnabledOnly(); 2108 mCalendar->setDefaultCalendarEnabledOnly();
2109 if ( saveCalendar( cal->mFileName ) ) 2109 if ( saveCalendar( cal->mFileName ) )
2110 cal->mLoadDt = QDateTime::currentDateTime(); 2110 cal->mLoadDt = QDateTime::currentDateTime();
2111 } 2111 }
2112 cal = calendars.next(); 2112 cal = calendars.next();
2113 } 2113 }
2114 restoreCalendarSettings(); 2114 restoreCalendarSettings();
2115 return true; 2115 return true;
2116} 2116}
2117bool CalendarView::saveCalendar( QString filename ) 2117bool CalendarView::saveCalendar( QString filename )
2118{ 2118{
2119 2119
2120 // Store back all unsaved data into calendar object 2120 // Store back all unsaved data into calendar object
2121 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2121 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2122 if ( mViewManager->currentView() ) 2122 if ( mViewManager->currentView() )
2123 mViewManager->currentView()->flushView(); 2123 mViewManager->currentView()->flushView();
2124 2124
2125 2125
2126 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2126 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2127 mStorage->setSaveFormat( new ICalFormat() ); 2127 mStorage->setSaveFormat( new ICalFormat() );
2128 mStorage->setFileName( filename ); 2128 mStorage->setFileName( filename );
2129 bool success; 2129 bool success;
2130 success = mStorage->save(); 2130 success = mStorage->save();
2131 if ( !success ) { 2131 if ( !success ) {
2132 return false; 2132 return false;
2133 } 2133 }
2134 if ( filename == MainWindow::defaultFileName() ) { 2134 if ( filename == MainWindow::defaultFileName() ) {
2135 setLoadedFileVersion( lfv ); 2135 setLoadedFileVersion( lfv );
2136 watchSavedFile(); 2136 watchSavedFile();
2137 } 2137 }
2138 return true; 2138 return true;
2139} 2139}
2140 2140
2141void CalendarView::closeCalendar() 2141void CalendarView::closeCalendar()
2142{ 2142{
2143 2143
2144 // child windows no longer valid 2144 // child windows no longer valid
2145 clearAllViews(); 2145 clearAllViews();
2146 emit closingDown(); 2146 emit closingDown();
2147 2147
2148 mCalendar->close(); 2148 mCalendar->close();
2149 setModified(false); 2149 setModified(false);
2150 updateView(); 2150 updateView();
2151} 2151}
2152 2152
2153void CalendarView::archiveCalendar() 2153void CalendarView::archiveCalendar()
2154{ 2154{
2155 mDialogManager->showArchiveDialog(); 2155 mDialogManager->showArchiveDialog();
2156} 2156}
2157 2157
2158 2158
2159void CalendarView::readSettings() 2159void CalendarView::readSettings()
2160{ 2160{
2161 2161
2162 2162
2163 // mViewManager->showAgendaView(); 2163 // mViewManager->showAgendaView();
2164 QString str; 2164 QString str;
2165 //qDebug("CalendarView::readSettings() "); 2165 //qDebug("CalendarView::readSettings() ");
2166 // read settings from the KConfig, supplying reasonable 2166 // read settings from the KConfig, supplying reasonable
2167 // defaults where none are to be found 2167 // defaults where none are to be found
2168 KConfig *config = KOGlobals::config(); 2168 KConfig *config = KOGlobals::config();
2169#ifndef KORG_NOSPLITTER 2169#ifndef KORG_NOSPLITTER
2170 config->setGroup("KOrganizer Geometry"); 2170 config->setGroup("KOrganizer Geometry");
2171 2171
2172 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2172 QValueList<int> sizes = config->readIntListEntry("Separator1");
2173 if (sizes.count() != 2) { 2173 if (sizes.count() != 2) {
2174 sizes << mDateNavigator->minimumSizeHint().width(); 2174 sizes << mDateNavigator->minimumSizeHint().width();
2175 sizes << 300; 2175 sizes << 300;
2176 } 2176 }
2177 mPanner->setSizes(sizes); 2177 mPanner->setSizes(sizes);
2178 2178
2179 sizes = config->readIntListEntry("Separator2"); 2179 sizes = config->readIntListEntry("Separator2");
2180 if ( ( mResourceView && sizes.count() == 4 ) || 2180 if ( ( mResourceView && sizes.count() == 4 ) ||
2181 ( !mResourceView && sizes.count() == 3 ) ) { 2181 ( !mResourceView && sizes.count() == 3 ) ) {
2182 mLeftSplitter->setSizes(sizes); 2182 mLeftSplitter->setSizes(sizes);
2183 } 2183 }
2184#endif 2184#endif
2185 globalFlagBlockAgenda = 1; 2185 globalFlagBlockAgenda = 1;
2186 mViewManager->showAgendaView(); 2186 mViewManager->showAgendaView();
2187 //mViewManager->readSettings( config ); 2187 //mViewManager->readSettings( config );
2188 mTodoList->restoreLayout(config,QString("Todo Layout")); 2188 mTodoList->restoreLayout(config,QString("Todo Layout"));
2189 readFilterSettings(config); 2189 readFilterSettings(config);
2190 2190
2191#ifdef DESKTOP_VERSION 2191#ifdef DESKTOP_VERSION
2192 config->setGroup("WidgetLayout"); 2192 config->setGroup("WidgetLayout");
2193 QStringList list; 2193 QStringList list;
2194 list = config->readListEntry("MainLayout"); 2194 list = config->readListEntry("MainLayout");
2195 int x,y,w,h; 2195 int x,y,w,h;
2196 if ( ! list.isEmpty() ) { 2196 if ( ! list.isEmpty() ) {
2197 x = list[0].toInt(); 2197 x = list[0].toInt();
2198 y = list[1].toInt(); 2198 y = list[1].toInt();
2199 w = list[2].toInt(); 2199 w = list[2].toInt();
2200 h = list[3].toInt(); 2200 h = list[3].toInt();
2201 KApplication::testCoords( &x,&y,&w,&h ); 2201 KApplication::testCoords( &x,&y,&w,&h );
2202 topLevelWidget()->setGeometry(x,y,w,h); 2202 topLevelWidget()->setGeometry(x,y,w,h);
2203 2203
2204 } else { 2204 } else {
2205 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2205 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2206 } 2206 }
2207 list = config->readListEntry("EditEventLayout"); 2207 list = config->readListEntry("EditEventLayout");
2208 if ( ! list.isEmpty() ) { 2208 if ( ! list.isEmpty() ) {
2209 x = list[0].toInt(); 2209 x = list[0].toInt();
2210 y = list[1].toInt(); 2210 y = list[1].toInt();
2211 w = list[2].toInt(); 2211 w = list[2].toInt();
2212 h = list[3].toInt(); 2212 h = list[3].toInt();
2213 KApplication::testCoords( &x,&y,&w,&h ); 2213 KApplication::testCoords( &x,&y,&w,&h );
2214 mEventEditor->setGeometry(x,y,w,h); 2214 mEventEditor->setGeometry(x,y,w,h);
2215 2215
2216 } 2216 }
2217 list = config->readListEntry("EditTodoLayout"); 2217 list = config->readListEntry("EditTodoLayout");
2218 if ( ! list.isEmpty() ) { 2218 if ( ! list.isEmpty() ) {
2219 x = list[0].toInt(); 2219 x = list[0].toInt();
2220 y = list[1].toInt(); 2220 y = list[1].toInt();
2221 w = list[2].toInt(); 2221 w = list[2].toInt();
2222 h = list[3].toInt(); 2222 h = list[3].toInt();
2223 KApplication::testCoords( &x,&y,&w,&h ); 2223 KApplication::testCoords( &x,&y,&w,&h );
2224 mTodoEditor->setGeometry(x,y,w,h); 2224 mTodoEditor->setGeometry(x,y,w,h);
2225 2225
2226 } 2226 }
2227 list = config->readListEntry("ViewerLayout"); 2227 list = config->readListEntry("ViewerLayout");
2228 if ( ! list.isEmpty() ) { 2228 if ( ! list.isEmpty() ) {
2229 x = list[0].toInt(); 2229 x = list[0].toInt();
2230 y = list[1].toInt(); 2230 y = list[1].toInt();
2231 w = list[2].toInt(); 2231 w = list[2].toInt();
2232 h = list[3].toInt(); 2232 h = list[3].toInt();
2233 KApplication::testCoords( &x,&y,&w,&h ); 2233 KApplication::testCoords( &x,&y,&w,&h );
2234 getEventViewerDialog()->setGeometry(x,y,w,h); 2234 getEventViewerDialog()->setGeometry(x,y,w,h);
2235 } 2235 }
2236#endif 2236#endif
2237 config->setGroup( "Views" ); 2237 config->setGroup( "Views" );
2238 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2238 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2239 2239
2240 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2240 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2241 2241
2242 int resetval = 0; 2242 int resetval = 0;
2243 int maxVal = 0; 2243 int maxVal = 0;
2244 if (sizes.count() != 3) { 2244 if (sizes.count() != 3) {
2245 if ( KOPrefs::instance()->mVerticalScreen ) { 2245 if ( KOPrefs::instance()->mVerticalScreen ) {
2246 resetval = mDateNavigator->sizeHint().width()+2; 2246 resetval = mDateNavigator->sizeHint().width()+2;
2247 } else { 2247 } else {
2248 resetval = mDateNavigator->sizeHint().height()+2; 2248 resetval = mDateNavigator->sizeHint().height()+2;
2249 } 2249 }
2250 } 2250 }
2251 if ( resetval ) { 2251 if ( resetval ) {
2252 sizes.clear(); 2252 sizes.clear();
2253 if ( KOPrefs::instance()->mVerticalScreen ) { 2253 if ( KOPrefs::instance()->mVerticalScreen ) {
2254 maxVal = QApplication::desktop()->width() -10; 2254 maxVal = QApplication::desktop()->width() -10;
2255 } else { 2255 } else {
2256 maxVal = QApplication::desktop()->height()-10; 2256 maxVal = QApplication::desktop()->height()-10;
2257 } 2257 }
2258 sizes << resetval; 2258 sizes << resetval;
2259 if ( maxVal < resetval + resetval) 2259 if ( maxVal < resetval + resetval)
2260 resetval = maxVal - resetval; 2260 resetval = maxVal - resetval;
2261 sizes << resetval; 2261 sizes << resetval;
2262 sizes << 100; 2262 sizes << 100;
2263 } 2263 }
2264 mLeftFrame->setSizes(sizes); 2264 mLeftFrame->setSizes(sizes);
2265 sizes = config->readIntListEntry("Main Splitter Frame"); 2265 sizes = config->readIntListEntry("Main Splitter Frame");
2266 resetval = 0; 2266 resetval = 0;
2267 maxVal = 0; 2267 maxVal = 0;
2268 if (sizes.count() != 2) { 2268 if (sizes.count() != 2) {
2269 if ( !KOPrefs::instance()->mVerticalScreen ) { 2269 if ( !KOPrefs::instance()->mVerticalScreen ) {
2270 resetval = mDateNavigator->sizeHint().width()+2; 2270 resetval = mDateNavigator->sizeHint().width()+2;
2271 } else { 2271 } else {
2272 resetval = mDateNavigator->sizeHint().height()+2; 2272 resetval = mDateNavigator->sizeHint().height()+2;
2273 } 2273 }
2274 } 2274 }
2275 if ( resetval ) { 2275 if ( resetval ) {
2276 sizes.clear(); 2276 sizes.clear();
2277 if ( !KOPrefs::instance()->mVerticalScreen ) { 2277 if ( !KOPrefs::instance()->mVerticalScreen ) {
2278 maxVal = QApplication::desktop()->width() -10; 2278 maxVal = QApplication::desktop()->width() -10;
2279 } else { 2279 } else {
2280 maxVal = QApplication::desktop()->height()-10; 2280 maxVal = QApplication::desktop()->height()-10;
2281 } 2281 }
2282 sizes << resetval; 2282 sizes << resetval;
2283 if ( maxVal < resetval + resetval) 2283 if ( maxVal < resetval + resetval)
2284 resetval = maxVal - resetval; 2284 resetval = maxVal - resetval;
2285 sizes << resetval; 2285 sizes << resetval;
2286 } 2286 }
2287 mMainFrame->setSizes(sizes); 2287 mMainFrame->setSizes(sizes);
2288 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2288 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2289 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2289 else if ( dateCount == 7 ) mNavigator->selectWeek();
2290 else mNavigator->selectDates( dateCount ); 2290 else mNavigator->selectDates( dateCount );
2291 // mViewManager->readSettings( config ); 2291 // mViewManager->readSettings( config );
2292 updateConfig(); 2292 updateConfig();
2293 globalFlagBlockAgenda = 2; 2293 globalFlagBlockAgenda = 2;
2294 mViewManager->readSettings( config ); 2294 mViewManager->readSettings( config );
2295 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2295 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2296} 2296}
2297 2297
2298 2298
2299void CalendarView::writeSettings() 2299void CalendarView::writeSettings()
2300{ 2300{
2301 // kdDebug() << "CalendarView::writeSettings" << endl; 2301 // kdDebug() << "CalendarView::writeSettings" << endl;
2302 2302
2303 KConfig *config = KOGlobals::config(); 2303 KConfig *config = KOGlobals::config();
2304 2304
2305 mViewManager->writeSettings( config ); 2305 mViewManager->writeSettings( config );
2306 mTodoList->saveLayout(config,QString("Todo Layout")); 2306 mTodoList->saveLayout(config,QString("Todo Layout"));
2307 mDialogManager->writeSettings( config ); 2307 mDialogManager->writeSettings( config );
2308 //KOPrefs::instance()->usrWriteConfig(); 2308 //KOPrefs::instance()->usrWriteConfig();
2309 KOPrefs::instance()->writeConfig(); 2309 KOPrefs::instance()->writeConfig();
2310 2310
2311 writeFilterSettings(config); 2311 writeFilterSettings(config);
2312 config->setGroup( "AppRun" ); 2312 config->setGroup( "AppRun" );
2313 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2313 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2314 int days = dt.daysTo( QDate::currentDate() ); 2314 int days = dt.daysTo( QDate::currentDate() );
2315 dt = dt.addDays( days ); 2315 dt = dt.addDays( days );
2316 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2316 int secs = dt.secsTo( QDateTime::currentDateTime() );
2317 config->writeEntry( "LatestProgramStopDays", days ); 2317 config->writeEntry( "LatestProgramStopDays", days );
2318 config->writeEntry( "LatestProgramStopSecs", secs ); 2318 config->writeEntry( "LatestProgramStopSecs", secs );
2319 //qDebug("KO: Writing stop time: %d ", secs); 2319 //qDebug("KO: Writing stop time: %d ", secs);
2320 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2320 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2321 //QDateTime latest = dt.addSecs ( secs ); 2321 //QDateTime latest = dt.addSecs ( secs );
2322 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2322 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2323 config->setGroup( "Views" ); 2323 config->setGroup( "Views" );
2324 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2324 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2325 2325
2326#if 0 2326#if 0
2327 qDebug("********************* "); 2327 qDebug("********************* ");
2328 qDebug("Testcode secsto "); 2328 qDebug("Testcode secsto ");
2329 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2329 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2330 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2330 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2331 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2331 int secsto = dt_nodaylight.secsTo( dt_daylight );
2332 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2332 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2333 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2333 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2334 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2334 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2335 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2335 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2336 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2336 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2337 qDebug("********************* testcode end"); 2337 qDebug("********************* testcode end");
2338 2338
2339#endif 2339#endif
2340 2340
2341 QValueList<int> listINT = mLeftFrame->sizes(); 2341 QValueList<int> listINT = mLeftFrame->sizes();
2342 config->writeEntry("Left Splitter Frame",listINT); 2342 config->writeEntry("Left Splitter Frame",listINT);
2343 QValueList<int> listINT2 = mMainFrame->sizes(); 2343 QValueList<int> listINT2 = mMainFrame->sizes();
2344 config->writeEntry("Main Splitter Frame",listINT2); 2344 config->writeEntry("Main Splitter Frame",listINT2);
2345#ifdef DESKTOP_VERSION 2345#ifdef DESKTOP_VERSION
2346 config->setGroup("WidgetLayout"); 2346 config->setGroup("WidgetLayout");
2347 QStringList list ;//= config->readListEntry("MainLayout"); 2347 QStringList list ;//= config->readListEntry("MainLayout");
2348 int x,y,w,h; 2348 int x,y,w,h;
2349 QWidget* wid; 2349 QWidget* wid;
2350 wid = topLevelWidget(); 2350 wid = topLevelWidget();
2351 x = wid->geometry().x(); 2351 x = wid->geometry().x();
2352 y = wid->geometry().y(); 2352 y = wid->geometry().y();
2353 w = wid->width(); 2353 w = wid->width();
2354 h = wid->height(); 2354 h = wid->height();
2355 list.clear(); 2355 list.clear();
2356 list << QString::number( x ); 2356 list << QString::number( x );
2357 list << QString::number( y ); 2357 list << QString::number( y );
2358 list << QString::number( w ); 2358 list << QString::number( w );
2359 list << QString::number( h ); 2359 list << QString::number( h );
2360 config->writeEntry("MainLayout",list ); 2360 config->writeEntry("MainLayout",list );
2361 2361
2362 wid = mEventEditor; 2362 wid = mEventEditor;
2363 x = wid->geometry().x(); 2363 x = wid->geometry().x();
2364 y = wid->geometry().y(); 2364 y = wid->geometry().y();
2365 w = wid->width(); 2365 w = wid->width();
2366 h = wid->height(); 2366 h = wid->height();
2367 list.clear(); 2367 list.clear();
2368 list << QString::number( x ); 2368 list << QString::number( x );
2369 list << QString::number( y ); 2369 list << QString::number( y );
2370 list << QString::number( w ); 2370 list << QString::number( w );
2371 list << QString::number( h ); 2371 list << QString::number( h );
2372 config->writeEntry("EditEventLayout",list ); 2372 config->writeEntry("EditEventLayout",list );
2373 2373
2374 wid = mTodoEditor; 2374 wid = mTodoEditor;
2375 x = wid->geometry().x(); 2375 x = wid->geometry().x();
2376 y = wid->geometry().y(); 2376 y = wid->geometry().y();
2377 w = wid->width(); 2377 w = wid->width();
2378 h = wid->height(); 2378 h = wid->height();
2379 list.clear(); 2379 list.clear();
2380 list << QString::number( x ); 2380 list << QString::number( x );
2381 list << QString::number( y ); 2381 list << QString::number( y );
2382 list << QString::number( w ); 2382 list << QString::number( w );
2383 list << QString::number( h ); 2383 list << QString::number( h );
2384 config->writeEntry("EditTodoLayout",list ); 2384 config->writeEntry("EditTodoLayout",list );
2385 wid = getEventViewerDialog(); 2385 wid = getEventViewerDialog();
2386 x = wid->geometry().x(); 2386 x = wid->geometry().x();
2387 y = wid->geometry().y(); 2387 y = wid->geometry().y();
2388 w = wid->width(); 2388 w = wid->width();
2389 h = wid->height(); 2389 h = wid->height();
2390 list.clear(); 2390 list.clear();
2391 list << QString::number( x ); 2391 list << QString::number( x );
2392 list << QString::number( y ); 2392 list << QString::number( y );
2393 list << QString::number( w ); 2393 list << QString::number( w );
2394 list << QString::number( h ); 2394 list << QString::number( h );
2395 config->writeEntry("ViewerLayout",list ); 2395 config->writeEntry("ViewerLayout",list );
2396 wid = mDialogManager->getSearchDialog(); 2396 wid = mDialogManager->getSearchDialog();
2397 if ( wid ) { 2397 if ( wid ) {
2398 x = wid->geometry().x(); 2398 x = wid->geometry().x();
2399 y = wid->geometry().y(); 2399 y = wid->geometry().y();
2400 w = wid->width(); 2400 w = wid->width();
2401 h = wid->height(); 2401 h = wid->height();
2402 list.clear(); 2402 list.clear();
2403 list << QString::number( x ); 2403 list << QString::number( x );
2404 list << QString::number( y ); 2404 list << QString::number( y );
2405 list << QString::number( w ); 2405 list << QString::number( w );
2406 list << QString::number( h ); 2406 list << QString::number( h );
2407 config->writeEntry("SearchLayout",list ); 2407 config->writeEntry("SearchLayout",list );
2408 } 2408 }
2409#endif 2409#endif
2410 2410
2411 2411
2412 config->sync(); 2412 config->sync();
2413} 2413}
2414 2414
2415void CalendarView::readFilterSettings(KConfig *config) 2415void CalendarView::readFilterSettings(KConfig *config)
2416{ 2416{
2417 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2417 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2418 2418
2419 mFilters.clear(); 2419 mFilters.clear();
2420 2420
2421 config->setGroup("General"); 2421 config->setGroup("General");
2422 QStringList filterList = config->readListEntry("CalendarFilters"); 2422 QStringList filterList = config->readListEntry("CalendarFilters");
2423 2423
2424 QStringList::ConstIterator it = filterList.begin(); 2424 QStringList::ConstIterator it = filterList.begin();
2425 QStringList::ConstIterator end = filterList.end(); 2425 QStringList::ConstIterator end = filterList.end();
2426 while(it != end) { 2426 while(it != end) {
2427 // kdDebug() << " filter: " << (*it) << endl; 2427 // kdDebug() << " filter: " << (*it) << endl;
2428 2428
2429 CalFilter *filter; 2429 CalFilter *filter;
2430 filter = new CalFilter(*it); 2430 filter = new CalFilter(*it);
2431 config->setGroup("Filter_" + (*it).utf8()); 2431 config->setGroup("Filter_" + (*it).utf8());
2432 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2432 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2433 filter->setCriteria(config->readNumEntry("Criteria",0)); 2433 filter->setCriteria(config->readNumEntry("Criteria",0));
2434 filter->setCategoryList(config->readListEntry("CategoryList")); 2434 filter->setCategoryList(config->readListEntry("CategoryList"));
2435 mFilters.append(filter); 2435 mFilters.append(filter);
2436 2436
2437 ++it; 2437 ++it;
2438 } 2438 }
2439 2439
2440 if (mFilters.count() == 0) { 2440 if (mFilters.count() == 0) {
2441 CalFilter *filter = new CalFilter(i18n("Default")); 2441 CalFilter *filter = new CalFilter(i18n("Default"));
2442 mFilters.append(filter); 2442 mFilters.append(filter);
2443 } 2443 }
2444 mFilterView->updateFilters(); 2444 mFilterView->updateFilters();
2445 config->setGroup("FilterView"); 2445 config->setGroup("FilterView");
2446 2446
2447 mFilterView->blockSignals(true); 2447 mFilterView->blockSignals(true);
2448 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2448 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2449 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2449 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2450 mFilterView->blockSignals(false); 2450 mFilterView->blockSignals(false);
2451 // We do it manually to avoid it being done twice by the above calls 2451 // We do it manually to avoid it being done twice by the above calls
2452 updateFilter(); 2452 updateFilter();
2453} 2453}
2454 2454
2455void CalendarView::writeFilterSettings(KConfig *config) 2455void CalendarView::writeFilterSettings(KConfig *config)
2456{ 2456{
2457 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2457 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2458 2458
2459 QStringList filterList; 2459 QStringList filterList;
2460 2460
2461 CalFilter *filter = mFilters.first(); 2461 CalFilter *filter = mFilters.first();
2462 while(filter) { 2462 while(filter) {
2463 // kdDebug() << " fn: " << filter->name() << endl; 2463 // kdDebug() << " fn: " << filter->name() << endl;
2464 filterList << filter->name(); 2464 filterList << filter->name();
2465 config->setGroup("Filter_" + filter->name().utf8()); 2465 config->setGroup("Filter_" + filter->name().utf8());
2466 config->writeEntry("Criteria",filter->criteria()); 2466 config->writeEntry("Criteria",filter->criteria());
2467 config->writeEntry("CategoryList",filter->categoryList()); 2467 config->writeEntry("CategoryList",filter->categoryList());
2468 filter = mFilters.next(); 2468 filter = mFilters.next();
2469 } 2469 }
2470 config->setGroup("General"); 2470 config->setGroup("General");
2471 config->writeEntry("CalendarFilters",filterList); 2471 config->writeEntry("CalendarFilters",filterList);
2472 2472
2473 config->setGroup("FilterView"); 2473 config->setGroup("FilterView");
2474 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2474 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2475 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2475 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2476} 2476}
2477 2477
2478 2478
2479void CalendarView::goToday() 2479void CalendarView::goToday()
2480{ 2480{
2481 if ( mViewManager->currentView()->isMonthView() ) 2481 if ( mViewManager->currentView()->isMonthView() )
2482 mNavigator->selectTodayMonth(); 2482 mNavigator->selectTodayMonth();
2483 else 2483 else
2484 mNavigator->selectToday(); 2484 mNavigator->selectToday();
2485} 2485}
2486 2486
2487void CalendarView::goNext() 2487void CalendarView::goNext()
2488{ 2488{
2489 mNavigator->selectNext(); 2489 mNavigator->selectNext();
2490} 2490}
2491 2491
2492void CalendarView::goPrevious() 2492void CalendarView::goPrevious()
2493{ 2493{
2494 mNavigator->selectPrevious(); 2494 mNavigator->selectPrevious();
2495} 2495}
2496void CalendarView::goNextMonth() 2496void CalendarView::goNextMonth()
2497{ 2497{
2498 mNavigator->selectNextMonth(); 2498 mNavigator->selectNextMonth();
2499} 2499}
2500 2500
2501void CalendarView::goPreviousMonth() 2501void CalendarView::goPreviousMonth()
2502{ 2502{
2503 mNavigator->selectPreviousMonth(); 2503 mNavigator->selectPreviousMonth();
2504} 2504}
2505 2505
2506void CalendarView::updateConfig() 2506void CalendarView::updateConfig()
2507{ 2507{
2508 if ( KOPrefs::instance()->mUseAppColors ) 2508 if ( KOPrefs::instance()->mUseAppColors )
2509 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2509 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2510 emit configChanged(); 2510 emit configChanged();
2511 mTodoList->updateConfig(); 2511 mTodoList->updateConfig();
2512 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2512 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2513 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2513 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2514 // To make the "fill window" configurations work 2514 // To make the "fill window" configurations work
2515 //mViewManager->raiseCurrentView(); 2515 //mViewManager->raiseCurrentView();
2516} 2516}
2517 2517
2518 2518
2519void CalendarView::eventChanged(Event *event) 2519void CalendarView::eventChanged(Event *event)
2520{ 2520{
2521 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2521 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2522 //updateUnmanagedViews(); 2522 //updateUnmanagedViews();
2523} 2523}
2524 2524
2525void CalendarView::eventAdded(Event *event) 2525void CalendarView::eventAdded(Event *event)
2526{ 2526{
2527 changeEventDisplay(event,KOGlobals::EVENTADDED); 2527 changeEventDisplay(event,KOGlobals::EVENTADDED);
2528} 2528}
2529 2529
2530void CalendarView::eventToBeDeleted(Event *) 2530void CalendarView::eventToBeDeleted(Event *)
2531{ 2531{
2532 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2532 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2533} 2533}
2534 2534
2535void CalendarView::eventDeleted() 2535void CalendarView::eventDeleted()
2536{ 2536{
2537 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2537 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2538} 2538}
2539void CalendarView::changeTodoDisplay(Todo *which, int action) 2539void CalendarView::changeTodoDisplay(Todo *which, int action)
2540{ 2540{
2541 changeIncidenceDisplay((Incidence *)which, action); 2541 changeIncidenceDisplay((Incidence *)which, action);
2542 mDateNavigator->updateView(); //LR 2542 mDateNavigator->updateView(); //LR
2543 //mDialogManager->updateSearchDialog(); 2543 //mDialogManager->updateSearchDialog();
2544 2544
2545 if (which) { 2545 if (which) {
2546 mViewManager->updateWNview(); 2546 mViewManager->updateWNview();
2547 //mTodoList->updateView(); 2547 //mTodoList->updateView();
2548 } 2548 }
2549 2549
2550} 2550}
2551 2551
2552void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2552void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2553{ 2553{
2554 updateUnmanagedViews(); 2554 updateUnmanagedViews();
2555 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2555 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2556 if ( action == KOGlobals::EVENTDELETED ) { //delete 2556 if ( action == KOGlobals::EVENTDELETED ) { //delete
2557 mCalendar->checkAlarmForIncidence( 0, true ); 2557 mCalendar->checkAlarmForIncidence( 0, true );
2558 if ( mEventViewerDialog ) 2558 if ( mEventViewerDialog )
2559 mEventViewerDialog->hide(); 2559 mEventViewerDialog->hide();
2560 } 2560 }
2561 else 2561 else
2562 mCalendar->checkAlarmForIncidence( which , false ); 2562 mCalendar->checkAlarmForIncidence( which , false );
2563} 2563}
2564 2564
2565// most of the changeEventDisplays() right now just call the view's 2565// most of the changeEventDisplays() right now just call the view's
2566// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2566// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2567void CalendarView::changeEventDisplay(Event *which, int action) 2567void CalendarView::changeEventDisplay(Event *which, int action)
2568{ 2568{
2569 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2569 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2570 changeIncidenceDisplay((Incidence *)which, action); 2570 changeIncidenceDisplay((Incidence *)which, action);
2571 mDateNavigator->updateView(); 2571 mDateNavigator->updateView();
2572 //mDialogManager->updateSearchDialog(); 2572 //mDialogManager->updateSearchDialog();
2573 2573
2574 if (which) { 2574 if (which) {
2575 // If there is an event view visible update the display 2575 // If there is an event view visible update the display
2576 mViewManager->currentView()->changeEventDisplay(which,action); 2576 mViewManager->currentView()->changeEventDisplay(which,action);
2577 // TODO: check, if update needed 2577 // TODO: check, if update needed
2578 // if (which->getTodoStatus()) { 2578 // if (which->getTodoStatus()) {
2579 mTodoList->updateView(); 2579 mTodoList->updateView();
2580 // } 2580 // }
2581 } else { 2581 } else {
2582 mViewManager->currentView()->updateView(); 2582 mViewManager->currentView()->updateView();
2583 } 2583 }
2584} 2584}
2585 2585
2586 2586
2587void CalendarView::updateTodoViews() 2587void CalendarView::updateTodoViews()
2588{ 2588{
2589 mTodoList->updateView(); 2589 mTodoList->updateView();
2590 mViewManager->currentView()->updateView(); 2590 mViewManager->currentView()->updateView();
2591 2591
2592} 2592}
2593 2593
2594 2594
2595void CalendarView::updateView(const QDate &start, const QDate &end) 2595void CalendarView::updateView(const QDate &start, const QDate &end)
2596{ 2596{
2597#ifdef DESKTOP_VERSION 2597#ifdef DESKTOP_VERSION
2598 mDateScrollBar->blockSignals( true );
2598 mDateScrollBar->setValue( start.dayOfYear()-1); 2599 mDateScrollBar->setValue( start.dayOfYear()-1);
2600 mDateScrollBar->blockSignals( false );
2599#endif 2601#endif
2600 mTodoList->updateView(); 2602 mTodoList->updateView();
2601 mViewManager->updateView(start, end); 2603 mViewManager->updateView(start, end);
2602 //mDateNavigator->updateView(); 2604 //mDateNavigator->updateView();
2603} 2605}
2604 2606
2605void CalendarView::clearAllViews() 2607void CalendarView::clearAllViews()
2606{ 2608{
2607 mTodoList->clearList(); 2609 mTodoList->clearList();
2608 mViewManager->clearAllViews(); 2610 mViewManager->clearAllViews();
2609 SearchDialog * sd = mDialogManager->getSearchDialog(); 2611 SearchDialog * sd = mDialogManager->getSearchDialog();
2610 if ( sd ) { 2612 if ( sd ) {
2611 KOListView* kol = sd->listview(); 2613 KOListView* kol = sd->listview();
2612 if ( kol ) 2614 if ( kol )
2613 kol->clearList(); 2615 kol->clearList();
2614 } 2616 }
2615} 2617}
2616void CalendarView::updateView() 2618void CalendarView::updateView()
2617{ 2619{
2618 DateList tmpList = mNavigator->selectedDates(); 2620 DateList tmpList = mNavigator->selectedDates();
2619 2621
2620 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2622 if ( KOPrefs::instance()->mHideNonStartedTodos )
2621 mTodoList->updateView(); 2623 mTodoList->updateView();
2622 // We assume that the navigator only selects consecutive days. 2624 // We assume that the navigator only selects consecutive days.
2623 updateView( tmpList.first(), tmpList.last() ); 2625 updateView( tmpList.first(), tmpList.last() );
2624} 2626}
2625 2627
2626void CalendarView::updateUnmanagedViews() 2628void CalendarView::updateUnmanagedViews()
2627{ 2629{
2628 mDateNavigator->updateDayMatrix(); 2630 mDateNavigator->updateDayMatrix();
2629} 2631}
2630 2632
2631int CalendarView::msgItemDelete(const QString name) 2633int CalendarView::msgItemDelete(const QString name)
2632{ 2634{
2633 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2635 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2634 i18n("This item will be\npermanently deleted."), 2636 i18n("This item will be\npermanently deleted."),
2635 i18n("KO/Pi Confirmation"),i18n("Delete")); 2637 i18n("KO/Pi Confirmation"),i18n("Delete"));
2636} 2638}
2637 2639
2638 2640
2639void CalendarView::edit_cut() 2641void CalendarView::edit_cut()
2640{ 2642{
2641 Event *anEvent=0; 2643 Event *anEvent=0;
2642 2644
2643 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2645 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2644 2646
2645 if (mViewManager->currentView()->isEventView()) { 2647 if (mViewManager->currentView()->isEventView()) {
2646 if ( incidence && incidence->typeID() == eventID ) { 2648 if ( incidence && incidence->typeID() == eventID ) {
2647 anEvent = static_cast<Event *>(incidence); 2649 anEvent = static_cast<Event *>(incidence);
2648 } 2650 }
2649 } 2651 }
2650 2652
2651 if (!anEvent) { 2653 if (!anEvent) {
2652 KNotifyClient::beep(); 2654 KNotifyClient::beep();
2653 return; 2655 return;
2654 } 2656 }
2655 DndFactory factory( mCalendar ); 2657 DndFactory factory( mCalendar );
2656 factory.cutIncidence(anEvent); 2658 factory.cutIncidence(anEvent);
2657 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2659 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2658} 2660}
2659 2661
2660void CalendarView::edit_copy() 2662void CalendarView::edit_copy()
2661{ 2663{
2662 Event *anEvent=0; 2664 Event *anEvent=0;
2663 2665
2664 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2666 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2665 2667
2666 if (mViewManager->currentView()->isEventView()) { 2668 if (mViewManager->currentView()->isEventView()) {
2667 if ( incidence && incidence->typeID() == eventID ) { 2669 if ( incidence && incidence->typeID() == eventID ) {
2668 anEvent = static_cast<Event *>(incidence); 2670 anEvent = static_cast<Event *>(incidence);
2669 } 2671 }
2670 } 2672 }
2671 2673
2672 if (!anEvent) { 2674 if (!anEvent) {
2673 KNotifyClient::beep(); 2675 KNotifyClient::beep();
2674 return; 2676 return;
2675 } 2677 }
2676 DndFactory factory( mCalendar ); 2678 DndFactory factory( mCalendar );
2677 factory.copyIncidence(anEvent); 2679 factory.copyIncidence(anEvent);
2678} 2680}
2679 2681
2680void CalendarView::edit_paste() 2682void CalendarView::edit_paste()
2681{ 2683{
2682 QDate date = mNavigator->selectedDates().first(); 2684 QDate date = mNavigator->selectedDates().first();
2683 2685
2684 DndFactory factory( mCalendar ); 2686 DndFactory factory( mCalendar );
2685 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2687 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2686 2688
2687 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2689 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2688} 2690}
2689void CalendarView::edit_global_options() 2691void CalendarView::edit_global_options()
2690{ 2692{
2691 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2693 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2692 emit save(); 2694 emit save();
2693 emit saveStopTimer(); 2695 emit saveStopTimer();
2694 mDialogManager->showGlobalOptionsDialog(); 2696 mDialogManager->showGlobalOptionsDialog();
2695 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2697 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2696 emit saveStopTimer(); 2698 emit saveStopTimer();
2697 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!"), 2699 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!"),
2698 i18n("Timezone settings"),i18n("Reload"))) { 2700 i18n("Timezone settings"),i18n("Reload"))) {
2699 qDebug("KO: TZ reload cancelled "); 2701 qDebug("KO: TZ reload cancelled ");
2700 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2702 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2701 return; 2703 return;
2702 } 2704 }
2703 qDebug("KO: Timezone change "); 2705 qDebug("KO: Timezone change ");
2704 loadCalendars(); 2706 loadCalendars();
2705 setModified(true); 2707 setModified(true);
2706 } 2708 }
2707 else 2709 else
2708 qDebug("KO: No tz change "); 2710 qDebug("KO: No tz change ");
2709} 2711}
2710void CalendarView::edit_options() 2712void CalendarView::edit_options()
2711{ 2713{
2712 mDialogManager->showOptionsDialog(); 2714 mDialogManager->showOptionsDialog();
2713} 2715}
2714 2716
2715 2717
2716void CalendarView::slotSelectPickerDate( QDate d) 2718void CalendarView::slotSelectPickerDate( QDate d)
2717{ 2719{
2718 mDateFrame->hide(); 2720 mDateFrame->hide();
2719 if ( mDatePickerMode == 1 ) { 2721 if ( mDatePickerMode == 1 ) {
2720 mNavigator->slotDaySelect( d ); 2722 mNavigator->slotDaySelect( d );
2721 } else if ( mDatePickerMode == 2 ) { 2723 } else if ( mDatePickerMode == 2 ) {
2722 if ( mMoveIncidence->typeID() == todoID ) { 2724 if ( mMoveIncidence->typeID() == todoID ) {
2723 Todo * to = (Todo *) mMoveIncidence; 2725 Todo * to = (Todo *) mMoveIncidence;
2724 QTime tim; 2726 QTime tim;
2725 int len = 0; 2727 int len = 0;
2726 if ( to->hasStartDate() && to->hasDueDate() ) 2728 if ( to->hasStartDate() && to->hasDueDate() )
2727 len = to->dtStart().secsTo( to->dtDue()); 2729 len = to->dtStart().secsTo( to->dtDue());
2728 if ( to->hasDueDate() ) 2730 if ( to->hasDueDate() )
2729 tim = to->dtDue().time(); 2731 tim = to->dtDue().time();
2730 else { 2732 else {
2731 tim = QTime ( 0,0,0 ); 2733 tim = QTime ( 0,0,0 );
2732 to->setFloats( true ); 2734 to->setFloats( true );
2733 to->setHasDueDate( true ); 2735 to->setHasDueDate( true );
2734 } 2736 }
2735 QDateTime dt ( d,tim ); 2737 QDateTime dt ( d,tim );
2736 to->setDtDue( dt ); 2738 to->setDtDue( dt );
2737 2739
2738 if ( to->hasStartDate() ) { 2740 if ( to->hasStartDate() ) {
2739 if ( len>0 ) 2741 if ( len>0 )
2740 to->setDtStart(to->dtDue().addSecs( -len )); 2742 to->setDtStart(to->dtDue().addSecs( -len ));
2741 else 2743 else
2742 if (to->dtStart() > to->dtDue() ) 2744 if (to->dtStart() > to->dtDue() )
2743 to->setDtStart(to->dtDue().addDays( -3 )); 2745 to->setDtStart(to->dtDue().addDays( -3 ));
2744 } 2746 }
2745 2747
2746 todoChanged( to ); 2748 todoChanged( to );
2747 } else { 2749 } else {
2748 if ( mMoveIncidence->doesRecur() ) { 2750 if ( mMoveIncidence->doesRecur() ) {
2749#if 0 2751#if 0
2750 // PENDING implement this 2752 // PENDING implement this
2751 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2753 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2752 mCalendar()->addIncidence( newInc ); 2754 mCalendar()->addIncidence( newInc );
2753 if ( mMoveIncidence->typeID() == todoID ) 2755 if ( mMoveIncidence->typeID() == todoID )
2754 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2756 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2755 else 2757 else
2756 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2758 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2757 mMoveIncidence = newInc; 2759 mMoveIncidence = newInc;
2758 2760
2759#endif 2761#endif
2760 } 2762 }
2761 QTime tim = mMoveIncidence->dtStart().time(); 2763 QTime tim = mMoveIncidence->dtStart().time();
2762 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2764 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2763 QDateTime dt ( d,tim ); 2765 QDateTime dt ( d,tim );
2764 mMoveIncidence->setDtStart( dt ); 2766 mMoveIncidence->setDtStart( dt );
2765 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2767 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2766 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2768 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2767 } 2769 }
2768 2770
2769 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2771 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2770 } 2772 }
2771} 2773}
2772 2774
2773void CalendarView::removeCategories() 2775void CalendarView::removeCategories()
2774{ 2776{
2775 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2777 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2776 QStringList catList = KOPrefs::instance()->mCustomCategories; 2778 QStringList catList = KOPrefs::instance()->mCustomCategories;
2777 QStringList catIncList; 2779 QStringList catIncList;
2778 QStringList newCatList; 2780 QStringList newCatList;
2779 Incidence* inc = incList.first(); 2781 Incidence* inc = incList.first();
2780 int i; 2782 int i;
2781 int count = 0; 2783 int count = 0;
2782 while ( inc ) { 2784 while ( inc ) {
2783 newCatList.clear(); 2785 newCatList.clear();
2784 catIncList = inc->categories() ; 2786 catIncList = inc->categories() ;
2785 for( i = 0; i< catIncList.count(); ++i ) { 2787 for( i = 0; i< catIncList.count(); ++i ) {
2786 if ( catList.contains (catIncList[i])) 2788 if ( catList.contains (catIncList[i]))
2787 newCatList.append( catIncList[i] ); 2789 newCatList.append( catIncList[i] );
2788 } 2790 }
2789 newCatList.sort(); 2791 newCatList.sort();
2790 inc->setCategories( newCatList.join(",") ); 2792 inc->setCategories( newCatList.join(",") );
2791 inc = incList.next(); 2793 inc = incList.next();
2792 } 2794 }
2793} 2795}
2794 2796
2795int CalendarView::addCategories() 2797int CalendarView::addCategories()
2796{ 2798{
2797 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2799 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2798 QStringList catList = KOPrefs::instance()->mCustomCategories; 2800 QStringList catList = KOPrefs::instance()->mCustomCategories;
2799 QStringList catIncList; 2801 QStringList catIncList;
2800 Incidence* inc = incList.first(); 2802 Incidence* inc = incList.first();
2801 int i; 2803 int i;
2802 int count = 0; 2804 int count = 0;
2803 while ( inc ) { 2805 while ( inc ) {
2804 catIncList = inc->categories() ; 2806 catIncList = inc->categories() ;
2805 for( i = 0; i< catIncList.count(); ++i ) { 2807 for( i = 0; i< catIncList.count(); ++i ) {
2806 if ( !catList.contains (catIncList[i])) { 2808 if ( !catList.contains (catIncList[i])) {
2807 catList.append( catIncList[i] ); 2809 catList.append( catIncList[i] );
2808 //qDebug("add cat %s ", catIncList[i].latin1()); 2810 //qDebug("add cat %s ", catIncList[i].latin1());
2809 ++count; 2811 ++count;
2810 } 2812 }
2811 } 2813 }
2812 inc = incList.next(); 2814 inc = incList.next();
2813 } 2815 }
2814 catList.sort(); 2816 catList.sort();
2815 KOPrefs::instance()->mCustomCategories = catList; 2817 KOPrefs::instance()->mCustomCategories = catList;
2816 return count; 2818 return count;
2817} 2819}
2818 2820
2819void CalendarView::manageCategories() 2821void CalendarView::manageCategories()
2820{ 2822{
2821 KOCatPrefs* cp = new KOCatPrefs(); 2823 KOCatPrefs* cp = new KOCatPrefs();
2822 cp->show(); 2824 cp->show();
2823 int w =cp->sizeHint().width() ; 2825 int w =cp->sizeHint().width() ;
2824 int h = cp->sizeHint().height() ; 2826 int h = cp->sizeHint().height() ;
2825 int dw = QApplication::desktop()->width(); 2827 int dw = QApplication::desktop()->width();
2826 int dh = QApplication::desktop()->height(); 2828 int dh = QApplication::desktop()->height();
2827 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2829 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2828 if ( !cp->exec() ) { 2830 if ( !cp->exec() ) {
2829 delete cp; 2831 delete cp;
2830 return; 2832 return;
2831 } 2833 }
2832 int count = 0; 2834 int count = 0;
2833 if ( cp->addCat() ) { 2835 if ( cp->addCat() ) {
2834 count = addCategories(); 2836 count = addCategories();
2835 if ( count ) { 2837 if ( count ) {
2836 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2838 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2837 writeSettings(); 2839 writeSettings();
2838 } else 2840 } else
2839 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2841 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2840 } else { 2842 } else {
2841 removeCategories(); 2843 removeCategories();
2842 updateView(); 2844 updateView();
2843 } 2845 }
2844 delete cp; 2846 delete cp;
2845} 2847}
2846 2848
2847void CalendarView::beamIncidence(Incidence * Inc) 2849void CalendarView::beamIncidence(Incidence * Inc)
2848{ 2850{
2849 QPtrList<Incidence> delSel ; 2851 QPtrList<Incidence> delSel ;
2850 delSel.append(Inc); 2852 delSel.append(Inc);
2851 beamIncidenceList( delSel ); 2853 beamIncidenceList( delSel );
2852} 2854}
2853void CalendarView::beamCalendar() 2855void CalendarView::beamCalendar()
2854{ 2856{
2855 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2857 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2856 //qDebug("beamCalendar() "); 2858 //qDebug("beamCalendar() ");
2857 beamIncidenceList( delSel ); 2859 beamIncidenceList( delSel );
2858} 2860}
2859void CalendarView::beamFilteredCalendar() 2861void CalendarView::beamFilteredCalendar()
2860{ 2862{
2861 QPtrList<Incidence> delSel = mCalendar->incidences(); 2863 QPtrList<Incidence> delSel = mCalendar->incidences();
2862 //qDebug("beamFilteredCalendar() "); 2864 //qDebug("beamFilteredCalendar() ");
2863 beamIncidenceList( delSel ); 2865 beamIncidenceList( delSel );
2864} 2866}
2865void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2867void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2866{ 2868{
2867 2869
2868 KOBeamPrefs beamDialog; 2870 KOBeamPrefs beamDialog;
2869 if ( beamDialog.exec () == QDialog::Rejected ) 2871 if ( beamDialog.exec () == QDialog::Rejected )
2870 return; 2872 return;
2871#ifdef DESKTOP_VERSION 2873#ifdef DESKTOP_VERSION
2872 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2874 QString fn = locateLocal( "tmp", "kopibeamfile" );
2873#else 2875#else
2874 QString fn = "/tmp/kopibeamfile"; 2876 QString fn = "/tmp/kopibeamfile";
2875#endif 2877#endif
2876 QString mes; 2878 QString mes;
2877 bool createbup = true; 2879 bool createbup = true;
2878 if ( createbup ) { 2880 if ( createbup ) {
2879 QString description = "\n"; 2881 QString description = "\n";
2880 CalendarLocal* cal = new CalendarLocal(); 2882 CalendarLocal* cal = new CalendarLocal();
2881 if ( beamDialog.beamLocal() ) 2883 if ( beamDialog.beamLocal() )
2882 cal->setLocalTime(); 2884 cal->setLocalTime();
2883 else 2885 else
2884 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2886 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2885 Incidence *incidence = delSel.first(); 2887 Incidence *incidence = delSel.first();
2886 bool addText = false; 2888 bool addText = false;
2887 if ( delSel.count() < 10 ) 2889 if ( delSel.count() < 10 )
2888 addText = true; 2890 addText = true;
2889 else { 2891 else {
2890 description.sprintf(i18n(" %d items?"),delSel.count() ); 2892 description.sprintf(i18n(" %d items?"),delSel.count() );
2891 } 2893 }
2892 while ( incidence ) { 2894 while ( incidence ) {
2893 Incidence *in = incidence->clone(); 2895 Incidence *in = incidence->clone();
2894 if ( ! in->summary().isEmpty() ) { 2896 if ( ! in->summary().isEmpty() ) {
2895 in->setDescription(""); 2897 in->setDescription("");
2896 } else { 2898 } else {
2897 in->setSummary( in->description().left(20)); 2899 in->setSummary( in->description().left(20));
2898 in->setDescription(""); 2900 in->setDescription("");
2899 } 2901 }
2900 if ( addText ) 2902 if ( addText )
2901 description += in->summary() + "\n"; 2903 description += in->summary() + "\n";
2902 cal->addIncidence( in ); 2904 cal->addIncidence( in );
2903 incidence = delSel.next(); 2905 incidence = delSel.next();
2904 } 2906 }
2905 if ( beamDialog.beamVcal() ) { 2907 if ( beamDialog.beamVcal() ) {
2906 fn += ".vcs"; 2908 fn += ".vcs";
2907 FileStorage storage( cal, fn, new VCalFormat ); 2909 FileStorage storage( cal, fn, new VCalFormat );
2908 storage.save(); 2910 storage.save();
2909 } else { 2911 } else {
2910 fn += ".ics"; 2912 fn += ".ics";
2911 FileStorage storage( cal, fn, new ICalFormat( ) ); 2913 FileStorage storage( cal, fn, new ICalFormat( ) );
2912 storage.save(); 2914 storage.save();
2913 } 2915 }
2914 delete cal; 2916 delete cal;
2915 mes = i18n("KO/Pi: Ready for beaming"); 2917 mes = i18n("KO/Pi: Ready for beaming");
2916 topLevelWidget()->setCaption(mes); 2918 topLevelWidget()->setCaption(mes);
2917 KApplication::convert2latin1( fn ); 2919 KApplication::convert2latin1( fn );
2918#ifndef DESKTOP_VERSION 2920#ifndef DESKTOP_VERSION
2919 Ir *ir = new Ir( this ); 2921 Ir *ir = new Ir( this );
2920 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2922 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2921 ir->send( fn, description, "text/x-vCalendar" ); 2923 ir->send( fn, description, "text/x-vCalendar" );
2922#endif 2924#endif
2923 } 2925 }
2924} 2926}
2925void CalendarView::beamDone( Ir *ir ) 2927void CalendarView::beamDone( Ir *ir )
2926{ 2928{
2927#ifndef DESKTOP_VERSION 2929#ifndef DESKTOP_VERSION
2928 delete ir; 2930 delete ir;
2929#endif 2931#endif
2930 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2932 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2931 topLevelWidget()->raise(); 2933 topLevelWidget()->raise();
2932} 2934}
2933 2935
2934void CalendarView::moveIncidence(Incidence * inc ) 2936void CalendarView::moveIncidence(Incidence * inc )
2935{ 2937{
2936 if ( !inc ) return; 2938 if ( !inc ) return;
2937 showDatePickerPopup(); 2939 showDatePickerPopup();
2938 mDatePickerMode = 2; 2940 mDatePickerMode = 2;
2939 mMoveIncidence = inc ; 2941 mMoveIncidence = inc ;
2940 QDate da; 2942 QDate da;
2941 if ( mMoveIncidence->typeID() == todoID ) { 2943 if ( mMoveIncidence->typeID() == todoID ) {
2942 Todo * to = (Todo *) mMoveIncidence; 2944 Todo * to = (Todo *) mMoveIncidence;
2943 if ( to->hasDueDate() ) 2945 if ( to->hasDueDate() )
2944 da = to->dtDue().date(); 2946 da = to->dtDue().date();
2945 else 2947 else
2946 da = QDate::currentDate(); 2948 da = QDate::currentDate();
2947 } else { 2949 } else {
2948 da = mMoveIncidence->dtStart().date(); 2950 da = mMoveIncidence->dtStart().date();
2949 } 2951 }
2950 //PENDING set date for recurring incidence to date of recurrence 2952 //PENDING set date for recurring incidence to date of recurrence
2951 //mMoveIncidenceOldDate; 2953 //mMoveIncidenceOldDate;
2952 mDatePicker->setDate( da ); 2954 mDatePicker->setDate( da );
2953} 2955}
2954void CalendarView::showDatePickerPopup() 2956void CalendarView::showDatePickerPopup()
2955{ 2957{
2956 if ( mDateFrame->isVisible() ) 2958 if ( mDateFrame->isVisible() )
2957 mDateFrame->hide(); 2959 mDateFrame->hide();
2958 else { 2960 else {
2959 int offX = 0, offY = 0; 2961 int offX = 0, offY = 0;
2960#ifdef DESKTOP_VERSION 2962#ifdef DESKTOP_VERSION
2961 int w =mDatePicker->sizeHint().width() ; 2963 int w =mDatePicker->sizeHint().width() ;
2962 int h = mDatePicker->sizeHint().height() ; 2964 int h = mDatePicker->sizeHint().height() ;
2963 int dw = topLevelWidget()->width(); 2965 int dw = topLevelWidget()->width();
2964 int dh = topLevelWidget()->height(); 2966 int dh = topLevelWidget()->height();
2965 offX = topLevelWidget()->x(); 2967 offX = topLevelWidget()->x();
2966 offY = topLevelWidget()->y(); 2968 offY = topLevelWidget()->y();
2967#else 2969#else
2968 int w =mDatePicker->sizeHint().width() ; 2970 int w =mDatePicker->sizeHint().width() ;
2969 int h = mDatePicker->sizeHint().height() ; 2971 int h = mDatePicker->sizeHint().height() ;
2970 int dw = QApplication::desktop()->width(); 2972 int dw = QApplication::desktop()->width();
2971 int dh = QApplication::desktop()->height(); 2973 int dh = QApplication::desktop()->height();
2972#endif 2974#endif
2973 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2975 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2974 mDateFrame->show(); 2976 mDateFrame->show();
2975 } 2977 }
2976} 2978}
2977void CalendarView::showDatePicker( ) 2979void CalendarView::showDatePicker( )
2978{ 2980{
2979 showDatePickerPopup(); 2981 showDatePickerPopup();
2980 mDatePickerMode = 1; 2982 mDatePickerMode = 1;
2981 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2983 mDatePicker->setDate( mNavigator->selectedDates().first() );
2982} 2984}
2983 2985
2984void CalendarView::showEventEditor() 2986void CalendarView::showEventEditor()
2985{ 2987{
2986#ifdef DESKTOP_VERSION 2988#ifdef DESKTOP_VERSION
2987 int x,y,w,h; 2989 int x,y,w,h;
2988 x = mEventEditor->geometry().x(); 2990 x = mEventEditor->geometry().x();
2989 y = mEventEditor->geometry().y(); 2991 y = mEventEditor->geometry().y();
2990 w = mEventEditor->width(); 2992 w = mEventEditor->width();
2991 h = mEventEditor->height(); 2993 h = mEventEditor->height();
2992 mEventEditor->show(); 2994 mEventEditor->show();
2993 mEventEditor->setGeometry(x,y,w,h); 2995 mEventEditor->setGeometry(x,y,w,h);
2994#else 2996#else
2995 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2997 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2996 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2998 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2997 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2999 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2998 qApp->processEvents(); 3000 qApp->processEvents();
2999 delete mEventEditor; 3001 delete mEventEditor;
3000 mEventEditor = mDialogManager->getEventEditor(); 3002 mEventEditor = mDialogManager->getEventEditor();
3001 topLevelWidget()->setCaption( i18n("") ); 3003 topLevelWidget()->setCaption( i18n("") );
3002 } 3004 }
3003 mEventEditor->showMaximized(); 3005 mEventEditor->showMaximized();
3004#endif 3006#endif
3005} 3007}
3006void CalendarView::showTodoEditor() 3008void CalendarView::showTodoEditor()
3007{ 3009{
3008#ifdef DESKTOP_VERSION 3010#ifdef DESKTOP_VERSION
3009 int x,y,w,h; 3011 int x,y,w,h;
3010 x = mTodoEditor->geometry().x(); 3012 x = mTodoEditor->geometry().x();
3011 y = mTodoEditor->geometry().y(); 3013 y = mTodoEditor->geometry().y();
3012 w = mTodoEditor->width(); 3014 w = mTodoEditor->width();
3013 h = mTodoEditor->height(); 3015 h = mTodoEditor->height();
3014 mTodoEditor->show(); 3016 mTodoEditor->show();
3015 mTodoEditor->setGeometry(x,y,w,h); 3017 mTodoEditor->setGeometry(x,y,w,h);
3016#else 3018#else
3017 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3019 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3018 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3020 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3019 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3021 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3020 qApp->processEvents(); 3022 qApp->processEvents();
3021 delete mTodoEditor; 3023 delete mTodoEditor;
3022 mTodoEditor = mDialogManager->getTodoEditor(); 3024 mTodoEditor = mDialogManager->getTodoEditor();
3023 topLevelWidget()->setCaption( i18n("") ); 3025 topLevelWidget()->setCaption( i18n("") );
3024 } 3026 }
3025 mTodoEditor->showMaximized(); 3027 mTodoEditor->showMaximized();
3026#endif 3028#endif
3027} 3029}
3028 3030
3029void CalendarView::cloneIncidence() 3031void CalendarView::cloneIncidence()
3030{ 3032{
3031 Incidence *incidence = currentSelection(); 3033 Incidence *incidence = currentSelection();
3032 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3034 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3033 if ( incidence ) { 3035 if ( incidence ) {
3034 cloneIncidence(incidence); 3036 cloneIncidence(incidence);
3035 } 3037 }
3036} 3038}
3037void CalendarView::moveIncidence() 3039void CalendarView::moveIncidence()
3038{ 3040{
3039 Incidence *incidence = currentSelection(); 3041 Incidence *incidence = currentSelection();
3040 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3042 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3041 if ( incidence ) { 3043 if ( incidence ) {
3042 moveIncidence(incidence); 3044 moveIncidence(incidence);
3043 } 3045 }
3044} 3046}
3045void CalendarView::beamIncidence() 3047void CalendarView::beamIncidence()
3046{ 3048{
3047 Incidence *incidence = currentSelection(); 3049 Incidence *incidence = currentSelection();
3048 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3050 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3049 if ( incidence ) { 3051 if ( incidence ) {
3050 beamIncidence(incidence); 3052 beamIncidence(incidence);
3051 } 3053 }
3052} 3054}
3053void CalendarView::toggleCancelIncidence() 3055void CalendarView::toggleCancelIncidence()
3054{ 3056{
3055 Incidence *incidence = currentSelection(); 3057 Incidence *incidence = currentSelection();
3056 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3058 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3057 if ( incidence ) { 3059 if ( incidence ) {
3058 cancelIncidence(incidence); 3060 cancelIncidence(incidence);
3059 } 3061 }
3060} 3062}
3061 3063
3062 3064
3063void CalendarView::cancelIncidence(Incidence * inc ) 3065void CalendarView::cancelIncidence(Incidence * inc )
3064{ 3066{
3065 inc->setCancelled( ! inc->cancelled() ); 3067 inc->setCancelled( ! inc->cancelled() );
3066 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3068 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3067 updateView(); 3069 updateView();
3068} 3070}
3069void CalendarView::cloneIncidence(Incidence * orgInc ) 3071void CalendarView::cloneIncidence(Incidence * orgInc )
3070{ 3072{
3071 Incidence * newInc = orgInc->clone(); 3073 Incidence * newInc = orgInc->clone();
3072 newInc->recreate(); 3074 newInc->recreate();
3073 3075
3074 if ( newInc->typeID() == todoID ) { 3076 if ( newInc->typeID() == todoID ) {
3075 Todo* t = (Todo*) newInc; 3077 Todo* t = (Todo*) newInc;
3076 bool cloneSub = false; 3078 bool cloneSub = false;
3077 if ( orgInc->relations().count() ) { 3079 if ( orgInc->relations().count() ) {
3078 int result = KMessageBox::warningYesNoCancel(this, 3080 int result = KMessageBox::warningYesNoCancel(this,
3079 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 ) ), 3081 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 ) ),
3080 i18n("Todo has subtodos"), 3082 i18n("Todo has subtodos"),
3081 i18n("Yes"), 3083 i18n("Yes"),
3082 i18n("No")); 3084 i18n("No"));
3083 3085
3084 if ( result == KMessageBox::Cancel ) { 3086 if ( result == KMessageBox::Cancel ) {
3085 delete t; 3087 delete t;
3086 return; 3088 return;
3087 } 3089 }
3088 if (result == KMessageBox::Yes) cloneSub = true; 3090 if (result == KMessageBox::Yes) cloneSub = true;
3089 } 3091 }
3090 showTodoEditor(); 3092 showTodoEditor();
3091 mTodoEditor->editTodo( t ); 3093 mTodoEditor->editTodo( t );
3092 if ( mTodoEditor->exec() ) { 3094 if ( mTodoEditor->exec() ) {
3093 if ( cloneSub ) { 3095 if ( cloneSub ) {
3094 orgInc->cloneRelations( t ); 3096 orgInc->cloneRelations( t );
3095 mCalendar->addIncidenceBranch( t ); 3097 mCalendar->addIncidenceBranch( t );
3096 updateView(); 3098 updateView();
3097 3099
3098 } else { 3100 } else {
3099 mCalendar->addTodo( t ); 3101 mCalendar->addTodo( t );
3100 updateView(); 3102 updateView();
3101 } 3103 }
3102 } else { 3104 } else {
3103 delete t; 3105 delete t;
3104 } 3106 }
3105 } 3107 }
3106 else { 3108 else {
3107 Event* e = (Event*) newInc; 3109 Event* e = (Event*) newInc;
3108 showEventEditor(); 3110 showEventEditor();
3109 mEventEditor->editEvent( e ); 3111 mEventEditor->editEvent( e );
3110 if ( mEventEditor->exec() ) { 3112 if ( mEventEditor->exec() ) {
3111 mCalendar->addEvent( e ); 3113 mCalendar->addEvent( e );
3112 updateView(); 3114 updateView();
3113 } else { 3115 } else {
3114 delete e; 3116 delete e;
3115 } 3117 }
3116 } 3118 }
3117 setActiveWindow(); 3119 setActiveWindow();
3118} 3120}
3119 3121
3120void CalendarView::newEvent() 3122void CalendarView::newEvent()
3121{ 3123{
3122 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3124 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3123 KOAgendaView *aView = mViewManager->agendaView(); 3125 KOAgendaView *aView = mViewManager->agendaView();
3124 if (aView) { 3126 if (aView) {
3125 if (aView->selectionStart().isValid()) { 3127 if (aView->selectionStart().isValid()) {
3126 if (aView->selectedIsAllDay()) { 3128 if (aView->selectedIsAllDay()) {
3127 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3129 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3128 } else { 3130 } else {
3129 newEvent(aView->selectionStart(),aView->selectionEnd()); 3131 newEvent(aView->selectionStart(),aView->selectionEnd());
3130 } 3132 }
3131 return; 3133 return;
3132 } 3134 }
3133 } 3135 }
3134 3136
3135 QDate date = mNavigator->selectedDates().first(); 3137 QDate date = mNavigator->selectedDates().first();
3136 QDateTime current = QDateTime::currentDateTime(); 3138 QDateTime current = QDateTime::currentDateTime();
3137 if ( date <= current.date() ) { 3139 if ( date <= current.date() ) {
3138 int hour = current.time().hour() +1; 3140 int hour = current.time().hour() +1;
3139 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3141 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3140 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3142 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3141 } else 3143 } else
3142 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3144 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3143 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3145 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3144 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3146 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3145} 3147}
3146 3148
3147void CalendarView::newEvent(QDateTime fh) 3149void CalendarView::newEvent(QDateTime fh)
3148{ 3150{
3149 newEvent(fh, 3151 newEvent(fh,
3150 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3152 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3151} 3153}
3152 3154
3153void CalendarView::newEvent(QDate dt) 3155void CalendarView::newEvent(QDate dt)
3154{ 3156{
3155 newEvent(QDateTime(dt, QTime(0,0,0)), 3157 newEvent(QDateTime(dt, QTime(0,0,0)),
3156 QDateTime(dt, QTime(0,0,0)), true); 3158 QDateTime(dt, QTime(0,0,0)), true);
3157} 3159}
3158void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3160void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3159{ 3161{
3160 newEvent(fromHint, toHint, false); 3162 newEvent(fromHint, toHint, false);
3161} 3163}
3162void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3164void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3163{ 3165{
3164 3166
3165 showEventEditor(); 3167 showEventEditor();
3166 mEventEditor->newEvent(fromHint,toHint,allDay); 3168 mEventEditor->newEvent(fromHint,toHint,allDay);
3167 if ( mFilterView->filtersEnabled() ) { 3169 if ( mFilterView->filtersEnabled() ) {
3168 CalFilter *filter = mFilterView->selectedFilter(); 3170 CalFilter *filter = mFilterView->selectedFilter();
3169 if (filter && filter->showCategories()) { 3171 if (filter && filter->showCategories()) {
3170 mEventEditor->setCategories(filter->categoryList().join(",") ); 3172 mEventEditor->setCategories(filter->categoryList().join(",") );
3171 } 3173 }
3172 if ( filter ) 3174 if ( filter )
3173 mEventEditor->setSecrecy( filter->getSecrecy() ); 3175 mEventEditor->setSecrecy( filter->getSecrecy() );
3174 } 3176 }
3175 mEventEditor->exec(); 3177 mEventEditor->exec();
3176 setActiveWindow(); 3178 setActiveWindow();
3177} 3179}
3178void CalendarView::todoAdded(Todo * t) 3180void CalendarView::todoAdded(Todo * t)
3179{ 3181{
3180 3182
3181 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3183 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3182 updateTodoViews(); 3184 updateTodoViews();
3183} 3185}
3184void CalendarView::todoChanged(Todo * t) 3186void CalendarView::todoChanged(Todo * t)
3185{ 3187{
3186 emit todoModified( t, 4 ); 3188 emit todoModified( t, 4 );
3187 // updateTodoViews(); 3189 // updateTodoViews();
3188} 3190}
3189void CalendarView::todoToBeDeleted(Todo *) 3191void CalendarView::todoToBeDeleted(Todo *)
3190{ 3192{
3191 //qDebug("todoToBeDeleted(Todo *) "); 3193 //qDebug("todoToBeDeleted(Todo *) ");
3192 updateTodoViews(); 3194 updateTodoViews();
3193} 3195}
3194void CalendarView::todoDeleted() 3196void CalendarView::todoDeleted()
3195{ 3197{
3196 //qDebug(" todoDeleted()"); 3198 //qDebug(" todoDeleted()");
3197 updateTodoViews(); 3199 updateTodoViews();
3198} 3200}
3199 3201
3200 3202
3201void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3203void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3202{ 3204{
3203 showTodoEditor(); 3205 showTodoEditor();
3204 mTodoEditor->newTodo(dt,0,allday); 3206 mTodoEditor->newTodo(dt,0,allday);
3205 if ( mFilterView->filtersEnabled() ) { 3207 if ( mFilterView->filtersEnabled() ) {
3206 CalFilter *filter = mFilterView->selectedFilter(); 3208 CalFilter *filter = mFilterView->selectedFilter();
3207 if (filter && filter->showCategories()) { 3209 if (filter && filter->showCategories()) {
3208 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3210 mTodoEditor->setCategories(filter->categoryList().join(",") );
3209 } 3211 }
3210 if ( filter ) 3212 if ( filter )
3211 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3213 mTodoEditor->setSecrecy( filter->getSecrecy() );
3212 } 3214 }
3213 mTodoEditor->exec(); 3215 mTodoEditor->exec();
3214 setActiveWindow(); 3216 setActiveWindow();
3215} 3217}
3216 3218
3217void CalendarView::newTodo() 3219void CalendarView::newTodo()
3218{ 3220{
3219 newTodoDateTime( QDateTime(),true ); 3221 newTodoDateTime( QDateTime(),true );
3220} 3222}
3221 3223
3222void CalendarView::newSubTodo() 3224void CalendarView::newSubTodo()
3223{ 3225{
3224 Todo *todo = selectedTodo(); 3226 Todo *todo = selectedTodo();
3225 if ( todo ) newSubTodo( todo ); 3227 if ( todo ) newSubTodo( todo );
3226} 3228}
3227 3229
3228void CalendarView::newSubTodo(Todo *parentEvent) 3230void CalendarView::newSubTodo(Todo *parentEvent)
3229{ 3231{
3230 3232
3231 showTodoEditor(); 3233 showTodoEditor();
3232 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3234 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3233 mTodoEditor->exec(); 3235 mTodoEditor->exec();
3234 setActiveWindow(); 3236 setActiveWindow();
3235} 3237}
3236 3238
3237void CalendarView::newFloatingEvent() 3239void CalendarView::newFloatingEvent()
3238{ 3240{
3239 DateList tmpList = mNavigator->selectedDates(); 3241 DateList tmpList = mNavigator->selectedDates();
3240 QDate date = tmpList.first(); 3242 QDate date = tmpList.first();
3241 3243
3242 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3244 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3243 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3245 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3244} 3246}
3245 3247
3246 3248
3247void CalendarView::editEvent( Event *event ) 3249void CalendarView::editEvent( Event *event )
3248{ 3250{
3249 3251
3250 if ( !event ) return; 3252 if ( !event ) return;
3251 if ( event->isReadOnly() ) { 3253 if ( event->isReadOnly() ) {
3252 showEvent( event ); 3254 showEvent( event );
3253 return; 3255 return;
3254 } 3256 }
3255 showEventEditor(); 3257 showEventEditor();
3256 mEventEditor->editEvent( event , mFlagEditDescription); 3258 mEventEditor->editEvent( event , mFlagEditDescription);
3257 mEventEditor->exec(); 3259 mEventEditor->exec();
3258 setActiveWindow(); 3260 setActiveWindow();
3259 3261
3260} 3262}
3261void CalendarView::editJournal( Journal *jour ) 3263void CalendarView::editJournal( Journal *jour )
3262{ 3264{
3263 if ( !jour ) return; 3265 if ( !jour ) return;
3264 mDialogManager->hideSearchDialog(); 3266 mDialogManager->hideSearchDialog();
3265 mViewManager->showJournalView(); 3267 mViewManager->showJournalView();
3266 mNavigator->slotDaySelect( jour->dtStart().date() ); 3268 mNavigator->slotDaySelect( jour->dtStart().date() );
3267} 3269}
3268void CalendarView::editTodo( Todo *todo ) 3270void CalendarView::editTodo( Todo *todo )
3269{ 3271{
3270 if ( !todo ) return; 3272 if ( !todo ) return;
3271 3273
3272 if ( todo->isReadOnly() ) { 3274 if ( todo->isReadOnly() ) {
3273 showTodo( todo ); 3275 showTodo( todo );
3274 return; 3276 return;
3275 } 3277 }
3276 showTodoEditor(); 3278 showTodoEditor();
3277 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3279 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3278 mTodoEditor->exec(); 3280 mTodoEditor->exec();
3279 setActiveWindow(); 3281 setActiveWindow();
3280 3282
3281} 3283}
3282 3284
3283KOEventViewerDialog* CalendarView::getEventViewerDialog() 3285KOEventViewerDialog* CalendarView::getEventViewerDialog()
3284{ 3286{
3285 if ( !mEventViewerDialog ) { 3287 if ( !mEventViewerDialog ) {
3286 mEventViewerDialog = new KOEventViewerDialog(0); 3288 mEventViewerDialog = new KOEventViewerDialog(0);
3287 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3289 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3288 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3290 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3289 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3291 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3290 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3292 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3291 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3293 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3292 viewManager(), SLOT( showAgendaView( bool ) ) ); 3294 viewManager(), SLOT( showAgendaView( bool ) ) );
3293 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3295 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3294 this, SLOT( slotViewerClosed() ) ); 3296 this, SLOT( slotViewerClosed() ) );
3295 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3297 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3296 this, SLOT( todoChanged(Todo *) ) ); 3298 this, SLOT( todoChanged(Todo *) ) );
3297 mEventViewerDialog->resize( 640, 480 ); 3299 mEventViewerDialog->resize( 640, 480 );
3298 3300
3299 } 3301 }
3300 return mEventViewerDialog; 3302 return mEventViewerDialog;
3301} 3303}
3302void CalendarView::showEvent(Event *event) 3304void CalendarView::showEvent(Event *event)
3303{ 3305{
3304 getEventViewerDialog()->setEvent(event); 3306 getEventViewerDialog()->setEvent(event);
3305 getEventViewerDialog()->showMe(); 3307 getEventViewerDialog()->showMe();
3306} 3308}
3307 3309
3308void CalendarView::showTodo(Todo *event) 3310void CalendarView::showTodo(Todo *event)
3309{ 3311{
3310 getEventViewerDialog()->setTodo(event); 3312 getEventViewerDialog()->setTodo(event);
3311 getEventViewerDialog()->showMe(); 3313 getEventViewerDialog()->showMe();
3312} 3314}
3313void CalendarView::showJournal( Journal *jour ) 3315void CalendarView::showJournal( Journal *jour )
3314{ 3316{
3315 getEventViewerDialog()->setJournal(jour); 3317 getEventViewerDialog()->setJournal(jour);
3316 getEventViewerDialog()->showMe(); 3318 getEventViewerDialog()->showMe();
3317 3319
3318} 3320}
3319// void CalendarView::todoModified (Todo *event, int changed) 3321// void CalendarView::todoModified (Todo *event, int changed)
3320// { 3322// {
3321// // if (mDialogList.find (event) != mDialogList.end ()) { 3323// // if (mDialogList.find (event) != mDialogList.end ()) {
3322// // kdDebug() << "Todo modified and open" << endl; 3324// // kdDebug() << "Todo modified and open" << endl;
3323// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3325// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3324// // temp->modified (changed); 3326// // temp->modified (changed);
3325 3327
3326// // } 3328// // }
3327 3329
3328// mViewManager->updateView(); 3330// mViewManager->updateView();
3329// } 3331// }
3330 3332
3331void CalendarView::appointment_show() 3333void CalendarView::appointment_show()
3332{ 3334{
3333 Event *anEvent = 0; 3335 Event *anEvent = 0;
3334 3336
3335 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3337 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3336 3338
3337 if (mViewManager->currentView()->isEventView()) { 3339 if (mViewManager->currentView()->isEventView()) {
3338 if ( incidence && incidence->typeID() == eventID ) { 3340 if ( incidence && incidence->typeID() == eventID ) {
3339 anEvent = static_cast<Event *>(incidence); 3341 anEvent = static_cast<Event *>(incidence);
3340 } 3342 }
3341 } 3343 }
3342 3344
3343 if (!anEvent) { 3345 if (!anEvent) {
3344 KNotifyClient::beep(); 3346 KNotifyClient::beep();
3345 return; 3347 return;
3346 } 3348 }
3347 3349
3348 showEvent(anEvent); 3350 showEvent(anEvent);
3349} 3351}
3350 3352
3351void CalendarView::appointment_edit() 3353void CalendarView::appointment_edit()
3352{ 3354{
3353 Event *anEvent = 0; 3355 Event *anEvent = 0;
3354 3356
3355 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3357 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3356 3358
3357 if (mViewManager->currentView()->isEventView()) { 3359 if (mViewManager->currentView()->isEventView()) {
3358 if ( incidence && incidence->typeID() == eventID ) { 3360 if ( incidence && incidence->typeID() == eventID ) {
3359 anEvent = static_cast<Event *>(incidence); 3361 anEvent = static_cast<Event *>(incidence);
3360 } 3362 }
3361 } 3363 }
3362 3364
3363 if (!anEvent) { 3365 if (!anEvent) {
3364 KNotifyClient::beep(); 3366 KNotifyClient::beep();
3365 return; 3367 return;
3366 } 3368 }
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index ca8d5f7..3c38f34 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -1,283 +1,289 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// 24//
25// Journal Entry 25// Journal Entry
26 26
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qvbox.h> 29#include <qvbox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qapplication.h> 36#include <qapplication.h>
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <ktextedit.h> 41#include <ktextedit.h>
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include "koprefs.h" 44#include "koprefs.h"
45#include <klineedit.h> 45#include <klineedit.h>
46 46
47#include <libkcal/journal.h> 47#include <libkcal/journal.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51 51
52#include "journalentry.h" 52#include "journalentry.h"
53//#include "journalentry.moc" 53//#include "journalentry.moc"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#endif 56#endif
57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
58 QFrame(parent) 58 QFrame(parent)
59{ 59{
60 heiHint = QApplication::desktop()->height() / 5 ; 60
61 int fac = 5;
62 heiHint = QApplication::desktop()->height();
63 if ( heiHint > 800 )
64 fac += 2;
65 heiHint = heiHint / fac;
66
61 showOnlyMode = false; 67 showOnlyMode = false;
62 mCalendar = calendar; 68 mCalendar = calendar;
63 mJournal = 0; 69 mJournal = 0;
64 visibleMode = true; 70 visibleMode = true;
65 QHBox * vb = new QHBox ( this ); 71 QHBox * vb = new QHBox ( this );
66 QPixmap iconp; 72 QPixmap iconp;
67 73
68 QPushButton * toggleJournal = new QPushButton( vb ); 74 QPushButton * toggleJournal = new QPushButton( vb );
69 iconp = SmallIcon("1updownarrow"); 75 iconp = SmallIcon("1updownarrow");
70 toggleJournal->setPixmap (iconp ) ; 76 toggleJournal->setPixmap (iconp ) ;
71 new QLabel(" "+i18n("Title: "),vb); 77 new QLabel(" "+i18n("Title: "),vb);
72 mTitle = new KLineEdit ( vb ); 78 mTitle = new KLineEdit ( vb );
73 mTitleLabel = new QLabel(i18n("Title"),vb); 79 mTitleLabel = new QLabel(i18n("Title"),vb);
74 mTitleLabel->setMargin(0); 80 mTitleLabel->setMargin(0);
75 mTitleLabel->setAlignment(AlignCenter); 81 mTitleLabel->setAlignment(AlignCenter);
76 QPushButton * loadTemplate = new QPushButton( vb ); 82 QPushButton * loadTemplate = new QPushButton( vb );
77 QPushButton * saveTemplate = new QPushButton( vb ); 83 QPushButton * saveTemplate = new QPushButton( vb );
78 if ( QApplication::desktop()->width() < 321 ) 84 if ( QApplication::desktop()->width() < 321 )
79 iconp = SmallIcon("fileexport16"); 85 iconp = SmallIcon("fileexport16");
80 else 86 else
81 iconp = SmallIcon("fileexport"); 87 iconp = SmallIcon("fileexport");
82 saveTemplate->setPixmap (iconp ) ; 88 saveTemplate->setPixmap (iconp ) ;
83 int size = saveTemplate->sizeHint().height(); 89 int size = saveTemplate->sizeHint().height();
84 if ( QApplication::desktop()->width() < 321 ) 90 if ( QApplication::desktop()->width() < 321 )
85 iconp = SmallIcon("fileimport16"); 91 iconp = SmallIcon("fileimport16");
86 else 92 else
87 iconp = SmallIcon("fileimport"); 93 iconp = SmallIcon("fileimport");
88 loadTemplate->setPixmap (iconp ) ; 94 loadTemplate->setPixmap (iconp ) ;
89 loadTemplate->setFixedSize( size, size ); 95 loadTemplate->setFixedSize( size, size );
90 saveTemplate->setFixedSize( size, size ); 96 saveTemplate->setFixedSize( size, size );
91 toggleJournal->setFixedSize( size , size ); 97 toggleJournal->setFixedSize( size , size );
92 mEditor = new KTextEdit(this); 98 mEditor = new KTextEdit(this);
93#ifndef DESKTOP_VERSION 99#ifndef DESKTOP_VERSION
94 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 100 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
95#endif 101#endif
96 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 102 mEditor->setWordWrap( KTextEdit::WidgetWidth );
97 QBoxLayout *topLayout = new QVBoxLayout(this); 103 QBoxLayout *topLayout = new QVBoxLayout(this);
98 topLayout->addWidget(vb); 104 topLayout->addWidget(vb);
99 topLayout->addWidget(mEditor); 105 topLayout->addWidget(mEditor);
100 mEditor->installEventFilter(this); 106 mEditor->installEventFilter(this);
101 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 107 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
102 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 108 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
103 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 109 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
104} 110}
105 111
106JournalEntry::~JournalEntry() 112JournalEntry::~JournalEntry()
107{ 113{
108 //qDebug("JournalEntry::~JournalEntry() "); 114 //qDebug("JournalEntry::~JournalEntry() ");
109} 115}
110QSize JournalEntry::sizeHint() const 116QSize JournalEntry::sizeHint() const
111{ 117{
112 return QSize ( 240, heiHint ); 118 return QSize ( 240, heiHint );
113} 119}
114void JournalEntry::slotSaveTemplate() 120void JournalEntry::slotSaveTemplate()
115{ 121{
116 QString fileName =locateLocal( "templates", "journals" ); 122 QString fileName =locateLocal( "templates", "journals" );
117 QDir t_dir; 123 QDir t_dir;
118 if ( !t_dir.exists(fileName) ) 124 if ( !t_dir.exists(fileName) )
119 t_dir.mkdir ( fileName ); 125 t_dir.mkdir ( fileName );
120 fileName += "/journal"; 126 fileName += "/journal";
121 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); 127 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
122 if ( fileName.length() == 0 ) 128 if ( fileName.length() == 0 )
123 return; 129 return;
124 130
125 QFile fileIn( fileName ); 131 QFile fileIn( fileName );
126 if (!fileIn.open( IO_WriteOnly ) ) { 132 if (!fileIn.open( IO_WriteOnly ) ) {
127 KMessageBox::error( this, i18n("Error saving template file\n '%1'.") 133 KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
128 .arg( fileName ) ); 134 .arg( fileName ) );
129 return; 135 return;
130 } 136 }
131 // QString text; 137 // QString text;
132 QTextStream tsIn( &fileIn ); 138 QTextStream tsIn( &fileIn );
133 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 139 tsIn.setCodec( QTextCodec::codecForName("utf8") );
134 tsIn << mEditor->text(); 140 tsIn << mEditor->text();
135 fileIn.close(); 141 fileIn.close();
136} 142}
137void JournalEntry::slotLoadTemplate() 143void JournalEntry::slotLoadTemplate()
138{ 144{
139 QString fileName =locateLocal( "templates", "journals" ); 145 QString fileName =locateLocal( "templates", "journals" );
140 QDir t_dir; 146 QDir t_dir;
141 if ( !t_dir.exists(fileName) ) 147 if ( !t_dir.exists(fileName) )
142 t_dir.mkdir ( fileName ); 148 t_dir.mkdir ( fileName );
143 fileName += "/journal"; 149 fileName += "/journal";
144 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); 150 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
145 if ( fileName.length() == 0 ) 151 if ( fileName.length() == 0 )
146 return; 152 return;
147 QFile fileIn( fileName ); 153 QFile fileIn( fileName );
148 if (!fileIn.open( IO_ReadOnly ) ) { 154 if (!fileIn.open( IO_ReadOnly ) ) {
149 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 155 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
150 .arg( fileName ) ); 156 .arg( fileName ) );
151 return; 157 return;
152 } 158 }
153 QTextStream tsIn( &fileIn ); 159 QTextStream tsIn( &fileIn );
154 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 160 tsIn.setCodec( QTextCodec::codecForName("utf8") );
155 QString text = tsIn.read(); 161 QString text = tsIn.read();
156 fileIn.close(); 162 fileIn.close();
157 int line, col; 163 int line, col;
158 mEditor->getCursorPosition (& line, & col ); 164 mEditor->getCursorPosition (& line, & col );
159 mEditor-> insertAt ( text, line, col, true ); 165 mEditor-> insertAt ( text, line, col, true );
160 //mEditor->setIgnoreMark( true ); 166 //mEditor->setIgnoreMark( true );
161} 167}
162void JournalEntry::setDate(const QDate &date) 168void JournalEntry::setDate(const QDate &date)
163{ 169{
164 showOnlyMode = false; 170 showOnlyMode = false;
165 writeJournal(); 171 writeJournal();
166 mDate = date; 172 mDate = date;
167 int id = mCalendar->defaultCalendar(); 173 int id = mCalendar->defaultCalendar();
168 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 174 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
169 mTitleLabel->setText( " (" + calname +")"); 175 mTitleLabel->setText( " (" + calname +")");
170} 176}
171 177
172void JournalEntry::toggleShowJournal() 178void JournalEntry::toggleShowJournal()
173{ 179{
174 if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) 180 if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty())
175 flushEntry(); 181 flushEntry();
176 if ( showOnlyMode ) 182 if ( showOnlyMode )
177 emit showJournalOnly( 0 ); 183 emit showJournalOnly( 0 );
178 else { 184 else {
179 // we have to protect mJournal from deleting if mJournal has empty text 185 // we have to protect mJournal from deleting if mJournal has empty text
180 visibleMode = false; // set to true via :setShowOnly() 186 visibleMode = false; // set to true via :setShowOnly()
181 emit showJournalOnly( mJournal ); 187 emit showJournalOnly( mJournal );
182 //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); 188 //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) );
183 } 189 }
184} 190}
185void JournalEntry::setVisibleOn() 191void JournalEntry::setVisibleOn()
186{ 192{
187 visibleMode = true; 193 visibleMode = true;
188} 194}
189void JournalEntry::setShowOnly() 195void JournalEntry::setShowOnly()
190{ 196{
191 showOnlyMode = true; 197 showOnlyMode = true;
192 if ( mTitle->text().isEmpty() ) 198 if ( mTitle->text().isEmpty() )
193 mTitle->setFocus(); 199 mTitle->setFocus();
194 else 200 else
195 mEditor->setFocus(); 201 mEditor->setFocus();
196} 202}
197void JournalEntry::setJournal(Journal *journal) 203void JournalEntry::setJournal(Journal *journal)
198{ 204{
199 writeJournal(); 205 writeJournal();
200 206
201 mJournal = journal; 207 mJournal = journal;
202 if ( journal->isReadOnly() ) 208 if ( journal->isReadOnly() )
203 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); 209 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")");
204 else 210 else
205 mTitle->setText(mJournal->summary()); 211 mTitle->setText(mJournal->summary());
206 mEditor->setText(mJournal->description()); 212 mEditor->setText(mJournal->description());
207 mTitle->setReadOnly (journal->isReadOnly() ); 213 mTitle->setReadOnly (journal->isReadOnly() );
208 mEditor->setReadOnly ( journal->isReadOnly() ); 214 mEditor->setReadOnly ( journal->isReadOnly() );
209 int id = mJournal->calID(); 215 int id = mJournal->calID();
210 216
211 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 217 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
212 mTitleLabel->setText( " (" + calname +")"); 218 mTitleLabel->setText( " (" + calname +")");
213 219
214} 220}
215 221
216Journal *JournalEntry::journal() const 222Journal *JournalEntry::journal() const
217{ 223{
218 return mJournal; 224 return mJournal;
219} 225}
220 226
221 227
222void JournalEntry::clear() 228void JournalEntry::clear()
223{ 229{
224 mJournal = 0; 230 mJournal = 0;
225 mEditor->setText(""); 231 mEditor->setText("");
226 mTitle->setText(""); 232 mTitle->setText("");
227} 233}
228 234
229bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 235bool JournalEntry::eventFilter( QObject *o, QEvent *e )
230{ 236{
231// kdDebug() << "JournalEntry::event received " << e->type() << endl; 237// kdDebug() << "JournalEntry::event received " << e->type() << endl;
232 238
233 if ( e->type() == QEvent::FocusOut ) { 239 if ( e->type() == QEvent::FocusOut ) {
234 writeJournal(); 240 writeJournal();
235 } 241 }
236 if ( e->type() == QEvent::KeyPress ) { 242 if ( e->type() == QEvent::KeyPress ) {
237 QKeyEvent * k = (QKeyEvent *) e; 243 QKeyEvent * k = (QKeyEvent *) e;
238 if ( k->state() == Qt::ControlButton ) { 244 if ( k->state() == Qt::ControlButton ) {
239 k->ignore(); 245 k->ignore();
240 //return true; 246 //return true;
241 } 247 }
242 } 248 }
243 249
244 return QFrame::eventFilter( o, e ); // standard event processing 250 return QFrame::eventFilter( o, e ); // standard event processing
245} 251}
246 252
247void JournalEntry::writeJournal() 253void JournalEntry::writeJournal()
248{ 254{
249 if ( !visibleMode ) return; 255 if ( !visibleMode ) return;
250 if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) { 256 if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) {
251 if ( mJournal ) { 257 if ( mJournal ) {
252 Journal* j = mJournal; 258 Journal* j = mJournal;
253 mJournal = 0; 259 mJournal = 0;
254 bool conf = KOPrefs::instance()->mConfirm; 260 bool conf = KOPrefs::instance()->mConfirm;
255 KOPrefs::instance()->mConfirm = false; 261 KOPrefs::instance()->mConfirm = false;
256 emit deleteJournal(j); 262 emit deleteJournal(j);
257 KOPrefs::instance()->mConfirm = conf; 263 KOPrefs::instance()->mConfirm = conf;
258 } 264 }
259 return; 265 return;
260 } 266 }
261 267
262// kdDebug() << "JournalEntry::writeJournal()..." << endl; 268// kdDebug() << "JournalEntry::writeJournal()..." << endl;
263 269
264 if (!mJournal) { 270 if (!mJournal) {
265 mJournal = new Journal; 271 mJournal = new Journal;
266 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 272 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
267 mCalendar->addJournal(mJournal); 273 mCalendar->addJournal(mJournal);
268 } 274 }
269 if ( mJournal->description() != mEditor->text() ) 275 if ( mJournal->description() != mEditor->text() )
270 mJournal->setDescription(mEditor->text()); 276 mJournal->setDescription(mEditor->text());
271 if ( mJournal->summary() != mTitle->text() ) 277 if ( mJournal->summary() != mTitle->text() )
272 mJournal->setSummary(mTitle->text()); 278 mJournal->setSummary(mTitle->text());
273} 279}
274 280
275void JournalEntry::flushEntry() 281void JournalEntry::flushEntry()
276{ 282{
277 writeJournal(); 283 writeJournal();
278} 284}
279void JournalEntry::keyPressEvent ( QKeyEvent * e ) 285void JournalEntry::keyPressEvent ( QKeyEvent * e )
280{ 286{
281 e->ignore(); 287 e->ignore();
282 288
283} 289}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 067c34c..ec1154a 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -432,785 +432,786 @@ void KODayMatrix::computeEvent(Event *event, int i )
432void KODayMatrix::updateViewTimed() 432void KODayMatrix::updateViewTimed()
433{ 433{
434 mUpdateTimer->stop(); 434 mUpdateTimer->stop();
435 if ( !mCalendar ) { 435 if ( !mCalendar ) {
436 qDebug("NOT CAL "); 436 qDebug("NOT CAL ");
437 return; 437 return;
438 } 438 }
439#if 1 439#if 1
440 440
441 441
442 int i; 442 int i;
443 int timeSpan = NUMDAYS-1; 443 int timeSpan = NUMDAYS-1;
444 QPtrList<Event> events = mCalendar->events(); 444 QPtrList<Event> events = mCalendar->events();
445 Event *event; 445 Event *event;
446 QDateTime dt; 446 QDateTime dt;
447 bool ok; 447 bool ok;
448 bDays.fill( false); 448 bDays.fill( false);
449 pDays.fill( false); 449 pDays.fill( false);
450 hDays.fill( false); 450 hDays.fill( false);
451 eDays.fill( false); 451 eDays.fill( false);
452 mHolidays.clear(); 452 mHolidays.clear();
453 QDate mStartDate = days[0]; 453 QDate mStartDate = days[0];
454 QDate endDate = mStartDate.addDays( timeSpan ); 454 QDate endDate = mStartDate.addDays( timeSpan );
455 for( event = events.first(); event; event = events.next() ) { // for event 455 for( event = events.first(); event; event = events.next() ) { // for event
456 ushort recurType = event->recurrence()->doesRecur(); 456 ushort recurType = event->recurrence()->doesRecur();
457 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 457 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
458 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 458 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
459 continue; 459 continue;
460 } 460 }
461 if ( event->doesRecur() ) { 461 if ( event->doesRecur() ) {
462 bool last; 462 bool last;
463 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 463 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
464 QDateTime incidenceEnd; 464 QDateTime incidenceEnd;
465 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 465 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
466 bool invalid = false; 466 bool invalid = false;
467 while( true ) { 467 while( true ) {
468 if ( incidenceStart.isValid() ) { 468 if ( incidenceStart.isValid() ) {
469 incidenceEnd = incidenceStart.addDays( eventlen ); 469 incidenceEnd = incidenceStart.addDays( eventlen );
470 int st = incidenceStart.date().daysTo( endDate ); 470 int st = incidenceStart.date().daysTo( endDate );
471 if ( st >= 0 ) { // start before timeend 471 if ( st >= 0 ) { // start before timeend
472 int end = mStartDate.daysTo( incidenceEnd.date() ); 472 int end = mStartDate.daysTo( incidenceEnd.date() );
473 if ( end >= 0 ) { // end after timestart --- got one! 473 if ( end >= 0 ) { // end after timestart --- got one!
474 //normalize 474 //normalize
475 st = timeSpan - st; 475 st = timeSpan - st;
476 if ( st < 0 ) st = 0; 476 if ( st < 0 ) st = 0;
477 if ( end > timeSpan ) end = timeSpan; 477 if ( end > timeSpan ) end = timeSpan;
478 int iii; 478 int iii;
479 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 479 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
480 for ( iii = st;iii<= end;++iii) { 480 for ( iii = st;iii<= end;++iii) {
481 computeEvent( event, iii ); 481 computeEvent( event, iii );
482 } 482 }
483 } 483 }
484 } 484 }
485 } else { 485 } else {
486 if ( invalid ) 486 if ( invalid )
487 break; 487 break;
488 invalid = true; 488 invalid = true;
489 //qDebug("invalid %s", event->summary().latin1()); 489 //qDebug("invalid %s", event->summary().latin1());
490 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 490 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
491 } 491 }
492 if ( last ) 492 if ( last )
493 break; 493 break;
494 bool ok; 494 bool ok;
495 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 495 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
496 if ( ! ok ) 496 if ( ! ok )
497 break; 497 break;
498 if ( incidenceStart.date() > endDate ) 498 if ( incidenceStart.date() > endDate )
499 break; 499 break;
500 } 500 }
501 } else { // no recur 501 } else { // no recur
502 int st = event->dtStart().date().daysTo( endDate ); 502 int st = event->dtStart().date().daysTo( endDate );
503 if ( st >= 0 ) { // start before timeend 503 if ( st >= 0 ) { // start before timeend
504 int end = mStartDate.daysTo( event->dtEnd().date() ); 504 int end = mStartDate.daysTo( event->dtEnd().date() );
505 if ( end >= 0 ) { // end after timestart --- got one! 505 if ( end >= 0 ) { // end after timestart --- got one!
506 //normalize 506 //normalize
507 st = timeSpan - st; 507 st = timeSpan - st;
508 if ( st < 0 ) st = 0; 508 if ( st < 0 ) st = 0;
509 if ( end > timeSpan ) end = timeSpan; 509 if ( end > timeSpan ) end = timeSpan;
510 int iii; 510 int iii;
511 for ( iii = st;iii<= end;++iii) 511 for ( iii = st;iii<= end;++iii)
512 computeEvent( event, iii ); 512 computeEvent( event, iii );
513 } 513 }
514 } 514 }
515 } 515 }
516 } 516 }
517 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 517 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
518 for(i = 0; i < NUMDAYS; i++) { 518 for(i = 0; i < NUMDAYS; i++) {
519 if ( ( (i+startDay) % 7 == 0 ) ) { 519 if ( ( (i+startDay) % 7 == 0 ) ) {
520 pDays.setBit(i); 520 pDays.setBit(i);
521 } 521 }
522 } 522 }
523 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 523 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
524 bDays.fill( false); 524 bDays.fill( false);
525 // insert due todos 525 // insert due todos
526 QPtrList<Todo> todos = mCalendar->todos( ); 526 QPtrList<Todo> todos = mCalendar->todos( );
527 Todo *todo; 527 Todo *todo;
528 for(todo = todos.first(); todo; todo = todos.next()) { 528 for(todo = todos.first(); todo; todo = todos.next()) {
529 //insertTodo( todo ); 529 //insertTodo( todo );
530 if ( todo->hasDueDate() ) { 530 if ( todo->hasDueDate() ) {
531 int day = mStartDate.daysTo( todo->dtDue().date() ); 531 int day = mStartDate.daysTo( todo->dtDue().date() );
532 if ( day >= 0 && day < timeSpan + 1) { 532 if ( day >= 0 && day < timeSpan + 1) {
533 int i = day; 533 int i = day;
534 QString holiStr = mHolidays[i]; 534 QString holiStr = mHolidays[i];
535 pDays.setBit(i); 535 pDays.setBit(i);
536 if ( !holiStr.isEmpty() ) 536 if ( !holiStr.isEmpty() )
537 holiStr += "\n"; 537 holiStr += "\n";
538 holiStr += i18n("Todo") + ": "+todo->summary(); 538 holiStr += i18n("Todo") + ": "+todo->summary();
539 if ( !todo->location().isEmpty() ) 539 if ( !todo->location().isEmpty() )
540 holiStr += " (" + todo->location() + ")"; 540 holiStr += " (" + todo->location() + ")";
541 bDays.setBit(i); 541 bDays.setBit(i);
542 mHolidays[i] =holiStr ; 542 mHolidays[i] =holiStr ;
543 eDays.setBit(i); 543 eDays.setBit(i);
544 } 544 }
545 } 545 }
546 } 546 }
547 } 547 }
548 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 548 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
549 bDays.fill( false); 549 bDays.fill( false);
550 // insert due todos 550 // insert due todos
551 QPtrList<Journal> todos = mCalendar->journals( ); 551 QPtrList<Journal> todos = mCalendar->journals( );
552 Journal *todo; 552 Journal *todo;
553 for(todo = todos.first(); todo; todo = todos.next()) { 553 for(todo = todos.first(); todo; todo = todos.next()) {
554 int day = mStartDate.daysTo( todo->dtStart().date() ); 554 int day = mStartDate.daysTo( todo->dtStart().date() );
555 if ( day >= 0 && day < timeSpan + 1) { 555 if ( day >= 0 && day < timeSpan + 1) {
556 int i = day; 556 int i = day;
557 QString holiStr = mHolidays[i]; 557 QString holiStr = mHolidays[i];
558 pDays.setBit(i); 558 pDays.setBit(i);
559 if ( !holiStr.isEmpty() ) 559 if ( !holiStr.isEmpty() )
560 holiStr += "\n"; 560 holiStr += "\n";
561 holiStr += i18n("Journal: ")+todo->summary().left(25); 561 holiStr += i18n("Journal: ")+todo->summary().left(25);
562 if ( todo->summary().length() > 25 ) 562 if ( todo->summary().length() > 25 )
563 holiStr +="..."; 563 holiStr +="...";
564 bDays.setBit(i); 564 bDays.setBit(i);
565 mHolidays[i] =holiStr ; 565 mHolidays[i] =holiStr ;
566 eDays.setBit(i); 566 eDays.setBit(i);
567 567
568 } 568 }
569 } 569 }
570 } 570 }
571#else 571#else
572 //qDebug("KODayMatrix::updateViewTimed "); 572 //qDebug("KODayMatrix::updateViewTimed ");
573 for(int i = 0; i < NUMDAYS; i++) { 573 for(int i = 0; i < NUMDAYS; i++) {
574 // if events are set for the day then remember to draw it bold 574 // if events are set for the day then remember to draw it bold
575 QPtrList<Event> eventlist = mCalendar->events(days[i]); 575 QPtrList<Event> eventlist = mCalendar->events(days[i]);
576 Event *event; 576 Event *event;
577 int numEvents = eventlist.count(); 577 int numEvents = eventlist.count();
578 QString holiStr = ""; 578 QString holiStr = "";
579 bDays.clearBit(i); 579 bDays.clearBit(i);
580 hDays.clearBit(i); 580 hDays.clearBit(i);
581 eDays.clearBit(i); 581 eDays.clearBit(i);
582 for(event=eventlist.first();event != 0;event=eventlist.next()) { 582 for(event=eventlist.first();event != 0;event=eventlist.next()) {
583 ushort recurType = event->recurrence()->doesRecur(); 583 ushort recurType = event->recurrence()->doesRecur();
584 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 584 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
585 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 585 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
586 numEvents--; 586 numEvents--;
587 } 587 }
588 if ( event->isHoliday()) { 588 if ( event->isHoliday()) {
589 hDays.setBit(i); 589 hDays.setBit(i);
590 if ( !holiStr.isEmpty() ) 590 if ( !holiStr.isEmpty() )
591 holiStr += "\n"; 591 holiStr += "\n";
592 holiStr += event->summary(); 592 holiStr += event->summary();
593 if ( !event->location().isEmpty() ) 593 if ( !event->location().isEmpty() )
594 holiStr += " (" + event->location() + ")"; 594 holiStr += " (" + event->location() + ")";
595 } 595 }
596 if ( event->isBirthday()) { 596 if ( event->isBirthday()) {
597 if ( !holiStr.isEmpty() ) 597 if ( !holiStr.isEmpty() )
598 holiStr += "\n"; 598 holiStr += "\n";
599 holiStr += i18n("Birthday") + ": "+event->summary(); 599 holiStr += i18n("Birthday") + ": "+event->summary();
600 if ( !event->location().isEmpty() ) 600 if ( !event->location().isEmpty() )
601 holiStr += " (" + event->location() + ")"; 601 holiStr += " (" + event->location() + ")";
602 bDays.setBit(i); 602 bDays.setBit(i);
603 } 603 }
604 } 604 }
605 if ( numEvents ) 605 if ( numEvents )
606 eDays.setBit(i); 606 eDays.setBit(i);
607 //if it is a holy day then draw it red. Sundays are consider holidays, too 607 //if it is a holy day then draw it red. Sundays are consider holidays, too
608 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 608 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
609 !holiStr.isEmpty()) { 609 !holiStr.isEmpty()) {
610 mHolidays[i] = holiStr; 610 mHolidays[i] = holiStr;
611 } else { 611 } else {
612 mHolidays[i] = QString::null; 612 mHolidays[i] = QString::null;
613 } 613 }
614 } 614 }
615#endif 615#endif
616 mRedrawNeeded = true; 616 mRedrawNeeded = true;
617 if ( ! mPendingUpdateBeforeRepaint ) 617 if ( ! mPendingUpdateBeforeRepaint )
618 repaint(false); 618 repaint(false);
619} 619}
620void KODayMatrix::updateView(QDate actdate) 620void KODayMatrix::updateView(QDate actdate)
621{ 621{
622 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) 622 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView )
623 mRedrawNeeded = true; 623 mRedrawNeeded = true;
624 mLastView = KOPrefs::instance()->mCurrentDisplayedView; 624 mLastView = KOPrefs::instance()->mCurrentDisplayedView;
625 if ( ! actdate.isValid() ) { 625 if ( ! actdate.isValid() ) {
626 //qDebug("date not valid "); 626 //qDebug("date not valid ");
627 return; 627 return;
628 } 628 }
629 mDayChanged = false; 629 mDayChanged = false;
630 //flag to indicate if the starting day of the matrix has changed by this call 630 //flag to indicate if the starting day of the matrix has changed by this call
631 //mDayChanged = false; 631 //mDayChanged = false;
632 // if a new startdate is to be set then apply Cornelius's calculation 632 // if a new startdate is to be set then apply Cornelius's calculation
633 // of the first day to be shown 633 // of the first day to be shown
634 if (actdate != startdate) { 634 if (actdate != startdate) {
635 // reset index of selection according to shift of starting date from startdate to actdate 635 // reset index of selection according to shift of starting date from startdate to actdate
636 if (mSelStart != NOSELECTION) { 636 if (mSelStart != NOSELECTION) {
637 int tmp = actdate.daysTo(startdate); 637 int tmp = actdate.daysTo(startdate);
638 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 638 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
639 // shift selection if new one would be visible at least partly ! 639 // shift selection if new one would be visible at least partly !
640 640
641 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 641 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
642 // nested if is required for next X display pushed from a different month - correction required 642 // nested if is required for next X display pushed from a different month - correction required
643 // otherwise, for month forward and backward, it must be avoided 643 // otherwise, for month forward and backward, it must be avoided
644 if( mSelStart > NUMDAYS || mSelStart < 0 ) 644 if( mSelStart > NUMDAYS || mSelStart < 0 )
645 mSelStart = mSelStart + tmp; 645 mSelStart = mSelStart + tmp;
646 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 646 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
647 mSelEnd = mSelEnd + tmp; 647 mSelEnd = mSelEnd + tmp;
648 } 648 }
649 } 649 }
650 startdate = actdate; 650 startdate = actdate;
651 mDayChanged = true; 651 mDayChanged = true;
652 recalculateToday(); 652 recalculateToday();
653 mRedrawNeeded = true; 653 mRedrawNeeded = true;
654 } 654 }
655 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 655 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
656 if ( !isVisible() ) { 656 if ( !isVisible() ) {
657 mPendingUpdateBeforeRepaint = true; 657 mPendingUpdateBeforeRepaint = true;
658 } else { 658 } else {
659#ifdef DESKTOP_VERSION 659#ifdef DESKTOP_VERSION
660 //mRepaintTimer->start( 100 ); 660 //mRepaintTimer->start( 100 );
661 //updateViewTimed(); 661 //updateViewTimed();
662 mUpdateTimer->start( 50 ); 662 mUpdateTimer->start( 50 );
663#else 663#else
664 mRepaintTimer->start( 350 ); 664 mRepaintTimer->start( 350 );
665 mUpdateTimer->start( 800 ); 665 mUpdateTimer->start( 800 );
666#endif 666#endif
667 } 667 }
668} 668}
669void KODayMatrix::updateEvents() 669void KODayMatrix::updateEvents()
670{ 670{
671 if ( !mCalendar ) return; 671 if ( !mCalendar ) return;
672 672
673 for( int i = 0; i < NUMDAYS; i++ ) { 673 for( int i = 0; i < NUMDAYS; i++ ) {
674 // if events are set for the day then remember to draw it bold 674 // if events are set for the day then remember to draw it bold
675 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 675 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
676 int numEvents = eventlist.count(); 676 int numEvents = eventlist.count();
677 Event *event; 677 Event *event;
678 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 678 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
679 ushort recurType = event->doesRecur(); 679 ushort recurType = event->doesRecur();
680 680
681 if ( ( recurType == Recurrence::rDaily && 681 if ( ( recurType == Recurrence::rDaily &&
682 !KOPrefs::instance()->mDailyRecur ) || 682 !KOPrefs::instance()->mDailyRecur ) ||
683 ( recurType == Recurrence::rWeekly && 683 ( recurType == Recurrence::rWeekly &&
684 !KOPrefs::instance()->mWeeklyRecur ) ) { 684 !KOPrefs::instance()->mWeeklyRecur ) ) {
685 numEvents--; 685 numEvents--;
686 } 686 }
687 } 687 }
688 if ( numEvents ) 688 if ( numEvents )
689 eDays.setBit(i); 689 eDays.setBit(i);
690 else 690 else
691 eDays.clearBit(i); 691 eDays.clearBit(i);
692 } 692 }
693} 693}
694 694
695const QDate& KODayMatrix::getDate(int offset) 695const QDate& KODayMatrix::getDate(int offset)
696{ 696{
697 if (offset < 0 || offset > NUMDAYS-1) { 697 if (offset < 0 || offset > NUMDAYS-1) {
698 qDebug("Wrong offset2 %d", offset); 698 qDebug("Wrong offset2 %d", offset);
699 return days[0]; 699 return days[0];
700 } 700 }
701 return days[offset]; 701 return days[offset];
702} 702}
703 703
704QString KODayMatrix::getHolidayLabel(int offset) 704QString KODayMatrix::getHolidayLabel(int offset)
705{ 705{
706 if (offset < 0 || offset > NUMDAYS-1) { 706 if (offset < 0 || offset > NUMDAYS-1) {
707 qDebug("Wrong offset1 %d", offset); 707 qDebug("Wrong offset1 %d", offset);
708 return QString(); 708 return QString();
709 } 709 }
710 return mHolidays[offset]; 710 return mHolidays[offset];
711} 711}
712 712
713int KODayMatrix::getDayIndexFrom(int x, int y) 713int KODayMatrix::getDayIndexFrom(int x, int y)
714{ 714{
715 int colModulo = (width()-2) % 7; 715 int colModulo = (width()-2) % 7;
716 int rowModulo = (height()-2) % 6; 716 int rowModulo = (height()-2) % 6;
717#if 0 717#if 0
718 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 718 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
719 6 - x/daysize.width() : x/daysize.width()); 719 6 - x/daysize.width() : x/daysize.width());
720#endif 720#endif
721 int xVal = (x-colModulo/2-2)/daysize.width(); 721 int xVal = (x-colModulo/2-2)/daysize.width();
722 int yVal = (y-rowModulo/2-2)/daysize.height(); 722 int yVal = (y-rowModulo/2-2)/daysize.height();
723 723
724 724
725 return 7*(yVal) + xVal; 725 return 7*(yVal) + xVal;
726 726
727} 727}
728 728
729// ---------------------------------------------------------------------------- 729// ----------------------------------------------------------------------------
730// M O U S E E V E N T H A N D L I N G 730// M O U S E E V E N T H A N D L I N G
731// ---------------------------------------------------------------------------- 731// ----------------------------------------------------------------------------
732 732
733void KODayMatrix::mousePressEvent (QMouseEvent* e) 733void KODayMatrix::mousePressEvent (QMouseEvent* e)
734{ 734{
735 735
736 if ( e->button() == LeftButton ) 736 if ( e->button() == LeftButton )
737 mouseDown = true; 737 mouseDown = true;
738 mSelStart = getDayIndexFrom(e->x(), e->y()); 738 mSelStart = getDayIndexFrom(e->x(), e->y());
739 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 739 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
740 mSelInit = mSelStart; 740 mSelInit = mSelStart;
741 mSelEnd = mSelStart; 741 mSelEnd = mSelStart;
742 mRedrawNeeded = true; 742 mRedrawNeeded = true;
743 repaint(false); 743 repaint(false);
744} 744}
745 745
746void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 746void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
747{ 747{
748 mRedrawNeeded = true; 748 mRedrawNeeded = true;
749 if ( e->button() == LeftButton ) 749 if ( e->button() == LeftButton )
750 if ( ! mouseDown ) { 750 if ( ! mouseDown ) {
751 return; 751 return;
752 } 752 }
753 else 753 else
754 mouseDown = false; 754 mouseDown = false;
755 int tmp = getDayIndexFrom(e->x(), e->y()); 755 int tmp = getDayIndexFrom(e->x(), e->y());
756 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 756 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
757 757
758 if (mSelInit > tmp) { 758 if (mSelInit > tmp) {
759 mSelEnd = mSelInit; 759 mSelEnd = mSelInit;
760 if (tmp != mSelStart) { 760 if (tmp != mSelStart) {
761 mSelStart = tmp; 761 mSelStart = tmp;
762 repaint(false); 762 repaint(false);
763 } 763 }
764 } else { 764 } else {
765 mSelStart = mSelInit; 765 mSelStart = mSelInit;
766 766
767 //repaint only if selection has changed 767 //repaint only if selection has changed
768 if (tmp != mSelEnd) { 768 if (tmp != mSelEnd) {
769 mSelEnd = tmp; 769 mSelEnd = tmp;
770 repaint(false); 770 repaint(false);
771 } 771 }
772 } 772 }
773 773
774 DateList daylist; 774 DateList daylist;
775 if ( mSelStart < 0 ) 775 if ( mSelStart < 0 )
776 mSelStart = 0; 776 mSelStart = 0;
777 for (int i = mSelStart; i <= mSelEnd; i++) { 777 for (int i = mSelStart; i <= mSelEnd; i++) {
778 daylist.append(days[i]); 778 daylist.append(days[i]);
779 } 779 }
780 emit selected((const DateList)daylist); 780 emit selected((const DateList)daylist);
781 781
782} 782}
783 783
784void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 784void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
785{ 785{
786 if ( ! mouseDown ) { 786 if ( ! mouseDown ) {
787 return; 787 return;
788 } 788 }
789 mRedrawNeeded = true; 789 mRedrawNeeded = true;
790 int tmp = getDayIndexFrom(e->x(), e->y()); 790 int tmp = getDayIndexFrom(e->x(), e->y());
791 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 791 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
792 792
793 if (mSelInit > tmp) { 793 if (mSelInit > tmp) {
794 mSelEnd = mSelInit; 794 mSelEnd = mSelInit;
795 if (tmp != mSelStart) { 795 if (tmp != mSelStart) {
796 mSelStart = tmp; 796 mSelStart = tmp;
797 repaint(false); 797 repaint(false);
798 } 798 }
799 } else { 799 } else {
800 mSelStart = mSelInit; 800 mSelStart = mSelInit;
801 801
802 //repaint only if selection has changed 802 //repaint only if selection has changed
803 if (tmp != mSelEnd) { 803 if (tmp != mSelEnd) {
804 mSelEnd = tmp; 804 mSelEnd = tmp;
805 repaint(false); 805 repaint(false);
806 } 806 }
807 } 807 }
808} 808}
809 809
810// ---------------------------------------------------------------------------- 810// ----------------------------------------------------------------------------
811// D R A G ' N D R O P H A N D L I N G 811// D R A G ' N D R O P H A N D L I N G
812// ---------------------------------------------------------------------------- 812// ----------------------------------------------------------------------------
813 813
814void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 814void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
815{ 815{
816#ifndef KORG_NODND 816#ifndef KORG_NODND
817 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 817 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
818 e->ignore(); 818 e->ignore();
819 return; 819 return;
820 } 820 }
821 821
822 // some visual feedback 822 // some visual feedback
823// oldPalette = palette(); 823// oldPalette = palette();
824// setPalette(my_HilitePalette); 824// setPalette(my_HilitePalette);
825// update(); 825// update();
826#endif 826#endif
827} 827}
828 828
829void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 829void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
830{ 830{
831#ifndef KORG_NODND 831#ifndef KORG_NODND
832 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 832 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
833 e->ignore(); 833 e->ignore();
834 return; 834 return;
835 } 835 }
836 836
837 e->accept(); 837 e->accept();
838#endif 838#endif
839} 839}
840 840
841void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 841void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
842{ 842{
843#ifndef KORG_NODND 843#ifndef KORG_NODND
844// setPalette(oldPalette); 844// setPalette(oldPalette);
845// update(); 845// update();
846#endif 846#endif
847} 847}
848 848
849void KODayMatrix::dropEvent(QDropEvent *e) 849void KODayMatrix::dropEvent(QDropEvent *e)
850{ 850{
851#ifndef KORG_NODND 851#ifndef KORG_NODND
852// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 852// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
853 853
854 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 854 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
855 e->ignore(); 855 e->ignore();
856 return; 856 return;
857 } 857 }
858 858
859 DndFactory factory( mCalendar ); 859 DndFactory factory( mCalendar );
860 Event *event = factory.createDrop(e); 860 Event *event = factory.createDrop(e);
861 861
862 if (event) { 862 if (event) {
863 e->acceptAction(); 863 e->acceptAction();
864 864
865 Event *existingEvent = mCalendar->event(event->uid()); 865 Event *existingEvent = mCalendar->event(event->uid());
866 866
867 if(existingEvent) { 867 if(existingEvent) {
868 // uniquify event 868 // uniquify event
869 event->recreate(); 869 event->recreate();
870/* 870/*
871 KMessageBox::sorry(this, 871 KMessageBox::sorry(this,
872 i18n("Event already exists in this calendar."), 872 i18n("Event already exists in this calendar."),
873 i18n("Drop Event")); 873 i18n("Drop Event"));
874 delete event; 874 delete event;
875 return; 875 return;
876*/ 876*/
877 } 877 }
878// kdDebug() << "Drop new Event" << endl; 878// kdDebug() << "Drop new Event" << endl;
879 // Adjust date 879 // Adjust date
880 QDateTime start = event->dtStart(); 880 QDateTime start = event->dtStart();
881 QDateTime end = event->dtEnd(); 881 QDateTime end = event->dtEnd();
882 int duration = start.daysTo(end); 882 int duration = start.daysTo(end);
883 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 883 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
884 884
885 start.setDate(days[idx]); 885 start.setDate(days[idx]);
886 end.setDate(days[idx].addDays(duration)); 886 end.setDate(days[idx].addDays(duration));
887 887
888 event->setDtStart(start); 888 event->setDtStart(start);
889 event->setDtEnd(end); 889 event->setDtEnd(end);
890 mCalendar->addEvent(event); 890 mCalendar->addEvent(event);
891 891
892 emit eventDropped(event); 892 emit eventDropped(event);
893 } else { 893 } else {
894// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 894// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
895 e->ignore(); 895 e->ignore();
896 } 896 }
897#endif 897#endif
898} 898}
899 899
900// ---------------------------------------------------------------------------- 900// ----------------------------------------------------------------------------
901// P A I N T E V E N T H A N D L I N G 901// P A I N T E V E N T H A N D L I N G
902// ---------------------------------------------------------------------------- 902// ----------------------------------------------------------------------------
903 903
904void KODayMatrix::paintEvent(QPaintEvent * pevent) 904void KODayMatrix::paintEvent(QPaintEvent * pevent)
905{ 905{
906 906
907 if ( width() <= 0 || height() <= 0 ) 907 if ( width() <= 0 || height() <= 0 )
908 return; 908 return;
909 if ( mPendingUpdateBeforeRepaint ) { 909 if ( mPendingUpdateBeforeRepaint ) {
910 updateViewTimed(); 910 updateViewTimed();
911 mPendingUpdateBeforeRepaint = false; 911 mPendingUpdateBeforeRepaint = false;
912 } 912 }
913#if 0 913#if 0
914 if ( myPix.width() != width() || myPix.height()!=height() ) { 914 if ( myPix.width() != width() || myPix.height()!=height() ) {
915 myPix.resize(size() ); 915 myPix.resize(size() );
916 mRedrawNeeded = true; 916 mRedrawNeeded = true;
917 } 917 }
918#endif 918#endif
919 if ( oldW != width() || oldH !=height() ) 919 if ( oldW != width() || oldH !=height() )
920 mRedrawNeeded = true; 920 mRedrawNeeded = true;
921 921
922 oldH = height() ; 922 oldH = height() ;
923 oldW = width(); 923 oldW = width();
924 if ( myPix.width() < width() || myPix.height() < height() ) { 924 if ( myPix.width() < width() || myPix.height() < height() ) {
925 myPix.resize(size() ); 925 myPix.resize(size() );
926 mRedrawNeeded = true; 926 mRedrawNeeded = true;
927 927
928 } 928 }
929 929
930 if ( mRedrawNeeded ) { 930 if ( mRedrawNeeded ) {
931 //qDebug("REDRAW "); 931 //qDebug("REDRAW ");
932 QPainter p(&myPix); 932 QPainter p(&myPix);
933 p.setFont(font()); 933 p.setFont(font());
934 934
935 935
936 int dheight = daysize.height(); 936 int dheight = daysize.height();
937 int dwidth = daysize.width(); 937 int dwidth = daysize.width();
938 int row,col; 938 int row,col;
939 int selw, selh; 939 int selw, selh;
940 int xyOff = frameWidth(); 940 int xyOff = frameWidth();
941 int colModulo = (width()-2) % 7; 941 int colModulo = (width()-2) % 7;
942 int rowModulo = (height()-2) % 6; 942 int rowModulo = (height()-2) % 6;
943 //qDebug("col %d row %d ",colModulo,rowModulo ); 943 //qDebug("col %d row %d ",colModulo,rowModulo );
944 944
945 bool isRTL = KOGlobals::self()->reverseLayout(); 945 bool isRTL = KOGlobals::self()->reverseLayout();
946 946
947 // draw background and topleft frame 947 // draw background and topleft frame
948 p.fillRect(0,0,width(),height(), mDefaultBackColor); 948 p.fillRect(0,0,width(),height(), mDefaultBackColor);
949 //p.setPen(mDefaultTextColor); 949 //p.setPen(mDefaultTextColor);
950 //p.drawRect(0, 0, width(), height()); 950 //p.drawRect(0, 0, width(), height());
951 int mSelStartT = mSelStart; 951 int mSelStartT = mSelStart;
952 int mSelEndT = mSelEnd; 952 int mSelEndT = mSelEnd;
953 if ( mSelEndT >= NUMDAYS ) 953 if ( mSelEndT >= NUMDAYS )
954 mSelEndT = NUMDAYS-1; 954 mSelEndT = NUMDAYS-1;
955 // draw selected days with highlighted background color 955 // draw selected days with highlighted background color
956 if (mSelStart != NOSELECTION) { 956 if (mSelStart != NOSELECTION) {
957 bool skip = false; 957 bool skip = false;
958 if ( ! mouseDown ) { 958 if ( ! mouseDown ) {
959 int mo = days[20].month(); 959 int mo = days[20].month();
960 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 960 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
961 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 961 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
962 int startMo = days[mSelStartT].month(); 962 int startMo = days[mSelStartT].month();
963 int endMo = days[mSelEndT].month(); 963 int endMo = days[mSelEndT].month();
964 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 964 if ( startMo == 12 && mo == 1 && endMo <= 2 )
965 startMo = 1; 965 startMo = 1;
966 if ( endMo == 1 && mo == 12 ) 966 if ( endMo == 1 && mo == 12 )
967 endMo = 12; 967 endMo = 12;
968 if ( mo == 12 && startMo == 1 ) 968 if ( mo == 12 && startMo == 1 )
969 startMo = 13; 969 startMo = 13;
970 if ( (startMo > mo || endMo < mo) ) { 970 if ( (startMo > mo || endMo < mo) ) {
971 skip = true; 971 skip = true;
972 } else { 972 } else {
973 if ( days[mSelStartT].month() != mo ) { 973 if ( days[mSelStartT].month() != mo ) {
974 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 974 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
975 mSelStartT += add +1; 975 mSelStartT += add +1;
976 } 976 }
977 if ( days[mSelEndT].month() != mo ) { 977 if ( days[mSelEndT].month() != mo ) {
978 int sub = days[mSelEndT].day(); 978 int sub = days[mSelEndT].day();
979 mSelEndT -= sub ; 979 mSelEndT -= sub ;
980 } 980 }
981 } 981 }
982 } 982 }
983 //qDebug("SKIP %d ", skip); 983 //qDebug("SKIP %d ", skip);
984 if ( ! skip ) { 984 if ( ! skip ) {
985 row = mSelStartT/7; 985 row = mSelStartT/7;
986 col = mSelStartT -row*7; 986 col = mSelStartT -row*7;
987 QColor selcol = KOPrefs::instance()->mHighlightColor; 987 QColor selcol = KOPrefs::instance()->mHighlightColor;
988 int addCol = 0; 988 int addCol = 0;
989 int addRow = 0; 989 int addRow = 0;
990 int addRow2 = 0; 990 int addRow2 = 0;
991 int addCol2 = 0; 991 int addCol2 = 0;
992 if (row == mSelEndT/7) { 992 if (row == mSelEndT/7) {
993 if ( rowModulo ) { 993 if ( rowModulo ) {
994 if ( row >= 6 - rowModulo ) 994 if ( row >= 6 - rowModulo )
995 addRow = row - 5 + rowModulo; 995 addRow = row - 5 + rowModulo;
996 } 996 }
997 if ( colModulo ) { 997 if ( colModulo ) {
998 int colt1 = mSelEndT%7; 998 int colt1 = mSelEndT%7;
999 //qDebug("colt1 %d ", colt1 ); 999 //qDebug("colt1 %d ", colt1 );
1000 if ( colt1 >= 7 - colModulo ) 1000 if ( colt1 >= 7 - colModulo )
1001 addCol = colt1 - 7 + colModulo+1; 1001 addCol = colt1 - 7 + colModulo+1;
1002 int colt = mSelStartT%7; 1002 int colt = mSelStartT%7;
1003 if ( colt >= 7 - colModulo ) 1003 if ( colt >= 7 - colModulo )
1004 addCol2 = colt - 7 + colModulo; 1004 addCol2 = colt - 7 + colModulo;
1005 addCol -= addCol2; 1005 addCol -= addCol2;
1006 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 1006 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
1007 } 1007 }
1008 // Single row selection 1008 // Single row selection
1009 //if ( row == 0) 1009 //if ( row == 0)
1010 // addRow = 1; 1010 // addRow = 1;
1011 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 1011 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
1012 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 1012 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
1013 } else { 1013 } else {
1014 // draw first row to the right 1014 // draw first row to the right
1015 if ( colModulo ) { 1015 if ( colModulo ) {
1016 if ( col >= 7 - colModulo ) 1016 if ( col >= 7 - colModulo )
1017 addCol2 = col - 7 + colModulo; 1017 addCol2 = col - 7 + colModulo;
1018 } 1018 }
1019 if ( rowModulo ) { 1019 if ( rowModulo ) {
1020 if ( row >= 6 - rowModulo ) 1020 if ( row >= 6 - rowModulo )
1021 addRow = row - 5 + rowModulo; 1021 addRow = row - 5 + rowModulo;
1022 } 1022 }
1023 //if ( row == 0) 1023 //if ( row == 0)
1024 // addRow = 1; 1024 // addRow = 1;
1025 int drawWid = width()-(col*dwidth+1+addCol2)-1; 1025 int drawWid = width()-(col*dwidth+1+addCol2)-1;
1026 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 1026 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
1027 dheight+1, selcol); 1027 dheight+1, selcol);
1028 // draw full block till last line 1028 // draw full block till last line
1029 selh = mSelEndT/7-row; 1029 selh = mSelEndT/7-row;
1030 addRow = 0; 1030 addRow = 0;
1031 if ( rowModulo ) { 1031 if ( rowModulo ) {
1032 if ( mSelEndT/7 >= 6 - rowModulo ) 1032 if ( mSelEndT/7 >= 6 - rowModulo )
1033 addRow = mSelEndT/7 - 5 + rowModulo; 1033 addRow = mSelEndT/7 - 5 + rowModulo;
1034 } 1034 }
1035 //qDebug("%d %d %d ",selh, row, addRow ); 1035 //qDebug("%d %d %d ",selh, row, addRow );
1036 int addrow2 = addRow-selh+1; 1036 int addrow2 = addRow-selh+1;
1037 if ( addrow2 < 0 ) 1037 if ( addrow2 < 0 )
1038 addrow2 = 0; 1038 addrow2 = 0;
1039 if (selh > 1) { 1039 if (selh > 1) {
1040 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 1040 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
1041 } 1041 }
1042 // draw last block from left to mSelEndT 1042 // draw last block from left to mSelEndT
1043 selw = mSelEndT-7*(mSelEndT/7)+1; 1043 selw = mSelEndT-7*(mSelEndT/7)+1;
1044 //qDebug("esl %d ",selw ); 1044 //qDebug("esl %d ",selw );
1045 int add = 0; 1045 int add = 0;
1046 if ( colModulo ) { 1046 if ( colModulo ) {
1047 add = 7 - colModulo; 1047 add = 7 - colModulo;
1048 if ( selw > add ) 1048 if ( selw > add )
1049 add = selw - add; 1049 add = selw - add;
1050 else 1050 else
1051 add = 0; 1051 add = 0;
1052 } 1052 }
1053 //qDebug("add %d ", add); 1053 //qDebug("add %d ", add);
1054 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 1054 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
1055 selw*dwidth+add, dheight+1, selcol); 1055 selw*dwidth+add, dheight+1, selcol);
1056 } 1056 }
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 // iterate over all days in the matrix and draw the day label in appropriate colors 1060 // iterate over all days in the matrix and draw the day label in appropriate colors
1061 QColor actcol = mDefaultTextColorShaded; 1061 QColor actcol = mDefaultTextColorShaded;
1062 p.setPen(actcol); 1062 p.setPen(actcol);
1063 QPen tmppen; 1063 QPen tmppen;
1064 for(int i = 0; i < NUMDAYS; i++) { 1064 for(int i = 0; i < NUMDAYS; i++) {
1065 row = i/7; 1065 row = i/7;
1066 col = isRTL ? 6-(i-row*7) : i-row*7; 1066 col = isRTL ? 6-(i-row*7) : i-row*7;
1067 1067
1068 // if it is the first day of a month switch color from normal to shaded and vice versa 1068 // if it is the first day of a month switch color from normal to shaded and vice versa
1069 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 1069 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
1070 if (actcol == mDefaultTextColorShaded) { 1070 if (actcol == mDefaultTextColorShaded) {
1071 actcol = mDefaultTextColor; 1071 actcol = mDefaultTextColor;
1072 } else { 1072 } else {
1073 actcol = mDefaultTextColorShaded; 1073 actcol = mDefaultTextColorShaded;
1074 } 1074 }
1075 p.setPen(actcol); 1075 p.setPen(actcol);
1076 } 1076 }
1077 if (actcol == mDefaultTextColorShaded) { 1077 if (actcol == mDefaultTextColorShaded) {
1078 if ( ! mouseDown ) { 1078 if ( ! mouseDown ) {
1079 continue; 1079 continue;
1080 } 1080 }
1081 } 1081 }
1082 //Reset pen color after selected days block 1082 //Reset pen color after selected days block
1083 if (i == mSelEndT+1) { 1083 if (i == mSelEndT+1) {
1084 p.setPen(actcol); 1084 p.setPen(actcol);
1085 } 1085 }
1086 1086
1087 // if today then draw rectangle around day 1087 // if today then draw rectangle around day
1088 if (today == i) { 1088 if (today == i) {
1089 tmppen = p.pen(); 1089 tmppen = p.pen();
1090 QPen mTodayPen(p.pen()); 1090 QPen mTodayPen(p.pen());
1091 if ( daysize.width() < 20 ) 1091 if ( daysize.width() < 20 )
1092 mTodayPen.setWidth(1); 1092 mTodayPen.setWidth(1);
1093 else 1093 else
1094 mTodayPen.setWidth(mTodayMarginWidth); 1094 mTodayPen.setWidth(mTodayMarginWidth);
1095 //draw red rectangle for holidays 1095 //draw red rectangle for holidays
1096 if (pDays.testBit(i)) { 1096 if (pDays.testBit(i)) {
1097 if (actcol == mDefaultTextColor) { 1097 if (actcol == mDefaultTextColor) {
1098 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1098 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
1099 } else { 1099 } else {
1100 mTodayPen.setColor(mHolidayColorShaded); 1100 mTodayPen.setColor(mHolidayColorShaded);
1101 } 1101 }
1102 } 1102 }
1103 //draw gray rectangle for today if in selection 1103 //draw gray rectangle for today if in selection
1104 if (i >= mSelStartT && i <= mSelEndT) { 1104 if (i >= mSelStartT && i <= mSelEndT) {
1105 QColor grey("grey"); 1105 QColor grey("grey");
1106 mTodayPen.setColor(grey); 1106 mTodayPen.setColor(grey);
1107 } 1107 }
1108 p.setPen(mTodayPen); 1108 p.setPen(mTodayPen);
1109 1109
1110 1110
1111 int addCol = 0; 1111 int addCol = 0;
1112 int addRow = 0; 1112 int addRow = 0;
1113 if (rowModulo) { 1113 if (rowModulo) {
1114 if ( row >= 6 - rowModulo ) 1114 if ( row >= 6 - rowModulo )
1115 addRow = row - 5 + rowModulo; 1115 addRow = row - 5 + rowModulo;
1116 } 1116 }
1117 if ( colModulo ) { 1117 if ( colModulo ) {
1118 if ( col >= 7 - colModulo ) 1118 if ( col >= 7 - colModulo )
1119 addCol = col - 6 + colModulo-1; 1119 addCol = col - 6 + colModulo-1;
1120 } 1120 }
1121 1121
1122 addCol += 1; 1122 addCol += 1;
1123 if ( row == 0 ) 1123 if ( row == 0 )
1124 addRow = 1; 1124 addRow = 1;
1125 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1125 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
1126 p.setPen(tmppen); 1126 p.setPen(tmppen);
1127 } 1127 }
1128 1128
1129 // if any events are on that day then draw it using a bold font 1129 // if any events are on that day then draw it using a bold font
1130 if ( eDays.testBit(i) ) { 1130 if ( eDays.testBit(i) ) {
1131 QFont myFont = font(); 1131 QFont myFont = font();
1132 myFont.setBold(true); 1132 myFont.setBold(true);
1133 p.setFont(myFont); 1133 p.setFont(myFont);
1134 } 1134 }
1135 1135
1136 // if it is a holiday then use the default holiday color 1136 // if it is a holiday then use the default holiday color
1137 if ( pDays.testBit(i)) { 1137 if ( pDays.testBit(i)) {
1138 if ( bDays.testBit(i) ) { 1138 if ( bDays.testBit(i) ) {
1139 if ( hDays.testBit(i) ) 1139 if ( hDays.testBit(i) )
1140 p.setPen(QColor(0,200,0)); 1140 p.setPen(QColor(0,200,0));
1141 else 1141 else
1142 p.setPen(QColor(Qt::blue)); 1142 p.setPen(QColor(Qt::blue));
1143 } else { 1143 } else {
1144 if (actcol == mDefaultTextColor ) { 1144 if (actcol == mDefaultTextColor ) {
1145 p.setPen(KOPrefs::instance()->mHolidayColor); 1145 p.setPen(KOPrefs::instance()->mHolidayColor);
1146 } else { 1146 } else {
1147 p.setPen(mHolidayColorShaded); 1147 p.setPen(mHolidayColorShaded);
1148 } 1148 }
1149 } 1149 }
1150 } 1150 }
1151 1151
1152 // draw selected days with special color 1152 // draw selected days with special color
1153 // DO NOT specially highlight holidays in selection ! 1153 // DO NOT specially highlight holidays in selection !
1154 if (i >= mSelStartT && i <= mSelEndT) { 1154 if (i >= mSelStartT && i <= mSelEndT) {
1155 ;//p.setPen(mSelectedDaysColor); 1155 ;//p.setPen(mSelectedDaysColor);
1156 } 1156 }
1157 1157
1158 int addCol = 0; 1158 int addCol = 0;
1159 int addRow = 0; 1159 int addRow = 0;
1160 if ( colModulo ) { 1160 if ( colModulo ) {
1161 if ( col >= 7 - colModulo ) 1161 if ( col >= 7 - colModulo )
1162 addCol = col - 7 + colModulo; 1162 addCol = col - 7 + colModulo;
1163 } 1163 }
1164 if ( rowModulo ) { 1164 if ( rowModulo ) {
1165 if ( row >= 6 - rowModulo ) 1165 if ( row >= 6 - rowModulo )
1166 addRow = row - 5 + rowModulo; 1166 addRow = row - 5 + rowModulo;
1167 } 1167 }
1168 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1168 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
1169 ++addCol;//++addCol; 1169 ++addCol;//++addCol;
1170 if ( row == 0) 1170 if ( row == 0)
1171 addRow = 1; 1171 addRow = 1;
1172 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1172 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
1173 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1173 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
1174 1174
1175 // reset color to actual color 1175 // reset color to actual color
1176 if (pDays.testBit(i)) { 1176 if (pDays.testBit(i)) {
1177 p.setPen(actcol); 1177 p.setPen(actcol);
1178 } 1178 }
1179 // reset bold font to plain font 1179 // reset bold font to plain font
1180 if ( eDays.testBit(i)) { 1180 if ( eDays.testBit(i)) {
1181 QFont myFont = font(); 1181 QFont myFont = font();
1182 myFont.setBold(false); 1182 myFont.setBold(false);
1183 p.setFont(myFont); 1183 p.setFont(myFont);
1184 } 1184 }
1185 } 1185 }
1186 p.setPen(mDefaultTextColor); 1186 p.setPen(mDefaultTextColor);
1187 p.drawRect(0, 0, width(), height()); 1187 p.drawRect(0, 0, width(), height());
1188 } else { 1188 } else {
1189 //qDebug("NO redraw "); 1189 //qDebug("NO redraw ");
1190 } 1190 }
1191 1191
1192 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1192 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
1193 mRedrawNeeded = false; 1193 mRedrawNeeded = false;
1194} 1194}
1195 1195
1196// ---------------------------------------------------------------------------- 1196// ----------------------------------------------------------------------------
1197// R E SI Z E E V E N T H A N D L I N G 1197// R E SI Z E E V E N T H A N D L I N G
1198// ---------------------------------------------------------------------------- 1198// ----------------------------------------------------------------------------
1199 1199
1200void KODayMatrix::resizeEvent(QResizeEvent *) 1200void KODayMatrix::resizeEvent(QResizeEvent * e)
1201{ 1201{
1202 QRect sz = frameRect(); 1202 QRect sz = frameRect();
1203 daysize.setHeight(sz.height()*7 / NUMDAYS); 1203 daysize.setHeight(sz.height()*7 / NUMDAYS);
1204 daysize.setWidth(sz.width() / 7); 1204 daysize.setWidth(sz.width() / 7);
1205 QFrame::resizeEvent( e );
1205} 1206}
1206 1207
1207QSize KODayMatrix::sizeHint() const 1208QSize KODayMatrix::sizeHint() const
1208{ 1209{
1209 1210
1210 QFontMetrics fm ( font() ); 1211 QFontMetrics fm ( font() );
1211 int wid = fm.width( "30") *7+3; 1212 int wid = fm.width( "30") *7+3;
1212 int hei = fm.height() * 6+3; 1213 int hei = fm.height() * 6+3;
1213 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 1214 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
1214 return QSize ( wid, hei ); 1215 return QSize ( wid, hei );
1215 1216
1216} 1217}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 2fbcd42..e07bc53 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,569 +1,569 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36 36
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44 44
45#include <libkcal/todo.h> 45#include <libkcal/todo.h>
46#include <libkcal/event.h> 46#include <libkcal/event.h>
47#include <libkdepim/categoryselectdialog.h> 47#include <libkdepim/categoryselectdialog.h>
48#include <libkdepim/kdateedit.h> 48#include <libkdepim/kdateedit.h>
49 49
50#include "koprefs.h" 50#include "koprefs.h"
51#include "koglobals.h" 51#include "koglobals.h"
52 52
53#include "koeditorgeneral.h" 53#include "koeditorgeneral.h"
54#include "kolocationbox.h" 54#include "kolocationbox.h"
55#ifndef DESKTOP_VERSION 55#ifndef DESKTOP_VERSION
56#include <qpe/qpeapplication.h> 56#include <qpe/qpeapplication.h>
57#else 57#else
58#include <qapplication.h> 58#include <qapplication.h>
59#endif 59#endif
60 60
61KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 61KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
62 QObject( parent, name) 62 QObject( parent, name)
63{ 63{
64 mNextFocus = 0; 64 mNextFocus = 0;
65} 65}
66 66
67KOEditorGeneral::~KOEditorGeneral() 67KOEditorGeneral::~KOEditorGeneral()
68{ 68{
69} 69}
70 70
71void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 71void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
72{ 72{
73 QGridLayout *headerLayout = new QGridLayout(topLayout); 73 QGridLayout *headerLayout = new QGridLayout(topLayout);
74 74
75#if 0 75#if 0
76 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 76 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
77 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 77 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
78#endif 78#endif
79 79
80 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 80 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
81 headerLayout->addWidget(summaryLabel,1,0); 81 headerLayout->addWidget(summaryLabel,1,0);
82 82
83 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 83 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
84 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 84 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
85 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 85 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
86 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 86 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
87 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 87 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
88 if ( QApplication::desktop()->width() > 320 ) 88 if ( QApplication::desktop()->width() > 320 )
89 mSummaryEdit->setMaximumHeight( hei +6 ); 89 mSummaryEdit->setMaximumHeight( hei +6 );
90 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 90 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
91 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 91 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
92 // mSummaryEdit = new QLineEdit(parent); 92 // mSummaryEdit = new QLineEdit(parent);
93 headerLayout->addWidget(mSummaryEdit,1,1); 93 headerLayout->addWidget(mSummaryEdit,1,1);
94 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 94 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
95 95
96 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 96 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
97 if ( QApplication::desktop()->height() < 320 ) 97 if ( QApplication::desktop()->height() < 320 )
98 headerLayout->addWidget(locationLabel,1,2); 98 headerLayout->addWidget(locationLabel,1,2);
99 else 99 else
100 headerLayout->addWidget(locationLabel,2,0); 100 headerLayout->addWidget(locationLabel,2,0);
101 101
102 mLocationEdit = new KOLocationBox(TRUE,parent,10); 102 mLocationEdit = new KOLocationBox(TRUE,parent,10);
103 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 103 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
104 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 104 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
105 mLocationEdit->setMaximumHeight( hei + 6); 105 mLocationEdit->setMaximumHeight( hei + 6);
106 106
107 // mLocationEdit = new QLineEdit(parent); 107 // mLocationEdit = new QLineEdit(parent);
108 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 108 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
109 if ( QApplication::desktop()->height() < 320 ) { 109 if ( QApplication::desktop()->height() < 320 ) {
110 headerLayout->addWidget(mLocationEdit,1,3); 110 headerLayout->addWidget(mLocationEdit,1,3);
111 headerLayout->setColStretch( 1, 10); 111 headerLayout->setColStretch( 1, 10);
112 headerLayout->setColStretch( 3, 10); 112 headerLayout->setColStretch( 3, 10);
113 } 113 }
114 else { 114 else {
115 headerLayout->addWidget(mLocationEdit,2,1); 115 headerLayout->addWidget(mLocationEdit,2,1);
116 headerLayout->setColStretch( 1, 10); 116 headerLayout->setColStretch( 1, 10);
117 } 117 }
118} 118}
119void KOEditorGeneral::setFocusOn( int i ) 119void KOEditorGeneral::setFocusOn( int i )
120{ 120{
121 mNextFocus = i; 121 mNextFocus = i;
122 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 122 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
123} 123}
124void KOEditorGeneral::slotSetFocusOn() 124void KOEditorGeneral::slotSetFocusOn()
125{ 125{
126 mNextFocus; 126 mNextFocus;
127 if ( mNextFocus == 1 ) { 127 if ( mNextFocus == 1 ) {
128 mDescriptionEdit->setFocus(); 128 mDescriptionEdit->setFocus();
129 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 129 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
130 } 130 }
131 if ( mNextFocus == 2 ) { 131 if ( mNextFocus == 2 ) {
132 mSummaryEdit->setFocus(); 132 mSummaryEdit->setFocus();
133 } 133 }
134} 134}
135void KOEditorGeneral::editCategories() 135void KOEditorGeneral::editCategories()
136{ 136{
137 // qDebug("KOEditorGeneral::editCategories() "); 137 // qDebug("KOEditorGeneral::editCategories() ");
138 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 138 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
139 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 139 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
140 //KOGlobals::fitDialogToScreen( csd ); 140 //KOGlobals::fitDialogToScreen( csd );
141 csd->setColorEnabled(); 141 csd->setColorEnabled();
142 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 142 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
143 csd->exec(); 143 csd->exec();
144 delete csd; 144 delete csd;
145} 145}
146 146
147void KOEditorGeneral::showCatPopup() 147void KOEditorGeneral::showCatPopup()
148{ 148{
149 mCatPopup->clear(); 149 mCatPopup->clear();
150 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 150 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
151 int index = 0; 151 int index = 0;
152 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 152 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
153 it != KOPrefs::instance()->mCustomCategories.end (); 153 it != KOPrefs::instance()->mCustomCategories.end ();
154 ++it) { 154 ++it) {
155 mCatPopup->insertItem (*it, index ); 155 mCatPopup->insertItem (*it, index );
156 //mCategory[index] = *it; 156 //mCategory[index] = *it;
157 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 157 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
158 ++index; 158 ++index;
159 } 159 }
160} 160}
161void KOEditorGeneral::selectedCatPopup( int index ) 161void KOEditorGeneral::selectedCatPopup( int index )
162{ 162{
163 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 163 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
164 QString colcat = categories.first(); 164 QString colcat = categories.first();
165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
166 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 166 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
167 else 167 else
168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
169 categories.sort (); 169 categories.sort ();
170 if ( !colcat.isEmpty() ) { 170 if ( !colcat.isEmpty() ) {
171 if ( categories.find ( colcat ) != categories.end () ) { 171 if ( categories.find ( colcat ) != categories.end () ) {
172 categories.remove( colcat ); 172 categories.remove( colcat );
173 categories.prepend( colcat ); 173 categories.prepend( colcat );
174 } 174 }
175 } 175 }
176 setCategories( categories.join(",") ); 176 setCategories( categories.join(",") );
177} 177}
178 178
179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
180{ 180{
181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
182 mCatPopup = new QPopupMenu ( parent ); 182 mCatPopup = new QPopupMenu ( parent );
183 mCatPopup->setCheckable (true); 183 mCatPopup->setCheckable (true);
184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
186 mCategoriesButton = new QPushButton(parent); 186 mCategoriesButton = new QPushButton(parent);
187 mCategoriesButton->setText(i18n("Categories")); 187 mCategoriesButton->setText(i18n("Categories..."));
188 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
188 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 189 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
189 categoriesLayout->addWidget(mCategoriesButton); 190 categoriesLayout->addWidget(mCategoriesButton);
190 mCategoriesButton->setPopup( mCatPopup );
191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); 191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
193 connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() )); 193 mCategoriesLabel->setPopup( mCatPopup );
194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
195 categoriesLayout->addWidget(mCategoriesLabel,1); 195 categoriesLayout->addWidget(mCategoriesLabel,1);
196} 196}
197 197
198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
199{ 199{
200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
201 201
202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
204 secrecyLayout->addWidget(mCancelBox); 204 secrecyLayout->addWidget(mCancelBox);
205 secrecyLayout->addWidget(secrecyLabel); 205 secrecyLayout->addWidget(secrecyLabel);
206 206
207 mSecrecyCombo = new QComboBox(parent); 207 mSecrecyCombo = new QComboBox(parent);
208 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 208 mSecrecyCombo->insertStringList(Incidence::secrecyList());
209 secrecyLayout->addWidget(mSecrecyCombo); 209 secrecyLayout->addWidget(mSecrecyCombo);
210} 210}
211 211
212void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 212void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
213{ 213{
214 mDescriptionEdit = new KTextEdit(parent); 214 mDescriptionEdit = new KTextEdit(parent);
215 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 215 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
216 mDescriptionEdit->append(""); 216 mDescriptionEdit->append("");
217 mDescriptionEdit->setReadOnly(false); 217 mDescriptionEdit->setReadOnly(false);
218 mDescriptionEdit->setOverwriteMode(false); 218 mDescriptionEdit->setOverwriteMode(false);
219 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 219 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
220 topLayout->addWidget(mDescriptionEdit); 220 topLayout->addWidget(mDescriptionEdit);
221#ifndef DESKTOP_VERSION 221#ifndef DESKTOP_VERSION
222 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 222 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
223#endif 223#endif
224 224
225} 225}
226 226
227void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 227void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
228{ 228{
229 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 229 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
230 230
231 //mAlarmBell = new QLabel(parent); 231 //mAlarmBell = new QLabel(parent);
232 //mAlarmBell->setPixmap(SmallIcon("bell")); 232 //mAlarmBell->setPixmap(SmallIcon("bell"));
233 //alarmLayout->addWidget(mAlarmBell); 233 //alarmLayout->addWidget(mAlarmBell);
234 if ( QApplication::desktop()->width() < 320 ) 234 if ( QApplication::desktop()->width() < 320 )
235 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 235 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
236 else 236 else
237 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 237 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
238 238
239 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 239 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
240 alarmLayout->addWidget(mAlarmButton); 240 alarmLayout->addWidget(mAlarmButton);
241 241
242 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 242 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
243 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 243 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
244 alarmLayout->addWidget(mAlarmTimeEdit); 244 alarmLayout->addWidget(mAlarmTimeEdit);
245 mAlarmIncrCombo = new QComboBox(false, parent); 245 mAlarmIncrCombo = new QComboBox(false, parent);
246 if ( QApplication::desktop()->width() < 320 ) { 246 if ( QApplication::desktop()->width() < 320 ) {
247 mAlarmIncrCombo->insertItem(i18n("min")); 247 mAlarmIncrCombo->insertItem(i18n("min"));
248 mAlarmIncrCombo->insertItem(i18n("hou")); 248 mAlarmIncrCombo->insertItem(i18n("hou"));
249 mAlarmIncrCombo->insertItem(i18n("day")); 249 mAlarmIncrCombo->insertItem(i18n("day"));
250 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 250 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
251 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 251 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
252 } else { 252 } else {
253 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 253 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
254 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 254 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
255 mAlarmIncrCombo->insertItem(i18n("day(s)")); 255 mAlarmIncrCombo->insertItem(i18n("day(s)"));
256 } 256 }
257 257
258 // mAlarmIncrCombo->setMinimumHeight(20); 258 // mAlarmIncrCombo->setMinimumHeight(20);
259 alarmLayout->addWidget(mAlarmIncrCombo); 259 alarmLayout->addWidget(mAlarmIncrCombo);
260 mAlarmSoundButton = new QPushButton(parent); 260 mAlarmSoundButton = new QPushButton(parent);
261 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 261 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
262 mAlarmSoundButton->setToggleButton(true); 262 mAlarmSoundButton->setToggleButton(true);
263 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 263 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
264 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 264 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
265 alarmLayout->addWidget(mAlarmSoundButton); 265 alarmLayout->addWidget(mAlarmSoundButton);
266 266
267 mAlarmProgramButton = new QPushButton(parent); 267 mAlarmProgramButton = new QPushButton(parent);
268 mAlarmProgramButton->setPixmap(SmallIcon("run")); 268 mAlarmProgramButton->setPixmap(SmallIcon("run"));
269 mAlarmProgramButton->setToggleButton(true); 269 mAlarmProgramButton->setToggleButton(true);
270 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 270 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
271 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 271 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
272 alarmLayout->addWidget(mAlarmProgramButton); 272 alarmLayout->addWidget(mAlarmProgramButton);
273 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 273 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
274 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 274 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
275 // if ( KOPrefs::instance()->mCompactDialogs ) { 275 // if ( KOPrefs::instance()->mCompactDialogs ) {
276 // mAlarmSoundButton->hide(); 276 // mAlarmSoundButton->hide();
277 // mAlarmProgramButton->hide(); 277 // mAlarmProgramButton->hide();
278 // } 278 // }
279} 279}
280 280
281void KOEditorGeneral::pickAlarmSound() 281void KOEditorGeneral::pickAlarmSound()
282{ 282{
283 283
284 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 284 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
285 285
286 bool oldState = mAlarmSoundButton->isOn(); 286 bool oldState = mAlarmSoundButton->isOn();
287 287
288 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 288 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
289 i18n("*.wav|Wav Files"), 0)); 289 i18n("*.wav|Wav Files"), 0));
290 if (!fileName.isEmpty()) { 290 if (!fileName.isEmpty()) {
291 mAlarmSound = fileName; 291 mAlarmSound = fileName;
292 QToolTip::remove(mAlarmSoundButton); 292 QToolTip::remove(mAlarmSoundButton);
293 QString dispStr = i18n("Playing '%1'").arg(fileName); 293 QString dispStr = i18n("Playing '%1'").arg(fileName);
294 QToolTip::add(mAlarmSoundButton, dispStr); 294 QToolTip::add(mAlarmSoundButton, dispStr);
295 mAlarmProgramButton->setOn(false); 295 mAlarmProgramButton->setOn(false);
296 mAlarmSoundButton->setOn(true); 296 mAlarmSoundButton->setOn(true);
297 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 297 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
298 } else { 298 } else {
299 mAlarmProgramButton->setOn(oldState); 299 mAlarmProgramButton->setOn(oldState);
300 mAlarmSoundButton->setOn(!oldState); 300 mAlarmSoundButton->setOn(!oldState);
301 301
302 302
303 } 303 }
304 304
305 if (mAlarmProgramButton->isOn()) 305 if (mAlarmProgramButton->isOn())
306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
307 if ( mAlarmSoundButton->isOn()) 307 if ( mAlarmSoundButton->isOn())
308 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 308 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
309 309
310} 310}
311 311
312void KOEditorGeneral::pickAlarmProgram() 312void KOEditorGeneral::pickAlarmProgram()
313{ 313{
314 bool oldState = mAlarmProgramButton->isOn(); 314 bool oldState = mAlarmProgramButton->isOn();
315 315
316 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 316 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
317 if (!fileName.isEmpty()) { 317 if (!fileName.isEmpty()) {
318 mAlarmProgram = fileName; 318 mAlarmProgram = fileName;
319 QToolTip::remove(mAlarmProgramButton); 319 QToolTip::remove(mAlarmProgramButton);
320 QString dispStr = i18n("Running '%1'").arg(fileName); 320 QString dispStr = i18n("Running '%1'").arg(fileName);
321 QToolTip::add(mAlarmProgramButton, dispStr); 321 QToolTip::add(mAlarmProgramButton, dispStr);
322 mAlarmSoundButton->setOn(false); 322 mAlarmSoundButton->setOn(false);
323 mAlarmProgramButton->setOn(true); 323 mAlarmProgramButton->setOn(true);
324 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 324 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
325 } else { 325 } else {
326 mAlarmProgramButton->setOn(!oldState); 326 mAlarmProgramButton->setOn(!oldState);
327 mAlarmSoundButton->setOn(oldState); 327 mAlarmSoundButton->setOn(oldState);
328 } 328 }
329 329
330 if (mAlarmProgramButton->isOn()) 330 if (mAlarmProgramButton->isOn())
331 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 331 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
332 if ( mAlarmSoundButton->isOn()) 332 if ( mAlarmSoundButton->isOn())
333 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 333 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
334 334
335} 335}
336 336
337 337
338QString KOEditorGeneral::getFittingPath( const QString s ) 338QString KOEditorGeneral::getFittingPath( const QString s )
339{ 339{
340 int maxlen = 50; 340 int maxlen = 50;
341 if ( QApplication::desktop()->width() < 640 ) { 341 if ( QApplication::desktop()->width() < 640 ) {
342 if ( QApplication::desktop()->width() < 320 ) 342 if ( QApplication::desktop()->width() < 320 )
343 maxlen = 22; 343 maxlen = 22;
344 else 344 else
345 maxlen = 35; 345 maxlen = 35;
346 } 346 }
347 if ( s.length() > maxlen ) { 347 if ( s.length() > maxlen ) {
348 return "..."+s.right(maxlen -3); 348 return "..."+s.right(maxlen -3);
349 } 349 }
350 return s; 350 return s;
351} 351}
352 352
353void KOEditorGeneral::enableAlarmEdit(bool enable) 353void KOEditorGeneral::enableAlarmEdit(bool enable)
354{ 354{
355 if ( enable ) { 355 if ( enable ) {
356 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 356 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
357 mAlarmSoundButton->setOn( true ); 357 mAlarmSoundButton->setOn( true );
358 if ( mAlarmSound.isEmpty() ) 358 if ( mAlarmSound.isEmpty() )
359 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 359 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
360 else { 360 else {
361 if ( ! QFile::exists( mAlarmSound ) ) 361 if ( ! QFile::exists( mAlarmSound ) )
362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
363 } 363 }
364 } 364 }
365 } 365 }
366 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 366 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
367 mAlarmTimeEdit->setEnabled(enable); 367 mAlarmTimeEdit->setEnabled(enable);
368 mAlarmSoundButton->setEnabled(enable); 368 mAlarmSoundButton->setEnabled(enable);
369 mAlarmProgramButton->setEnabled(enable); 369 mAlarmProgramButton->setEnabled(enable);
370 mAlarmIncrCombo->setEnabled(enable); 370 mAlarmIncrCombo->setEnabled(enable);
371} 371}
372 372
373void KOEditorGeneral::disableAlarmEdit(bool disable) 373void KOEditorGeneral::disableAlarmEdit(bool disable)
374{ 374{
375 enableAlarmEdit( !disable ); 375 enableAlarmEdit( !disable );
376} 376}
377 377
378void KOEditorGeneral::enableAlarm( bool enable ) 378void KOEditorGeneral::enableAlarm( bool enable )
379{ 379{
380 enableAlarmEdit( enable ); 380 enableAlarmEdit( enable );
381} 381}
382 382
383void KOEditorGeneral::alarmDisable(bool disable) 383void KOEditorGeneral::alarmDisable(bool disable)
384{ 384{
385 if (!disable) { 385 if (!disable) {
386 //mAlarmBell->setEnabled(true); 386 //mAlarmBell->setEnabled(true);
387 mAlarmButton->setEnabled(true); 387 mAlarmButton->setEnabled(true);
388 } else { 388 } else {
389 //mAlarmBell->setEnabled(false); 389 //mAlarmBell->setEnabled(false);
390 mAlarmButton->setEnabled(false); 390 mAlarmButton->setEnabled(false);
391 mAlarmButton->setChecked(false); 391 mAlarmButton->setChecked(false);
392 mAlarmTimeEdit->setEnabled(false); 392 mAlarmTimeEdit->setEnabled(false);
393 mAlarmSoundButton->setEnabled(false); 393 mAlarmSoundButton->setEnabled(false);
394 mAlarmProgramButton->setEnabled(false); 394 mAlarmProgramButton->setEnabled(false);
395 mAlarmIncrCombo->setEnabled(false); 395 mAlarmIncrCombo->setEnabled(false);
396 } 396 }
397} 397}
398 398
399void KOEditorGeneral::setCategories(const QString &str) 399void KOEditorGeneral::setCategories(const QString &str)
400{ 400{
401 QString tt = str; 401 QString tt = str;
402 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); 402 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>");
403 mCategoriesLabel->setText(str); 403 mCategoriesLabel->setText(str);
404} 404}
405 405
406void KOEditorGeneral::setDefaults(bool allDay) 406void KOEditorGeneral::setDefaults(bool allDay)
407{ 407{
408#if 0 408#if 0
409 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 409 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
410#endif 410#endif
411 411
412 mAlarmMessage = i18n("Edit new item"); 412 mAlarmMessage = i18n("Edit new item");
413 enableAlarmEdit( !allDay ); 413 enableAlarmEdit( !allDay );
414 414
415 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 415 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
416 int alarmTime; 416 int alarmTime;
417 int a[] = { 1,5,10,15,30,60,180, 1440 }; 417 int a[] = { 1,5,10,15,30,60,180, 1440 };
418 int index = KOPrefs::instance()->mAlarmTime; 418 int index = KOPrefs::instance()->mAlarmTime;
419 if (index < 0 || index > 7) { 419 if (index < 0 || index > 7) {
420 alarmTime = 15; 420 alarmTime = 15;
421 } else { 421 } else {
422 alarmTime = a[index]; 422 alarmTime = a[index];
423 } 423 }
424 mAlarmButton ->setChecked( false ); 424 mAlarmButton ->setChecked( false );
425 mAlarmTimeEdit->setValue(alarmTime); 425 mAlarmTimeEdit->setValue(alarmTime);
426 mAlarmIncrCombo->setCurrentItem(0); 426 mAlarmIncrCombo->setCurrentItem(0);
427 enableAlarmEdit( false ); 427 enableAlarmEdit( false );
428 //alarmDisable (false); 428 //alarmDisable (false);
429 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 429 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
430 mCancelBox->setChecked( false ); 430 mCancelBox->setChecked( false );
431 mSummaryEdit->setEditText(""); 431 mSummaryEdit->setEditText("");
432 mLocationEdit->setEditText(""); 432 mLocationEdit->setEditText("");
433 mDescriptionEdit->setText(""); 433 mDescriptionEdit->setText("");
434 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 434 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
435 setCategories(""); 435 setCategories("");
436} 436}
437void KOEditorGeneral::setSecrecy( int num ) 437void KOEditorGeneral::setSecrecy( int num )
438{ 438{
439 mSecrecyCombo->setCurrentItem(num); 439 mSecrecyCombo->setCurrentItem(num);
440} 440}
441void KOEditorGeneral::readIncidence(Incidence *event) 441void KOEditorGeneral::readIncidence(Incidence *event)
442{ 442{
443 443
444 mAlarmMessage = event->summary(); 444 mAlarmMessage = event->summary();
445 if ( ! event->location().isEmpty() ) 445 if ( ! event->location().isEmpty() )
446 mAlarmMessage += " ("+event->location()+")"; 446 mAlarmMessage += " ("+event->location()+")";
447 mAlarmIncrCombo->setCurrentItem(0); 447 mAlarmIncrCombo->setCurrentItem(0);
448 mSummaryEdit->setEditText(event->summary()); 448 mSummaryEdit->setEditText(event->summary());
449 mLocationEdit->setEditText(event->location()); 449 mLocationEdit->setEditText(event->location());
450 mDescriptionEdit->setText(event->description()); 450 mDescriptionEdit->setText(event->description());
451 451
452#if 0 452#if 0
453 // organizer information 453 // organizer information
454 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 454 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
455#endif 455#endif
456 456
457 enableAlarmEdit( event->isAlarmEnabled() ); 457 enableAlarmEdit( event->isAlarmEnabled() );
458 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 458 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
459 if(!event->isAlarmEnabled()) { 459 if(!event->isAlarmEnabled()) {
460 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 460 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
461 int alarmTime; 461 int alarmTime;
462 int a[] = { 1,5,10,15,30,60,180, 1440 }; 462 int a[] = { 1,5,10,15,30,60,180, 1440 };
463 int index = KOPrefs::instance()->mAlarmTime; 463 int index = KOPrefs::instance()->mAlarmTime;
464 if (index < 0 || index > 7) { 464 if (index < 0 || index > 7) {
465 alarmTime = 15; 465 alarmTime = 15;
466 } else { 466 } else {
467 alarmTime = a[index]; 467 alarmTime = a[index];
468 } 468 }
469 mAlarmTimeEdit->setValue(alarmTime); 469 mAlarmTimeEdit->setValue(alarmTime);
470 } 470 }
471 mAlarmButton->setChecked( event->isAlarmEnabled() ); 471 mAlarmButton->setChecked( event->isAlarmEnabled() );
472 mSecrecyCombo->setCurrentItem(event->secrecy()); 472 mSecrecyCombo->setCurrentItem(event->secrecy());
473 mCancelBox->setChecked( event->cancelled() ); 473 mCancelBox->setChecked( event->cancelled() );
474 mAlarmProgramButton->setOn(false); 474 mAlarmProgramButton->setOn(false);
475 mAlarmSoundButton->setOn(false); 475 mAlarmSoundButton->setOn(false);
476 476
477 // set up alarm stuff 477 // set up alarm stuff
478 QPtrList<Alarm> alarms = event->alarms(); 478 QPtrList<Alarm> alarms = event->alarms();
479 Alarm* alarm; 479 Alarm* alarm;
480 mAlarmIncrCombo->setCurrentItem(0); 480 mAlarmIncrCombo->setCurrentItem(0);
481 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 481 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
482 int offset; 482 int offset;
483 if ( alarm->hasTime() ) { 483 if ( alarm->hasTime() ) {
484 QDateTime t = alarm->time(); 484 QDateTime t = alarm->time();
485 offset = event->dtStart().secsTo( t ); 485 offset = event->dtStart().secsTo( t );
486 } else { 486 } else {
487 offset = alarm->startOffset().asSeconds(); 487 offset = alarm->startOffset().asSeconds();
488 } 488 }
489 if ( offset != 0 ) { 489 if ( offset != 0 ) {
490 offset = offset / -60; // make minutes 490 offset = offset / -60; // make minutes
491 if (offset % 60 == 0) { // divides evenly into hours? 491 if (offset % 60 == 0) { // divides evenly into hours?
492 offset = offset / 60; 492 offset = offset / 60;
493 mAlarmIncrCombo->setCurrentItem(1); 493 mAlarmIncrCombo->setCurrentItem(1);
494 if (offset % 24 == 0) { // divides evenly into days? 494 if (offset % 24 == 0) { // divides evenly into days?
495 offset = offset / 24; 495 offset = offset / 24;
496 mAlarmIncrCombo->setCurrentItem(2); 496 mAlarmIncrCombo->setCurrentItem(2);
497 } 497 }
498 } 498 }
499 } 499 }
500 mAlarmTimeEdit->setValue( offset ); 500 mAlarmTimeEdit->setValue( offset );
501 if (alarm->type() == Alarm::Procedure) { 501 if (alarm->type() == Alarm::Procedure) {
502 502
503 mAlarmProgram = alarm->programFile(); 503 mAlarmProgram = alarm->programFile();
504 mAlarmProgramButton->setOn(true); 504 mAlarmProgramButton->setOn(true);
505 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 505 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
506 QToolTip::add(mAlarmProgramButton, dispStr); 506 QToolTip::add(mAlarmProgramButton, dispStr);
507 } 507 }
508 else if (alarm->type() == Alarm::Audio) { 508 else if (alarm->type() == Alarm::Audio) {
509 mAlarmSound = alarm->audioFile(); 509 mAlarmSound = alarm->audioFile();
510 if ( ! QFile::exists( mAlarmSound ) ) 510 if ( ! QFile::exists( mAlarmSound ) )
511 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 511 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
512 mAlarmSoundButton->setOn(true); 512 mAlarmSoundButton->setOn(true);
513 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 513 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
514 QToolTip::add(mAlarmSoundButton, dispStr); 514 QToolTip::add(mAlarmSoundButton, dispStr);
515 } 515 }
516 mAlarmButton->setChecked(alarm->enabled()); 516 mAlarmButton->setChecked(alarm->enabled());
517 enableAlarmEdit( alarm->enabled() ); 517 enableAlarmEdit( alarm->enabled() );
518 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 518 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
519 // TODO: Deal with multiple alarms 519 // TODO: Deal with multiple alarms
520 break; // For now, stop after the first alarm 520 break; // For now, stop after the first alarm
521 } 521 }
522 522
523 setCategories(event->categoriesStr()); 523 setCategories(event->categoriesStr());
524} 524}
525 525
526void KOEditorGeneral::writeIncidence(Incidence *event) 526void KOEditorGeneral::writeIncidence(Incidence *event)
527{ 527{
528 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 528 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
529 mLocationEdit->save(KOLocationBox::LOCATION); 529 mLocationEdit->save(KOLocationBox::LOCATION);
530 event->setSummary(mSummaryEdit->currentText()); 530 event->setSummary(mSummaryEdit->currentText());
531 event->setLocation(mLocationEdit->currentText()); 531 event->setLocation(mLocationEdit->currentText());
532 event->setDescription(mDescriptionEdit->text()); 532 event->setDescription(mDescriptionEdit->text());
533 event->setCategories(mCategoriesLabel->text()); 533 event->setCategories(mCategoriesLabel->text());
534 event->setSecrecy(mSecrecyCombo->currentItem()); 534 event->setSecrecy(mSecrecyCombo->currentItem());
535 event->setCancelled(mCancelBox->isChecked() );; 535 event->setCancelled(mCancelBox->isChecked() );;
536 // alarm stuff 536 // alarm stuff
537 if (mAlarmButton->isChecked()) { 537 if (mAlarmButton->isChecked()) {
538 if (event->alarms().count() == 0) 538 if (event->alarms().count() == 0)
539 event->newAlarm(); 539 event->newAlarm();
540 QPtrList<Alarm> alarms = event->alarms(); 540 QPtrList<Alarm> alarms = event->alarms();
541 Alarm *alarm; 541 Alarm *alarm;
542 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 542 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
543 alarm->setEnabled(true); 543 alarm->setEnabled(true);
544 int j = mAlarmTimeEdit->value()* -60; 544 int j = mAlarmTimeEdit->value()* -60;
545 if (mAlarmIncrCombo->currentItem() == 1) 545 if (mAlarmIncrCombo->currentItem() == 1)
546 j = j * 60; 546 j = j * 60;
547 else if (mAlarmIncrCombo->currentItem() == 2) 547 else if (mAlarmIncrCombo->currentItem() == 2)
548 j = j * (60 * 24); 548 j = j * (60 * 24);
549 alarm->setStartOffset( j ); 549 alarm->setStartOffset( j );
550 550
551 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 551 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
552 alarm->setProcedureAlarm(mAlarmProgram); 552 alarm->setProcedureAlarm(mAlarmProgram);
553 } 553 }
554 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 554 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
555 alarm->setAudioAlarm(mAlarmSound); 555 alarm->setAudioAlarm(mAlarmSound);
556 else 556 else
557 alarm->setType(Alarm::Invalid); 557 alarm->setType(Alarm::Invalid);
558 //alarm->setAudioAlarm("default"); 558 //alarm->setAudioAlarm("default");
559 // TODO: Deal with multiple alarms 559 // TODO: Deal with multiple alarms
560 break; // For now, stop after the first alarm 560 break; // For now, stop after the first alarm
561 } 561 }
562 } else { 562 } else {
563 Alarm* alarm = event->alarms().first(); 563 Alarm* alarm = event->alarms().first();
564 if ( alarm ) { 564 if ( alarm ) {
565 alarm->setEnabled(false); 565 alarm->setEnabled(false);
566 alarm->setType(Alarm::Invalid); 566 alarm->setType(Alarm::Invalid);
567 } 567 }
568 } 568 }
569} 569}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 9db2040..02d7aae 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,603 +1,603 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 QColor defaultTodoRunColor = QColor(99,194,30); 65 QColor defaultTodoRunColor = QColor(99,194,30);
66 KPrefs::setCurrentGroup("General"); 66 KPrefs::setCurrentGroup("General");
67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
70 addItemBool("ShowIconSearch",&mShowIconSearch,true); 70 addItemBool("ShowIconSearch",&mShowIconSearch,true);
71 addItemBool("ShowIconList",&mShowIconList,true); 71 addItemBool("ShowIconList",&mShowIconList,true);
72 addItemBool("ShowIconDay1",&mShowIconDay1,true); 72 addItemBool("ShowIconDay1",&mShowIconDay1,true);
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 134
135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
136 addItemBool("Enable Project View",&mEnableProjectView,false); 136 addItemBool("Enable Project View",&mEnableProjectView,false);
137 addItemBool("Auto Save",&mAutoSave,false); 137 addItemBool("Auto Save",&mAutoSave,false);
138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
139 addItemBool("Confirm Deletes",&mConfirm,true); 139 addItemBool("Confirm Deletes",&mConfirm,true);
140 addItemString("Archive File",&mArchiveFile); 140 addItemString("Archive File",&mArchiveFile);
141 addItemString("Html Export File",&mHtmlExportFile, 141 addItemString("Html Export File",&mHtmlExportFile,
142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
143 addItemBool("Html With Save",&mHtmlWithSave,false); 143 addItemBool("Html With Save",&mHtmlWithSave,false);
144 144
145 KPrefs::setCurrentGroup("Personal Settings"); 145 KPrefs::setCurrentGroup("Personal Settings");
146 146
147 addItemInt("Mail Client",&mMailClient,MailClientKMail); 147 addItemInt("Mail Client",&mMailClient,MailClientKMail);
148 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 148 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
149 addItemBool("Bcc",&mBcc,false); 149 addItemBool("Bcc",&mBcc,false);
150 150
151 KPrefs::setCurrentGroup("Time & Date"); 151 KPrefs::setCurrentGroup("Time & Date");
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 KPrefs::setCurrentGroup("AlarmSettings"); 157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162 162
163 163
164 KPrefs::setCurrentGroup("Calendar"); 164 KPrefs::setCurrentGroup("Calendar");
165 165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167 167
168 KPrefs::setCurrentGroup("Fonts"); 168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 QFont fon = KGlobalSettings::generalFont(); 170 QFont fon = KGlobalSettings::generalFont();
171 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 171 addItemFont("TimeBar Font",&mTimeBarFont,fon );
172 addItemFont("MonthView Font",&mMonthViewFont,fon); 172 addItemFont("MonthView Font",&mMonthViewFont,fon);
173 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 173 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
176 addItemFont("TodoView Font",&mTodoViewFont,fon); 176 addItemFont("TodoView Font",&mTodoViewFont,fon);
177 addItemFont("ListView Font",&mListViewFont,fon); 177 addItemFont("ListView Font",&mListViewFont,fon);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
179 addItemFont("EditBox Font",&mEditBoxFont,fon); 179 addItemFont("EditBox Font",&mEditBoxFont,fon);
180 addItemFont("JournalView Font",&mJornalViewFont,fon); 180 addItemFont("JournalView Font",&mJornalViewFont,fon);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
182 addItemFont("EventView Font",&mEventViewFont,fon); 182 addItemFont("EventView Font",&mEventViewFont,fon);
183 183
184 KPrefs::setCurrentGroup("RemoteSyncing"); 184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
188 addItemInt("LastSyncTime",&mLastSyncTime,0); 188 addItemInt("LastSyncTime",&mLastSyncTime,0);
189 189
190#ifdef _WIN32_ 190#ifdef _WIN32_
191 QString hdp= locateLocal("data","korganizer")+"\\\\"; 191 QString hdp= locateLocal("data","korganizer")+"\\\\";
192#else 192#else
193 QString hdp= locateLocal("data","korganizer")+"/"; 193 QString hdp= locateLocal("data","korganizer")+"/";
194#endif 194#endif
195 195
196 KPrefs::setCurrentGroup("LoadSaveFileNames"); 196 KPrefs::setCurrentGroup("LoadSaveFileNames");
197 197
198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
202 202
203 203
204 KPrefs::setCurrentGroup("Locale"); 204 KPrefs::setCurrentGroup("Locale");
205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
206 206
207 207
208 KPrefs::setCurrentGroup("Colors"); 208 KPrefs::setCurrentGroup("Colors");
209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
223 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 223 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
227 addItemBool("UseAppColors",&mUseAppColors,false); 227 addItemBool("UseAppColors",&mUseAppColors,false);
228 228
229 229
230 230
231 KPrefs::setCurrentGroup("Views"); 231 KPrefs::setCurrentGroup("Views");
232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true); 232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
233 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 233 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
234 addItemInt("Hour Size",&mHourSize,8); 234 addItemInt("Hour Size",&mHourSize,8);
235 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 235 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
239 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 239 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
242#ifdef DESKTOP_VERION 242#ifdef DESKTOP_VERION
243 addItemBool("Enable ToolTips",&mEnableToolTips,true); 243 addItemBool("Enable ToolTips",&mEnableToolTips,true);
244#else 244#else
245 addItemBool("Enable ToolTips",&mEnableToolTips,false); 245 addItemBool("Enable ToolTips",&mEnableToolTips,false);
246#endif 246#endif
247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
267#ifdef DESKTOP_VERSION 267#ifdef DESKTOP_VERSION
268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
269#else 269#else
270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
271#endif 271#endif
272 addItemInt("Day Begins",&mDayBegins,7); 272 addItemInt("Day Begins",&mDayBegins,7);
273 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 273 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
274 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 274 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
275 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 275 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
277 277
278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
279 addItemBool("Full View Month",&mFullViewMonth,true); 279 addItemBool("Full View Month",&mFullViewMonth,true);
280 addItemBool("Full View Todo",&mFullViewTodo,true); 280 addItemBool("Full View Todo",&mFullViewTodo,true);
281 addItemBool("Quick Todo",&mEnableQuickTodo,false); 281 addItemBool("Quick Todo",&mEnableQuickTodo,false);
282 282
283 addItemInt("Next X Days",&mNextXDays,3); 283 addItemInt("Next X Days",&mNextXDays,3);
284 284
285 KPrefs::setCurrentGroup("Printer"); 285 KPrefs::setCurrentGroup("Printer");
286 286
287 KPrefs::setCurrentGroup("Layout"); 287 KPrefs::setCurrentGroup("Layout");
288 288
289 addItemBool("CompactDialogs",&mCompactDialogs,false); 289 addItemBool("CompactDialogs",&mCompactDialogs,false);
290 addItemBool("VerticalScreen",&mVerticalScreen,true); 290 addItemBool("VerticalScreen",&mVerticalScreen,true);
291 291
292 KPrefs::setCurrentGroup("KOrganizer Plugins"); 292 KPrefs::setCurrentGroup("KOrganizer Plugins");
293 293
294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
295 295
296 KPrefs::setCurrentGroup("Group Scheduling"); 296 KPrefs::setCurrentGroup("Group Scheduling");
297 297
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer")
395 << i18n("Break") 395 << i18n("Break")
396 << i18n("Family") << i18n("Favorites") << i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Key Customer") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts")
398 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") 398 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping")
400 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch") 406// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema")
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 KConfig fc (locateLocal("config","kopicalendarrc")); 439 KConfig fc (locateLocal("config","kopicalendarrc"));
440 fc.setGroup("CC"); 440 fc.setGroup("CC");
441 int numCals = fc.readNumEntry("NumberCalendars",0 ); 441 int numCals = fc.readNumEntry("NumberCalendars",0 );
442 mNextAvailableCalendar = 1; 442 mNextAvailableCalendar = 1;
443 if ( numCals == 0 ) { 443 if ( numCals == 0 ) {
444 KopiCalendarFile *kkf = getNewCalendar(); 444 KopiCalendarFile *kkf = getNewCalendar();
445 kkf->isStandard = true; 445 kkf->isStandard = true;
446 kkf->mName = i18n("Standard"); 446 kkf->mName = i18n("Standard");
447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
448 } 448 }
449 while ( mNextAvailableCalendar <= numCals ) { 449 while ( mNextAvailableCalendar <= numCals ) {
450 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 450 //qDebug("Read cal #%d ", mNextAvailableCalendar );
451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
452 KopiCalendarFile *kkf = getNewCalendar(); 452 KopiCalendarFile *kkf = getNewCalendar();
453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
460 if ( kkf->mCalNumber == 1 ) { 460 if ( kkf->mCalNumber == 1 ) {
461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
462 } 462 }
463 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); 463 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() );
464 if ( kkf->mName == i18n("Birthdays") ) { 464 if ( kkf->mName == i18n("Birthdays") ) {
465 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); 465 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" );
466 } 466 }
467 } 467 }
468 468
469 KPimPrefs::usrReadConfig(); 469 KPimPrefs::usrReadConfig();
470} 470}
471 471
472KopiCalendarFile * KOPrefs::getCalendar( int num ) 472KopiCalendarFile * KOPrefs::getCalendar( int num )
473{ 473{
474 return mDefCalColors[num-1]; 474 return mDefCalColors[num-1];
475} 475}
476 476
477KopiCalendarFile * KOPrefs::getNewCalendar() 477KopiCalendarFile * KOPrefs::getNewCalendar()
478{ 478{
479 KopiCalendarFile * kkf = new KopiCalendarFile(); 479 KopiCalendarFile * kkf = new KopiCalendarFile();
480 kkf->mCalNumber = mNextAvailableCalendar; 480 kkf->mCalNumber = mNextAvailableCalendar;
481 mDefCalColors.resize( mNextAvailableCalendar ); 481 mDefCalColors.resize( mNextAvailableCalendar );
482 mDefCalColors[mNextAvailableCalendar-1] = kkf; 482 mDefCalColors[mNextAvailableCalendar-1] = kkf;
483 ++mNextAvailableCalendar; 483 ++mNextAvailableCalendar;
484 kkf->mDefaultColor = mEventColor; 484 kkf->mDefaultColor = mEventColor;
485 kkf->mName = i18n("New Calendar"); 485 kkf->mName = i18n("New Calendar");
486 mCalendars.append( kkf ); 486 mCalendars.append( kkf );
487 return kkf; 487 return kkf;
488} 488}
489void KOPrefs::deleteCalendar( int num ) 489void KOPrefs::deleteCalendar( int num )
490{ 490{
491 KopiCalendarFile * kkf = mCalendars.first(); 491 KopiCalendarFile * kkf = mCalendars.first();
492 while ( kkf ) { 492 while ( kkf ) {
493 if ( kkf->mCalNumber == num ) { 493 if ( kkf->mCalNumber == num ) {
494 qDebug("KOPrefs::deleteCalendar %d ", num ); 494 qDebug("KOPrefs::deleteCalendar %d ", num );
495 mCalendars.remove( kkf ); 495 mCalendars.remove( kkf );
496 delete kkf; 496 delete kkf;
497 return; 497 return;
498 } 498 }
499 kkf = mCalendars.next(); 499 kkf = mCalendars.next();
500 } 500 }
501} 501}
502QString KOPrefs::calName( int calNum) const 502QString KOPrefs::calName( int calNum) const
503{ 503{
504 return (mDefCalColors[calNum-1])->mName; 504 return (mDefCalColors[calNum-1])->mName;
505} 505}
506QColor KOPrefs::defaultColor( int calNum ) const 506QColor KOPrefs::defaultColor( int calNum ) const
507{ 507{
508 if ( calNum == 1 ) return mEventColor; 508 if ( calNum == 1 ) return mEventColor;
509 return (mDefCalColors[calNum-1])->mDefaultColor; 509 return (mDefCalColors[calNum-1])->mDefaultColor;
510} 510}
511void KOPrefs::usrWriteConfig() 511void KOPrefs::usrWriteConfig()
512{ 512{
513 config()->setGroup("General"); 513 config()->setGroup("General");
514 config()->writeEntry("Custom Categories",mCustomCategories); 514 config()->writeEntry("Custom Categories",mCustomCategories);
515 515
516 config()->setGroup("Personal Settings"); 516 config()->setGroup("Personal Settings");
517 config()->writeEntry("user_name",mName); 517 config()->writeEntry("user_name",mName);
518 config()->writeEntry("user_email",mEmail); 518 config()->writeEntry("user_email",mEmail);
519 519
520 config()->setGroup("Category Colors"); 520 config()->setGroup("Category Colors");
521 QDictIterator<QColor> it(mCategoryColors); 521 QDictIterator<QColor> it(mCategoryColors);
522 while (it.current()) { 522 while (it.current()) {
523 config()->writeEntry(it.currentKey(),*(it.current())); 523 config()->writeEntry(it.currentKey(),*(it.current()));
524 ++it; 524 ++it;
525 } 525 }
526 KConfig fc (locateLocal("config","kopicalendarrc")); 526 KConfig fc (locateLocal("config","kopicalendarrc"));
527 fc.setGroup("CC"); 527 fc.setGroup("CC");
528 fc.writeEntry("NumberCalendars",mCalendars.count()); 528 fc.writeEntry("NumberCalendars",mCalendars.count());
529 int numCal = 1; 529 int numCal = 1;
530 int writeCal = 0; 530 int writeCal = 0;
531 while ( numCal < mNextAvailableCalendar ) { 531 while ( numCal < mNextAvailableCalendar ) {
532 KopiCalendarFile * kkf = mCalendars.first(); 532 KopiCalendarFile * kkf = mCalendars.first();
533 while ( kkf ) { 533 while ( kkf ) {
534 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 534 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
535 if ( kkf->mCalNumber == numCal ) { 535 if ( kkf->mCalNumber == numCal ) {
536 ++writeCal; 536 ++writeCal;
537 //qDebug("Write calendar %d %d ", numCal , writeCal); 537 //qDebug("Write calendar %d %d ", numCal , writeCal);
538 QString prefix = "Cal_" + QString::number( writeCal ); 538 QString prefix = "Cal_" + QString::number( writeCal );
539 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 539 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
540 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 540 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
541 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 541 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
542 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 542 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
543 fc.writeEntry( prefix+"_Name", kkf->mName); 543 fc.writeEntry( prefix+"_Name", kkf->mName);
544 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 544 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
545 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 545 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
546 } 546 }
547 kkf = mCalendars.next(); 547 kkf = mCalendars.next();
548 } 548 }
549 ++numCal; 549 ++numCal;
550 } 550 }
551 fc.sync(); 551 fc.sync();
552 KPimPrefs::usrWriteConfig(); 552 KPimPrefs::usrWriteConfig();
553} 553}
554 554
555void KOPrefs::setCategoryColor(QString cat,const QColor & color) 555void KOPrefs::setCategoryColor(QString cat,const QColor & color)
556{ 556{
557 mCategoryColors.replace(cat,new QColor(color)); 557 mCategoryColors.replace(cat,new QColor(color));
558} 558}
559 559
560QColor *KOPrefs::categoryColor(QString cat) 560QColor *KOPrefs::categoryColor(QString cat)
561{ 561{
562 QColor *color = 0; 562 QColor *color = 0;
563 563
564 if (!cat.isEmpty()) color = mCategoryColors[cat]; 564 if (!cat.isEmpty()) color = mCategoryColors[cat];
565 565
566 if (color) return color; 566 if (color) return color;
567 else return &mDefaultCategoryColor; 567 else return &mDefaultCategoryColor;
568} 568}
569 569
570void KOPrefs::setFullName(const QString &name) 570void KOPrefs::setFullName(const QString &name)
571{ 571{
572 mName = name; 572 mName = name;
573} 573}
574 574
575void KOPrefs::setEmail(const QString &email) 575void KOPrefs::setEmail(const QString &email)
576{ 576{
577 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 577 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
578 mEmail = email; 578 mEmail = email;
579} 579}
580 580
581QString KOPrefs::fullName() 581QString KOPrefs::fullName()
582{ 582{
583 if (mEmailControlCenter) { 583 if (mEmailControlCenter) {
584 KEMailSettings settings; 584 KEMailSettings settings;
585 return settings.getSetting(KEMailSettings::RealName); 585 return settings.getSetting(KEMailSettings::RealName);
586 } else { 586 } else {
587 return mName; 587 return mName;
588 } 588 }
589} 589}
590 590
591QString KOPrefs::email() 591QString KOPrefs::email()
592{ 592{
593 if (mEmailControlCenter) { 593 if (mEmailControlCenter) {
594 KEMailSettings settings; 594 KEMailSettings settings;
595 return settings.getSetting(KEMailSettings::EmailAddress); 595 return settings.getSetting(KEMailSettings::EmailAddress);
596 } else { 596 } else {
597 return mEmail; 597 return mEmail;
598 } 598 }
599} 599}
600KConfig* KOPrefs::getConfig() 600KConfig* KOPrefs::getConfig()
601{ 601{
602 return config(); 602 return config();
603} 603}