-rw-r--r-- | korganizer/calendarview.cpp | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6e60c56..b0be340 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1879,11 +1879,14 @@ void CalendarView::addCalendarId( int id ) | |||
1879 | } | 1879 | } |
1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1881 | { | 1881 | { |
1882 | 1882 | cal->mErrorOnLoad = false; | |
1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) | 1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1884 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
1884 | return true; | 1885 | return true; |
1886 | } | ||
1885 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1887 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1886 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1888 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1889 | cal->mErrorOnLoad = true; | ||
1887 | return false; | 1890 | return false; |
1888 | } | 1891 | } |
1889 | bool CalendarView::openCalendar(QString filename, bool merge) | 1892 | bool CalendarView::openCalendar(QString filename, bool merge) |
@@ -1983,7 +1986,33 @@ void CalendarView::watchSavedFile() | |||
1983 | } | 1986 | } |
1984 | loadedFileVersion = dt; | 1987 | loadedFileVersion = dt; |
1985 | } | 1988 | } |
1986 | 1989 | bool CalendarView::checkAllFileVersions() | |
1990 | { | ||
1991 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1992 | KopiCalendarFile * cal = calendars.first(); | ||
1993 | mCalendar->setDefaultCalendar( 1 ); | ||
1994 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
1995 | if ( !checkFileVersion(MainWindow::defaultFileName())) | ||
1996 | return false; | ||
1997 | cal = calendars.next(); | ||
1998 | QDateTime storeTemp = loadedFileVersion; | ||
1999 | while ( cal ) { | ||
2000 | if ( !cal->mErrorOnLoad ) { | ||
2001 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | ||
2002 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2003 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | ||
2004 | if ( !checkFileVersion(cal->mFileName )) { | ||
2005 | loadedFileVersion = storeTemp; | ||
2006 | updateView(); | ||
2007 | return false; | ||
2008 | } | ||
2009 | } | ||
2010 | cal = calendars.next(); | ||
2011 | } | ||
2012 | loadedFileVersion = storeTemp; | ||
2013 | updateView(); | ||
2014 | return true; | ||
2015 | } | ||
1987 | bool CalendarView::checkFileVersion(QString fn) | 2016 | bool CalendarView::checkFileVersion(QString fn) |
1988 | { | 2017 | { |
1989 | QFileInfo finf ( fn ); | 2018 | QFileInfo finf ( fn ); |
@@ -1994,7 +2023,7 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1994 | //qDebug("file on disk version %s",dt.toString().latin1()); | 2023 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1995 | if ( dt <= loadedFileVersion ) | 2024 | if ( dt <= loadedFileVersion ) |
1996 | return true; | 2025 | return true; |
1997 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2026 | 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)) , |
1998 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2027 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1999 | i18n("Sync+save")); | 2028 | i18n("Sync+save")); |
2000 | 2029 | ||
@@ -2012,8 +2041,7 @@ bool CalendarView::checkFileVersion(QString fn) | |||
2012 | syncCalendar( fn, 3 ); | 2041 | syncCalendar( fn, 3 ); |
2013 | Event * e = getLastSyncEvent(); | 2042 | Event * e = getLastSyncEvent(); |
2014 | if ( e ) | 2043 | if ( e ) |
2015 | deleteEvent ( e ); | 2044 | mCalendar->deleteEvent( e ); |
2016 | updateView(); | ||
2017 | return true; | 2045 | return true; |
2018 | } | 2046 | } |
2019 | bool CalendarView::saveCalendars() | 2047 | bool CalendarView::saveCalendars() |
@@ -2025,10 +2053,11 @@ bool CalendarView::saveCalendars() | |||
2025 | saveCalendar( MainWindow::defaultFileName() ); | 2053 | saveCalendar( MainWindow::defaultFileName() ); |
2026 | cal = calendars.next(); | 2054 | cal = calendars.next(); |
2027 | while ( cal ) { | 2055 | while ( cal ) { |
2028 | if ( !cal->isReadOnly ) { | 2056 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2029 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2057 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2030 | mCalendar->setDefaultCalendarEnabledOnly(); | 2058 | mCalendar->setDefaultCalendarEnabledOnly(); |
2031 | saveCalendar( cal->mFileName ); | 2059 | if ( saveCalendar( cal->mFileName ) ) |
2060 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
2032 | } | 2061 | } |
2033 | cal = calendars.next(); | 2062 | cal = calendars.next(); |
2034 | } | 2063 | } |