summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp45
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/kofilterview.cpp18
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp12
5 files changed, 68 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 6e60c56..b0be340 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1881,7 +1881,10 @@ 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;
@@ -1985,3 +1988,29 @@ void CalendarView::watchSavedFile()
}
-
+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)
@@ -1996,3 +2025,3 @@ bool CalendarView::checkFileVersion(QString fn)
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"),
@@ -2014,4 +2043,3 @@ bool CalendarView::checkFileVersion(QString fn)
if ( e )
- deleteEvent ( e );
- updateView();
+ mCalendar->deleteEvent( e );
return true;
@@ -2027,6 +2055,7 @@ bool CalendarView::saveCalendars()
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();
}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index ec5b7ab..d836fee 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -512,2 +512,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
bool checkFileVersion(QString fn);
+ bool checkAllFileVersions();
bool checkFileChanged(QString fn);
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 361eec8..19d731f 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -233,3 +233,11 @@ void KOCalEditView::infoCal( int id )
QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
- KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
+ if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
+ if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
+ emit calendarAdded( id );
+ readConfig();
+ emit needsUpdate();
+ }
+ }
+ else
+ KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
}
@@ -296,2 +304,4 @@ void KOCalEditView::readConfig()
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
cb = new KOCalCheckButton( mw );
@@ -300,2 +310,4 @@ void KOCalEditView::readConfig()
cb->setNum( kkf->mCalNumber );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
@@ -311,2 +323,4 @@ void KOCalEditView::readConfig()
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
cb = new KOCalCheckButton( mw );
@@ -316,2 +330,4 @@ void KOCalEditView::readConfig()
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
KColorButton *colb = new KColorButton( mw );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index f114d88..463fc33 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -58,2 +58,3 @@ class KopiCalendarFile : public QObject
mDefaultColor = Qt::red;
+ mErrorOnLoad = false;
}
@@ -63,2 +64,3 @@ class KopiCalendarFile : public QObject
bool isReadOnly;
+ bool mErrorOnLoad;
QString mName;
@@ -67,2 +69,3 @@ class KopiCalendarFile : public QObject
QColor mDefaultColor;
+ QDateTime mLoadDt;
};
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f05ada5..472a978 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1826,3 +1826,3 @@ void MainWindow::save()
mSyncManager->setBlockSave(true);
- if ( mView->checkFileVersion( defaultFileName()) ) {
+ if ( mView->checkAllFileVersions() ) {
if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
@@ -1845,4 +1845,12 @@ void MainWindow::save()
// backup ok
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ cal = calendars.next();
+ while ( cal ) {
+ if ( !cal->mErrorOnLoad ) {
+ int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
+ }
+ cal = calendars.next();
+ }
KOPrefs::instance()->mLastBackupDate = daysTo;
-
} else if ( retval == 2 ){