author | zautrix <zautrix> | 2005-06-26 13:45:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 13:45:09 (UTC) |
commit | bb565390dd1c31929780df60e2bb06e9259f4d0b (patch) (side-by-side diff) | |
tree | 3f9f8b72ba68958553e8b20f5061ab55ec7b50f1 /korganizer | |
parent | d9255cd129d42abf08efc11ff9b29e831e05e803 (diff) | |
download | kdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.zip kdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.tar.gz kdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/mainwindow.cpp | 113 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
2 files changed, 57 insertions, 57 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 48320a5..b9d8742 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1012,53 +1012,54 @@ void MainWindow::initActions() action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); importMenu_X->insertSeparator(); action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); //#ifndef DESKTOP_VERSION importMenu_X->insertSeparator(); action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); //#else #ifdef _OL_IMPORT_ importMenu_X->insertSeparator(); action = new QAction( "import_ol", i18n("Import from OL"), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); #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() ) ); importMenu->insertSeparator(); importMenu->insertItem( i18n("Import"), importMenu_X ); //importMenu->insertSeparator(); action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, this ); action->addTo( exportMenu_X ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); //LR QPopupMenu *ex2phone = new QPopupMenu( this ); ex2phone->insertItem(i18n("Complete calendar..."), 1 ); ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); importMenu->insertItem( i18n("Export"), exportMenu_X ); #ifndef DESKTOP_VERSION //importMenu->insertSeparator(); brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, @@ -1824,94 +1825,103 @@ void MainWindow::saveOnClose() if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) save(); mView->writeSettings(); } void MainWindow::slotModifiedChanged( bool changed ) { if ( mBlockAtStartup ) return; int msec; // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } 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."); return; } if ( mSyncManager->blockSave() ) return; mSyncManager->setBlockSave(true); if ( mView->checkAllFileVersions() ) { 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!"); mView->saveCalendars(); mCalendarModifiedFlag = false; int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Needed %d ms for saving.",msNeeded ); QString savemes; savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); setCaption(savemes); } else setCaption(i18n("Saving cancelled!")); mSyncManager->setBlockSave( false ); } void MainWindow::keyReleaseEvent ( QKeyEvent * e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void MainWindow::keyPressEvent ( QKeyEvent * e ) { @@ -2279,107 +2289,96 @@ void MainWindow::setCaptionToDates() if ( !addString.isEmpty() ) selDates = addString+", "+selDates ; } setCaption( i18n("Dates: ") + selDates ); } void MainWindow::showConfigureAgenda( ) { int iii; for ( iii = 1;iii<= 10 ;++iii ){ configureAgendaMenu->setItemChecked( (iii+1)*2, false ); } configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); } void MainWindow::configureAgenda( int item ) { if ( KOPrefs::instance()->mHourSize == item ) return; KOPrefs::instance()->mHourSize=item; mView->viewManager()->agendaView()->updateConfig(); } 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; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( info. exists() ) { mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); int result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, i18n("Load!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { loadbup = false; } } else { QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 0, 1 ); return; } if ( loadbup ) { mView->openCalendar( fn ); KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } +#endif } void MainWindow::quickImportIcal() { importFile( KOPrefs::instance()->mLastImportFile, false ); } void MainWindow::importFile( QString fn, bool quick ) { QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return; } int result = 0; if ( !quick ) { mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, "Import", "Cancel", 0, diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 9a8bc7f..c9817c3 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -60,48 +60,49 @@ class MainWindow : public QMainWindow void usertrans(); void features(); void synchowto(); void storagehowto(); void timetrackinghowto(); void kdesynchowto(); void multisynchowto(); void whatsNew(); void keyBindings(); void aboutAutoSaving();; void aboutKnownBugs(); void processIncidenceSelection( Incidence * ); void importQtopia(); void importBday(); void importOL(); void importIcal(); void importFile( QString, bool ); void quickImportIcal(); void slotModifiedChanged( bool ); void save(); + void backupAllFiles(); void saveStopTimer(); void configureToolBar( int ); void printSel(); void printCal(); void printListView(); void saveCalendar(); void loadCalendar(); void exportVCalendar(); void fillFilterMenu(); void fillFilterMenuTB(); void selectFilter( int ); void fillFilterMenuPopup(); void selectFilterPopup( int ); void exportToPhone( int ); void toggleBeamReceive(); void disableBR(bool); signals: void selectWeek ( int ); private slots: void showConfigureAgenda(); void getFile( bool ); void syncFileRequest(); protected: |