summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b0be340..dd4ea41 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1837,61 +1837,63 @@ void CalendarView::setSyncEventsReadOnly()
1837 ev = eL.first(); 1837 ev = eL.first();
1838 while ( ev ) { 1838 while ( ev ) {
1839 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1839 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1840 ev->setReadOnly( true ); 1840 ev->setReadOnly( true );
1841 ev = eL.next(); 1841 ev = eL.next();
1842 } 1842 }
1843} 1843}
1844 1844
1845bool CalendarView::loadCalendars() 1845bool CalendarView::loadCalendars()
1846{ 1846{
1847 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1847 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1848 KopiCalendarFile * cal = calendars.first(); 1848 KopiCalendarFile * cal = calendars.first();
1849 mCalendar->setDefaultCalendar( 1 ); 1849 mCalendar->setDefaultCalendar( 1 );
1850 openCalendar( MainWindow::defaultFileName(), false ); 1850 openCalendar( MainWindow::defaultFileName(), false );
1851 cal = calendars.next(); 1851 cal = calendars.next();
1852 while ( cal ) { 1852 while ( cal ) {
1853 addCalendar( cal ); 1853 addCalendar( cal );
1854 cal = calendars.next(); 1854 cal = calendars.next();
1855 } 1855 }
1856 restoreCalendarSettings(); 1856 restoreCalendarSettings();
1857 mCalendar->reInitAlarmSettings(); 1857 mCalendar->reInitAlarmSettings();
1858 setSyncEventsReadOnly(); 1858 setSyncEventsReadOnly();
1859 updateUnmanagedViews(); 1859 updateUnmanagedViews();
1860 updateView(); 1860 updateView();
1861 return true;
1861} 1862}
1862bool CalendarView::restoreCalendarSettings() 1863bool CalendarView::restoreCalendarSettings()
1863{ 1864{
1864 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1865 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1865 KopiCalendarFile * cal = calendars.first(); 1866 KopiCalendarFile * cal = calendars.first();
1866 while ( cal ) { 1867 while ( cal ) {
1867 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1868 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1868 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1869 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1869 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1870 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1870 if ( cal->isStandard ) 1871 if ( cal->isStandard )
1871 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1872 mCalendar->setDefaultCalendar( cal->mCalNumber );
1872 cal = calendars.next(); 1873 cal = calendars.next();
1873 } 1874 }
1875 return true;
1874} 1876}
1875void CalendarView::addCalendarId( int id ) 1877void CalendarView::addCalendarId( int id )
1876{ 1878{
1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1879 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1878 addCalendar( cal ); 1880 addCalendar( cal );
1879} 1881}
1880bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1882bool CalendarView::addCalendar( KopiCalendarFile * cal )
1881{ 1883{
1882 cal->mErrorOnLoad = false; 1884 cal->mErrorOnLoad = false;
1883 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1885 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1884 cal->mLoadDt = QDateTime::currentDateTime(); 1886 cal->mLoadDt = QDateTime::currentDateTime();
1885 return true; 1887 return true;
1886 } 1888 }
1887 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1889 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1888 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1890 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1889 cal->mErrorOnLoad = true; 1891 cal->mErrorOnLoad = true;
1890 return false; 1892 return false;
1891} 1893}
1892bool CalendarView::openCalendar(QString filename, bool merge) 1894bool CalendarView::openCalendar(QString filename, bool merge)
1893{ 1895{
1894 1896
1895 if (filename.isEmpty()) { 1897 if (filename.isEmpty()) {
1896 return false; 1898 return false;
1897 } 1899 }
@@ -2041,48 +2043,49 @@ bool CalendarView::checkFileVersion(QString fn)
2041 syncCalendar( fn, 3 ); 2043 syncCalendar( fn, 3 );
2042 Event * e = getLastSyncEvent(); 2044 Event * e = getLastSyncEvent();
2043 if ( e ) 2045 if ( e )
2044 mCalendar->deleteEvent( e ); 2046 mCalendar->deleteEvent( e );
2045 return true; 2047 return true;
2046} 2048}
2047bool CalendarView::saveCalendars() 2049bool CalendarView::saveCalendars()
2048{ 2050{
2049 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2051 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2050 KopiCalendarFile * cal = calendars.first(); 2052 KopiCalendarFile * cal = calendars.first();
2051 mCalendar->setDefaultCalendar( 1 ); 2053 mCalendar->setDefaultCalendar( 1 );
2052 mCalendar->setDefaultCalendarEnabledOnly(); 2054 mCalendar->setDefaultCalendarEnabledOnly();
2053 saveCalendar( MainWindow::defaultFileName() ); 2055 saveCalendar( MainWindow::defaultFileName() );
2054 cal = calendars.next(); 2056 cal = calendars.next();
2055 while ( cal ) { 2057 while ( cal ) {
2056 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2058 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2057 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2059 mCalendar->setDefaultCalendar( cal->mCalNumber );
2058 mCalendar->setDefaultCalendarEnabledOnly(); 2060 mCalendar->setDefaultCalendarEnabledOnly();
2059 if ( saveCalendar( cal->mFileName ) ) 2061 if ( saveCalendar( cal->mFileName ) )
2060 cal->mLoadDt = QDateTime::currentDateTime(); 2062 cal->mLoadDt = QDateTime::currentDateTime();
2061 } 2063 }
2062 cal = calendars.next(); 2064 cal = calendars.next();
2063 } 2065 }
2064 restoreCalendarSettings(); 2066 restoreCalendarSettings();
2067 return true;
2065} 2068}
2066bool CalendarView::saveCalendar( QString filename ) 2069bool CalendarView::saveCalendar( QString filename )
2067{ 2070{
2068 2071
2069 // Store back all unsaved data into calendar object 2072 // Store back all unsaved data into calendar object
2070 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2073 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2071 if ( mViewManager->currentView() ) 2074 if ( mViewManager->currentView() )
2072 mViewManager->currentView()->flushView(); 2075 mViewManager->currentView()->flushView();
2073 2076
2074 2077
2075 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2078 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2076 mStorage->setSaveFormat( new ICalFormat() ); 2079 mStorage->setSaveFormat( new ICalFormat() );
2077 mStorage->setFileName( filename ); 2080 mStorage->setFileName( filename );
2078 bool success; 2081 bool success;
2079 success = mStorage->save(); 2082 success = mStorage->save();
2080 if ( !success ) { 2083 if ( !success ) {
2081 return false; 2084 return false;
2082 } 2085 }
2083 if ( filename == MainWindow::defaultFileName() ) { 2086 if ( filename == MainWindow::defaultFileName() ) {
2084 setLoadedFileVersion( lfv ); 2087 setLoadedFileVersion( lfv );
2085 watchSavedFile(); 2088 watchSavedFile();
2086 } 2089 }
2087 return true; 2090 return true;
2088} 2091}