author | zautrix <zautrix> | 2005-10-12 11:14:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-12 11:14:13 (UTC) |
commit | a72f3f3acfac791715a1c512fc4cc4c3facdbb62 (patch) (side-by-side diff) | |
tree | 202c588777f8d4585a8c57164b1b412d7ad73e8a /korganizer | |
parent | 3ecfc912f657a710ed35c93dc6eb2991cce06835 (diff) | |
download | kdepimpi-a72f3f3acfac791715a1c512fc4cc4c3facdbb62.zip kdepimpi-a72f3f3acfac791715a1c512fc4cc4c3facdbb62.tar.gz kdepimpi-a72f3f3acfac791715a1c512fc4cc4c3facdbb62.tar.bz2 |
fix
-rw-r--r-- | korganizer/mainwindow.cpp | 75 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
2 files changed, 62 insertions, 17 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index c597138..66bb19b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -170,6 +170,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : p.drawLine( 2,7,6,7); } } + mAutoSaveDisabled = false; mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; QString confFile = locateLocal("config","korganizerrc"); @@ -537,17 +538,33 @@ bool MainWindow::askForQuitOnSaveError() } return retval; } - +bool MainWindow::checkAutosave() +{ + bool savedata = true; + if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { + switch( QMessageBox::information( this, "KO/Pi", + i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), + i18n("Yes, Save!"), i18n("No"), + 0, 0 ) ) { + case 1: + case 2: + savedata = false; + break; + default: + break; + } + } + return savedata; +} void MainWindow::closeEvent( QCloseEvent* ce ) { - - - if ( ! KOPrefs::instance()->mAskForQuit ) { - saveOnClose(); - if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { - ce->ignore(); - return; + if ( checkAutosave() ) { + saveOnClose(); + if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { + ce->ignore(); + return; + } } mClosed = true; ce->accept(); @@ -559,11 +576,13 @@ void MainWindow::closeEvent( QCloseEvent* ce ) i18n("Do you really want\nto close KO/Pi?"), i18n("Close"), i18n("No"), 0, 0 ) ) { - case 0: - saveOnClose(); - if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { - ce->ignore(); - return; + case 0: + if ( checkAutosave() ) { + saveOnClose(); + if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { + ce->ignore(); + return; + } } mClosed = true; ce->accept(); @@ -1657,6 +1676,7 @@ void MainWindow::keyBindings() i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + + i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ @@ -1972,10 +1992,18 @@ void MainWindow::slotModifiedChanged( bool ) return; int msec; + if ( mAutoSaveDisabled ) { + QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); + qDebug("KO: Autosave disabled (data change deteced)!"); + } if ( mCalendarModifiedFlag ) { //qDebug(" MainWindow timer is running "); return; } + mCalendarModifiedFlag = true; + if ( mAutoSaveDisabled ) { + return; + } // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) @@ -1986,11 +2014,15 @@ void MainWindow::slotModifiedChanged( bool ) mSaveTimerStart = QDateTime::currentDateTime(); mSaveDelay = msec/1000; qDebug("KO: Saving File in %d secs!", msec/1000); - mCalendarModifiedFlag = true; +} +void MainWindow::autoSaveWarning() +{ + setCaption(i18n("Autosave disabled!" )); } void MainWindow::saveStopTimer() { mSaveTimer.stop(); + mSaveDelay = 0; } void MainWindow::backupAllFiles() { @@ -2207,8 +2239,19 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) case Qt::Key_V: mView->viewManager()->showTodoView(); break; - case Qt::Key_C: - mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); + case Qt::Key_C: + if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { + if ( mAutoSaveDisabled ) { + mAutoSaveDisabled = false; + setCaption(i18n("Autosave enabled!" )); + return; + } else { + mAutoSaveDisabled = true; + saveStopTimer(); + setCaption(i18n("Autosave disabled! Save timer stopped!" )); + } + } else + mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); break; case Qt::Key_P: mView->showDatePicker( ); diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 71c069b..d8018b6 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -52,6 +52,7 @@ class MainWindow : public QMainWindow void recieve( const QCString& msg, const QByteArray& data ); void receiveStart( const QCString& msg, const QByteArray& data ); protected slots: + void autoSaveWarning(); void loadDataAfterStart(); void calHint(); void startMultiSync(); @@ -121,7 +122,8 @@ class MainWindow : public QMainWindow bool askForQuitOnSaveError(); private: - + bool mAutoSaveDisabled; + bool checkAutosave(); QCString mCStringMess; QByteArray mByteData; |