summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 6746de2..a10e93c 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1865,1539 +1865,1544 @@ bool CalendarView::importQtopia( const QString &categories,
1865 1865
1866 updateView(); 1866 updateView();
1867 return true; 1867 return true;
1868 1868
1869#if 0 1869#if 0
1870 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1870 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1871 mCurrentSyncDevice = "qtopia-XML"; 1871 mCurrentSyncDevice = "qtopia-XML";
1872 if ( mSyncManager->mAskForPreferences ) 1872 if ( mSyncManager->mAskForPreferences )
1873 edit_sync_options(); 1873 edit_sync_options();
1874 qApp->processEvents(); 1874 qApp->processEvents();
1875 CalendarLocal* calendar = new CalendarLocal(); 1875 CalendarLocal* calendar = new CalendarLocal();
1876 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1876 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1877 bool syncOK = false; 1877 bool syncOK = false;
1878 QtopiaFormat qtopiaFormat; 1878 QtopiaFormat qtopiaFormat;
1879 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1879 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1880 bool loadOk = true; 1880 bool loadOk = true;
1881 if ( !categories.isEmpty() ) 1881 if ( !categories.isEmpty() )
1882 loadOk = qtopiaFormat.load( calendar, categories ); 1882 loadOk = qtopiaFormat.load( calendar, categories );
1883 if ( loadOk && !datebook.isEmpty() ) 1883 if ( loadOk && !datebook.isEmpty() )
1884 loadOk = qtopiaFormat.load( calendar, datebook ); 1884 loadOk = qtopiaFormat.load( calendar, datebook );
1885 if ( loadOk && !todolist.isEmpty() ) 1885 if ( loadOk && !todolist.isEmpty() )
1886 loadOk = qtopiaFormat.load( calendar, todolist ); 1886 loadOk = qtopiaFormat.load( calendar, todolist );
1887 1887
1888 if ( loadOk ) { 1888 if ( loadOk ) {
1889 getEventViewerDialog()->setSyncMode( true ); 1889 getEventViewerDialog()->setSyncMode( true );
1890 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1890 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1891 getEventViewerDialog()->setSyncMode( false ); 1891 getEventViewerDialog()->setSyncMode( false );
1892 qApp->processEvents(); 1892 qApp->processEvents();
1893 if ( syncOK ) { 1893 if ( syncOK ) {
1894 if ( mSyncManager->mWriteBackFile ) 1894 if ( mSyncManager->mWriteBackFile )
1895 { 1895 {
1896 // write back XML file 1896 // write back XML file
1897 1897
1898 } 1898 }
1899 setModified( true ); 1899 setModified( true );
1900 } 1900 }
1901 } else { 1901 } else {
1902 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1902 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1903 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1903 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1904 question, i18n("Ok")) ; 1904 question, i18n("Ok")) ;
1905 } 1905 }
1906 delete calendar; 1906 delete calendar;
1907 updateView(); 1907 updateView();
1908 return syncOK; 1908 return syncOK;
1909 1909
1910 1910
1911#endif 1911#endif
1912 1912
1913} 1913}
1914 1914
1915void CalendarView::setSyncEventsReadOnly() 1915void CalendarView::setSyncEventsReadOnly()
1916{ 1916{
1917 mCalendar->setSyncEventsReadOnly(); 1917 mCalendar->setSyncEventsReadOnly();
1918} 1918}
1919 1919
1920bool CalendarView::loadCalendars() 1920bool CalendarView::loadCalendars()
1921{ 1921{
1922 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1922 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1923 KopiCalendarFile * cal = calendars.first(); 1923 KopiCalendarFile * cal = calendars.first();
1924 mCalendar->setDefaultCalendar( 1 ); 1924 mCalendar->setDefaultCalendar( 1 );
1925 openCalendar( MainWindow::defaultFileName(), false ); 1925 openCalendar( MainWindow::defaultFileName(), false );
1926 cal = calendars.next(); 1926 cal = calendars.next();
1927 while ( cal ) { 1927 while ( cal ) {
1928 addCalendar( cal ); 1928 addCalendar( cal );
1929 cal = calendars.next(); 1929 cal = calendars.next();
1930 } 1930 }
1931 restoreCalendarSettings(); 1931 restoreCalendarSettings();
1932 return true; 1932 return true;
1933} 1933}
1934bool CalendarView::restoreCalendarSettings() 1934bool CalendarView::restoreCalendarSettings()
1935{ 1935{
1936 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1936 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1937 KopiCalendarFile * cal = calendars.first(); 1937 KopiCalendarFile * cal = calendars.first();
1938 while ( cal ) { 1938 while ( cal ) {
1939 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1939 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1940 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1940 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1941 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1941 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1942 if ( cal->isStandard ) 1942 if ( cal->isStandard )
1943 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1943 mCalendar->setDefaultCalendar( cal->mCalNumber );
1944 cal = calendars.next(); 1944 cal = calendars.next();
1945 } 1945 }
1946 setSyncEventsReadOnly(); 1946 setSyncEventsReadOnly();
1947 mCalendar->reInitAlarmSettings(); 1947 mCalendar->reInitAlarmSettings();
1948 updateUnmanagedViews(); 1948 updateUnmanagedViews();
1949 updateView(); 1949 updateView();
1950 return true; 1950 return true;
1951} 1951}
1952void CalendarView::addCalendarId( int id ) 1952void CalendarView::addCalendarId( int id )
1953{ 1953{
1954 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1954 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1955 if ( cal ) 1955 if ( cal )
1956 addCalendar( cal ); 1956 addCalendar( cal );
1957} 1957}
1958bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1958bool CalendarView::addCalendar( KopiCalendarFile * cal )
1959{ 1959{
1960 cal->mErrorOnLoad = false; 1960 cal->mErrorOnLoad = false;
1961 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1961 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1962 cal->mLoadDt = QDateTime::currentDateTime(); 1962 cal->mLoadDt = QDateTime::currentDateTime();
1963 return true; 1963 return true;
1964 } 1964 }
1965 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 1965 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
1966 cal->mErrorOnLoad = true; 1966 cal->mErrorOnLoad = true;
1967 return false; 1967 return false;
1968} 1968}
1969bool CalendarView::openCalendar(QString filename, bool merge) 1969bool CalendarView::openCalendar(QString filename, bool merge)
1970{ 1970{
1971 1971
1972 if (filename.isEmpty()) { 1972 if (filename.isEmpty()) {
1973 return false; 1973 return false;
1974 } 1974 }
1975 1975
1976 if (!QFile::exists(filename)) { 1976 if (!QFile::exists(filename)) {
1977 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1977 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1978 return false; 1978 return false;
1979 } 1979 }
1980 1980
1981 globalFlagBlockAgenda = 1; 1981 globalFlagBlockAgenda = 1;
1982 clearAllViews(); 1982 clearAllViews();
1983 if (!merge) { 1983 if (!merge) {
1984 mViewManager->setDocumentId( filename ); 1984 mViewManager->setDocumentId( filename );
1985 mCalendar->close(); 1985 mCalendar->close();
1986 } 1986 }
1987 mStorage->setFileName( filename ); 1987 mStorage->setFileName( filename );
1988 1988
1989 if ( mStorage->load() ) { 1989 if ( mStorage->load() ) {
1990 if ( merge ) ;//setModified( true ); 1990 if ( merge ) ;//setModified( true );
1991 else { 1991 else {
1992 //setModified( true ); 1992 //setModified( true );
1993 mViewManager->setDocumentId( filename ); 1993 mViewManager->setDocumentId( filename );
1994 mDialogManager->setDocumentId( filename ); 1994 mDialogManager->setDocumentId( filename );
1995 mTodoList->setDocumentId( filename ); 1995 mTodoList->setDocumentId( filename );
1996 } 1996 }
1997 globalFlagBlockAgenda = 2; 1997 globalFlagBlockAgenda = 2;
1998 // if ( getLastSyncEvent() ) 1998 // if ( getLastSyncEvent() )
1999 // getLastSyncEvent()->setReadOnly( true ); 1999 // getLastSyncEvent()->setReadOnly( true );
2000 mCalendar->reInitAlarmSettings(); 2000 mCalendar->reInitAlarmSettings();
2001 setSyncEventsReadOnly(); 2001 setSyncEventsReadOnly();
2002 updateUnmanagedViews(); 2002 updateUnmanagedViews();
2003 updateView(); 2003 updateView();
2004 if ( filename != MainWindow::defaultFileName() ) { 2004 if ( filename != MainWindow::defaultFileName() ) {
2005 saveCalendar( MainWindow::defaultFileName() ); 2005 saveCalendar( MainWindow::defaultFileName() );
2006 } else { 2006 } else {
2007 QFileInfo finf ( MainWindow::defaultFileName()); 2007 QFileInfo finf ( MainWindow::defaultFileName());
2008 if ( finf.exists() ) { 2008 if ( finf.exists() ) {
2009 setLoadedFileVersion( finf.lastModified () ); 2009 setLoadedFileVersion( finf.lastModified () );
2010 } 2010 }
2011 } 2011 }
2012 return true; 2012 return true;
2013 } else { 2013 } else {
2014 // while failing to load, the calendar object could 2014 // while failing to load, the calendar object could
2015 // have become partially populated. Clear it out. 2015 // have become partially populated. Clear it out.
2016 if ( !merge ) { 2016 if ( !merge ) {
2017 mCalendar->close(); 2017 mCalendar->close();
2018 mViewManager->setDocumentId( filename ); 2018 mViewManager->setDocumentId( filename );
2019 mDialogManager->setDocumentId( filename ); 2019 mDialogManager->setDocumentId( filename );
2020 mTodoList->setDocumentId( filename ); 2020 mTodoList->setDocumentId( filename );
2021 } 2021 }
2022 2022
2023 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2023 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2024 2024
2025 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2025 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2026 globalFlagBlockAgenda = 2; 2026 globalFlagBlockAgenda = 2;
2027 mCalendar->reInitAlarmSettings(); 2027 mCalendar->reInitAlarmSettings();
2028 setSyncEventsReadOnly(); 2028 setSyncEventsReadOnly();
2029 updateUnmanagedViews(); 2029 updateUnmanagedViews();
2030 updateView(); 2030 updateView();
2031 } 2031 }
2032 return false; 2032 return false;
2033} 2033}
2034void CalendarView::showOpenError() 2034void CalendarView::showOpenError()
2035{ 2035{
2036 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2036 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2037} 2037}
2038void CalendarView::setLoadedFileVersion(QDateTime dt) 2038void CalendarView::setLoadedFileVersion(QDateTime dt)
2039{ 2039{
2040 loadedFileVersion = dt; 2040 loadedFileVersion = dt;
2041} 2041}
2042bool CalendarView::checkFileChanged(QString fn) 2042bool CalendarView::checkFileChanged(QString fn)
2043{ 2043{
2044 QFileInfo finf ( fn ); 2044 QFileInfo finf ( fn );
2045 if ( !finf.exists() ) 2045 if ( !finf.exists() )
2046 return true; 2046 return true;
2047 QDateTime dt = finf.lastModified (); 2047 QDateTime dt = finf.lastModified ();
2048 if ( dt <= loadedFileVersion ) 2048 if ( dt <= loadedFileVersion )
2049 return false; 2049 return false;
2050 return true; 2050 return true;
2051 2051
2052} 2052}
2053void CalendarView::watchSavedFile() 2053void CalendarView::watchSavedFile()
2054{ 2054{
2055 QFileInfo finf ( MainWindow::defaultFileName()); 2055 QFileInfo finf ( MainWindow::defaultFileName());
2056 if ( !finf.exists() ) 2056 if ( !finf.exists() )
2057 return; 2057 return;
2058 QDateTime dt = finf.lastModified (); 2058 QDateTime dt = finf.lastModified ();
2059 if ( dt < loadedFileVersion ) { 2059 if ( dt < loadedFileVersion ) {
2060 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2060 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2061 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2061 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2062 return; 2062 return;
2063 } 2063 }
2064 loadedFileVersion = dt; 2064 loadedFileVersion = dt;
2065} 2065}
2066bool CalendarView::checkAllFileVersions() 2066bool CalendarView::checkAllFileVersions()
2067{ 2067{
2068 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2068 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2069 KopiCalendarFile * cal = calendars.first(); 2069 KopiCalendarFile * cal = calendars.first();
2070 mCalendar->setDefaultCalendar( 1 ); 2070 mCalendar->setDefaultCalendar( 1 );
2071 mCalendar->setDefaultCalendarEnabledOnly(); 2071 mCalendar->setDefaultCalendarEnabledOnly();
2072 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2072 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2073 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2073 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2074 restoreCalendarSettings(); 2074 restoreCalendarSettings();
2075 return false; 2075 return false;
2076 } 2076 }
2077 } 2077 }
2078 cal = calendars.next(); 2078 cal = calendars.next();
2079 QDateTime storeTemp = loadedFileVersion; 2079 QDateTime storeTemp = loadedFileVersion;
2080 while ( cal ) { 2080 while ( cal ) {
2081 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2081 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2082 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2082 mCalendar->setDefaultCalendar( cal->mCalNumber );
2083 mCalendar->setDefaultCalendarEnabledOnly(); 2083 mCalendar->setDefaultCalendarEnabledOnly();
2084 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2084 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2085 if ( !checkFileVersion(cal->mFileName )) { 2085 if ( !checkFileVersion(cal->mFileName )) {
2086 loadedFileVersion = storeTemp; 2086 loadedFileVersion = storeTemp;
2087 restoreCalendarSettings(); 2087 restoreCalendarSettings();
2088 return false; 2088 return false;
2089 } 2089 }
2090 } 2090 }
2091 cal = calendars.next(); 2091 cal = calendars.next();
2092 } 2092 }
2093 loadedFileVersion = storeTemp; 2093 loadedFileVersion = storeTemp;
2094 return true; 2094 return true;
2095} 2095}
2096bool CalendarView::checkFileVersion(QString fn) 2096bool CalendarView::checkFileVersion(QString fn)
2097{ 2097{
2098 QFileInfo finf ( fn ); 2098 QFileInfo finf ( fn );
2099 if ( !finf.exists() ) 2099 if ( !finf.exists() )
2100 return true; 2100 return true;
2101 QDateTime dt = finf.lastModified (); 2101 QDateTime dt = finf.lastModified ();
2102 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2102 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2103 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2103 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2104 if ( dt <= loadedFileVersion ) 2104 if ( dt <= loadedFileVersion )
2105 return true; 2105 return true;
2106 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2106 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2107 i18n("KO/Pi Warning"),i18n("Overwrite"), 2107 i18n("KO/Pi Warning"),i18n("Overwrite"),
2108 i18n("Sync+save")); 2108 i18n("Sync+save"));
2109 2109
2110 if ( km == KMessageBox::Cancel ) 2110 if ( km == KMessageBox::Cancel )
2111 return false; 2111 return false;
2112 if ( km == KMessageBox::Yes ) 2112 if ( km == KMessageBox::Yes )
2113 return true; 2113 return true;
2114 2114
2115 setSyncDevice("deleteaftersync" ); 2115 setSyncDevice("deleteaftersync" );
2116 mSyncManager->mAskForPreferences = true; 2116 mSyncManager->mAskForPreferences = true;
2117 mSyncManager->mSyncAlgoPrefs = 3; 2117 mSyncManager->mSyncAlgoPrefs = 3;
2118 mSyncManager->mWriteBackFile = false; 2118 mSyncManager->mWriteBackFile = false;
2119 mSyncManager->mWriteBackExistingOnly = false; 2119 mSyncManager->mWriteBackExistingOnly = false;
2120 mSyncManager->mShowSyncSummary = false; 2120 mSyncManager->mShowSyncSummary = false;
2121 syncCalendar( fn, 3 ); 2121 syncCalendar( fn, 3 );
2122 Event * e = getLastSyncEvent(); 2122 Event * e = getLastSyncEvent();
2123 if ( e ) 2123 if ( e )
2124 mCalendar->deleteEvent( e ); 2124 mCalendar->deleteEvent( e );
2125 return true; 2125 return true;
2126} 2126}
2127bool CalendarView::saveCalendars() 2127bool CalendarView::saveCalendars()
2128{ 2128{
2129 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2129 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2130 KopiCalendarFile * cal = calendars.first(); 2130 KopiCalendarFile * cal = calendars.first();
2131 mCalendar->setDefaultCalendar( 1 ); 2131 mCalendar->setDefaultCalendar( 1 );
2132 mCalendar->setDefaultCalendarEnabledOnly(); 2132 mCalendar->setDefaultCalendarEnabledOnly();
2133 saveCalendar( MainWindow::defaultFileName() ); 2133 saveCalendar( MainWindow::defaultFileName() );
2134 cal = calendars.next(); 2134 cal = calendars.next();
2135 while ( cal ) { 2135 while ( cal ) {
2136 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2136 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2137 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2137 mCalendar->setDefaultCalendar( cal->mCalNumber );
2138 mCalendar->setDefaultCalendarEnabledOnly(); 2138 mCalendar->setDefaultCalendarEnabledOnly();
2139 if ( saveCalendar( cal->mFileName ) ) 2139 if ( saveCalendar( cal->mFileName ) )
2140 cal->mLoadDt = QDateTime::currentDateTime(); 2140 cal->mLoadDt = QDateTime::currentDateTime();
2141 } 2141 }
2142 cal = calendars.next(); 2142 cal = calendars.next();
2143 } 2143 }
2144 restoreCalendarSettings(); 2144 restoreCalendarSettings();
2145 return true; 2145 return true;
2146} 2146}
2147bool CalendarView::saveCalendar( QString filename ) 2147bool CalendarView::saveCalendar( QString filename )
2148{ 2148{
2149 2149
2150 // Store back all unsaved data into calendar object 2150 // Store back all unsaved data into calendar object
2151 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2151 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2152 if ( mViewManager->currentView() ) 2152 if ( mViewManager->currentView() )
2153 mViewManager->currentView()->flushView(); 2153 mViewManager->currentView()->flushView();
2154 2154
2155 2155
2156 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2156 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2157 mStorage->setSaveFormat( new ICalFormat() ); 2157 mStorage->setSaveFormat( new ICalFormat() );
2158 mStorage->setFileName( filename ); 2158 mStorage->setFileName( filename );
2159 bool success; 2159 bool success;
2160 success = mStorage->save(); 2160 success = mStorage->save();
2161 if ( !success ) { 2161 if ( !success ) {
2162 return false; 2162 return false;
2163 } 2163 }
2164 if ( filename == MainWindow::defaultFileName() ) { 2164 if ( filename == MainWindow::defaultFileName() ) {
2165 setLoadedFileVersion( lfv ); 2165 setLoadedFileVersion( lfv );
2166 watchSavedFile(); 2166 watchSavedFile();
2167 } 2167 }
2168 return true; 2168 return true;
2169} 2169}
2170 2170
2171void CalendarView::closeCalendar() 2171void CalendarView::closeCalendar()
2172{ 2172{
2173 2173
2174 // child windows no longer valid 2174 // child windows no longer valid
2175 clearAllViews(); 2175 clearAllViews();
2176 emit closingDown(); 2176 emit closingDown();
2177 2177
2178 mCalendar->close(); 2178 mCalendar->close();
2179 setModified(false); 2179 setModified(false);
2180 updateView(); 2180 updateView();
2181} 2181}
2182 2182
2183void CalendarView::archiveCalendar() 2183void CalendarView::archiveCalendar()
2184{ 2184{
2185 mDialogManager->showArchiveDialog(); 2185 mDialogManager->showArchiveDialog();
2186} 2186}
2187 2187
2188 2188
2189void CalendarView::readSettings() 2189void CalendarView::readSettings()
2190{ 2190{
2191 2191
2192 2192
2193 // mViewManager->showAgendaView(); 2193 // mViewManager->showAgendaView();
2194 QString str; 2194 QString str;
2195 //qDebug("CalendarView::readSettings() "); 2195 //qDebug("CalendarView::readSettings() ");
2196 // read settings from the KConfig, supplying reasonable 2196 // read settings from the KConfig, supplying reasonable
2197 // defaults where none are to be found 2197 // defaults where none are to be found
2198 KConfig *config = KOGlobals::config(); 2198 KConfig *config = KOGlobals::config();
2199#ifndef KORG_NOSPLITTER 2199#ifndef KORG_NOSPLITTER
2200 config->setGroup("KOrganizer Geometry"); 2200 config->setGroup("KOrganizer Geometry");
2201 2201
2202 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2202 QValueList<int> sizes = config->readIntListEntry("Separator1");
2203 if (sizes.count() != 2) { 2203 if (sizes.count() != 2) {
2204 sizes << mDateNavigator->minimumSizeHint().width(); 2204 sizes << mDateNavigator->minimumSizeHint().width();
2205 sizes << 300; 2205 sizes << 300;
2206 } 2206 }
2207 mPanner->setSizes(sizes); 2207 mPanner->setSizes(sizes);
2208 2208
2209 sizes = config->readIntListEntry("Separator2"); 2209 sizes = config->readIntListEntry("Separator2");
2210 if ( ( mResourceView && sizes.count() == 4 ) || 2210 if ( ( mResourceView && sizes.count() == 4 ) ||
2211 ( !mResourceView && sizes.count() == 3 ) ) { 2211 ( !mResourceView && sizes.count() == 3 ) ) {
2212 mLeftSplitter->setSizes(sizes); 2212 mLeftSplitter->setSizes(sizes);
2213 } 2213 }
2214#endif 2214#endif
2215 globalFlagBlockAgenda = 1; 2215 globalFlagBlockAgenda = 1;
2216 mViewManager->showAgendaView(); 2216 mViewManager->showAgendaView();
2217 //mViewManager->readSettings( config ); 2217 //mViewManager->readSettings( config );
2218 mTodoList->restoreLayout(config,QString("Todo Layout")); 2218 mTodoList->restoreLayout(config,QString("Todo Layout"));
2219 readFilterSettings(config); 2219 readFilterSettings(config);
2220 2220
2221#ifdef DESKTOP_VERSION 2221#ifdef DESKTOP_VERSION
2222 config->setGroup("WidgetLayout"); 2222 config->setGroup("WidgetLayout");
2223 QStringList list; 2223 QStringList list;
2224 list = config->readListEntry("MainLayout"); 2224 list = config->readListEntry("MainLayout");
2225 int x,y,w,h; 2225 int x,y,w,h;
2226 if ( ! list.isEmpty() ) { 2226 if ( ! list.isEmpty() ) {
2227 x = list[0].toInt(); 2227 x = list[0].toInt();
2228 y = list[1].toInt(); 2228 y = list[1].toInt();
2229 w = list[2].toInt(); 2229 w = list[2].toInt();
2230 h = list[3].toInt(); 2230 h = list[3].toInt();
2231 KApplication::testCoords( &x,&y,&w,&h ); 2231 KApplication::testCoords( &x,&y,&w,&h );
2232 topLevelWidget()->setGeometry(x,y,w,h); 2232 topLevelWidget()->setGeometry(x,y,w,h);
2233 2233
2234 } else { 2234 } else {
2235 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2235 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2236 } 2236 }
2237 list = config->readListEntry("EditEventLayout"); 2237 list = config->readListEntry("EditEventLayout");
2238 if ( ! list.isEmpty() ) { 2238 if ( ! list.isEmpty() ) {
2239 x = list[0].toInt(); 2239 x = list[0].toInt();
2240 y = list[1].toInt(); 2240 y = list[1].toInt();
2241 w = list[2].toInt(); 2241 w = list[2].toInt();
2242 h = list[3].toInt(); 2242 h = list[3].toInt();
2243 KApplication::testCoords( &x,&y,&w,&h ); 2243 KApplication::testCoords( &x,&y,&w,&h );
2244 mEventEditor->setGeometry(x,y,w,h); 2244 mEventEditor->setGeometry(x,y,w,h);
2245 2245
2246 } 2246 }
2247 list = config->readListEntry("EditTodoLayout"); 2247 list = config->readListEntry("EditTodoLayout");
2248 if ( ! list.isEmpty() ) { 2248 if ( ! list.isEmpty() ) {
2249 x = list[0].toInt(); 2249 x = list[0].toInt();
2250 y = list[1].toInt(); 2250 y = list[1].toInt();
2251 w = list[2].toInt(); 2251 w = list[2].toInt();
2252 h = list[3].toInt(); 2252 h = list[3].toInt();
2253 KApplication::testCoords( &x,&y,&w,&h ); 2253 KApplication::testCoords( &x,&y,&w,&h );
2254 mTodoEditor->setGeometry(x,y,w,h); 2254 mTodoEditor->setGeometry(x,y,w,h);
2255 2255
2256 } 2256 }
2257 list = config->readListEntry("ViewerLayout"); 2257 list = config->readListEntry("ViewerLayout");
2258 if ( ! list.isEmpty() ) { 2258 if ( ! list.isEmpty() ) {
2259 x = list[0].toInt(); 2259 x = list[0].toInt();
2260 y = list[1].toInt(); 2260 y = list[1].toInt();
2261 w = list[2].toInt(); 2261 w = list[2].toInt();
2262 h = list[3].toInt(); 2262 h = list[3].toInt();
2263 KApplication::testCoords( &x,&y,&w,&h ); 2263 KApplication::testCoords( &x,&y,&w,&h );
2264 getEventViewerDialog()->setGeometry(x,y,w,h); 2264 getEventViewerDialog()->setGeometry(x,y,w,h);
2265 } 2265 }
2266#endif 2266#endif
2267 config->setGroup( "Views" ); 2267 config->setGroup( "Views" );
2268 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2268 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2269 2269
2270 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2270 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2271 2271
2272 int resetval = 0; 2272 int resetval = 0;
2273 int maxVal = 0; 2273 int maxVal = 0;
2274 if (sizes.count() != 3) { 2274 if (sizes.count() != 3) {
2275 if ( KOPrefs::instance()->mVerticalScreen ) { 2275 if ( KOPrefs::instance()->mVerticalScreen ) {
2276 resetval = mDateNavigator->sizeHint().width()+2; 2276 resetval = mDateNavigator->sizeHint().width()+2;
2277 } else { 2277 } else {
2278 resetval = mDateNavigator->sizeHint().height()+2; 2278 resetval = mDateNavigator->sizeHint().height()+2;
2279 } 2279 }
2280 } 2280 }
2281 if ( resetval ) { 2281 if ( resetval ) {
2282 sizes.clear(); 2282 sizes.clear();
2283 if ( KOPrefs::instance()->mVerticalScreen ) { 2283 if ( KOPrefs::instance()->mVerticalScreen ) {
2284 maxVal = QApplication::desktop()->width() -10; 2284 maxVal = QApplication::desktop()->width() -10;
2285 } else { 2285 } else {
2286 maxVal = QApplication::desktop()->height()-10; 2286 maxVal = QApplication::desktop()->height()-10;
2287 } 2287 }
2288 sizes << resetval; 2288 sizes << resetval;
2289 if ( maxVal < resetval + resetval) 2289 if ( maxVal < resetval + resetval)
2290 resetval = maxVal - resetval; 2290 resetval = maxVal - resetval;
2291 sizes << resetval; 2291 sizes << resetval;
2292 sizes << 100; 2292 sizes << 100;
2293 } 2293 }
2294 mLeftFrame->setSizes(sizes); 2294 mLeftFrame->setSizes(sizes);
2295 sizes = config->readIntListEntry("Main Splitter Frame"); 2295 sizes = config->readIntListEntry("Main Splitter Frame");
2296 resetval = 0; 2296 resetval = 0;
2297 maxVal = 0; 2297 maxVal = 0;
2298 if (sizes.count() != 2) { 2298 if (sizes.count() != 2) {
2299 if ( !KOPrefs::instance()->mVerticalScreen ) { 2299 if ( !KOPrefs::instance()->mVerticalScreen ) {
2300 resetval = mDateNavigator->sizeHint().width()+2; 2300 resetval = mDateNavigator->sizeHint().width()+2;
2301 } else { 2301 } else {
2302 resetval = mDateNavigator->sizeHint().height()+2; 2302 resetval = mDateNavigator->sizeHint().height()+2;
2303 } 2303 }
2304 } 2304 }
2305 if ( resetval ) { 2305 if ( resetval ) {
2306 sizes.clear(); 2306 sizes.clear();
2307 if ( !KOPrefs::instance()->mVerticalScreen ) { 2307 if ( !KOPrefs::instance()->mVerticalScreen ) {
2308 maxVal = QApplication::desktop()->width() -10; 2308 maxVal = QApplication::desktop()->width() -10;
2309 } else { 2309 } else {
2310 maxVal = QApplication::desktop()->height()-10; 2310 maxVal = QApplication::desktop()->height()-10;
2311 } 2311 }
2312 sizes << resetval; 2312 sizes << resetval;
2313 if ( maxVal < resetval + resetval) 2313 if ( maxVal < resetval + resetval)
2314 resetval = maxVal - resetval; 2314 resetval = maxVal - resetval;
2315 sizes << resetval; 2315 sizes << resetval;
2316 } 2316 }
2317 mMainFrame->setSizes(sizes); 2317 mMainFrame->setSizes(sizes);
2318 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2318 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2319 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2319 else if ( dateCount == 7 ) mNavigator->selectWeek();
2320 else mNavigator->selectDates( dateCount ); 2320 else mNavigator->selectDates( dateCount );
2321 // mViewManager->readSettings( config ); 2321 // mViewManager->readSettings( config );
2322 updateConfig(); 2322 updateConfig();
2323 globalFlagBlockAgenda = 2; 2323 globalFlagBlockAgenda = 2;
2324 mViewManager->readSettings( config ); 2324 mViewManager->readSettings( config );
2325 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2325 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2326} 2326}
2327 2327
2328void CalendarView::checkSuspendAlarm() 2328void CalendarView::checkSuspendAlarm()
2329{ 2329{
2330 if ( mSuspendTimer->isActive() ) { 2330 if ( mSuspendTimer->isActive() ) {
2331 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2331 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2332 } 2332 }
2333} 2333}
2334void CalendarView::writeSettings() 2334void CalendarView::writeSettings()
2335{ 2335{
2336 // kdDebug() << "CalendarView::writeSettings" << endl; 2336 // kdDebug() << "CalendarView::writeSettings" << endl;
2337 2337
2338 KConfig *config = KOGlobals::config(); 2338 KConfig *config = KOGlobals::config();
2339 2339
2340 mViewManager->writeSettings( config ); 2340 mViewManager->writeSettings( config );
2341 mTodoList->saveLayout(config,QString("Todo Layout")); 2341 mTodoList->saveLayout(config,QString("Todo Layout"));
2342 mDialogManager->writeSettings( config ); 2342 mDialogManager->writeSettings( config );
2343 //KOPrefs::instance()->usrWriteConfig(); 2343 //KOPrefs::instance()->usrWriteConfig();
2344 KOPrefs::instance()->writeConfig(); 2344 KOPrefs::instance()->writeConfig();
2345 2345
2346 writeFilterSettings(config); 2346 writeFilterSettings(config);
2347 config->setGroup( "AppRun" ); 2347 config->setGroup( "AppRun" );
2348 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2348 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2349 int days = dt.daysTo( QDate::currentDate() ); 2349 int days = dt.daysTo( QDate::currentDate() );
2350 dt = dt.addDays( days ); 2350 dt = dt.addDays( days );
2351 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2351 int secs = dt.secsTo( QDateTime::currentDateTime() );
2352 config->writeEntry( "LatestProgramStopDays", days ); 2352 config->writeEntry( "LatestProgramStopDays", days );
2353 config->writeEntry( "LatestProgramStopSecs", secs ); 2353 config->writeEntry( "LatestProgramStopSecs", secs );
2354 //qDebug("KO: Writing stop time: %d ", secs); 2354 //qDebug("KO: Writing stop time: %d ", secs);
2355 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2355 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2356 //QDateTime latest = dt.addSecs ( secs ); 2356 //QDateTime latest = dt.addSecs ( secs );
2357 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2357 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2358 config->setGroup( "Views" ); 2358 config->setGroup( "Views" );
2359 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2359 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2360 2360
2361#if 0 2361#if 0
2362 qDebug("********************* "); 2362 qDebug("********************* ");
2363 qDebug("Testcode secsto "); 2363 qDebug("Testcode secsto ");
2364 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2364 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2365 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2365 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2366 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2366 int secsto = dt_nodaylight.secsTo( dt_daylight );
2367 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2367 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2368 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2368 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2369 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2369 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2370 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2370 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2371 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2371 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2372 qDebug("********************* testcode end"); 2372 qDebug("********************* testcode end");
2373 2373
2374#endif 2374#endif
2375 2375
2376 QValueList<int> listINT = mLeftFrame->sizes(); 2376 QValueList<int> listINT = mLeftFrame->sizes();
2377 config->writeEntry("Left Splitter Frame",listINT); 2377 config->writeEntry("Left Splitter Frame",listINT);
2378 QValueList<int> listINT2 = mMainFrame->sizes(); 2378 QValueList<int> listINT2 = mMainFrame->sizes();
2379 config->writeEntry("Main Splitter Frame",listINT2); 2379 config->writeEntry("Main Splitter Frame",listINT2);
2380#ifdef DESKTOP_VERSION 2380#ifdef DESKTOP_VERSION
2381 config->setGroup("WidgetLayout"); 2381 config->setGroup("WidgetLayout");
2382 QStringList list ;//= config->readListEntry("MainLayout"); 2382 QStringList list ;//= config->readListEntry("MainLayout");
2383 int x,y,w,h; 2383 int x,y,w,h;
2384 QWidget* wid; 2384 QWidget* wid;
2385 wid = topLevelWidget(); 2385 wid = topLevelWidget();
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("MainLayout",list ); 2395 config->writeEntry("MainLayout",list );
2396 2396
2397 wid = mEventEditor; 2397 wid = mEventEditor;
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("EditEventLayout",list ); 2407 config->writeEntry("EditEventLayout",list );
2408 2408
2409 wid = mTodoEditor; 2409 wid = mTodoEditor;
2410 x = wid->geometry().x(); 2410 x = wid->geometry().x();
2411 y = wid->geometry().y(); 2411 y = wid->geometry().y();
2412 w = wid->width(); 2412 w = wid->width();
2413 h = wid->height(); 2413 h = wid->height();
2414 list.clear(); 2414 list.clear();
2415 list << QString::number( x ); 2415 list << QString::number( x );
2416 list << QString::number( y ); 2416 list << QString::number( y );
2417 list << QString::number( w ); 2417 list << QString::number( w );
2418 list << QString::number( h ); 2418 list << QString::number( h );
2419 config->writeEntry("EditTodoLayout",list ); 2419 config->writeEntry("EditTodoLayout",list );
2420 wid = getEventViewerDialog(); 2420 wid = getEventViewerDialog();
2421 x = wid->geometry().x(); 2421 x = wid->geometry().x();
2422 y = wid->geometry().y(); 2422 y = wid->geometry().y();
2423 w = wid->width(); 2423 w = wid->width();
2424 h = wid->height(); 2424 h = wid->height();
2425 list.clear(); 2425 list.clear();
2426 list << QString::number( x ); 2426 list << QString::number( x );
2427 list << QString::number( y ); 2427 list << QString::number( y );
2428 list << QString::number( w ); 2428 list << QString::number( w );
2429 list << QString::number( h ); 2429 list << QString::number( h );
2430 config->writeEntry("ViewerLayout",list ); 2430 config->writeEntry("ViewerLayout",list );
2431 wid = mDialogManager->getSearchDialog(); 2431 wid = mDialogManager->getSearchDialog();
2432 if ( wid ) { 2432 if ( wid ) {
2433 x = wid->geometry().x(); 2433 x = wid->geometry().x();
2434 y = wid->geometry().y(); 2434 y = wid->geometry().y();
2435 w = wid->width(); 2435 w = wid->width();
2436 h = wid->height(); 2436 h = wid->height();
2437 list.clear(); 2437 list.clear();
2438 list << QString::number( x ); 2438 list << QString::number( x );
2439 list << QString::number( y ); 2439 list << QString::number( y );
2440 list << QString::number( w ); 2440 list << QString::number( w );
2441 list << QString::number( h ); 2441 list << QString::number( h );
2442 config->writeEntry("SearchLayout",list ); 2442 config->writeEntry("SearchLayout",list );
2443 } 2443 }
2444#endif 2444#endif
2445 2445
2446 2446
2447 config->sync(); 2447 config->sync();
2448} 2448}
2449 2449
2450void CalendarView::readFilterSettings(KConfig *config) 2450void CalendarView::readFilterSettings(KConfig *config)
2451{ 2451{
2452 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2452 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2453 2453
2454 mFilters.clear(); 2454 mFilters.clear();
2455 2455
2456 config->setGroup("General"); 2456 config->setGroup("General");
2457 QStringList filterList = config->readListEntry("CalendarFilters"); 2457 QStringList filterList = config->readListEntry("CalendarFilters");
2458 2458
2459 QStringList::ConstIterator it = filterList.begin(); 2459 QStringList::ConstIterator it = filterList.begin();
2460 QStringList::ConstIterator end = filterList.end(); 2460 QStringList::ConstIterator end = filterList.end();
2461 while(it != end) { 2461 while(it != end) {
2462 // kdDebug() << " filter: " << (*it) << endl; 2462 // kdDebug() << " filter: " << (*it) << endl;
2463 2463
2464 CalFilter *filter; 2464 CalFilter *filter;
2465 filter = new CalFilter(*it); 2465 filter = new CalFilter(*it);
2466 config->setGroup("Filter_" + (*it).utf8()); 2466 config->setGroup("Filter_" + (*it).utf8());
2467 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2467 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2468 filter->setCriteria(config->readNumEntry("Criteria",0)); 2468 filter->setCriteria(config->readNumEntry("Criteria",0));
2469 filter->setCategoryList(config->readListEntry("CategoryList")); 2469 filter->setCategoryList(config->readListEntry("CategoryList"));
2470 mFilters.append(filter); 2470 mFilters.append(filter);
2471 2471
2472 ++it; 2472 ++it;
2473 } 2473 }
2474 2474
2475 if (mFilters.count() == 0) { 2475 if (mFilters.count() == 0) {
2476 CalFilter *filter = new CalFilter(i18n("Default")); 2476 CalFilter *filter = new CalFilter(i18n("Default"));
2477 mFilters.append(filter); 2477 mFilters.append(filter);
2478 } 2478 }
2479 mFilterView->updateFilters(); 2479 mFilterView->updateFilters();
2480 config->setGroup("FilterView"); 2480 config->setGroup("FilterView");
2481 2481
2482 mFilterView->blockSignals(true); 2482 mFilterView->blockSignals(true);
2483 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2483 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2484 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2484 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2485 mFilterView->blockSignals(false); 2485 mFilterView->blockSignals(false);
2486 // We do it manually to avoid it being done twice by the above calls 2486 // We do it manually to avoid it being done twice by the above calls
2487 updateFilter(); 2487 updateFilter();
2488} 2488}
2489 2489
2490void CalendarView::writeFilterSettings(KConfig *config) 2490void CalendarView::writeFilterSettings(KConfig *config)
2491{ 2491{
2492 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2492 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2493 2493
2494 QStringList filterList; 2494 QStringList filterList;
2495 2495
2496 CalFilter *filter = mFilters.first(); 2496 CalFilter *filter = mFilters.first();
2497 while(filter) { 2497 while(filter) {
2498 // kdDebug() << " fn: " << filter->name() << endl; 2498 // kdDebug() << " fn: " << filter->name() << endl;
2499 filterList << filter->name(); 2499 filterList << filter->name();
2500 config->setGroup("Filter_" + filter->name().utf8()); 2500 config->setGroup("Filter_" + filter->name().utf8());
2501 config->writeEntry("Criteria",filter->criteria()); 2501 config->writeEntry("Criteria",filter->criteria());
2502 config->writeEntry("CategoryList",filter->categoryList()); 2502 config->writeEntry("CategoryList",filter->categoryList());
2503 filter = mFilters.next(); 2503 filter = mFilters.next();
2504 } 2504 }
2505 config->setGroup("General"); 2505 config->setGroup("General");
2506 config->writeEntry("CalendarFilters",filterList); 2506 config->writeEntry("CalendarFilters",filterList);
2507 2507
2508 config->setGroup("FilterView"); 2508 config->setGroup("FilterView");
2509 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2509 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2510 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2510 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2511} 2511}
2512 2512
2513 2513
2514void CalendarView::goToday() 2514void CalendarView::goToday()
2515{ 2515{
2516 if ( mViewManager->currentView()->isMonthView() ) 2516 if ( mViewManager->currentView()->isMonthView() )
2517 mNavigator->selectTodayMonth(); 2517 mNavigator->selectTodayMonth();
2518 else 2518 else
2519 mNavigator->selectToday(); 2519 mNavigator->selectToday();
2520} 2520}
2521 2521
2522void CalendarView::goNext() 2522void CalendarView::goNext()
2523{ 2523{
2524 mNavigator->selectNext(); 2524 mNavigator->selectNext();
2525} 2525}
2526 2526
2527void CalendarView::goPrevious() 2527void CalendarView::goPrevious()
2528{ 2528{
2529 mNavigator->selectPrevious(); 2529 mNavigator->selectPrevious();
2530} 2530}
2531void CalendarView::goNextMonth() 2531void CalendarView::goNextMonth()
2532{ 2532{
2533 mNavigator->selectNextMonth(); 2533 mNavigator->selectNextMonth();
2534} 2534}
2535 2535
2536void CalendarView::goPreviousMonth() 2536void CalendarView::goPreviousMonth()
2537{ 2537{
2538 mNavigator->selectPreviousMonth(); 2538 mNavigator->selectPreviousMonth();
2539} 2539}
2540 2540
2541void CalendarView::updateConfig() 2541void CalendarView::updateConfig()
2542{ 2542{
2543 if ( KOPrefs::instance()->mUseAppColors ) 2543 if ( KOPrefs::instance()->mUseAppColors )
2544 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2544 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2545 emit configChanged(); 2545 emit configChanged();
2546 mTodoList->updateConfig(); 2546 mTodoList->updateConfig();
2547 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2547 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2548 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2548 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2549 // To make the "fill window" configurations work 2549 // To make the "fill window" configurations work
2550 //mViewManager->raiseCurrentView(); 2550 //mViewManager->raiseCurrentView();
2551} 2551}
2552 2552
2553 2553
2554void CalendarView::eventChanged(Event *event) 2554void CalendarView::eventChanged(Event *event)
2555{ 2555{
2556 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2556 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2557 //updateUnmanagedViews(); 2557 //updateUnmanagedViews();
2558} 2558}
2559 2559
2560void CalendarView::eventAdded(Event *event) 2560void CalendarView::eventAdded(Event *event)
2561{ 2561{
2562 changeEventDisplay(event,KOGlobals::EVENTADDED); 2562 changeEventDisplay(event,KOGlobals::EVENTADDED);
2563} 2563}
2564 2564
2565void CalendarView::eventToBeDeleted(Event *) 2565void CalendarView::eventToBeDeleted(Event *)
2566{ 2566{
2567 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2567 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2568} 2568}
2569 2569
2570void CalendarView::eventDeleted() 2570void CalendarView::eventDeleted()
2571{ 2571{
2572 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2572 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2573} 2573}
2574void CalendarView::changeTodoDisplay(Todo *which, int action) 2574void CalendarView::changeTodoDisplay(Todo *which, int action)
2575{ 2575{
2576 changeIncidenceDisplay((Incidence *)which, action); 2576 changeIncidenceDisplay((Incidence *)which, action);
2577 mDateNavigator->updateView(); //LR 2577 mDateNavigator->updateView(); //LR
2578 //mDialogManager->updateSearchDialog(); 2578 //mDialogManager->updateSearchDialog();
2579 2579
2580 if (which) { 2580 if (which) {
2581 mViewManager->updateWNview(); 2581 mViewManager->updateWNview();
2582 //mTodoList->updateView(); 2582 //mTodoList->updateView();
2583 } 2583 }
2584 2584
2585} 2585}
2586 2586
2587void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2587void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2588{ 2588{
2589 updateUnmanagedViews(); 2589 updateUnmanagedViews();
2590 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2590 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2591 if ( action == KOGlobals::EVENTDELETED ) { //delete 2591 if ( action == KOGlobals::EVENTDELETED ) { //delete
2592 mCalendar->checkAlarmForIncidence( 0, true ); 2592 mCalendar->checkAlarmForIncidence( 0, true );
2593 if ( mEventViewerDialog ) 2593 if ( mEventViewerDialog )
2594 mEventViewerDialog->hide(); 2594 mEventViewerDialog->hide();
2595 } 2595 }
2596 else 2596 else
2597 mCalendar->checkAlarmForIncidence( which , false ); 2597 mCalendar->checkAlarmForIncidence( which , false );
2598} 2598}
2599 2599
2600// most of the changeEventDisplays() right now just call the view's 2600// most of the changeEventDisplays() right now just call the view's
2601// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2601// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2602void CalendarView::changeEventDisplay(Event *which, int action) 2602void CalendarView::changeEventDisplay(Event *which, int action)
2603{ 2603{
2604 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2604 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2605 changeIncidenceDisplay((Incidence *)which, action); 2605 changeIncidenceDisplay((Incidence *)which, action);
2606 mDateNavigator->updateView(); 2606 mDateNavigator->updateView();
2607 //mDialogManager->updateSearchDialog(); 2607 //mDialogManager->updateSearchDialog();
2608 2608
2609 if (which) { 2609 if (which) {
2610 // If there is an event view visible update the display 2610 // If there is an event view visible update the display
2611 mViewManager->currentView()->changeEventDisplay(which,action); 2611 mViewManager->currentView()->changeEventDisplay(which,action);
2612 // TODO: check, if update needed 2612 // TODO: check, if update needed
2613 // if (which->getTodoStatus()) { 2613 // if (which->getTodoStatus()) {
2614 mTodoList->updateView(); 2614 mTodoList->updateView();
2615 // } 2615 // }
2616 } else { 2616 } else {
2617 mViewManager->currentView()->updateView(); 2617 mViewManager->currentView()->updateView();
2618 } 2618 }
2619} 2619}
2620 2620
2621 2621
2622void CalendarView::updateTodoViews() 2622void CalendarView::updateTodoViews()
2623{ 2623{
2624 mTodoList->updateView(); 2624 mTodoList->updateView();
2625 mViewManager->currentView()->updateView(); 2625 mViewManager->currentView()->updateView();
2626 2626
2627} 2627}
2628 2628
2629 2629
2630void CalendarView::updateView(const QDate &start, const QDate &end) 2630void CalendarView::updateView(const QDate &start, const QDate &end)
2631{ 2631{
2632#ifdef DESKTOP_VERSION 2632#ifdef DESKTOP_VERSION
2633 mDateScrollBar->blockSignals( true ); 2633 if ( ! mDateScrollBar->draggingSlider () ) {
2634 mDateScrollBar->setValue( start.dayOfYear()-1); 2634 int dof = start.dayOfYear()-1;
2635 mDateScrollBar->blockSignals( false ); 2635 if ( dof != mDateScrollBar->value() ) {
2636 mDateScrollBar->blockSignals( true );
2637 mDateScrollBar->setValue( start.dayOfYear()-1);
2638 mDateScrollBar->blockSignals( false );
2639 }
2640 }
2636#endif 2641#endif
2637 mTodoList->updateView(); 2642 mTodoList->updateView();
2638 mViewManager->updateView(start, end); 2643 mViewManager->updateView(start, end);
2639 //mDateNavigator->updateView(); 2644 //mDateNavigator->updateView();
2640} 2645}
2641 2646
2642void CalendarView::clearAllViews() 2647void CalendarView::clearAllViews()
2643{ 2648{
2644 mTodoList->clearList(); 2649 mTodoList->clearList();
2645 mViewManager->clearAllViews(); 2650 mViewManager->clearAllViews();
2646 SearchDialog * sd = mDialogManager->getSearchDialog(); 2651 SearchDialog * sd = mDialogManager->getSearchDialog();
2647 if ( sd ) { 2652 if ( sd ) {
2648 KOListView* kol = sd->listview(); 2653 KOListView* kol = sd->listview();
2649 if ( kol ) 2654 if ( kol )
2650 kol->clearList(); 2655 kol->clearList();
2651 } 2656 }
2652} 2657}
2653void CalendarView::updateView() 2658void CalendarView::updateView()
2654{ 2659{
2655 DateList tmpList = mNavigator->selectedDates(); 2660 DateList tmpList = mNavigator->selectedDates();
2656 2661
2657 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2662 if ( KOPrefs::instance()->mHideNonStartedTodos )
2658 mTodoList->updateView(); 2663 mTodoList->updateView();
2659 // We assume that the navigator only selects consecutive days. 2664 // We assume that the navigator only selects consecutive days.
2660 updateView( tmpList.first(), tmpList.last() ); 2665 updateView( tmpList.first(), tmpList.last() );
2661} 2666}
2662 2667
2663void CalendarView::updateUnmanagedViews() 2668void CalendarView::updateUnmanagedViews()
2664{ 2669{
2665 mDateNavigator->updateDayMatrix(); 2670 mDateNavigator->updateDayMatrix();
2666} 2671}
2667 2672
2668int CalendarView::msgItemDelete(const QString name) 2673int CalendarView::msgItemDelete(const QString name)
2669{ 2674{
2670 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2675 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2671 i18n("This item will be\npermanently deleted."), 2676 i18n("This item will be\npermanently deleted."),
2672 i18n("KO/Pi Confirmation"),i18n("Delete")); 2677 i18n("KO/Pi Confirmation"),i18n("Delete"));
2673} 2678}
2674 2679
2675 2680
2676void CalendarView::edit_cut() 2681void CalendarView::edit_cut()
2677{ 2682{
2678 Event *anEvent=0; 2683 Event *anEvent=0;
2679 2684
2680 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2685 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2681 2686
2682 if (mViewManager->currentView()->isEventView()) { 2687 if (mViewManager->currentView()->isEventView()) {
2683 if ( incidence && incidence->typeID() == eventID ) { 2688 if ( incidence && incidence->typeID() == eventID ) {
2684 anEvent = static_cast<Event *>(incidence); 2689 anEvent = static_cast<Event *>(incidence);
2685 } 2690 }
2686 } 2691 }
2687 2692
2688 if (!anEvent) { 2693 if (!anEvent) {
2689 KNotifyClient::beep(); 2694 KNotifyClient::beep();
2690 return; 2695 return;
2691 } 2696 }
2692 DndFactory factory( mCalendar ); 2697 DndFactory factory( mCalendar );
2693 factory.cutIncidence(anEvent); 2698 factory.cutIncidence(anEvent);
2694 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2699 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2695} 2700}
2696 2701
2697void CalendarView::edit_copy() 2702void CalendarView::edit_copy()
2698{ 2703{
2699 Event *anEvent=0; 2704 Event *anEvent=0;
2700 2705
2701 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2706 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2702 2707
2703 if (mViewManager->currentView()->isEventView()) { 2708 if (mViewManager->currentView()->isEventView()) {
2704 if ( incidence && incidence->typeID() == eventID ) { 2709 if ( incidence && incidence->typeID() == eventID ) {
2705 anEvent = static_cast<Event *>(incidence); 2710 anEvent = static_cast<Event *>(incidence);
2706 } 2711 }
2707 } 2712 }
2708 2713
2709 if (!anEvent) { 2714 if (!anEvent) {
2710 KNotifyClient::beep(); 2715 KNotifyClient::beep();
2711 return; 2716 return;
2712 } 2717 }
2713 DndFactory factory( mCalendar ); 2718 DndFactory factory( mCalendar );
2714 factory.copyIncidence(anEvent); 2719 factory.copyIncidence(anEvent);
2715} 2720}
2716 2721
2717void CalendarView::edit_paste() 2722void CalendarView::edit_paste()
2718{ 2723{
2719 QDate date = mNavigator->selectedDates().first(); 2724 QDate date = mNavigator->selectedDates().first();
2720 2725
2721 DndFactory factory( mCalendar ); 2726 DndFactory factory( mCalendar );
2722 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2727 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2723 2728
2724 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2729 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2725} 2730}
2726void CalendarView::edit_global_options() 2731void CalendarView::edit_global_options()
2727{ 2732{
2728 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2733 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2729 emit save(); 2734 emit save();
2730 emit saveStopTimer(); 2735 emit saveStopTimer();
2731 mDialogManager->showGlobalOptionsDialog(); 2736 mDialogManager->showGlobalOptionsDialog();
2732 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2737 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2733 emit saveStopTimer(); 2738 emit saveStopTimer();
2734 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!"), 2739 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!"),
2735 i18n("Timezone settings"),i18n("Reload"))) { 2740 i18n("Timezone settings"),i18n("Reload"))) {
2736 qDebug("KO: TZ reload cancelled "); 2741 qDebug("KO: TZ reload cancelled ");
2737 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2742 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2738 return; 2743 return;
2739 } 2744 }
2740 qDebug("KO: Timezone change "); 2745 qDebug("KO: Timezone change ");
2741 loadCalendars(); 2746 loadCalendars();
2742 setModified(true); 2747 setModified(true);
2743 } 2748 }
2744 else 2749 else
2745 qDebug("KO: No tz change "); 2750 qDebug("KO: No tz change ");
2746} 2751}
2747void CalendarView::edit_options() 2752void CalendarView::edit_options()
2748{ 2753{
2749 mDialogManager->showOptionsDialog(); 2754 mDialogManager->showOptionsDialog();
2750} 2755}
2751 2756
2752 2757
2753void CalendarView::slotSelectPickerDate( QDate d) 2758void CalendarView::slotSelectPickerDate( QDate d)
2754{ 2759{
2755 mDateFrame->hide(); 2760 mDateFrame->hide();
2756 if ( mDatePickerMode == 1 ) { 2761 if ( mDatePickerMode == 1 ) {
2757 mNavigator->slotDaySelect( d ); 2762 mNavigator->slotDaySelect( d );
2758 } else if ( mDatePickerMode == 2 ) { 2763 } else if ( mDatePickerMode == 2 ) {
2759 if ( mMoveIncidence->typeID() == todoID ) { 2764 if ( mMoveIncidence->typeID() == todoID ) {
2760 Todo * to = (Todo *) mMoveIncidence; 2765 Todo * to = (Todo *) mMoveIncidence;
2761 QTime tim; 2766 QTime tim;
2762 int len = 0; 2767 int len = 0;
2763 if ( to->hasStartDate() && to->hasDueDate() ) 2768 if ( to->hasStartDate() && to->hasDueDate() )
2764 len = to->dtStart().secsTo( to->dtDue()); 2769 len = to->dtStart().secsTo( to->dtDue());
2765 if ( to->hasDueDate() ) 2770 if ( to->hasDueDate() )
2766 tim = to->dtDue().time(); 2771 tim = to->dtDue().time();
2767 else { 2772 else {
2768 tim = QTime ( 0,0,0 ); 2773 tim = QTime ( 0,0,0 );
2769 to->setFloats( true ); 2774 to->setFloats( true );
2770 to->setHasDueDate( true ); 2775 to->setHasDueDate( true );
2771 } 2776 }
2772 QDateTime dt ( d,tim ); 2777 QDateTime dt ( d,tim );
2773 to->setDtDue( dt ); 2778 to->setDtDue( dt );
2774 2779
2775 if ( to->hasStartDate() ) { 2780 if ( to->hasStartDate() ) {
2776 if ( len>0 ) 2781 if ( len>0 )
2777 to->setDtStart(to->dtDue().addSecs( -len )); 2782 to->setDtStart(to->dtDue().addSecs( -len ));
2778 else 2783 else
2779 if (to->dtStart() > to->dtDue() ) 2784 if (to->dtStart() > to->dtDue() )
2780 to->setDtStart(to->dtDue().addDays( -3 )); 2785 to->setDtStart(to->dtDue().addDays( -3 ));
2781 } 2786 }
2782 2787
2783 todoChanged( to ); 2788 todoChanged( to );
2784 } else { 2789 } else {
2785 if ( mMoveIncidence->doesRecur() ) { 2790 if ( mMoveIncidence->doesRecur() ) {
2786#if 0 2791#if 0
2787 // PENDING implement this 2792 // PENDING implement this
2788 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2793 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2789 mCalendar()->addIncidence( newInc ); 2794 mCalendar()->addIncidence( newInc );
2790 if ( mMoveIncidence->typeID() == todoID ) 2795 if ( mMoveIncidence->typeID() == todoID )
2791 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2796 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2792 else 2797 else
2793 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2798 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2794 mMoveIncidence = newInc; 2799 mMoveIncidence = newInc;
2795 2800
2796#endif 2801#endif
2797 } 2802 }
2798 QTime tim = mMoveIncidence->dtStart().time(); 2803 QTime tim = mMoveIncidence->dtStart().time();
2799 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2804 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2800 QDateTime dt ( d,tim ); 2805 QDateTime dt ( d,tim );
2801 mMoveIncidence->setDtStart( dt ); 2806 mMoveIncidence->setDtStart( dt );
2802 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2807 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2803 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2808 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2804 } 2809 }
2805 2810
2806 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2811 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2807 } 2812 }
2808} 2813}
2809 2814
2810void CalendarView::removeCategories() 2815void CalendarView::removeCategories()
2811{ 2816{
2812 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2817 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2813 QStringList catList = KOPrefs::instance()->mCustomCategories; 2818 QStringList catList = KOPrefs::instance()->mCustomCategories;
2814 QStringList catIncList; 2819 QStringList catIncList;
2815 QStringList newCatList; 2820 QStringList newCatList;
2816 Incidence* inc = incList.first(); 2821 Incidence* inc = incList.first();
2817 uint i; 2822 uint i;
2818 while ( inc ) { 2823 while ( inc ) {
2819 newCatList.clear(); 2824 newCatList.clear();
2820 catIncList = inc->categories() ; 2825 catIncList = inc->categories() ;
2821 for( i = 0; i< catIncList.count(); ++i ) { 2826 for( i = 0; i< catIncList.count(); ++i ) {
2822 if ( catList.contains (catIncList[i])) 2827 if ( catList.contains (catIncList[i]))
2823 newCatList.append( catIncList[i] ); 2828 newCatList.append( catIncList[i] );
2824 } 2829 }
2825 newCatList.sort(); 2830 newCatList.sort();
2826 inc->setCategories( newCatList.join(",") ); 2831 inc->setCategories( newCatList.join(",") );
2827 inc = incList.next(); 2832 inc = incList.next();
2828 } 2833 }
2829} 2834}
2830 2835
2831int CalendarView::addCategories() 2836int CalendarView::addCategories()
2832{ 2837{
2833 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2838 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2834 QStringList catList = KOPrefs::instance()->mCustomCategories; 2839 QStringList catList = KOPrefs::instance()->mCustomCategories;
2835 QStringList catIncList; 2840 QStringList catIncList;
2836 Incidence* inc = incList.first(); 2841 Incidence* inc = incList.first();
2837 uint i; 2842 uint i;
2838 int count = 0; 2843 int count = 0;
2839 while ( inc ) { 2844 while ( inc ) {
2840 catIncList = inc->categories() ; 2845 catIncList = inc->categories() ;
2841 for( i = 0; i< catIncList.count(); ++i ) { 2846 for( i = 0; i< catIncList.count(); ++i ) {
2842 if ( !catList.contains (catIncList[i])) { 2847 if ( !catList.contains (catIncList[i])) {
2843 catList.append( catIncList[i] ); 2848 catList.append( catIncList[i] );
2844 //qDebug("add cat %s ", catIncList[i].latin1()); 2849 //qDebug("add cat %s ", catIncList[i].latin1());
2845 ++count; 2850 ++count;
2846 } 2851 }
2847 } 2852 }
2848 inc = incList.next(); 2853 inc = incList.next();
2849 } 2854 }
2850 catList.sort(); 2855 catList.sort();
2851 KOPrefs::instance()->mCustomCategories = catList; 2856 KOPrefs::instance()->mCustomCategories = catList;
2852 return count; 2857 return count;
2853} 2858}
2854 2859
2855void CalendarView::editCategories() 2860void CalendarView::editCategories()
2856{ 2861{
2857 qDebug("CalendarView::editCategories() "); 2862 qDebug("CalendarView::editCategories() ");
2858 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 2863 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
2859 ced.exec(); 2864 ced.exec();
2860} 2865}
2861void CalendarView::manageCategories() 2866void CalendarView::manageCategories()
2862{ 2867{
2863 KOCatPrefs* cp = new KOCatPrefs(); 2868 KOCatPrefs* cp = new KOCatPrefs();
2864 cp->show(); 2869 cp->show();
2865 int w =cp->sizeHint().width() ; 2870 int w =cp->sizeHint().width() ;
2866 int h = cp->sizeHint().height() ; 2871 int h = cp->sizeHint().height() ;
2867 int dw = QApplication::desktop()->width(); 2872 int dw = QApplication::desktop()->width();
2868 int dh = QApplication::desktop()->height(); 2873 int dh = QApplication::desktop()->height();
2869 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2874 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2870 if ( !cp->exec() ) { 2875 if ( !cp->exec() ) {
2871 delete cp; 2876 delete cp;
2872 return; 2877 return;
2873 } 2878 }
2874 int count = 0; 2879 int count = 0;
2875 if ( cp->addCat() ) { 2880 if ( cp->addCat() ) {
2876 count = addCategories(); 2881 count = addCategories();
2877 if ( count ) { 2882 if ( count ) {
2878 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2883 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2879 writeSettings(); 2884 writeSettings();
2880 } else 2885 } else
2881 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2886 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2882 } else { 2887 } else {
2883 removeCategories(); 2888 removeCategories();
2884 updateView(); 2889 updateView();
2885 } 2890 }
2886 delete cp; 2891 delete cp;
2887} 2892}
2888 2893
2889void CalendarView::beamIncidence(Incidence * Inc) 2894void CalendarView::beamIncidence(Incidence * Inc)
2890{ 2895{
2891 QPtrList<Incidence> delSel ; 2896 QPtrList<Incidence> delSel ;
2892 delSel.append(Inc); 2897 delSel.append(Inc);
2893 beamIncidenceList( delSel ); 2898 beamIncidenceList( delSel );
2894} 2899}
2895void CalendarView::beamCalendar() 2900void CalendarView::beamCalendar()
2896{ 2901{
2897 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2902 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2898 //qDebug("beamCalendar() "); 2903 //qDebug("beamCalendar() ");
2899 beamIncidenceList( delSel ); 2904 beamIncidenceList( delSel );
2900} 2905}
2901void CalendarView::beamFilteredCalendar() 2906void CalendarView::beamFilteredCalendar()
2902{ 2907{
2903 QPtrList<Incidence> delSel = mCalendar->incidences(); 2908 QPtrList<Incidence> delSel = mCalendar->incidences();
2904 //qDebug("beamFilteredCalendar() "); 2909 //qDebug("beamFilteredCalendar() ");
2905 beamIncidenceList( delSel ); 2910 beamIncidenceList( delSel );
2906} 2911}
2907void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2912void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2908{ 2913{
2909 2914
2910 KOBeamPrefs beamDialog; 2915 KOBeamPrefs beamDialog;
2911 if ( beamDialog.exec () == QDialog::Rejected ) 2916 if ( beamDialog.exec () == QDialog::Rejected )
2912 return; 2917 return;
2913#ifdef DESKTOP_VERSION 2918#ifdef DESKTOP_VERSION
2914 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2919 QString fn = locateLocal( "tmp", "kopibeamfile" );
2915#else 2920#else
2916 QString fn = "/tmp/kopibeamfile"; 2921 QString fn = "/tmp/kopibeamfile";
2917#endif 2922#endif
2918 QString mes; 2923 QString mes;
2919 bool createbup = true; 2924 bool createbup = true;
2920 if ( createbup ) { 2925 if ( createbup ) {
2921 QString description = "\n"; 2926 QString description = "\n";
2922 CalendarLocal* cal = new CalendarLocal(); 2927 CalendarLocal* cal = new CalendarLocal();
2923 if ( beamDialog.beamLocal() ) 2928 if ( beamDialog.beamLocal() )
2924 cal->setLocalTime(); 2929 cal->setLocalTime();
2925 else 2930 else
2926 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2931 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2927 Incidence *incidence = delSel.first(); 2932 Incidence *incidence = delSel.first();
2928 bool addText = false; 2933 bool addText = false;
2929 if ( delSel.count() < 10 ) 2934 if ( delSel.count() < 10 )
2930 addText = true; 2935 addText = true;
2931 else { 2936 else {
2932 description.sprintf(i18n(" %d items?"),delSel.count() ); 2937 description.sprintf(i18n(" %d items?"),delSel.count() );
2933 } 2938 }
2934 while ( incidence ) { 2939 while ( incidence ) {
2935 Incidence *in = incidence->clone(); 2940 Incidence *in = incidence->clone();
2936 if ( ! in->summary().isEmpty() ) { 2941 if ( ! in->summary().isEmpty() ) {
2937 in->setDescription(""); 2942 in->setDescription("");
2938 } else { 2943 } else {
2939 in->setSummary( in->description().left(20)); 2944 in->setSummary( in->description().left(20));
2940 in->setDescription(""); 2945 in->setDescription("");
2941 } 2946 }
2942 if ( addText ) 2947 if ( addText )
2943 description += in->summary() + "\n"; 2948 description += in->summary() + "\n";
2944 cal->addIncidence( in ); 2949 cal->addIncidence( in );
2945 incidence = delSel.next(); 2950 incidence = delSel.next();
2946 } 2951 }
2947 if ( beamDialog.beamVcal() ) { 2952 if ( beamDialog.beamVcal() ) {
2948 fn += ".vcs"; 2953 fn += ".vcs";
2949 FileStorage storage( cal, fn, new VCalFormat ); 2954 FileStorage storage( cal, fn, new VCalFormat );
2950 storage.save(); 2955 storage.save();
2951 } else { 2956 } else {
2952 fn += ".ics"; 2957 fn += ".ics";
2953 FileStorage storage( cal, fn, new ICalFormat( ) ); 2958 FileStorage storage( cal, fn, new ICalFormat( ) );
2954 storage.save(); 2959 storage.save();
2955 } 2960 }
2956 delete cal; 2961 delete cal;
2957 mes = i18n("KO/Pi: Ready for beaming"); 2962 mes = i18n("KO/Pi: Ready for beaming");
2958 topLevelWidget()->setCaption(mes); 2963 topLevelWidget()->setCaption(mes);
2959 KApplication::convert2latin1( fn ); 2964 KApplication::convert2latin1( fn );
2960#ifndef DESKTOP_VERSION 2965#ifndef DESKTOP_VERSION
2961 Ir *ir = new Ir( this ); 2966 Ir *ir = new Ir( this );
2962 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2967 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2963 ir->send( fn, description, "text/x-vCalendar" ); 2968 ir->send( fn, description, "text/x-vCalendar" );
2964#endif 2969#endif
2965 } 2970 }
2966} 2971}
2967 2972
2968#ifndef DESKTOP_VERSION 2973#ifndef DESKTOP_VERSION
2969void CalendarView::beamDone( Ir *ir ) 2974void CalendarView::beamDone( Ir *ir )
2970{ 2975{
2971 delete ir; 2976 delete ir;
2972 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2977 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2973 topLevelWidget()->raise(); 2978 topLevelWidget()->raise();
2974} 2979}
2975#else 2980#else
2976void CalendarView::beamDone( Ir *){;} 2981void CalendarView::beamDone( Ir *){;}
2977#endif 2982#endif
2978void CalendarView::moveIncidence(Incidence * inc ) 2983void CalendarView::moveIncidence(Incidence * inc )
2979{ 2984{
2980 if ( !inc ) return; 2985 if ( !inc ) return;
2981 showDatePickerPopup(); 2986 showDatePickerPopup();
2982 mDatePickerMode = 2; 2987 mDatePickerMode = 2;
2983 mMoveIncidence = inc ; 2988 mMoveIncidence = inc ;
2984 QDate da; 2989 QDate da;
2985 if ( mMoveIncidence->typeID() == todoID ) { 2990 if ( mMoveIncidence->typeID() == todoID ) {
2986 Todo * to = (Todo *) mMoveIncidence; 2991 Todo * to = (Todo *) mMoveIncidence;
2987 if ( to->hasDueDate() ) 2992 if ( to->hasDueDate() )
2988 da = to->dtDue().date(); 2993 da = to->dtDue().date();
2989 else 2994 else
2990 da = QDate::currentDate(); 2995 da = QDate::currentDate();
2991 } else { 2996 } else {
2992 da = mMoveIncidence->dtStart().date(); 2997 da = mMoveIncidence->dtStart().date();
2993 } 2998 }
2994 //PENDING set date for recurring incidence to date of recurrence 2999 //PENDING set date for recurring incidence to date of recurrence
2995 //mMoveIncidenceOldDate; 3000 //mMoveIncidenceOldDate;
2996 mDatePicker->setDate( da ); 3001 mDatePicker->setDate( da );
2997} 3002}
2998void CalendarView::showDatePickerPopup() 3003void CalendarView::showDatePickerPopup()
2999{ 3004{
3000 if ( mDateFrame->isVisible() ) 3005 if ( mDateFrame->isVisible() )
3001 mDateFrame->hide(); 3006 mDateFrame->hide();
3002 else { 3007 else {
3003 int offX = 0, offY = 0; 3008 int offX = 0, offY = 0;
3004#ifdef DESKTOP_VERSION 3009#ifdef DESKTOP_VERSION
3005 int w =mDatePicker->sizeHint().width() ; 3010 int w =mDatePicker->sizeHint().width() ;
3006 int h = mDatePicker->sizeHint().height() ; 3011 int h = mDatePicker->sizeHint().height() ;
3007 int dw = topLevelWidget()->width(); 3012 int dw = topLevelWidget()->width();
3008 int dh = topLevelWidget()->height(); 3013 int dh = topLevelWidget()->height();
3009 offX = topLevelWidget()->x(); 3014 offX = topLevelWidget()->x();
3010 offY = topLevelWidget()->y(); 3015 offY = topLevelWidget()->y();
3011#else 3016#else
3012 int w =mDatePicker->sizeHint().width() ; 3017 int w =mDatePicker->sizeHint().width() ;
3013 int h = mDatePicker->sizeHint().height() ; 3018 int h = mDatePicker->sizeHint().height() ;
3014 int dw = QApplication::desktop()->width(); 3019 int dw = QApplication::desktop()->width();
3015 int dh = QApplication::desktop()->height(); 3020 int dh = QApplication::desktop()->height();
3016#endif 3021#endif
3017 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3022 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3018 mDateFrame->show(); 3023 mDateFrame->show();
3019 } 3024 }
3020} 3025}
3021void CalendarView::showDatePicker( ) 3026void CalendarView::showDatePicker( )
3022{ 3027{
3023 showDatePickerPopup(); 3028 showDatePickerPopup();
3024 mDatePickerMode = 1; 3029 mDatePickerMode = 1;
3025 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3030 mDatePicker->setDate( mNavigator->selectedDates().first() );
3026} 3031}
3027 3032
3028void CalendarView::showEventEditor() 3033void CalendarView::showEventEditor()
3029{ 3034{
3030#ifdef DESKTOP_VERSION 3035#ifdef DESKTOP_VERSION
3031 int x,y,w,h; 3036 int x,y,w,h;
3032 x = mEventEditor->geometry().x(); 3037 x = mEventEditor->geometry().x();
3033 y = mEventEditor->geometry().y(); 3038 y = mEventEditor->geometry().y();
3034 w = mEventEditor->width(); 3039 w = mEventEditor->width();
3035 h = mEventEditor->height(); 3040 h = mEventEditor->height();
3036 mEventEditor->show(); 3041 mEventEditor->show();
3037 mEventEditor->setGeometry(x,y,w,h); 3042 mEventEditor->setGeometry(x,y,w,h);
3038#else 3043#else
3039 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3044 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3040 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3045 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3041 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3046 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3042 qApp->processEvents(); 3047 qApp->processEvents();
3043 delete mEventEditor; 3048 delete mEventEditor;
3044 mEventEditor = mDialogManager->getEventEditor(); 3049 mEventEditor = mDialogManager->getEventEditor();
3045 topLevelWidget()->setCaption( i18n("") ); 3050 topLevelWidget()->setCaption( i18n("") );
3046 } 3051 }
3047 mEventEditor->showMaximized(); 3052 mEventEditor->showMaximized();
3048#endif 3053#endif
3049} 3054}
3050void CalendarView::showTodoEditor() 3055void CalendarView::showTodoEditor()
3051{ 3056{
3052#ifdef DESKTOP_VERSION 3057#ifdef DESKTOP_VERSION
3053 int x,y,w,h; 3058 int x,y,w,h;
3054 x = mTodoEditor->geometry().x(); 3059 x = mTodoEditor->geometry().x();
3055 y = mTodoEditor->geometry().y(); 3060 y = mTodoEditor->geometry().y();
3056 w = mTodoEditor->width(); 3061 w = mTodoEditor->width();
3057 h = mTodoEditor->height(); 3062 h = mTodoEditor->height();
3058 mTodoEditor->show(); 3063 mTodoEditor->show();
3059 mTodoEditor->setGeometry(x,y,w,h); 3064 mTodoEditor->setGeometry(x,y,w,h);
3060#else 3065#else
3061 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3066 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3062 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3067 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3063 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3068 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3064 qApp->processEvents(); 3069 qApp->processEvents();
3065 delete mTodoEditor; 3070 delete mTodoEditor;
3066 mTodoEditor = mDialogManager->getTodoEditor(); 3071 mTodoEditor = mDialogManager->getTodoEditor();
3067 topLevelWidget()->setCaption( i18n("") ); 3072 topLevelWidget()->setCaption( i18n("") );
3068 } 3073 }
3069 mTodoEditor->showMaximized(); 3074 mTodoEditor->showMaximized();
3070#endif 3075#endif
3071} 3076}
3072 3077
3073void CalendarView::cloneIncidence() 3078void CalendarView::cloneIncidence()
3074{ 3079{
3075 Incidence *incidence = currentSelection(); 3080 Incidence *incidence = currentSelection();
3076 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3081 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3077 if ( incidence ) { 3082 if ( incidence ) {
3078 cloneIncidence(incidence); 3083 cloneIncidence(incidence);
3079 } 3084 }
3080} 3085}
3081void CalendarView::moveIncidence() 3086void CalendarView::moveIncidence()
3082{ 3087{
3083 Incidence *incidence = currentSelection(); 3088 Incidence *incidence = currentSelection();
3084 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3085 if ( incidence ) { 3090 if ( incidence ) {
3086 moveIncidence(incidence); 3091 moveIncidence(incidence);
3087 } 3092 }
3088} 3093}
3089void CalendarView::beamIncidence() 3094void CalendarView::beamIncidence()
3090{ 3095{
3091 Incidence *incidence = currentSelection(); 3096 Incidence *incidence = currentSelection();
3092 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3097 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3093 if ( incidence ) { 3098 if ( incidence ) {
3094 beamIncidence(incidence); 3099 beamIncidence(incidence);
3095 } 3100 }
3096} 3101}
3097void CalendarView::toggleCancelIncidence() 3102void CalendarView::toggleCancelIncidence()
3098{ 3103{
3099 Incidence *incidence = currentSelection(); 3104 Incidence *incidence = currentSelection();
3100 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3105 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3101 if ( incidence ) { 3106 if ( incidence ) {
3102 cancelIncidence(incidence); 3107 cancelIncidence(incidence);
3103 } 3108 }
3104} 3109}
3105 3110
3106 3111
3107void CalendarView::cancelIncidence(Incidence * inc ) 3112void CalendarView::cancelIncidence(Incidence * inc )
3108{ 3113{
3109 inc->setCancelled( ! inc->cancelled() ); 3114 inc->setCancelled( ! inc->cancelled() );
3110 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3115 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3111 updateView(); 3116 updateView();
3112} 3117}
3113void CalendarView::cloneIncidence(Incidence * orgInc ) 3118void CalendarView::cloneIncidence(Incidence * orgInc )
3114{ 3119{
3115 Incidence * newInc = orgInc->clone(); 3120 Incidence * newInc = orgInc->clone();
3116 newInc->recreate(); 3121 newInc->recreate();
3117 3122
3118 if ( newInc->typeID() == todoID ) { 3123 if ( newInc->typeID() == todoID ) {
3119 Todo* t = (Todo*) newInc; 3124 Todo* t = (Todo*) newInc;
3120 bool cloneSub = false; 3125 bool cloneSub = false;
3121 if ( orgInc->relations().count() ) { 3126 if ( orgInc->relations().count() ) {
3122 int result = KMessageBox::warningYesNoCancel(this, 3127 int result = KMessageBox::warningYesNoCancel(this,
3123 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 ) ), 3128 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 ) ),
3124 i18n("Todo has subtodos"), 3129 i18n("Todo has subtodos"),
3125 i18n("Yes"), 3130 i18n("Yes"),
3126 i18n("No")); 3131 i18n("No"));
3127 3132
3128 if ( result == KMessageBox::Cancel ) { 3133 if ( result == KMessageBox::Cancel ) {
3129 delete t; 3134 delete t;
3130 return; 3135 return;
3131 } 3136 }
3132 if (result == KMessageBox::Yes) cloneSub = true; 3137 if (result == KMessageBox::Yes) cloneSub = true;
3133 } 3138 }
3134 showTodoEditor(); 3139 showTodoEditor();
3135 mTodoEditor->editTodo( t ); 3140 mTodoEditor->editTodo( t );
3136 if ( mTodoEditor->exec() ) { 3141 if ( mTodoEditor->exec() ) {
3137 if ( cloneSub ) { 3142 if ( cloneSub ) {
3138 orgInc->cloneRelations( t ); 3143 orgInc->cloneRelations( t );
3139 mCalendar->addIncidenceBranch( t ); 3144 mCalendar->addIncidenceBranch( t );
3140 updateView(); 3145 updateView();
3141 3146
3142 } else { 3147 } else {
3143 mCalendar->addTodo( t ); 3148 mCalendar->addTodo( t );
3144 updateView(); 3149 updateView();
3145 } 3150 }
3146 } else { 3151 } else {
3147 delete t; 3152 delete t;
3148 } 3153 }
3149 } 3154 }
3150 else { 3155 else {
3151 Event* e = (Event*) newInc; 3156 Event* e = (Event*) newInc;
3152 showEventEditor(); 3157 showEventEditor();
3153 mEventEditor->editEvent( e ); 3158 mEventEditor->editEvent( e );
3154 if ( mEventEditor->exec() ) { 3159 if ( mEventEditor->exec() ) {
3155 mCalendar->addEvent( e ); 3160 mCalendar->addEvent( e );
3156 updateView(); 3161 updateView();
3157 } else { 3162 } else {
3158 delete e; 3163 delete e;
3159 } 3164 }
3160 } 3165 }
3161 setActiveWindow(); 3166 setActiveWindow();
3162} 3167}
3163 3168
3164void CalendarView::newEvent() 3169void CalendarView::newEvent()
3165{ 3170{
3166 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3171 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3167 KOAgendaView *aView = mViewManager->agendaView(); 3172 KOAgendaView *aView = mViewManager->agendaView();
3168 if (aView) { 3173 if (aView) {
3169 if (aView->selectionStart().isValid()) { 3174 if (aView->selectionStart().isValid()) {
3170 if (aView->selectedIsAllDay()) { 3175 if (aView->selectedIsAllDay()) {
3171 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3176 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3172 } else { 3177 } else {
3173 newEvent(aView->selectionStart(),aView->selectionEnd()); 3178 newEvent(aView->selectionStart(),aView->selectionEnd());
3174 } 3179 }
3175 return; 3180 return;
3176 } 3181 }
3177 } 3182 }
3178 3183
3179 QDate date = mNavigator->selectedDates().first(); 3184 QDate date = mNavigator->selectedDates().first();
3180 QDateTime current = QDateTime::currentDateTime(); 3185 QDateTime current = QDateTime::currentDateTime();
3181 if ( date <= current.date() ) { 3186 if ( date <= current.date() ) {
3182 int hour = current.time().hour() +1; 3187 int hour = current.time().hour() +1;
3183 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3188 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3184 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3189 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3185 } else 3190 } else
3186 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3191 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3187 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3192 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3188 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3193 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3189} 3194}
3190 3195
3191void CalendarView::newEvent(QDateTime fh) 3196void CalendarView::newEvent(QDateTime fh)
3192{ 3197{
3193 newEvent(fh, 3198 newEvent(fh,
3194 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3199 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3195} 3200}
3196 3201
3197void CalendarView::newEvent(QDate dt) 3202void CalendarView::newEvent(QDate dt)
3198{ 3203{
3199 newEvent(QDateTime(dt, QTime(0,0,0)), 3204 newEvent(QDateTime(dt, QTime(0,0,0)),
3200 QDateTime(dt, QTime(0,0,0)), true); 3205 QDateTime(dt, QTime(0,0,0)), true);
3201} 3206}
3202void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3207void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3203{ 3208{
3204 newEvent(fromHint, toHint, false); 3209 newEvent(fromHint, toHint, false);
3205} 3210}
3206void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3211void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3207{ 3212{
3208 3213
3209 showEventEditor(); 3214 showEventEditor();
3210 mEventEditor->newEvent(fromHint,toHint,allDay); 3215 mEventEditor->newEvent(fromHint,toHint,allDay);
3211 if ( mFilterView->filtersEnabled() ) { 3216 if ( mFilterView->filtersEnabled() ) {
3212 CalFilter *filter = mFilterView->selectedFilter(); 3217 CalFilter *filter = mFilterView->selectedFilter();
3213 if (filter && filter->showCategories()) { 3218 if (filter && filter->showCategories()) {
3214 mEventEditor->setCategories(filter->categoryList().join(",") ); 3219 mEventEditor->setCategories(filter->categoryList().join(",") );
3215 } 3220 }
3216 if ( filter ) 3221 if ( filter )
3217 mEventEditor->setSecrecy( filter->getSecrecy() ); 3222 mEventEditor->setSecrecy( filter->getSecrecy() );
3218 } 3223 }
3219 mEventEditor->exec(); 3224 mEventEditor->exec();
3220 setActiveWindow(); 3225 setActiveWindow();
3221} 3226}
3222void CalendarView::todoAdded(Todo * t) 3227void CalendarView::todoAdded(Todo * t)
3223{ 3228{
3224 3229
3225 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3230 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3226 updateTodoViews(); 3231 updateTodoViews();
3227} 3232}
3228void CalendarView::todoChanged(Todo * t) 3233void CalendarView::todoChanged(Todo * t)
3229{ 3234{
3230 emit todoModified( t, 4 ); 3235 emit todoModified( t, 4 );
3231 // updateTodoViews(); 3236 // updateTodoViews();
3232} 3237}
3233void CalendarView::todoToBeDeleted(Todo *) 3238void CalendarView::todoToBeDeleted(Todo *)
3234{ 3239{
3235 //qDebug("todoToBeDeleted(Todo *) "); 3240 //qDebug("todoToBeDeleted(Todo *) ");
3236 updateTodoViews(); 3241 updateTodoViews();
3237} 3242}
3238void CalendarView::todoDeleted() 3243void CalendarView::todoDeleted()
3239{ 3244{
3240 //qDebug(" todoDeleted()"); 3245 //qDebug(" todoDeleted()");
3241 updateTodoViews(); 3246 updateTodoViews();
3242} 3247}
3243 3248
3244 3249
3245void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3250void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3246{ 3251{
3247 showTodoEditor(); 3252 showTodoEditor();
3248 mTodoEditor->newTodo(dt,0,allday); 3253 mTodoEditor->newTodo(dt,0,allday);
3249 if ( mFilterView->filtersEnabled() ) { 3254 if ( mFilterView->filtersEnabled() ) {
3250 CalFilter *filter = mFilterView->selectedFilter(); 3255 CalFilter *filter = mFilterView->selectedFilter();
3251 if (filter && filter->showCategories()) { 3256 if (filter && filter->showCategories()) {
3252 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3257 mTodoEditor->setCategories(filter->categoryList().join(",") );
3253 } 3258 }
3254 if ( filter ) 3259 if ( filter )
3255 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3260 mTodoEditor->setSecrecy( filter->getSecrecy() );
3256 } 3261 }
3257 mTodoEditor->exec(); 3262 mTodoEditor->exec();
3258 setActiveWindow(); 3263 setActiveWindow();
3259} 3264}
3260 3265
3261void CalendarView::newTodo() 3266void CalendarView::newTodo()
3262{ 3267{
3263 newTodoDateTime( QDateTime(),true ); 3268 newTodoDateTime( QDateTime(),true );
3264} 3269}
3265 3270
3266void CalendarView::newSubTodo() 3271void CalendarView::newSubTodo()
3267{ 3272{
3268 Todo *todo = selectedTodo(); 3273 Todo *todo = selectedTodo();
3269 if ( todo ) newSubTodo( todo ); 3274 if ( todo ) newSubTodo( todo );
3270} 3275}
3271 3276
3272void CalendarView::newSubTodo(Todo *parentEvent) 3277void CalendarView::newSubTodo(Todo *parentEvent)
3273{ 3278{
3274 3279
3275 showTodoEditor(); 3280 showTodoEditor();
3276 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3281 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3277 mTodoEditor->exec(); 3282 mTodoEditor->exec();
3278 setActiveWindow(); 3283 setActiveWindow();
3279} 3284}
3280 3285
3281void CalendarView::newFloatingEvent() 3286void CalendarView::newFloatingEvent()
3282{ 3287{
3283 DateList tmpList = mNavigator->selectedDates(); 3288 DateList tmpList = mNavigator->selectedDates();
3284 QDate date = tmpList.first(); 3289 QDate date = tmpList.first();
3285 3290
3286 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3291 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3287 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3292 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3288} 3293}
3289 3294
3290 3295
3291void CalendarView::editEvent( Event *event ) 3296void CalendarView::editEvent( Event *event )
3292{ 3297{
3293 3298
3294 if ( !event ) return; 3299 if ( !event ) return;
3295 if ( event->isReadOnly() ) { 3300 if ( event->isReadOnly() ) {
3296 showEvent( event ); 3301 showEvent( event );
3297 return; 3302 return;
3298 } 3303 }
3299 showEventEditor(); 3304 showEventEditor();
3300 mEventEditor->editEvent( event , mFlagEditDescription); 3305 mEventEditor->editEvent( event , mFlagEditDescription);
3301 mEventEditor->exec(); 3306 mEventEditor->exec();
3302 setActiveWindow(); 3307 setActiveWindow();
3303 3308
3304} 3309}
3305void CalendarView::editJournal( Journal *jour ) 3310void CalendarView::editJournal( Journal *jour )
3306{ 3311{
3307 if ( !jour ) return; 3312 if ( !jour ) return;
3308 mDialogManager->hideSearchDialog(); 3313 mDialogManager->hideSearchDialog();
3309 mViewManager->showJournalView(); 3314 mViewManager->showJournalView();
3310 mNavigator->slotDaySelect( jour->dtStart().date() ); 3315 mNavigator->slotDaySelect( jour->dtStart().date() );
3311} 3316}
3312void CalendarView::editTodo( Todo *todo ) 3317void CalendarView::editTodo( Todo *todo )
3313{ 3318{
3314 if ( !todo ) return; 3319 if ( !todo ) return;
3315 3320
3316 if ( todo->isReadOnly() ) { 3321 if ( todo->isReadOnly() ) {
3317 showTodo( todo ); 3322 showTodo( todo );
3318 return; 3323 return;
3319 } 3324 }
3320 showTodoEditor(); 3325 showTodoEditor();
3321 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3326 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3322 mTodoEditor->exec(); 3327 mTodoEditor->exec();
3323 setActiveWindow(); 3328 setActiveWindow();
3324 3329
3325} 3330}
3326 3331
3327KOEventViewerDialog* CalendarView::getEventViewerDialog() 3332KOEventViewerDialog* CalendarView::getEventViewerDialog()
3328{ 3333{
3329 if ( !mEventViewerDialog ) { 3334 if ( !mEventViewerDialog ) {
3330 mEventViewerDialog = new KOEventViewerDialog(0); 3335 mEventViewerDialog = new KOEventViewerDialog(0);
3331 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3336 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3332 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3337 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3333 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3338 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3334 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3339 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3335 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3340 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3336 viewManager(), SLOT( showAgendaView( bool ) ) ); 3341 viewManager(), SLOT( showAgendaView( bool ) ) );
3337 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3342 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3338 this, SLOT( slotViewerClosed() ) ); 3343 this, SLOT( slotViewerClosed() ) );
3339 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3344 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3340 this, SLOT( todoChanged(Todo *) ) ); 3345 this, SLOT( todoChanged(Todo *) ) );
3341 mEventViewerDialog->resize( 640, 480 ); 3346 mEventViewerDialog->resize( 640, 480 );
3342 3347
3343 } 3348 }
3344 return mEventViewerDialog; 3349 return mEventViewerDialog;
3345} 3350}
3346void CalendarView::showEvent(Event *event) 3351void CalendarView::showEvent(Event *event)
3347{ 3352{
3348 getEventViewerDialog()->setEvent(event); 3353 getEventViewerDialog()->setEvent(event);
3349 getEventViewerDialog()->showMe(); 3354 getEventViewerDialog()->showMe();
3350} 3355}
3351 3356
3352void CalendarView::showTodo(Todo *event) 3357void CalendarView::showTodo(Todo *event)
3353{ 3358{
3354 getEventViewerDialog()->setTodo(event); 3359 getEventViewerDialog()->setTodo(event);
3355 getEventViewerDialog()->showMe(); 3360 getEventViewerDialog()->showMe();
3356} 3361}
3357void CalendarView::showJournal( Journal *jour ) 3362void CalendarView::showJournal( Journal *jour )
3358{ 3363{
3359 getEventViewerDialog()->setJournal(jour); 3364 getEventViewerDialog()->setJournal(jour);
3360 getEventViewerDialog()->showMe(); 3365 getEventViewerDialog()->showMe();
3361 3366
3362} 3367}
3363// void CalendarView::todoModified (Todo *event, int changed) 3368// void CalendarView::todoModified (Todo *event, int changed)
3364// { 3369// {
3365// // if (mDialogList.find (event) != mDialogList.end ()) { 3370// // if (mDialogList.find (event) != mDialogList.end ()) {
3366// // kdDebug() << "Todo modified and open" << endl; 3371// // kdDebug() << "Todo modified and open" << endl;
3367// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3372// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3368// // temp->modified (changed); 3373// // temp->modified (changed);
3369 3374
3370// // } 3375// // }
3371 3376
3372// mViewManager->updateView(); 3377// mViewManager->updateView();
3373// } 3378// }
3374 3379
3375void CalendarView::appointment_show() 3380void CalendarView::appointment_show()
3376{ 3381{
3377 Event *anEvent = 0; 3382 Event *anEvent = 0;
3378 3383
3379 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3384 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3380 3385
3381 if (mViewManager->currentView()->isEventView()) { 3386 if (mViewManager->currentView()->isEventView()) {
3382 if ( incidence && incidence->typeID() == eventID ) { 3387 if ( incidence && incidence->typeID() == eventID ) {
3383 anEvent = static_cast<Event *>(incidence); 3388 anEvent = static_cast<Event *>(incidence);
3384 } 3389 }
3385 } 3390 }
3386 3391
3387 if (!anEvent) { 3392 if (!anEvent) {
3388 KNotifyClient::beep(); 3393 KNotifyClient::beep();
3389 return; 3394 return;
3390 } 3395 }
3391 3396
3392 showEvent(anEvent); 3397 showEvent(anEvent);
3393} 3398}
3394 3399
3395void CalendarView::appointment_edit() 3400void CalendarView::appointment_edit()
3396{ 3401{
3397 Event *anEvent = 0; 3402 Event *anEvent = 0;
3398 3403
3399 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3404 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3400 3405
3401 if (mViewManager->currentView()->isEventView()) { 3406 if (mViewManager->currentView()->isEventView()) {
3402 if ( incidence && incidence->typeID() == eventID ) { 3407 if ( incidence && incidence->typeID() == eventID ) {
3403 anEvent = static_cast<Event *>(incidence); 3408 anEvent = static_cast<Event *>(incidence);