summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -1870,29 +1870,32 @@ bool CalendarView::restoreCalendarSettings()
1870 if ( cal->isStandard ) 1870 if ( cal->isStandard )
1871 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1871 mCalendar->setDefaultCalendar( cal->mCalNumber );
1872 cal = calendars.next(); 1872 cal = calendars.next();
1873 } 1873 }
1874} 1874}
1875void CalendarView::addCalendarId( int id ) 1875void CalendarView::addCalendarId( int id )
1876{ 1876{
1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1878 addCalendar( cal ); 1878 addCalendar( cal );
1879} 1879}
1880bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1880bool 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}
1889bool CalendarView::openCalendar(QString filename, bool merge) 1892bool CalendarView::openCalendar(QString filename, bool merge)
1890{ 1893{
1891 1894
1892 if (filename.isEmpty()) { 1895 if (filename.isEmpty()) {
1893 return false; 1896 return false;
1894 } 1897 }
1895 1898
1896 if (!QFile::exists(filename)) { 1899 if (!QFile::exists(filename)) {
1897 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1900 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1898 return false; 1901 return false;
@@ -1974,70 +1977,96 @@ void CalendarView::watchSavedFile()
1974{ 1977{
1975 QFileInfo finf ( MainWindow::defaultFileName()); 1978 QFileInfo finf ( MainWindow::defaultFileName());
1976 if ( !finf.exists() ) 1979 if ( !finf.exists() )
1977 return; 1980 return;
1978 QDateTime dt = finf.lastModified (); 1981 QDateTime dt = finf.lastModified ();
1979 if ( dt < loadedFileVersion ) { 1982 if ( dt < loadedFileVersion ) {
1980 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1983 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1981 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1984 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1982 return; 1985 return;
1983 } 1986 }
1984 loadedFileVersion = dt; 1987 loadedFileVersion = dt;
1985} 1988}
1986 1989bool 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}
1987bool CalendarView::checkFileVersion(QString fn) 2016bool CalendarView::checkFileVersion(QString fn)
1988{ 2017{
1989 QFileInfo finf ( fn ); 2018 QFileInfo finf ( fn );
1990 if ( !finf.exists() ) 2019 if ( !finf.exists() )
1991 return true; 2020 return true;
1992 QDateTime dt = finf.lastModified (); 2021 QDateTime dt = finf.lastModified ();
1993 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 2022 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
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
2001 if ( km == KMessageBox::Cancel ) 2030 if ( km == KMessageBox::Cancel )
2002 return false; 2031 return false;
2003 if ( km == KMessageBox::Yes ) 2032 if ( km == KMessageBox::Yes )
2004 return true; 2033 return true;
2005 2034
2006 setSyncDevice("deleteaftersync" ); 2035 setSyncDevice("deleteaftersync" );
2007 mSyncManager->mAskForPreferences = true; 2036 mSyncManager->mAskForPreferences = true;
2008 mSyncManager->mSyncAlgoPrefs = 3; 2037 mSyncManager->mSyncAlgoPrefs = 3;
2009 mSyncManager->mWriteBackFile = false; 2038 mSyncManager->mWriteBackFile = false;
2010 mSyncManager->mWriteBackExistingOnly = false; 2039 mSyncManager->mWriteBackExistingOnly = false;
2011 mSyncManager->mShowSyncSummary = false; 2040 mSyncManager->mShowSyncSummary = false;
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}
2019bool CalendarView::saveCalendars() 2047bool CalendarView::saveCalendars()
2020{ 2048{
2021 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2049 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2022 KopiCalendarFile * cal = calendars.first(); 2050 KopiCalendarFile * cal = calendars.first();
2023 mCalendar->setDefaultCalendar( 1 ); 2051 mCalendar->setDefaultCalendar( 1 );
2024 mCalendar->setDefaultCalendarEnabledOnly(); 2052 mCalendar->setDefaultCalendarEnabledOnly();
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 }
2035 restoreCalendarSettings(); 2064 restoreCalendarSettings();
2036} 2065}
2037bool CalendarView::saveCalendar( QString filename ) 2066bool CalendarView::saveCalendar( QString filename )
2038{ 2067{
2039 2068
2040 // Store back all unsaved data into calendar object 2069 // Store back all unsaved data into calendar object
2041 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2070 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2042 if ( mViewManager->currentView() ) 2071 if ( mViewManager->currentView() )
2043 mViewManager->currentView()->flushView(); 2072 mViewManager->currentView()->flushView();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index ec5b7ab..d836fee 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -501,24 +501,25 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
501 501
502 public: 502 public:
503 // show a standard warning 503 // show a standard warning
504 // returns KMsgBox::yesNoCancel() 504 // returns KMsgBox::yesNoCancel()
505 int msgCalModified(); 505 int msgCalModified();
506 virtual bool sync(KSyncManager* manager, QString filename, int mode); 506 virtual bool sync(KSyncManager* manager, QString filename, int mode);
507 507
508 virtual bool syncExternal(KSyncManager* manager, QString resource); 508 virtual bool syncExternal(KSyncManager* manager, QString resource);
509 virtual void removeSyncInfo( QString syncProfile); 509 virtual void removeSyncInfo( QString syncProfile);
510 void setSyncManager(KSyncManager* manager); 510 void setSyncManager(KSyncManager* manager);
511 void setLoadedFileVersion(QDateTime); 511 void setLoadedFileVersion(QDateTime);
512 bool checkFileVersion(QString fn); 512 bool checkFileVersion(QString fn);
513 bool checkAllFileVersions();
513 bool checkFileChanged(QString fn); 514 bool checkFileChanged(QString fn);
514 Event* getLastSyncEvent(); 515 Event* getLastSyncEvent();
515 /** Adapt navigation units correpsonding to step size of navigation of the 516 /** Adapt navigation units correpsonding to step size of navigation of the
516 * current view. 517 * current view.
517 */ 518 */
518 void adaptNavigationUnits(); 519 void adaptNavigationUnits();
519 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 520 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
520 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 521 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
521 //Attendee* getYourAttendee(Event *event); 522 //Attendee* getYourAttendee(Event *event);
522 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 523 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
523 protected: 524 protected:
524 void schedule(Scheduler::Method, Incidence *incidence = 0); 525 void schedule(Scheduler::Method, Incidence *incidence = 0);
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 361eec8..19d731f 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -222,25 +222,33 @@ void KOCalEditView::deleteCal( int id )
222 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 222 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
223 if ( kkf->isStandard ) 223 if ( kkf->isStandard )
224 selectStdCal( 1, true ); 224 selectStdCal( 1, true );
225 emit removeCalendar ( id ); 225 emit removeCalendar ( id );
226 KOPrefs::instance()->mCalendars.remove ( kkf ); 226 KOPrefs::instance()->mCalendars.remove ( kkf );
227 emit needsUpdate(); 227 emit needsUpdate();
228 readConfig(); 228 readConfig();
229} 229}
230void KOCalEditView::infoCal( int id ) 230void KOCalEditView::infoCal( int id )
231{ 231{
232 QString name = KOPrefs::instance()->getCalendar( id )->mName; 232 QString name = KOPrefs::instance()->getCalendar( id )->mName;
233 QString file = KOPrefs::instance()->getCalendar( id )->mFileName; 233 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
234 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 234 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
235 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) ) ) {
236 emit calendarAdded( id );
237 readConfig();
238 emit needsUpdate();
239 }
240 }
241 else
242 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
235} 243}
236void KOCalEditView::readConfig() 244void KOCalEditView::readConfig()
237{ 245{
238 246
239 mStdandardB.clear(); 247 mStdandardB.clear();
240 mEnabledB.clear(); 248 mEnabledB.clear();
241 mAlarmB.clear(); 249 mAlarmB.clear();
242 mROB.clear(); 250 mROB.clear();
243 251
244 if ( mw ) delete mw; 252 if ( mw ) delete mw;
245 mw = new QWidget ( this ); 253 mw = new QWidget ( this );
246 ml->addWidget ( mw ); 254 ml->addWidget ( mw );
@@ -285,44 +293,52 @@ void KOCalEditView::readConfig()
285#endif 293#endif
286 294
287 295
288 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 296 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
289 int row = 1; 297 int row = 1;
290 while ( kkf ) { 298 while ( kkf ) {
291 299
292 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 300 KOCalCheckButton* cb = new KOCalCheckButton( mw );
293 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 301 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
294 cb->setChecked( kkf->isStandard ); 302 cb->setChecked( kkf->isStandard );
295 cb->setNum( kkf->mCalNumber ); 303 cb->setNum( kkf->mCalNumber );
296 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
305 if ( kkf->mErrorOnLoad )
306 cb->setEnabled( false );
297 cb = new KOCalCheckButton( mw ); 307 cb = new KOCalCheckButton( mw );
298 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); 308 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
299 cb->setChecked( kkf->isEnabled ); 309 cb->setChecked( kkf->isEnabled );
300 cb->setNum( kkf->mCalNumber ); 310 cb->setNum( kkf->mCalNumber );
311 if ( kkf->mErrorOnLoad )
312 cb->setEnabled( false );
301 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
302 KOCalButton* name = new KOCalButton( mw ); 314 KOCalButton* name = new KOCalButton( mw );
303 name->setNum( kkf->mCalNumber ); 315 name->setNum( kkf->mCalNumber );
304 name->setText( kkf->mName ); 316 name->setText( kkf->mName );
305 mainLayout->addWidget( name,row,2 ); 317 mainLayout->addWidget( name,row,2 );
306 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 318 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
307 cb = new KOCalCheckButton( mw ); 319 cb = new KOCalCheckButton( mw );
308 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); 320 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
309 cb->setChecked( kkf->isAlarmEnabled ); 321 cb->setChecked( kkf->isAlarmEnabled );
310 cb->setNum( kkf->mCalNumber ); 322 cb->setNum( kkf->mCalNumber );
311 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 323 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
324 if ( kkf->mErrorOnLoad )
325 cb->setEnabled( false );
312 cb = new KOCalCheckButton( mw ); 326 cb = new KOCalCheckButton( mw );
313 mainLayout->addWidget( cb,row,4 );mROB.append( cb ); 327 mainLayout->addWidget( cb,row,4 );mROB.append( cb );
314 cb->setChecked( kkf->isReadOnly ); 328 cb->setChecked( kkf->isReadOnly );
315 cb->setNum( kkf->mCalNumber ); 329 cb->setNum( kkf->mCalNumber );
316 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 330 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
331 if ( kkf->mErrorOnLoad )
332 cb->setEnabled( false );
317 KColorButton *colb = new KColorButton( mw ); 333 KColorButton *colb = new KColorButton( mw );
318 mainLayout->addWidget( colb,row,5 ); 334 mainLayout->addWidget( colb,row,5 );
319 colb->setID( kkf->mCalNumber ); 335 colb->setID( kkf->mCalNumber );
320 colb->setColor( kkf->mDefaultColor ); 336 colb->setColor( kkf->mDefaultColor );
321 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 337 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
322 if ( row > 1) { 338 if ( row > 1) {
323 KOCalButton* calb = new KOCalButton( mw ); 339 KOCalButton* calb = new KOCalButton( mw );
324 mainLayout->addWidget( calb,row,6 ); 340 mainLayout->addWidget( calb,row,6 );
325 calb->setNum( kkf->mCalNumber ); 341 calb->setNum( kkf->mCalNumber );
326 calb->setPixmap ( SmallIcon("minus")); 342 calb->setPixmap ( SmallIcon("minus"));
327 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 343 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
328 int hei = calb->sizeHint().height(); 344 int hei = calb->sizeHint().height();
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index f114d88..463fc33 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -47,33 +47,36 @@ class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mCalNumber = 0; 57 mCalNumber = 0;
58 mDefaultColor = Qt::red; 58 mDefaultColor = Qt::red;
59 mErrorOnLoad = false;
59 } 60 }
60 bool isStandard; 61 bool isStandard;
61 bool isEnabled; 62 bool isEnabled;
62 bool isAlarmEnabled; 63 bool isAlarmEnabled;
63 bool isReadOnly; 64 bool isReadOnly;
65 bool mErrorOnLoad;
64 QString mName; 66 QString mName;
65 QString mFileName; 67 QString mFileName;
66 int mCalNumber; 68 int mCalNumber;
67 QColor mDefaultColor; 69 QColor mDefaultColor;
70 QDateTime mLoadDt;
68}; 71};
69class KOPrefs : public KPimPrefs 72class KOPrefs : public KPimPrefs
70{ 73{
71 public: 74 public:
72 enum { FormatVCalendar, FormatICalendar }; 75 enum { FormatVCalendar, FormatICalendar };
73 enum { MailClientKMail, MailClientSendmail }; 76 enum { MailClientKMail, MailClientSendmail };
74 enum { IMIPDummy, IMIPKMail }; 77 enum { IMIPDummy, IMIPKMail };
75 enum { IMIPOutbox, IMIPdirectsend }; 78 enum { IMIPOutbox, IMIPdirectsend };
76 enum { neverAuto, addressbookAuto, selectedAuto }; 79 enum { neverAuto, addressbookAuto, selectedAuto };
77 enum { standardDestination, askDestination }; 80 enum { standardDestination, askDestination };
78 81
79 virtual ~KOPrefs(); 82 virtual ~KOPrefs();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f05ada5..472a978 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1815,45 +1815,53 @@ void MainWindow::saveStopTimer()
1815{ 1815{
1816 mSaveTimer.stop(); 1816 mSaveTimer.stop();
1817} 1817}
1818void MainWindow::save() 1818void MainWindow::save()
1819{ 1819{
1820 if ( !mCalendarModifiedFlag ) { 1820 if ( !mCalendarModifiedFlag ) {
1821 qDebug("KO: Calendar not modified. Nothing saved."); 1821 qDebug("KO: Calendar not modified. Nothing saved.");
1822 return; 1822 return;
1823 } 1823 }
1824 if ( mSyncManager->blockSave() ) 1824 if ( mSyncManager->blockSave() )
1825 return; 1825 return;
1826 mSyncManager->setBlockSave(true); 1826 mSyncManager->setBlockSave(true);
1827 if ( mView->checkFileVersion( defaultFileName()) ) { 1827 if ( mView->checkAllFileVersions() ) {
1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1829 QDate reference ( 2000,1,1); 1829 QDate reference ( 2000,1,1);
1830 int daysTo = reference.daysTo ( QDate::currentDate() ); 1830 int daysTo = reference.daysTo ( QDate::currentDate() );
1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1832 setCaption(i18n("Creating backup ... please wait ..." )); 1832 setCaption(i18n("Creating backup ... please wait ..." ));
1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1834 // we need the file path, the backup dir and the number of bups as param 1834 // we need the file path, the backup dir and the number of bups as param
1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1837 bupDir = KGlobalSettings::backupDataDir(); 1837 bupDir = KGlobalSettings::backupDataDir();
1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1839 if ( retval == 0 ) { 1839 if ( retval == 0 ) {
1840 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1840 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1841 // retval == 0 : backup skipped for today, try again tomorrow 1841 // retval == 0 : backup skipped for today, try again tomorrow
1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1843 } else if ( retval == 1 ){ 1843 } else if ( retval == 1 ){
1844 qDebug("KO: Backup created."); 1844 qDebug("KO: Backup created.");
1845 // backup ok 1845 // backup ok
1846 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1847 KopiCalendarFile * cal = calendars.first();
1848 cal = calendars.next();
1849 while ( cal ) {
1850 if ( !cal->mErrorOnLoad ) {
1851 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1852 }
1853 cal = calendars.next();
1854 }
1846 KOPrefs::instance()->mLastBackupDate = daysTo; 1855 KOPrefs::instance()->mLastBackupDate = daysTo;
1847
1848 } else if ( retval == 2 ){ 1856 } else if ( retval == 2 ){
1849 qDebug("KO: Backup globally cancelled."); 1857 qDebug("KO: Backup globally cancelled.");
1850 // backup globally cancelled 1858 // backup globally cancelled
1851 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1859 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1852 } 1860 }
1853 // retval == 3: do nothing, try again later 1861 // retval == 3: do nothing, try again later
1854 } 1862 }
1855 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1863 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1856 } 1864 }
1857 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1865 QTime neededSaveTime = QDateTime::currentDateTime().time();
1858 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1866 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1859 qDebug("KO: Start saving data to file!"); 1867 qDebug("KO: Start saving data to file!");