-rw-r--r-- | korganizer/calendarview.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 12 |
2 files changed, 22 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 316826a..ca071b2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -826,25 +826,25 @@ void CalendarView::checkFiles() | |||
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
839 | } | 839 | } |
840 | static bool firstTime = true; | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | 841 | if ( firstTime ) { |
842 | firstTime = false; | 842 | firstTime = false; |
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
847 | { | 847 | { |
848 | KConfig *config = KOGlobals::config(); | 848 | KConfig *config = KOGlobals::config(); |
849 | config->setGroup( "AppRun" ); | 849 | config->setGroup( "AppRun" ); |
850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
@@ -2522,36 +2522,46 @@ bool CalendarView::checkFileVersion(QString fn) | |||
2522 | syncCalendar( fn, 3 ); | 2522 | syncCalendar( fn, 3 ); |
2523 | Event * e = getLastSyncEvent(); | 2523 | Event * e = getLastSyncEvent(); |
2524 | if ( e ) | 2524 | if ( e ) |
2525 | mCalendar->deleteEvent( e ); | 2525 | mCalendar->deleteEvent( e ); |
2526 | return true; | 2526 | return true; |
2527 | } | 2527 | } |
2528 | bool CalendarView::saveCalendars() | 2528 | bool CalendarView::saveCalendars() |
2529 | { | 2529 | { |
2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2531 | KopiCalendarFile * cal = calendars.first(); | 2531 | KopiCalendarFile * cal = calendars.first(); |
2532 | mCalendar->setDefaultCalendar( 1 ); | 2532 | mCalendar->setDefaultCalendar( 1 ); |
2533 | mCalendar->setDefaultCalendarEnabledOnly(); | 2533 | mCalendar->setDefaultCalendarEnabledOnly(); |
2534 | saveCalendar( MainWindow::defaultFileName() ); | 2534 | QString saveError; |
2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | ||
2536 | saveError = cal->mName +"\n"; | ||
2535 | cal = calendars.next(); | 2537 | cal = calendars.next(); |
2536 | while ( cal ) { | 2538 | while ( cal ) { |
2537 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2538 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2539 | mCalendar->setDefaultCalendarEnabledOnly(); | 2541 | mCalendar->setDefaultCalendarEnabledOnly(); |
2540 | if ( saveCalendar( cal->mFileName ) ) | 2542 | if ( saveCalendar( cal->mFileName ) ) |
2541 | cal->mLoadDt = QDateTime::currentDateTime(); | 2543 | cal->mLoadDt = QDateTime::currentDateTime(); |
2544 | else | ||
2545 | saveError += cal->mName + "\n"; | ||
2542 | } | 2546 | } |
2543 | cal = calendars.next(); | 2547 | cal = calendars.next(); |
2544 | } | 2548 | } |
2545 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2550 | |||
2551 | if ( !saveError.isEmpty() ) { | ||
2552 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | ||
2553 | KMessageBox::error(this, saveError, i18n("Error saving data")); | ||
2554 | return false; | ||
2555 | } | ||
2546 | return true; | 2556 | return true; |
2547 | } | 2557 | } |
2548 | bool CalendarView::saveCalendar( QString filename ) | 2558 | bool CalendarView::saveCalendar( QString filename ) |
2549 | { | 2559 | { |
2550 | 2560 | ||
2551 | // Store back all unsaved data into calendar object | 2561 | // Store back all unsaved data into calendar object |
2552 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2562 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2553 | if ( mViewManager->currentView() ) | 2563 | if ( mViewManager->currentView() ) |
2554 | mViewManager->currentView()->flushView(); | 2564 | mViewManager->currentView()->flushView(); |
2555 | 2565 | ||
2556 | 2566 | ||
2557 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2567 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 94bc4c1..9c55e9f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -497,36 +497,44 @@ void MainWindow::showMaximized () | |||
497 | mView->goToday(); | 497 | mView->goToday(); |
498 | #endif | 498 | #endif |
499 | QWidget::showMaximized () ; | 499 | QWidget::showMaximized () ; |
500 | mClosed = false; | 500 | mClosed = false; |
501 | } | 501 | } |
502 | void MainWindow::closeEvent( QCloseEvent* ce ) | 502 | void MainWindow::closeEvent( QCloseEvent* ce ) |
503 | { | 503 | { |
504 | 504 | ||
505 | 505 | ||
506 | 506 | ||
507 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 507 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
508 | saveOnClose(); | 508 | saveOnClose(); |
509 | if ( mCalendarModifiedFlag ) { | ||
510 | ce->ignore(); | ||
511 | return; | ||
512 | } | ||
509 | mClosed = true; | 513 | mClosed = true; |
510 | ce->accept(); | 514 | ce->accept(); |
511 | return; | 515 | return; |
512 | 516 | ||
513 | } | 517 | } |
514 | 518 | ||
515 | switch( QMessageBox::information( this, "KO/Pi", | 519 | switch( QMessageBox::information( this, "KO/Pi", |
516 | i18n("Do you really want\nto close KO/Pi?"), | 520 | i18n("Do you really want\nto close KO/Pi?"), |
517 | i18n("Close"), i18n("No"), | 521 | i18n("Close"), i18n("No"), |
518 | 0, 0 ) ) { | 522 | 0, 0 ) ) { |
519 | case 0: | 523 | case 0: |
520 | saveOnClose(); | 524 | saveOnClose(); |
525 | if ( mCalendarModifiedFlag ) { | ||
526 | ce->ignore(); | ||
527 | return; | ||
528 | } | ||
521 | mClosed = true; | 529 | mClosed = true; |
522 | ce->accept(); | 530 | ce->accept(); |
523 | break; | 531 | break; |
524 | case 1: | 532 | case 1: |
525 | ce->ignore(); | 533 | ce->ignore(); |
526 | break; | 534 | break; |
527 | case 2: | 535 | case 2: |
528 | 536 | ||
529 | default: | 537 | default: |
530 | break; | 538 | break; |
531 | } | 539 | } |
532 | 540 | ||
@@ -1993,26 +2001,26 @@ void MainWindow::save() | |||
1993 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2001 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1994 | QDate reference ( 2000,1,1); | 2002 | QDate reference ( 2000,1,1); |
1995 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2003 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1996 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2004 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1997 | backupAllFiles(); | 2005 | backupAllFiles(); |
1998 | } | 2006 | } |
1999 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2007 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2000 | } | 2008 | } |
2001 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 2009 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
2002 | if ( !isMinimized () ) | 2010 | if ( !isMinimized () ) |
2003 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2011 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2004 | qDebug("KO: Start saving data to file!"); | 2012 | qDebug("KO: Start saving data to file!"); |
2005 | mView->saveCalendars(); | 2013 | if ( mView->saveCalendars() ) |
2006 | mCalendarModifiedFlag = false; | 2014 | mCalendarModifiedFlag = false; |
2007 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 2015 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
2008 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2016 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2009 | QString savemes; | 2017 | QString savemes; |
2010 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2018 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2011 | if ( !isMinimized () ) | 2019 | if ( !isMinimized () ) |
2012 | setCaption(savemes); | 2020 | setCaption(savemes); |
2013 | else | 2021 | else |
2014 | qDebug(savemes); | 2022 | qDebug(savemes); |
2015 | } else { | 2023 | } else { |
2016 | setCaption(i18n("Saving cancelled!")); | 2024 | setCaption(i18n("Saving cancelled!")); |
2017 | mCalendarModifiedFlag = false; | 2025 | mCalendarModifiedFlag = false; |
2018 | slotModifiedChanged( true ); | 2026 | slotModifiedChanged( true ); |