-rw-r--r-- | korganizer/calendarview.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1338224..377a66f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1852,16 +1852,12 @@ bool CalendarView::loadCalendars() | |||
1852 | cal = calendars.next(); | 1852 | cal = calendars.next(); |
1853 | while ( cal ) { | 1853 | while ( cal ) { |
1854 | addCalendar( cal ); | 1854 | addCalendar( cal ); |
1855 | cal = calendars.next(); | 1855 | cal = calendars.next(); |
1856 | } | 1856 | } |
1857 | restoreCalendarSettings(); | 1857 | restoreCalendarSettings(); |
1858 | mCalendar->reInitAlarmSettings(); | ||
1859 | setSyncEventsReadOnly(); | ||
1860 | updateUnmanagedViews(); | ||
1861 | updateView(); | ||
1862 | return true; | 1858 | return true; |
1863 | } | 1859 | } |
1864 | bool CalendarView::restoreCalendarSettings() | 1860 | bool CalendarView::restoreCalendarSettings() |
1865 | { | 1861 | { |
1866 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1862 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1867 | KopiCalendarFile * cal = calendars.first(); | 1863 | KopiCalendarFile * cal = calendars.first(); |
@@ -1870,12 +1866,16 @@ bool CalendarView::restoreCalendarSettings() | |||
1870 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1866 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1871 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1867 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1872 | if ( cal->isStandard ) | 1868 | if ( cal->isStandard ) |
1873 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1869 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1874 | cal = calendars.next(); | 1870 | cal = calendars.next(); |
1875 | } | 1871 | } |
1872 | setSyncEventsReadOnly(); | ||
1873 | mCalendar->reInitAlarmSettings(); | ||
1874 | updateUnmanagedViews(); | ||
1875 | updateView(); | ||
1876 | return true; | 1876 | return true; |
1877 | } | 1877 | } |
1878 | void CalendarView::addCalendarId( int id ) | 1878 | void CalendarView::addCalendarId( int id ) |
1879 | { | 1879 | { |
1880 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1880 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1881 | addCalendar( cal ); | 1881 | addCalendar( cal ); |
@@ -1992,41 +1992,44 @@ void CalendarView::watchSavedFile() | |||
1992 | bool CalendarView::checkAllFileVersions() | 1992 | bool CalendarView::checkAllFileVersions() |
1993 | { | 1993 | { |
1994 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1994 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1995 | KopiCalendarFile * cal = calendars.first(); | 1995 | KopiCalendarFile * cal = calendars.first(); |
1996 | mCalendar->setDefaultCalendar( 1 ); | 1996 | mCalendar->setDefaultCalendar( 1 ); |
1997 | mCalendar->setDefaultCalendarEnabledOnly(); | 1997 | mCalendar->setDefaultCalendarEnabledOnly(); |
1998 | if ( !checkFileVersion(MainWindow::defaultFileName())) | 1998 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
1999 | return false; | 1999 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2000 | restoreCalendarSettings(); | ||
2001 | return false; | ||
2002 | } | ||
2003 | } | ||
2000 | cal = calendars.next(); | 2004 | cal = calendars.next(); |
2001 | QDateTime storeTemp = loadedFileVersion; | 2005 | QDateTime storeTemp = loadedFileVersion; |
2002 | while ( cal ) { | 2006 | while ( cal ) { |
2003 | if ( !cal->mErrorOnLoad ) { | 2007 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2004 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2008 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2005 | mCalendar->setDefaultCalendarEnabledOnly(); | 2009 | mCalendar->setDefaultCalendarEnabledOnly(); |
2006 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2010 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2007 | if ( !checkFileVersion(cal->mFileName )) { | 2011 | if ( !checkFileVersion(cal->mFileName )) { |
2008 | loadedFileVersion = storeTemp; | 2012 | loadedFileVersion = storeTemp; |
2009 | updateView(); | 2013 | restoreCalendarSettings(); |
2010 | return false; | 2014 | return false; |
2011 | } | 2015 | } |
2012 | } | 2016 | } |
2013 | cal = calendars.next(); | 2017 | cal = calendars.next(); |
2014 | } | 2018 | } |
2015 | loadedFileVersion = storeTemp; | 2019 | loadedFileVersion = storeTemp; |
2016 | updateView(); | ||
2017 | return true; | 2020 | return true; |
2018 | } | 2021 | } |
2019 | bool CalendarView::checkFileVersion(QString fn) | 2022 | bool CalendarView::checkFileVersion(QString fn) |
2020 | { | 2023 | { |
2021 | QFileInfo finf ( fn ); | 2024 | QFileInfo finf ( fn ); |
2022 | if ( !finf.exists() ) | 2025 | if ( !finf.exists() ) |
2023 | return true; | 2026 | return true; |
2024 | QDateTime dt = finf.lastModified (); | 2027 | QDateTime dt = finf.lastModified (); |
2025 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 2028 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2026 | //qDebug("file on disk version %s",dt.toString().latin1()); | 2029 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2027 | if ( dt <= loadedFileVersion ) | 2030 | if ( dt <= loadedFileVersion ) |
2028 | return true; | 2031 | return true; |
2029 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2032 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2030 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2033 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2031 | i18n("Sync+save")); | 2034 | i18n("Sync+save")); |
2032 | 2035 | ||