-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 8 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 113 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
3 files changed, 64 insertions, 58 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index 90521ec..2ade5bd 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt @@ -1356,9 +1356,9 @@ { "Use standard backup dir","Standard Backupverzeichnis" }, { "Number of Backups:","Anzahl der Backups" }, { "Make backup every ","Mache ein Backup alle " }, { " days"," Tage" }, -{ "Creating backup ... please wait ...","Erzeuge Backup ... bitte warten ..." }, +{ "Creating backup ... please wait ...","Erstelle Backup ... bitte warten ..." }, { "Backup Failed!","Backup Problem!" }, { "Try again now","Versuche jetzt nochmal" }, { "Try again later","Versuche später nochmal" }, { "Try again tomorrow","Versuche morgen nochmal" }, @@ -1449,8 +1449,14 @@ { "Details","Details" }, { "Profession","Beruf" }, { "Children","Kinder" }, { "Department","Abteilung" }, +{ "Backup cancelled","Backup abgebrochen" }, +{ "Backup globally disabled","Backup global abgeschaltet" }, +{ "Backup succesfully finished","Backup erfolgreich beendet" }, +{ "(Hint: You can enable automatic backup in the global settings!)","(Hinweis: Sie können ein automatisches Backup in den globalen Einstellungen konfigurieren!)" }, +{ "This will <b>backup all calendar files</b> to the directory %1 %2","Das schreibt ein <b>Backup aller Kalenderdateien</b> in das Verzeichnis %1 %2" }, +{ "","" }, { "","" }, { "","" }, { "","" }, { "","" }, diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 48320a5..b9d8742 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1032,13 +1032,14 @@ void MainWindow::initActions() #endif //#endif //importMenu->insertSeparator(); +#if 0 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); - +#endif action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); @@ -1844,8 +1845,46 @@ void MainWindow::slotModifiedChanged( bool changed ) void MainWindow::saveStopTimer() { mSaveTimer.stop(); } +void MainWindow::backupAllFiles() +{ + QDate reference ( 2000,1,1); + int daysTo = reference.daysTo ( QDate::currentDate() ); + setCaption(i18n("Creating backup ... please wait ..." )); + qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); + // we need the file path, the backup dir and the number of bups as param + QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; + if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) + bupDir = KGlobalSettings::backupDataDir(); + int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); + if ( retval == 0 ) { + setCaption(i18n("Backup cancelled" )); + qDebug("KO: Backup cancelled. Will try again tomorrow "); + // retval == 0 : backup skipped for today, try again tomorrow + KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; + } else if ( retval == 1 ){ + qDebug("KO: Backup created."); + // 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; + setCaption(i18n("Backup succesfully finished" )); + } else if ( retval == 2 ){ + setCaption(i18n("Backup globally disabled" )); + qDebug("KO: Backup globally cancelled."); + // backup globally cancelled + KPimGlobalPrefs::instance()->mBackupEnabled = false; + } + // retval == 3: do nothing, try again later +} void MainWindow::save() { if ( !mCalendarModifiedFlag ) { qDebug("KO: Calendar not modified. Nothing saved."); @@ -1858,40 +1897,11 @@ void MainWindow::save() if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ QDate reference ( 2000,1,1); int daysTo = reference.daysTo ( QDate::currentDate() ); if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { - setCaption(i18n("Creating backup ... please wait ..." )); - qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); - // we need the file path, the backup dir and the number of bups as param - QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; - if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) - bupDir = KGlobalSettings::backupDataDir(); - int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); - if ( retval == 0 ) { - qDebug("KO: Backup cancelled. Will try again tomorrow "); - // retval == 0 : backup skipped for today, try again tomorrow - KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; - } else if ( retval == 1 ){ - qDebug("KO: Backup created."); - // 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 ){ - qDebug("KO: Backup globally cancelled."); - // backup globally cancelled - KPimGlobalPrefs::instance()->mBackupEnabled = false; - } - // retval == 3: do nothing, try again later + backupAllFiles(); } - ; // KPimGlobalPrefs::instance()->mLastBackupDate + ; // KPimGlobalPrefs::instance()->mLastBackupDate } QTime neededSaveTime = QDateTime::currentDateTime().time(); setCaption(i18n("KO/Pi:Saving Data to File ..." )); qDebug("KO: Start saving data to file!"); @@ -2299,37 +2309,25 @@ void MainWindow::configureAgenda( int item ) } void MainWindow::saveCalendar() { - QString fn = KOPrefs::instance()->mLastSaveFile; - fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); - - if ( fn == "" ) - return; - QFileInfo info; - info.setFile( fn ); - QString mes; - bool createbup = true; - if ( info. exists() ) { - mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; - int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, - i18n("Overwrite!"), i18n("Cancel"), 0, - 0, 1 ); - if ( result != 0 ) { - createbup = false; - } - } - if ( createbup ) { - mView->saveCalendar( fn ); - mes = i18n("KO/Pi:Saved %1").arg(fn); - KOPrefs::instance()->mLastSaveFile = fn; - setCaption(mes); - } + + QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; + if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) + bupDir = KGlobalSettings::backupDataDir(); + bupDir = KGlobal::formatMessage ( bupDir, 0 ); + QString bupHint; + if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) + bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); + if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; + backupAllFiles(); } void MainWindow::loadCalendar() { - QString fn = KOPrefs::instance()->mLastLoadFile; + +#if 0 + QString fn = KOPrefs::instance()->mLastLoadFile; fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); if ( fn == "" ) return; @@ -2358,8 +2356,9 @@ void MainWindow::loadCalendar() KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } +#endif } void MainWindow::quickImportIcal() { diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 9a8bc7f..c9817c3 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -80,8 +80,9 @@ class MainWindow : public QMainWindow void slotModifiedChanged( bool ); void save(); + void backupAllFiles(); void saveStopTimer(); void configureToolBar( int ); void printSel(); void printCal(); |