-rw-r--r-- | korganizer/mainwindow.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 3feb4ab..a2c20a8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -256,12 +256,14 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
256 | // qApp->processEvents(); | 256 | // qApp->processEvents(); |
257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
258 | //fillSyncMenu(); | 258 | //fillSyncMenu(); |
259 | 259 | ||
260 | 260 | ||
261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
262 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
263 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | ||
262 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 264 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
263 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 265 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
264 | mSyncManager->setDefaultFileName( defaultFileName()); | 266 | mSyncManager->setDefaultFileName( defaultFileName()); |
265 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 267 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
266 | mSyncManager->fillSyncMenu(); | 268 | mSyncManager->fillSyncMenu(); |
267 | 269 | ||
@@ -1444,43 +1446,54 @@ void MainWindow::saveOnClose() | |||
1444 | save(); | 1446 | save(); |
1445 | } | 1447 | } |
1446 | void MainWindow::slotModifiedChanged( bool changed ) | 1448 | void MainWindow::slotModifiedChanged( bool changed ) |
1447 | { | 1449 | { |
1448 | if ( mBlockAtStartup ) | 1450 | if ( mBlockAtStartup ) |
1449 | return; | 1451 | return; |
1452 | |||
1450 | int msec; | 1453 | int msec; |
1451 | // we store the changes after 1 minute, | 1454 | // we store the changes after 1 minute, |
1452 | // and for safety reasons after 10 minutes again | 1455 | // and for safety reasons after 10 minutes again |
1453 | if ( !mSyncManager->blockSave() ) | 1456 | if ( !mSyncManager->blockSave() ) |
1454 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1457 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1455 | else | 1458 | else |
1456 | msec = 1000 * 600; | 1459 | msec = 1000 * 600; |
1457 | mSaveTimer.start( msec, true ); // 1 minute | 1460 | mSaveTimer.start( msec, true ); // 1 minute |
1458 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1461 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1459 | mCalendarModifiedFlag = true; | 1462 | mCalendarModifiedFlag = true; |
1460 | } | 1463 | } |
1464 | void MainWindow::saveStopTimer() | ||
1465 | { | ||
1466 | mSaveTimer.stop(); | ||
1467 | if (mSaveTimer.isActive() ) | ||
1468 | qDebug("ti active "); | ||
1469 | else | ||
1470 | qDebug("KO: Save timer stopped"); | ||
1471 | } | ||
1461 | void MainWindow::save() | 1472 | void MainWindow::save() |
1462 | { | 1473 | { |
1474 | if ( !mCalendarModifiedFlag ) { | ||
1475 | qDebug("KO: Calendar not modified. Nothing saved."); | ||
1476 | return; | ||
1477 | } | ||
1463 | if ( mSyncManager->blockSave() ) | 1478 | if ( mSyncManager->blockSave() ) |
1464 | return; | 1479 | return; |
1465 | mSyncManager->setBlockSave(true); | 1480 | mSyncManager->setBlockSave(true); |
1466 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1481 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1467 | |||
1468 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1482 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1469 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1483 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1470 | qDebug("KO: Start saving data to file!"); | 1484 | qDebug("KO: Start saving data to file!"); |
1471 | mView->saveCalendar( defaultFileName() ); | 1485 | mView->saveCalendar( defaultFileName() ); |
1472 | 1486 | mCalendarModifiedFlag = false; | |
1473 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1487 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1474 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1488 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1475 | QString savemes; | 1489 | QString savemes; |
1476 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1490 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1477 | setCaption(savemes); | 1491 | setCaption(savemes); |
1478 | } else | 1492 | } else |
1479 | setCaption(i18n("Saving cancelled!")); | 1493 | setCaption(i18n("Saving cancelled!")); |
1480 | mCalendarModifiedFlag = false; | ||
1481 | mSyncManager->setBlockSave( false ); | 1494 | mSyncManager->setBlockSave( false ); |
1482 | } | 1495 | } |
1483 | 1496 | ||
1484 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1497 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1485 | { | 1498 | { |
1486 | if ( !e->isAutoRepeat() ) { | 1499 | if ( !e->isAutoRepeat() ) { |