summaryrefslogtreecommitdiffabout
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
parent0000f74badd326f62620d818a5e5d9944e55bda0 (diff)
downloadkdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.zip
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.gz
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.bz2
fixxxx
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp45
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/kofilterview.cpp16
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp12
5 files changed, 67 insertions, 10 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,2 +233,10 @@ void KOCalEditView::infoCal( int id )
QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
+ 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 ){