summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-17 19:50:38 (UTC)
committer zautrix <zautrix>2005-08-17 19:50:38 (UTC)
commit39f1119563e038a029fd23c4b3af03eda02fe308 (patch) (unidiff)
treeb552570e883436ec451cdb7d4b215206c2ca3ba3 /korganizer
parentdfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5 (diff)
downloadkdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.zip
kdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.tar.gz
kdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.tar.bz2
kopi save error warning
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp14
-rw-r--r--korganizer/mainwindow.cpp12
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
@@ -790,97 +790,97 @@ void CalendarView::scrollBarValue(int val )
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void 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}
846void CalendarView::checkAlarms() 846void 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 ) );
851 int daysto = dt.daysTo( QDate::currentDate() ); 851 int daysto = dt.daysTo( QDate::currentDate() );
852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
853 dt = dt.addDays( days ); 853 dt = dt.addDays( days );
854 int secto = dt.secsTo( QDateTime::currentDateTime() ); 854 int secto = dt.secsTo( QDateTime::currentDateTime() );
855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
856 //qDebug("KO: Reading program stop %d ", secs); 856 //qDebug("KO: Reading program stop %d ", secs);
857 //secs -= ( 3600 * 24*3 ); // debug only 857 //secs -= ( 3600 * 24*3 ); // debug only
858 QDateTime latest = dt.addSecs ( secs ); 858 QDateTime latest = dt.addSecs ( secs );
859 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 859 qDebug("KO: Last termination on %s ", latest.toString().latin1());
860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
861 QPtrList<Incidence> el = mCalendar->rawIncidences(); 861 QPtrList<Incidence> el = mCalendar->rawIncidences();
862 QPtrList<Incidence> al; 862 QPtrList<Incidence> al;
863 Incidence* inL = el.first(); 863 Incidence* inL = el.first();
864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
866 while ( inL ) { 866 while ( inL ) {
867 bool ok = false; 867 bool ok = false;
868 int offset = 0; 868 int offset = 0;
869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
870 if ( ok ) { 870 if ( ok ) {
871 //qDebug("OK %s",next.toString().latin1()); 871 //qDebug("OK %s",next.toString().latin1());
872 if ( next < cur ) { 872 if ( next < cur ) {
873 al.append( inL ); 873 al.append( inL );
874 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 874 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
875 } 875 }
876 } 876 }
877 inL = el.next(); 877 inL = el.next();
878 } 878 }
879 if ( al.count() ) { 879 if ( al.count() ) {
880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
881 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 881 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
882 QVBoxLayout* lay = new QVBoxLayout( dia ); 882 QVBoxLayout* lay = new QVBoxLayout( dia );
883 lay->setSpacing( 0 ); 883 lay->setSpacing( 0 );
884 lay->setMargin( 0 ); 884 lay->setMargin( 0 );
885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
@@ -2486,108 +2486,118 @@ bool CalendarView::checkAllFileVersions()
2486 if ( !checkFileVersion(cal->mFileName )) { 2486 if ( !checkFileVersion(cal->mFileName )) {
2487 loadedFileVersion = storeTemp; 2487 loadedFileVersion = storeTemp;
2488 restoreCalendarSettings(); 2488 restoreCalendarSettings();
2489 return false; 2489 return false;
2490 } 2490 }
2491 } 2491 }
2492 cal = calendars.next(); 2492 cal = calendars.next();
2493 } 2493 }
2494 loadedFileVersion = storeTemp; 2494 loadedFileVersion = storeTemp;
2495 return true; 2495 return true;
2496} 2496}
2497bool CalendarView::checkFileVersion(QString fn) 2497bool CalendarView::checkFileVersion(QString fn)
2498{ 2498{
2499 QFileInfo finf ( fn ); 2499 QFileInfo finf ( fn );
2500 if ( !finf.exists() ) 2500 if ( !finf.exists() )
2501 return true; 2501 return true;
2502 QDateTime dt = finf.lastModified (); 2502 QDateTime dt = finf.lastModified ();
2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2505 if ( dt <= loadedFileVersion ) 2505 if ( dt <= loadedFileVersion )
2506 return true; 2506 return true;
2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2508 i18n("KO/Pi Warning"),i18n("Overwrite"), 2508 i18n("KO/Pi Warning"),i18n("Overwrite"),
2509 i18n("Sync+save")); 2509 i18n("Sync+save"));
2510 2510
2511 if ( km == KMessageBox::Cancel ) 2511 if ( km == KMessageBox::Cancel )
2512 return false; 2512 return false;
2513 if ( km == KMessageBox::Yes ) 2513 if ( km == KMessageBox::Yes )
2514 return true; 2514 return true;
2515 2515
2516 setSyncDevice("deleteaftersync" ); 2516 setSyncDevice("deleteaftersync" );
2517 mSyncManager->mAskForPreferences = true; 2517 mSyncManager->mAskForPreferences = true;
2518 mSyncManager->mSyncAlgoPrefs = 3; 2518 mSyncManager->mSyncAlgoPrefs = 3;
2519 mSyncManager->mWriteBackFile = false; 2519 mSyncManager->mWriteBackFile = false;
2520 mSyncManager->mWriteBackExistingOnly = false; 2520 mSyncManager->mWriteBackExistingOnly = false;
2521 mSyncManager->mShowSyncSummary = false; 2521 mSyncManager->mShowSyncSummary = false;
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}
2528bool CalendarView::saveCalendars() 2528bool 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}
2548bool CalendarView::saveCalendar( QString filename ) 2558bool 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);
2558 mStorage->setSaveFormat( new ICalFormat() ); 2568 mStorage->setSaveFormat( new ICalFormat() );
2559 mStorage->setFileName( filename ); 2569 mStorage->setFileName( filename );
2560 bool success; 2570 bool success;
2561 success = mStorage->save(); 2571 success = mStorage->save();
2562 if ( !success ) { 2572 if ( !success ) {
2563 return false; 2573 return false;
2564 } 2574 }
2565 if ( filename == MainWindow::defaultFileName() ) { 2575 if ( filename == MainWindow::defaultFileName() ) {
2566 setLoadedFileVersion( lfv ); 2576 setLoadedFileVersion( lfv );
2567 watchSavedFile(); 2577 watchSavedFile();
2568 } 2578 }
2569 return true; 2579 return true;
2570} 2580}
2571 2581
2572void CalendarView::closeCalendar() 2582void CalendarView::closeCalendar()
2573{ 2583{
2574 2584
2575 // child windows no longer valid 2585 // child windows no longer valid
2576 clearAllViews(); 2586 clearAllViews();
2577 emit closingDown(); 2587 emit closingDown();
2578 2588
2579 mCalendar->close(); 2589 mCalendar->close();
2580 setModified(false); 2590 setModified(false);
2581 updateView(); 2591 updateView();
2582} 2592}
2583 2593
2584void CalendarView::archiveCalendar() 2594void CalendarView::archiveCalendar()
2585{ 2595{
2586 mDialogManager->showArchiveDialog(); 2596 mDialogManager->showArchiveDialog();
2587} 2597}
2588 2598
2589 2599
2590void CalendarView::readSettings() 2600void CalendarView::readSettings()
2591{ 2601{
2592 2602
2593 2603
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 94bc4c1..9c55e9f 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -461,108 +461,116 @@ void MainWindow::disableBR(bool b)
461 } 461 }
462 } 462 }
463#endif 463#endif
464 464
465} 465}
466bool MainWindow::beamReceiveEnabled() 466bool MainWindow::beamReceiveEnabled()
467{ 467{
468#ifndef DESKTOP_VERSION 468#ifndef DESKTOP_VERSION
469 return ( infrared != 0 ); 469 return ( infrared != 0 );
470#endif 470#endif
471 return false; 471 return false;
472} 472}
473 473
474void MainWindow::toggleBeamReceive() 474void MainWindow::toggleBeamReceive()
475{ 475{
476 if ( mBRdisabled ) 476 if ( mBRdisabled )
477 return; 477 return;
478#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
479 if ( infrared ) { 479 if ( infrared ) {
480 qDebug("KO: Disable BeamReceive "); 480 qDebug("KO: Disable BeamReceive ");
481 delete infrared; 481 delete infrared;
482 infrared = 0; 482 infrared = 0;
483 brAction->setOn(false); 483 brAction->setOn(false);
484 return; 484 return;
485 } 485 }
486 qDebug("KO: Enable BeamReceive "); 486 qDebug("KO: Enable BeamReceive ");
487 brAction->setOn(true); 487 brAction->setOn(true);
488 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 488 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
489 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 489 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
490#endif 490#endif
491} 491}
492void MainWindow::showMaximized () 492void MainWindow::showMaximized ()
493{ 493{
494#ifndef DESKTOP_VERSION 494#ifndef DESKTOP_VERSION
495 if ( ! globalFlagBlockStartup ) 495 if ( ! globalFlagBlockStartup )
496 if ( mClosed ) 496 if ( mClosed )
497 mView->goToday(); 497 mView->goToday();
498#endif 498#endif
499 QWidget::showMaximized () ; 499 QWidget::showMaximized () ;
500 mClosed = false; 500 mClosed = false;
501} 501}
502void MainWindow::closeEvent( QCloseEvent* ce ) 502void 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
533 541
534} 542}
535 543
536void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 544void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
537{ 545{
538 QDataStream stream( data, IO_ReadOnly ); 546 QDataStream stream( data, IO_ReadOnly );
539 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 547 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
540 //QString datamess; 548 //QString datamess;
541 //qDebug("message "); 549 //qDebug("message ");
542 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 550 qDebug("KO: QCOP message received: %s ", cmsg.data() );
543 551
544 if ( cmsg == "setDocument(QString)" ) { 552 if ( cmsg == "setDocument(QString)" ) {
545 QDataStream stream( data, IO_ReadOnly ); 553 QDataStream stream( data, IO_ReadOnly );
546 QString fileName; 554 QString fileName;
547 stream >> fileName; 555 stream >> fileName;
548 //qDebug("filename %s ", fileName.latin1()); 556 //qDebug("filename %s ", fileName.latin1());
549 showMaximized(); 557 showMaximized();
550 raise(); 558 raise();
551 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 559 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
552 mSyncManager->slotSyncMenu( 1002 ); 560 mSyncManager->slotSyncMenu( 1002 );
553 return; 561 return;
554 } 562 }
555 563
556 if ( cmsg == "-writeFile" ) { 564 if ( cmsg == "-writeFile" ) {
557 // I made from the "-writeFile" an "-writeAlarm" 565 // I made from the "-writeFile" an "-writeAlarm"
558 mView->viewManager()->showWhatsNextView(); 566 mView->viewManager()->showWhatsNextView();
559 mCalendar->checkAlarmForIncidence( 0, true); 567 mCalendar->checkAlarmForIncidence( 0, true);
560 showMaximized(); 568 showMaximized();
561 raise(); 569 raise();
562 return; 570 return;
563 571
564 } 572 }
565 if ( cmsg == "-writeFileSilent" ) { 573 if ( cmsg == "-writeFileSilent" ) {
566 // I made from the "-writeFile" an "-writeAlarm" 574 // I made from the "-writeFile" an "-writeAlarm"
567 // mView->viewManager()->showWhatsNextView(); 575 // mView->viewManager()->showWhatsNextView();
568 mCalendar->checkAlarmForIncidence( 0, true); 576 mCalendar->checkAlarmForIncidence( 0, true);
@@ -1957,98 +1965,98 @@ void MainWindow::backupAllFiles()
1957 qDebug("KO: Backup created."); 1965 qDebug("KO: Backup created.");
1958 // backup ok 1966 // backup ok
1959 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1967 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1960 KopiCalendarFile * cal = calendars.first(); 1968 KopiCalendarFile * cal = calendars.first();
1961 cal = calendars.next(); 1969 cal = calendars.next();
1962 while ( cal ) { 1970 while ( cal ) {
1963 if ( !cal->mErrorOnLoad ) { 1971 if ( !cal->mErrorOnLoad ) {
1964 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1972 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1965 } 1973 }
1966 cal = calendars.next(); 1974 cal = calendars.next();
1967 } 1975 }
1968 KOPrefs::instance()->mLastBackupDate = daysTo; 1976 KOPrefs::instance()->mLastBackupDate = daysTo;
1969 setCaption(i18n("Backup succesfully finished" )); 1977 setCaption(i18n("Backup succesfully finished" ));
1970 } else if ( retval == 2 ){ 1978 } else if ( retval == 2 ){
1971 setCaption(i18n("Backup globally disabled" )); 1979 setCaption(i18n("Backup globally disabled" ));
1972 qDebug("KO: Backup globally cancelled."); 1980 qDebug("KO: Backup globally cancelled.");
1973 // backup globally cancelled 1981 // backup globally cancelled
1974 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1982 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1975 } 1983 }
1976 // retval == 3: do nothing, try again later 1984 // retval == 3: do nothing, try again later
1977} 1985}
1978void MainWindow::save() 1986void MainWindow::save()
1979{ 1987{
1980 1988
1981 if ( mView->viewManager()->journalView() ) 1989 if ( mView->viewManager()->journalView() )
1982 mView->viewManager()->journalView()->checkModified(); 1990 mView->viewManager()->journalView()->checkModified();
1983 if ( !mCalendarModifiedFlag ) { 1991 if ( !mCalendarModifiedFlag ) {
1984 qDebug("KO: Calendar not modified. Nothing saved."); 1992 qDebug("KO: Calendar not modified. Nothing saved.");
1985 return; 1993 return;
1986 } 1994 }
1987 if ( mSyncManager->blockSave() ) { 1995 if ( mSyncManager->blockSave() ) {
1988 slotModifiedChanged( true ); 1996 slotModifiedChanged( true );
1989 return; 1997 return;
1990 } 1998 }
1991 mSyncManager->setBlockSave(true); 1999 mSyncManager->setBlockSave(true);
1992 if ( mView->checkAllFileVersions() ) { 2000 if ( mView->checkAllFileVersions() ) {
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 );
2019 } 2027 }
2020 mSyncManager->setBlockSave( false ); 2028 mSyncManager->setBlockSave( false );
2021} 2029}
2022 2030
2023void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2031void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2024{ 2032{
2025 if ( !e->isAutoRepeat() ) { 2033 if ( !e->isAutoRepeat() ) {
2026 mFlagKeyPressed = false; 2034 mFlagKeyPressed = false;
2027 } 2035 }
2028} 2036}
2029void MainWindow::keyPressEvent ( QKeyEvent * e ) 2037void MainWindow::keyPressEvent ( QKeyEvent * e )
2030{ 2038{
2031 qApp->processEvents(); 2039 qApp->processEvents();
2032 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2040 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2033 e->ignore(); 2041 e->ignore();
2034 // qDebug(" ignore %d",e->isAutoRepeat() ); 2042 // qDebug(" ignore %d",e->isAutoRepeat() );
2035 return; 2043 return;
2036 } 2044 }
2037 if (! e->isAutoRepeat() ) 2045 if (! e->isAutoRepeat() )
2038 mFlagKeyPressed = true; 2046 mFlagKeyPressed = true;
2039 KOPrefs *p = KOPrefs::instance(); 2047 KOPrefs *p = KOPrefs::instance();
2040 bool showSelectedDates = false; 2048 bool showSelectedDates = false;
2041 int size; 2049 int size;
2042 int pro = 0; 2050 int pro = 0;
2043 //qDebug("MainWindow::keyPressEvent "); 2051 //qDebug("MainWindow::keyPressEvent ");
2044 switch ( e->key() ) { 2052 switch ( e->key() ) {
2045 case Qt::Key_Right: 2053 case Qt::Key_Right:
2046 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2054 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2047 mView->goNextMonth(); 2055 mView->goNextMonth();
2048 else 2056 else
2049 mView->goNext(); 2057 mView->goNext();
2050 showSelectedDates = true; 2058 showSelectedDates = true;
2051 break; 2059 break;
2052 case Qt::Key_Left: 2060 case Qt::Key_Left:
2053 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2061 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2054 mView->goPreviousMonth(); 2062 mView->goPreviousMonth();