summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-06-13 20:42:10 (UTC)
committer zautrix <zautrix>2005-06-13 20:42:10 (UTC)
commitfe1114cea0321405b362d642912f1f72257c7cbd (patch) (side-by-side diff)
tree89f5cc1050a86c497fc406ebbea88669b6bea1a6 /korganizer/calendarview.cpp
parent0000f74badd326f62620d818a5e5d9944e55bda0 (diff)
downloadkdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.zip
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.gz
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.bz2
fixxxx
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp45
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 )
}
bool CalendarView::addCalendar( KopiCalendarFile * cal )
{
-
- if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
+ cal->mErrorOnLoad = false;
+ if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
+ cal->mLoadDt = QDateTime::currentDateTime();
return true;
+ }
qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
+ cal->mErrorOnLoad = true;
return false;
}
bool CalendarView::openCalendar(QString filename, bool merge)
@@ -1983,7 +1986,33 @@ void CalendarView::watchSavedFile()
}
loadedFileVersion = dt;
}
-
+bool CalendarView::checkAllFileVersions()
+{
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ mCalendar->setDefaultCalendar( 1 );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ if ( !checkFileVersion(MainWindow::defaultFileName()))
+ return false;
+ cal = calendars.next();
+ QDateTime storeTemp = loadedFileVersion;
+ while ( cal ) {
+ if ( !cal->mErrorOnLoad ) {
+ mCalendar->setDefaultCalendar( cal->mCalNumber );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ loadedFileVersion = cal->mLoadDt.addSecs( 15 );
+ if ( !checkFileVersion(cal->mFileName )) {
+ loadedFileVersion = storeTemp;
+ updateView();
+ return false;
+ }
+ }
+ cal = calendars.next();
+ }
+ loadedFileVersion = storeTemp;
+ updateView();
+ return true;
+}
bool CalendarView::checkFileVersion(QString fn)
{
QFileInfo finf ( fn );
@@ -1994,7 +2023,7 @@ bool CalendarView::checkFileVersion(QString fn)
//qDebug("file on disk version %s",dt.toString().latin1());
if ( dt <= loadedFileVersion )
return true;
- 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)) ,
+ 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)) ,
i18n("KO/Pi Warning"),i18n("Overwrite"),
i18n("Sync+save"));
@@ -2012,8 +2041,7 @@ bool CalendarView::checkFileVersion(QString fn)
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
if ( e )
- deleteEvent ( e );
- updateView();
+ mCalendar->deleteEvent( e );
return true;
}
bool CalendarView::saveCalendars()
@@ -2025,10 +2053,11 @@ bool CalendarView::saveCalendars()
saveCalendar( MainWindow::defaultFileName() );
cal = calendars.next();
while ( cal ) {
- if ( !cal->isReadOnly ) {
+ if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
mCalendar->setDefaultCalendar( cal->mCalNumber );
mCalendar->setDefaultCalendarEnabledOnly();
- saveCalendar( cal->mFileName );
+ if ( saveCalendar( cal->mFileName ) )
+ cal->mLoadDt = QDateTime::currentDateTime();
}
cal = calendars.next();
}