summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 08:07:41 (UTC)
committer zautrix <zautrix>2004-10-05 08:07:41 (UTC)
commitad859d26b813101adab963f50e694961702561d9 (patch) (unidiff)
tree36eb7f12ee6ee80f50cdd13bbfaba74e9a1b37d1
parentfc2c103f45a6d4e4105259436266538c645f2c87 (diff)
downloadkdepimpi-ad859d26b813101adab963f50e694961702561d9.zip
kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.gz
kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.bz2
cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp115
-rw-r--r--korganizer/mainwindow.h2
-rw-r--r--libkcal/calstorage.h2
-rw-r--r--libkcal/filestorage.cpp4
-rw-r--r--libkcal/filestorage.h2
-rw-r--r--libkcal/icalformat.cpp24
-rw-r--r--libkcal/icalformat.h3
10 files changed, 20 insertions, 154 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index eaea040..fecc7e2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -456,3178 +456,3180 @@ void CalendarView::init()
456 mAlarmTimer = new QTimer( this ); 456 mAlarmTimer = new QTimer( this );
457 mRecheckAlarmTimer = new QTimer( this ); 457 mRecheckAlarmTimer = new QTimer( this );
458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
461 mAlarmDialog = new AlarmDialog( this ); 461 mAlarmDialog = new AlarmDialog( this );
462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
463 mAlarmDialog->setServerNotification( false ); 463 mAlarmDialog->setServerNotification( false );
464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
465} 465}
466 466
467 467
468CalendarView::~CalendarView() 468CalendarView::~CalendarView()
469{ 469{
470 // kdDebug() << "~CalendarView()" << endl; 470 // kdDebug() << "~CalendarView()" << endl;
471 //qDebug("CalendarView::~CalendarView() "); 471 //qDebug("CalendarView::~CalendarView() ");
472 delete mDialogManager; 472 delete mDialogManager;
473 delete mViewManager; 473 delete mViewManager;
474 delete mStorage; 474 delete mStorage;
475 delete mDateFrame ; 475 delete mDateFrame ;
476 delete beamDialog; 476 delete beamDialog;
477 //kdDebug() << "~CalendarView() done" << endl; 477 //kdDebug() << "~CalendarView() done" << endl;
478} 478}
479void CalendarView::timerAlarm() 479void CalendarView::timerAlarm()
480{ 480{
481 //qDebug("CalendarView::timerAlarm() "); 481 //qDebug("CalendarView::timerAlarm() ");
482 computeAlarm(mAlarmNotification ); 482 computeAlarm(mAlarmNotification );
483} 483}
484 484
485void CalendarView::suspendAlarm() 485void CalendarView::suspendAlarm()
486{ 486{
487 //qDebug(" CalendarView::suspendAlarm() "); 487 //qDebug(" CalendarView::suspendAlarm() ");
488 computeAlarm(mSuspendAlarmNotification ); 488 computeAlarm(mSuspendAlarmNotification );
489 489
490} 490}
491 491
492void CalendarView::startAlarm( QString mess , QString filename) 492void CalendarView::startAlarm( QString mess , QString filename)
493{ 493{
494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
496 496
497} 497}
498 498
499void CalendarView::checkNextTimerAlarm() 499void CalendarView::checkNextTimerAlarm()
500{ 500{
501 mCalendar->checkAlarmForIncidence( 0, true ); 501 mCalendar->checkAlarmForIncidence( 0, true );
502} 502}
503 503
504void CalendarView::computeAlarm( QString msg ) 504void CalendarView::computeAlarm( QString msg )
505{ 505{
506 506
507 QString mess = msg; 507 QString mess = msg;
508 QString mAlarmMessage = mess.mid( 9 ); 508 QString mAlarmMessage = mess.mid( 9 );
509 QString filename = MainWindow::resourcePath(); 509 QString filename = MainWindow::resourcePath();
510 filename += "koalarm.wav"; 510 filename += "koalarm.wav";
511 QString tempfilename; 511 QString tempfilename;
512 if ( mess.left( 13 ) == "suspend_alarm") { 512 if ( mess.left( 13 ) == "suspend_alarm") {
513 bool error = false; 513 bool error = false;
514 int len = mess.mid( 13 ).find("+++"); 514 int len = mess.mid( 13 ).find("+++");
515 if ( len < 2 ) 515 if ( len < 2 )
516 error = true; 516 error = true;
517 else { 517 else {
518 tempfilename = mess.mid( 13, len ); 518 tempfilename = mess.mid( 13, len );
519 if ( !QFile::exists( tempfilename ) ) 519 if ( !QFile::exists( tempfilename ) )
520 error = true; 520 error = true;
521 } 521 }
522 if ( ! error ) { 522 if ( ! error ) {
523 filename = tempfilename; 523 filename = tempfilename;
524 } 524 }
525 mAlarmMessage = mess.mid( 13+len+3 ); 525 mAlarmMessage = mess.mid( 13+len+3 );
526 //qDebug("suspend file %s ",tempfilename.latin1() ); 526 //qDebug("suspend file %s ",tempfilename.latin1() );
527 startAlarm( mAlarmMessage, filename); 527 startAlarm( mAlarmMessage, filename);
528 return; 528 return;
529 } 529 }
530 if ( mess.left( 11 ) == "timer_alarm") { 530 if ( mess.left( 11 ) == "timer_alarm") {
531 //mTimerTime = 0; 531 //mTimerTime = 0;
532 startAlarm( mess.mid( 11 ), filename ); 532 startAlarm( mess.mid( 11 ), filename );
533 return; 533 return;
534 } 534 }
535 if ( mess.left( 10 ) == "proc_alarm") { 535 if ( mess.left( 10 ) == "proc_alarm") {
536 bool error = false; 536 bool error = false;
537 int len = mess.mid( 10 ).find("+++"); 537 int len = mess.mid( 10 ).find("+++");
538 if ( len < 2 ) 538 if ( len < 2 )
539 error = true; 539 error = true;
540 else { 540 else {
541 tempfilename = mess.mid( 10, len ); 541 tempfilename = mess.mid( 10, len );
542 if ( !QFile::exists( tempfilename ) ) 542 if ( !QFile::exists( tempfilename ) )
543 error = true; 543 error = true;
544 } 544 }
545 if ( error ) { 545 if ( error ) {
546 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 546 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
547 mAlarmMessage += mess.mid( 10+len+3+9 ); 547 mAlarmMessage += mess.mid( 10+len+3+9 );
548 } else { 548 } else {
549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
550 //qDebug("-----system command %s ",tempfilename.latin1() ); 550 //qDebug("-----system command %s ",tempfilename.latin1() );
551#ifndef _WIN32_ 551#ifndef _WIN32_
552 if ( vfork () == 0 ) { 552 if ( vfork () == 0 ) {
553 execl ( tempfilename.latin1(), 0 ); 553 execl ( tempfilename.latin1(), 0 );
554 return; 554 return;
555 } 555 }
556#else 556#else
557 QProcess* p = new QProcess(); 557 QProcess* p = new QProcess();
558 p->addArgument( tempfilename.latin1() ); 558 p->addArgument( tempfilename.latin1() );
559 p->start(); 559 p->start();
560 return; 560 return;
561#endif 561#endif
562 562
563 return; 563 return;
564 } 564 }
565 565
566 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 566 //qDebug("+++++++system command %s ",tempfilename.latin1() );
567 } 567 }
568 if ( mess.left( 11 ) == "audio_alarm") { 568 if ( mess.left( 11 ) == "audio_alarm") {
569 bool error = false; 569 bool error = false;
570 int len = mess.mid( 11 ).find("+++"); 570 int len = mess.mid( 11 ).find("+++");
571 if ( len < 2 ) 571 if ( len < 2 )
572 error = true; 572 error = true;
573 else { 573 else {
574 tempfilename = mess.mid( 11, len ); 574 tempfilename = mess.mid( 11, len );
575 if ( !QFile::exists( tempfilename ) ) 575 if ( !QFile::exists( tempfilename ) )
576 error = true; 576 error = true;
577 } 577 }
578 if ( ! error ) { 578 if ( ! error ) {
579 filename = tempfilename; 579 filename = tempfilename;
580 } 580 }
581 mAlarmMessage = mess.mid( 11+len+3+9 ); 581 mAlarmMessage = mess.mid( 11+len+3+9 );
582 //qDebug("audio file command %s ",tempfilename.latin1() ); 582 //qDebug("audio file command %s ",tempfilename.latin1() );
583 } 583 }
584 if ( mess.left( 9 ) == "cal_alarm") { 584 if ( mess.left( 9 ) == "cal_alarm") {
585 mAlarmMessage = mess.mid( 9 ) ; 585 mAlarmMessage = mess.mid( 9 ) ;
586 } 586 }
587 587
588 startAlarm( mAlarmMessage, filename ); 588 startAlarm( mAlarmMessage, filename );
589 589
590 590
591} 591}
592 592
593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
594{ 594{
595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
596 596
597 mSuspendAlarmNotification = noti; 597 mSuspendAlarmNotification = noti;
598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
600 mSuspendTimer->start( ms , true ); 600 mSuspendTimer->start( ms , true );
601 601
602} 602}
603 603
604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
608#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
610#endif 610#endif
611 return; 611 return;
612 } 612 }
613 int maxSec; 613 int maxSec;
614 //maxSec = 5; //testing only 614 //maxSec = 5; //testing only
615 maxSec = 86400+3600; // one day+1hour 615 maxSec = 86400+3600; // one day+1hour
616 mAlarmNotification = noti; 616 mAlarmNotification = noti;
617 int sec = QDateTime::currentDateTime().secsTo( qdt ); 617 int sec = QDateTime::currentDateTime().secsTo( qdt );
618 if ( sec > maxSec ) { 618 if ( sec > maxSec ) {
619 mRecheckAlarmTimer->start( maxSec * 1000 ); 619 mRecheckAlarmTimer->start( maxSec * 1000 );
620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
621 return; 621 return;
622 } else { 622 } else {
623 mRecheckAlarmTimer->stop(); 623 mRecheckAlarmTimer->stop();
624 } 624 }
625 //qDebug("Alarm timer started with secs: %d ", sec); 625 //qDebug("Alarm timer started with secs: %d ", sec);
626 mAlarmTimer->start( sec *1000 , true ); 626 mAlarmTimer->start( sec *1000 , true );
627 627
628} 628}
629// called by mRecheckAlarmTimer to get next alarm 629// called by mRecheckAlarmTimer to get next alarm
630// we need this, because a QTimer has only a max range of 25 days 630// we need this, because a QTimer has only a max range of 25 days
631void CalendarView::recheckTimerAlarm() 631void CalendarView::recheckTimerAlarm()
632{ 632{
633 mAlarmTimer->stop(); 633 mAlarmTimer->stop();
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 mCalendar->checkAlarmForIncidence( 0, true ); 635 mCalendar->checkAlarmForIncidence( 0, true );
636} 636}
637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
641#ifndef DESKTOP_VERSION 641#ifndef DESKTOP_VERSION
642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
643#endif 643#endif
644 return; 644 return;
645 } 645 }
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647} 647}
648void CalendarView::selectWeekNum ( int num ) 648void CalendarView::selectWeekNum ( int num )
649{ 649{
650 dateNavigator()->selectWeek( num ); 650 dateNavigator()->selectWeek( num );
651 mViewManager->showWeekView(); 651 mViewManager->showWeekView();
652} 652}
653KOViewManager *CalendarView::viewManager() 653KOViewManager *CalendarView::viewManager()
654{ 654{
655 return mViewManager; 655 return mViewManager;
656} 656}
657 657
658KODialogManager *CalendarView::dialogManager() 658KODialogManager *CalendarView::dialogManager()
659{ 659{
660 return mDialogManager; 660 return mDialogManager;
661} 661}
662 662
663QDate CalendarView::startDate() 663QDate CalendarView::startDate()
664{ 664{
665 DateList dates = mNavigator->selectedDates(); 665 DateList dates = mNavigator->selectedDates();
666 666
667 return dates.first(); 667 return dates.first();
668} 668}
669 669
670QDate CalendarView::endDate() 670QDate CalendarView::endDate()
671{ 671{
672 DateList dates = mNavigator->selectedDates(); 672 DateList dates = mNavigator->selectedDates();
673 673
674 return dates.last(); 674 return dates.last();
675} 675}
676 676
677 677
678void CalendarView::createPrinter() 678void CalendarView::createPrinter()
679{ 679{
680#ifndef KORG_NOPRINTER 680#ifndef KORG_NOPRINTER
681 if (!mCalPrinter) { 681 if (!mCalPrinter) {
682 mCalPrinter = new CalPrinter(this, mCalendar); 682 mCalPrinter = new CalPrinter(this, mCalendar);
683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
684 } 684 }
685#endif 685#endif
686} 686}
687 687
688void CalendarView::confSync() 688void CalendarView::confSync()
689{ 689{
690 static KSyncPrefsDialog* sp = 0; 690 static KSyncPrefsDialog* sp = 0;
691 if ( ! sp ) { 691 if ( ! sp ) {
692 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 692 sp = new KSyncPrefsDialog( this, "syncprefs", true );
693 } 693 }
694 sp->usrReadConfig(); 694 sp->usrReadConfig();
695#ifndef DESKTOP_VERSION 695#ifndef DESKTOP_VERSION
696 sp->showMaximized(); 696 sp->showMaximized();
697#else 697#else
698 sp->show(); 698 sp->show();
699#endif 699#endif
700 sp->exec(); 700 sp->exec();
701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
703} 703}
704 704
705 705
706//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
708 708
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 715
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 717{
718 718
719 //void setZaurusId(int id); 719 //void setZaurusId(int id);
720 // int zaurusId() const; 720 // int zaurusId() const;
721 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
722 // int zaurusUid() const; 722 // int zaurusUid() const;
723 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
724 // int zaurusStat() const; 724 // int zaurusStat() const;
725 // 0 equal 725 // 0 equal
726 // 1 take local 726 // 1 take local
727 // 2 take remote 727 // 2 take remote
728 // 3 cancel 728 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
730 QDateTime localMod = local->lastModified(); 730 QDateTime localMod = local->lastModified();
731 QDateTime remoteMod = remote->lastModified(); 731 QDateTime remoteMod = remote->lastModified();
732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
733 bool remCh, locCh; 733 bool remCh, locCh;
734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
735 //if ( remCh ) 735 //if ( remCh )
736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
737 locCh = ( localMod > mLastCalendarSync ); 737 locCh = ( localMod > mLastCalendarSync );
738 if ( !remCh && ! locCh ) { 738 if ( !remCh && ! locCh ) {
739 //qDebug("both not changed "); 739 //qDebug("both not changed ");
740 lastSync = localMod.addDays(1); 740 lastSync = localMod.addDays(1);
741 if ( mode <= SYNC_PREF_ASK ) 741 if ( mode <= SYNC_PREF_ASK )
742 return 0; 742 return 0;
743 } else { 743 } else {
744 if ( locCh ) { 744 if ( locCh ) {
745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
746 lastSync = localMod.addDays( -1 ); 746 lastSync = localMod.addDays( -1 );
747 if ( !remCh ) 747 if ( !remCh )
748 remoteMod = ( lastSync.addDays( -1 ) ); 748 remoteMod = ( lastSync.addDays( -1 ) );
749 } else { 749 } else {
750 //qDebug(" not loc changed "); 750 //qDebug(" not loc changed ");
751 lastSync = localMod.addDays( 1 ); 751 lastSync = localMod.addDays( 1 );
752 if ( remCh ) 752 if ( remCh )
753 remoteMod =( lastSync.addDays( 1 ) ); 753 remoteMod =( lastSync.addDays( 1 ) );
754 754
755 } 755 }
756 } 756 }
757 full = true; 757 full = true;
758 if ( mode < SYNC_PREF_ASK ) 758 if ( mode < SYNC_PREF_ASK )
759 mode = SYNC_PREF_ASK; 759 mode = SYNC_PREF_ASK;
760 } else { 760 } else {
761 if ( localMod == remoteMod ) 761 if ( localMod == remoteMod )
762 if ( local->revision() == remote->revision() ) 762 if ( local->revision() == remote->revision() )
763 return 0; 763 return 0;
764 764
765 } 765 }
766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
767 767
768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
770 //full = true; //debug only 770 //full = true; //debug only
771 if ( full ) { 771 if ( full ) {
772 bool equ = false; 772 bool equ = false;
773 if ( local->type() == "Event" ) { 773 if ( local->type() == "Event" ) {
774 equ = (*((Event*) local) == *((Event*) remote)); 774 equ = (*((Event*) local) == *((Event*) remote));
775 } 775 }
776 else if ( local->type() =="Todo" ) 776 else if ( local->type() =="Todo" )
777 equ = (*((Todo*) local) == (*(Todo*) remote)); 777 equ = (*((Todo*) local) == (*(Todo*) remote));
778 else if ( local->type() =="Journal" ) 778 else if ( local->type() =="Journal" )
779 equ = (*((Journal*) local) == *((Journal*) remote)); 779 equ = (*((Journal*) local) == *((Journal*) remote));
780 if ( equ ) { 780 if ( equ ) {
781 //qDebug("equal "); 781 //qDebug("equal ");
782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
784 } 784 }
785 if ( mode < SYNC_PREF_FORCE_LOCAL ) 785 if ( mode < SYNC_PREF_FORCE_LOCAL )
786 return 0; 786 return 0;
787 787
788 }//else //debug only 788 }//else //debug only
789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
790 } 790 }
791 int result; 791 int result;
792 bool localIsNew; 792 bool localIsNew;
793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
794 794
795 if ( full && mode < SYNC_PREF_NEWEST ) 795 if ( full && mode < SYNC_PREF_NEWEST )
796 mode = SYNC_PREF_ASK; 796 mode = SYNC_PREF_ASK;
797 797
798 switch( mode ) { 798 switch( mode ) {
799 case SYNC_PREF_LOCAL: 799 case SYNC_PREF_LOCAL:
800 if ( lastSync > remoteMod ) 800 if ( lastSync > remoteMod )
801 return 1; 801 return 1;
802 if ( lastSync > localMod ) 802 if ( lastSync > localMod )
803 return 2; 803 return 2;
804 return 1; 804 return 1;
805 break; 805 break;
806 case SYNC_PREF_REMOTE: 806 case SYNC_PREF_REMOTE:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 2; 811 return 2;
812 break; 812 break;
813 case SYNC_PREF_NEWEST: 813 case SYNC_PREF_NEWEST:
814 if ( localMod > remoteMod ) 814 if ( localMod > remoteMod )
815 return 1; 815 return 1;
816 else 816 else
817 return 2; 817 return 2;
818 break; 818 break;
819 case SYNC_PREF_ASK: 819 case SYNC_PREF_ASK:
820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
821 if ( lastSync > remoteMod ) 821 if ( lastSync > remoteMod )
822 return 1; 822 return 1;
823 if ( lastSync > localMod ) 823 if ( lastSync > localMod )
824 return 2; 824 return 2;
825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
826 localIsNew = localMod >= remoteMod; 826 localIsNew = localMod >= remoteMod;
827 if ( localIsNew ) 827 if ( localIsNew )
828 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
829 else 829 else
830 getEventViewerDialog()->setColorMode( 2 ); 830 getEventViewerDialog()->setColorMode( 2 );
831 getEventViewerDialog()->setIncidence(local); 831 getEventViewerDialog()->setIncidence(local);
832 if ( localIsNew ) 832 if ( localIsNew )
833 getEventViewerDialog()->setColorMode( 2 ); 833 getEventViewerDialog()->setColorMode( 2 );
834 else 834 else
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 getEventViewerDialog()->addIncidence(remote); 836 getEventViewerDialog()->addIncidence(remote);
837 getEventViewerDialog()->setColorMode( 0 ); 837 getEventViewerDialog()->setColorMode( 0 );
838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
840 getEventViewerDialog()->showMe(); 840 getEventViewerDialog()->showMe();
841 result = getEventViewerDialog()->executeS( localIsNew ); 841 result = getEventViewerDialog()->executeS( localIsNew );
842 return result; 842 return result;
843 843
844 break; 844 break;
845 case SYNC_PREF_FORCE_LOCAL: 845 case SYNC_PREF_FORCE_LOCAL:
846 return 1; 846 return 1;
847 break; 847 break;
848 case SYNC_PREF_FORCE_REMOTE: 848 case SYNC_PREF_FORCE_REMOTE:
849 return 2; 849 return 2;
850 break; 850 break;
851 851
852 default: 852 default:
853 // SYNC_PREF_TAKE_BOTH not implemented 853 // SYNC_PREF_TAKE_BOTH not implemented
854 break; 854 break;
855 } 855 }
856 return 0; 856 return 0;
857} 857}
858Event* CalendarView::getLastSyncEvent() 858Event* CalendarView::getLastSyncEvent()
859{ 859{
860 Event* lse; 860 Event* lse;
861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
863 if (!lse) { 863 if (!lse) {
864 lse = new Event(); 864 lse = new Event();
865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
866 QString sum = ""; 866 QString sum = "";
867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
868 sum = "E: "; 868 sum = "E: ";
869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
870 lse->setDtStart( mLastCalendarSync ); 870 lse->setDtStart( mLastCalendarSync );
871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
872 lse->setCategories( i18n("SyncEvent") ); 872 lse->setCategories( i18n("SyncEvent") );
873 lse->setReadOnly( true ); 873 lse->setReadOnly( true );
874 mCalendar->addEvent( lse ); 874 mCalendar->addEvent( lse );
875 } 875 }
876 876
877 return lse; 877 return lse;
878 878
879} 879}
880// probaly useless 880// probaly useless
881void CalendarView::setupExternSyncProfiles() 881void CalendarView::setupExternSyncProfiles()
882{ 882{
883 Event* lse; 883 Event* lse;
884 mExternLastSyncEvent.clear(); 884 mExternLastSyncEvent.clear();
885 int i; 885 int i;
886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
888 if ( lse ) 888 if ( lse )
889 mExternLastSyncEvent.append( lse ); 889 mExternLastSyncEvent.append( lse );
890 else 890 else
891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
892 } 892 }
893 893
894} 894}
895// we check, if the to delete event has a id for a profile 895// we check, if the to delete event has a id for a profile
896// if yes, we set this id in the profile to delete 896// if yes, we set this id in the profile to delete
897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
898{ 898{
899 if ( lastSync.count() == 0 ) { 899 if ( lastSync.count() == 0 ) {
900 //qDebug(" lastSync.count() == 0"); 900 //qDebug(" lastSync.count() == 0");
901 return; 901 return;
902 } 902 }
903 if ( toDelete->type() == "Journal" ) 903 if ( toDelete->type() == "Journal" )
904 return; 904 return;
905 905
906 Event* eve = lastSync.first(); 906 Event* eve = lastSync.first();
907 907
908 while ( eve ) { 908 while ( eve ) {
909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
910 if ( !id.isEmpty() ) { 910 if ( !id.isEmpty() ) {
911 QString des = eve->description(); 911 QString des = eve->description();
912 QString pref = "e"; 912 QString pref = "e";
913 if ( toDelete->type() == "Todo" ) 913 if ( toDelete->type() == "Todo" )
914 pref = "t"; 914 pref = "t";
915 des += pref+ id + ","; 915 des += pref+ id + ",";
916 eve->setReadOnly( false ); 916 eve->setReadOnly( false );
917 eve->setDescription( des ); 917 eve->setDescription( des );
918 //qDebug("setdes %s ", des.latin1()); 918 //qDebug("setdes %s ", des.latin1());
919 eve->setReadOnly( true ); 919 eve->setReadOnly( true );
920 } 920 }
921 eve = lastSync.next(); 921 eve = lastSync.next();
922 } 922 }
923 923
924} 924}
925void CalendarView::checkExternalId( Incidence * inc ) 925void CalendarView::checkExternalId( Incidence * inc )
926{ 926{
927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
928 checkExternSyncEvent( lastSync, inc ); 928 checkExternSyncEvent( lastSync, inc );
929 929
930} 930}
931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
932{ 932{
933 bool syncOK = true; 933 bool syncOK = true;
934 int addedEvent = 0; 934 int addedEvent = 0;
935 int addedEventR = 0; 935 int addedEventR = 0;
936 int deletedEventR = 0; 936 int deletedEventR = 0;
937 int deletedEventL = 0; 937 int deletedEventL = 0;
938 int changedLocal = 0; 938 int changedLocal = 0;
939 int changedRemote = 0; 939 int changedRemote = 0;
940 //QPtrList<Event> el = local->rawEvents(); 940 //QPtrList<Event> el = local->rawEvents();
941 Event* eventR; 941 Event* eventR;
942 QString uid; 942 QString uid;
943 int take; 943 int take;
944 Event* eventL; 944 Event* eventL;
945 Event* eventRSync; 945 Event* eventRSync;
946 Event* eventLSync; 946 Event* eventLSync;
947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
949 bool fullDateRange = false; 949 bool fullDateRange = false;
950 local->resetTempSyncStat(); 950 local->resetTempSyncStat();
951 mLastCalendarSync = QDateTime::currentDateTime(); 951 mLastCalendarSync = QDateTime::currentDateTime();
952 QDateTime modifiedCalendar = mLastCalendarSync;; 952 QDateTime modifiedCalendar = mLastCalendarSync;;
953 eventLSync = getLastSyncEvent(); 953 eventLSync = getLastSyncEvent();
954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
955 if ( eventR ) { 955 if ( eventR ) {
956 eventRSync = (Event*) eventR->clone(); 956 eventRSync = (Event*) eventR->clone();
957 remote->deleteEvent(eventR ); 957 remote->deleteEvent(eventR );
958 958
959 } else { 959 } else {
960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
961 eventRSync = (Event*)eventLSync->clone(); 961 eventRSync = (Event*)eventLSync->clone();
962 } else { 962 } else {
963 fullDateRange = true; 963 fullDateRange = true;
964 eventRSync = new Event(); 964 eventRSync = new Event();
965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
967 eventRSync->setDtStart( mLastCalendarSync ); 967 eventRSync->setDtStart( mLastCalendarSync );
968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
969 eventRSync->setCategories( i18n("SyncEvent") ); 969 eventRSync->setCategories( i18n("SyncEvent") );
970 } 970 }
971 } 971 }
972 if ( eventLSync->dtStart() == mLastCalendarSync ) 972 if ( eventLSync->dtStart() == mLastCalendarSync )
973 fullDateRange = true; 973 fullDateRange = true;
974 974
975 if ( ! fullDateRange ) { 975 if ( ! fullDateRange ) {
976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
977 977
978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
980 fullDateRange = true; 980 fullDateRange = true;
981 } 981 }
982 } 982 }
983 if ( fullDateRange ) 983 if ( fullDateRange )
984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
985 else 985 else
986 mLastCalendarSync = eventLSync->dtStart(); 986 mLastCalendarSync = eventLSync->dtStart();
987 // for resyncing if own file has changed 987 // for resyncing if own file has changed
988 if ( mCurrentSyncDevice == "deleteaftersync" ) { 988 if ( mCurrentSyncDevice == "deleteaftersync" ) {
989 mLastCalendarSync = loadedFileVersion; 989 mLastCalendarSync = loadedFileVersion;
990 qDebug("setting mLastCalendarSync "); 990 qDebug("setting mLastCalendarSync ");
991 } 991 }
992 //qDebug("*************************** "); 992 //qDebug("*************************** ");
993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
994 QPtrList<Incidence> er = remote->rawIncidences(); 994 QPtrList<Incidence> er = remote->rawIncidences();
995 Incidence* inR = er.first(); 995 Incidence* inR = er.first();
996 Incidence* inL; 996 Incidence* inL;
997 QProgressBar bar( er.count(),0 ); 997 QProgressBar bar( er.count(),0 );
998 bar.setCaption (i18n("Syncing - close to abort!") ); 998 bar.setCaption (i18n("Syncing - close to abort!") );
999 999
1000 int w = 300; 1000 int w = 300;
1001 if ( QApplication::desktop()->width() < 320 ) 1001 if ( QApplication::desktop()->width() < 320 )
1002 w = 220; 1002 w = 220;
1003 int h = bar.sizeHint().height() ; 1003 int h = bar.sizeHint().height() ;
1004 int dw = QApplication::desktop()->width(); 1004 int dw = QApplication::desktop()->width();
1005 int dh = QApplication::desktop()->height(); 1005 int dh = QApplication::desktop()->height();
1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1007 bar.show(); 1007 bar.show();
1008 int modulo = (er.count()/10)+1; 1008 int modulo = (er.count()/10)+1;
1009 int incCounter = 0; 1009 int incCounter = 0;
1010 while ( inR ) { 1010 while ( inR ) {
1011 if ( ! bar.isVisible() ) 1011 if ( ! bar.isVisible() )
1012 return false; 1012 return false;
1013 if ( incCounter % modulo == 0 ) 1013 if ( incCounter % modulo == 0 )
1014 bar.setProgress( incCounter ); 1014 bar.setProgress( incCounter );
1015 ++incCounter; 1015 ++incCounter;
1016 uid = inR->uid(); 1016 uid = inR->uid();
1017 bool skipIncidence = false; 1017 bool skipIncidence = false;
1018 if ( uid.left(15) == QString("last-syncEvent-") ) 1018 if ( uid.left(15) == QString("last-syncEvent-") )
1019 skipIncidence = true; 1019 skipIncidence = true;
1020 QString idS; 1020 QString idS;
1021 qApp->processEvents(); 1021 qApp->processEvents();
1022 if ( !skipIncidence ) { 1022 if ( !skipIncidence ) {
1023 inL = local->incidence( uid ); 1023 inL = local->incidence( uid );
1024 if ( inL ) { // maybe conflict - same uid in both calendars 1024 if ( inL ) { // maybe conflict - same uid in both calendars
1025 int maxrev = inL->revision(); 1025 int maxrev = inL->revision();
1026 if ( maxrev < inR->revision() ) 1026 if ( maxrev < inR->revision() )
1027 maxrev = inR->revision(); 1027 maxrev = inR->revision();
1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1029 //qDebug("take %d %s ", take, inL->summary().latin1()); 1029 //qDebug("take %d %s ", take, inL->summary().latin1());
1030 if ( take == 3 ) 1030 if ( take == 3 )
1031 return false; 1031 return false;
1032 if ( take == 1 ) {// take local 1032 if ( take == 1 ) {// take local
1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1035 else 1035 else
1036 idS = inR->IDStr(); 1036 idS = inR->IDStr();
1037 remote->deleteIncidence( inR ); 1037 remote->deleteIncidence( inR );
1038 if ( inL->revision() < maxrev ) 1038 if ( inL->revision() < maxrev )
1039 inL->setRevision( maxrev ); 1039 inL->setRevision( maxrev );
1040 inR = inL->clone(); 1040 inR = inL->clone();
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1043 inR->setIDStr( idS ); 1043 inR->setIDStr( idS );
1044 remote->addIncidence( inR ); 1044 remote->addIncidence( inR );
1045 ++changedRemote; 1045 ++changedRemote;
1046 } else { 1046 } else {
1047 if ( inR->revision() < maxrev ) 1047 if ( inR->revision() < maxrev )
1048 inR->setRevision( maxrev ); 1048 inR->setRevision( maxrev );
1049 idS = inL->IDStr(); 1049 idS = inL->IDStr();
1050 local->deleteIncidence( inL ); 1050 local->deleteIncidence( inL );
1051 inL = inR->clone(); 1051 inL = inR->clone();
1052 inL->setIDStr( idS ); 1052 inL->setIDStr( idS );
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1056 } 1056 }
1057 local->addIncidence( inL ); 1057 local->addIncidence( inL );
1058 ++changedLocal; 1058 ++changedLocal;
1059 } 1059 }
1060 } 1060 }
1061 } else { // no conflict 1061 } else { // no conflict
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1064 QString pref = "e"; 1064 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1066 pref = "t"; 1066 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1070 ++deletedEventR;
1071 } else { 1071 } else {
1072 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1073 inL = inR->clone();
1074 local->addIncidence( inL ); 1074 local->addIncidence( inL );
1075 ++addedEvent; 1075 ++addedEvent;
1076 } 1076 }
1077 } else { 1077 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1079 inR->setLastModified( modifiedCalendar );
1080 local->addIncidence( inR->clone() ); 1080 local->addIncidence( inR->clone() );
1081 ++addedEvent; 1081 ++addedEvent;
1082 } else { 1082 } else {
1083 checkExternSyncEvent(eventRSyncSharp, inR); 1083 checkExternSyncEvent(eventRSyncSharp, inR);
1084 remote->deleteIncidence( inR ); 1084 remote->deleteIncidence( inR );
1085 ++deletedEventR; 1085 ++deletedEventR;
1086 } 1086 }
1087 } 1087 }
1088 } 1088 }
1089 } 1089 }
1090 inR = er.next(); 1090 inR = er.next();
1091 } 1091 }
1092 QPtrList<Incidence> el = local->rawIncidences(); 1092 QPtrList<Incidence> el = local->rawIncidences();
1093 inL = el.first(); 1093 inL = el.first();
1094 modulo = (el.count()/10)+1; 1094 modulo = (el.count()/10)+1;
1095 bar.setCaption (i18n("Add / remove events") ); 1095 bar.setCaption (i18n("Add / remove events") );
1096 bar.setTotalSteps ( el.count() ) ; 1096 bar.setTotalSteps ( el.count() ) ;
1097 bar.show(); 1097 bar.show();
1098 incCounter = 0; 1098 incCounter = 0;
1099 1099
1100 while ( inL ) { 1100 while ( inL ) {
1101 1101
1102 qApp->processEvents(); 1102 qApp->processEvents();
1103 if ( ! bar.isVisible() ) 1103 if ( ! bar.isVisible() )
1104 return false; 1104 return false;
1105 if ( incCounter % modulo == 0 ) 1105 if ( incCounter % modulo == 0 )
1106 bar.setProgress( incCounter ); 1106 bar.setProgress( incCounter );
1107 ++incCounter; 1107 ++incCounter;
1108 uid = inL->uid(); 1108 uid = inL->uid();
1109 bool skipIncidence = false; 1109 bool skipIncidence = false;
1110 if ( uid.left(15) == QString("last-syncEvent-") ) 1110 if ( uid.left(15) == QString("last-syncEvent-") )
1111 skipIncidence = true; 1111 skipIncidence = true;
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1113 skipIncidence = true; 1113 skipIncidence = true;
1114 if ( !skipIncidence ) { 1114 if ( !skipIncidence ) {
1115 inR = remote->incidence( uid ); 1115 inR = remote->incidence( uid );
1116 if ( ! inR ) { 1116 if ( ! inR ) {
1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1119 checkExternSyncEvent(eventLSyncSharp, inL); 1119 checkExternSyncEvent(eventLSyncSharp, inL);
1120 local->deleteIncidence( inL ); 1120 local->deleteIncidence( inL );
1121 ++deletedEventL; 1121 ++deletedEventL;
1122 } else { 1122 } else {
1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1124 inL->removeID(mCurrentSyncDevice ); 1124 inL->removeID(mCurrentSyncDevice );
1125 ++addedEventR; 1125 ++addedEventR;
1126 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1126 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1127 inL->setLastModified( modifiedCalendar ); 1127 inL->setLastModified( modifiedCalendar );
1128 inR = inL->clone(); 1128 inR = inL->clone();
1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1130 remote->addIncidence( inR ); 1130 remote->addIncidence( inR );
1131 } 1131 }
1132 } 1132 }
1133 } else { 1133 } else {
1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1135 checkExternSyncEvent(eventLSyncSharp, inL); 1135 checkExternSyncEvent(eventLSyncSharp, inL);
1136 local->deleteIncidence( inL ); 1136 local->deleteIncidence( inL );
1137 ++deletedEventL; 1137 ++deletedEventL;
1138 } else { 1138 } else {
1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1140 ++addedEventR; 1140 ++addedEventR;
1141 inL->setLastModified( modifiedCalendar ); 1141 inL->setLastModified( modifiedCalendar );
1142 remote->addIncidence( inL->clone() ); 1142 remote->addIncidence( inL->clone() );
1143 } 1143 }
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 } 1147 }
1148 inL = el.next(); 1148 inL = el.next();
1149 } 1149 }
1150 int delFut = 0; 1150 int delFut = 0;
1151 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1151 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1152 er = remote->rawIncidences(); 1152 er = remote->rawIncidences();
1153 inR = er.first(); 1153 inR = er.first();
1154 QDateTime dt; 1154 QDateTime dt;
1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
1157 while ( inR ) { 1157 while ( inR ) {
1158 if ( inR->type() == "Todo" ) { 1158 if ( inR->type() == "Todo" ) {
1159 Todo * t = (Todo*)inR; 1159 Todo * t = (Todo*)inR;
1160 if ( t->hasDueDate() ) 1160 if ( t->hasDueDate() )
1161 dt = t->dtDue(); 1161 dt = t->dtDue();
1162 else 1162 else
1163 dt = cur.addSecs( 62 ); 1163 dt = cur.addSecs( 62 );
1164 } 1164 }
1165 else if (inR->type() == "Event" ) { 1165 else if (inR->type() == "Event" ) {
1166 bool ok; 1166 bool ok;
1167 dt = inR->getNextOccurence( cur, &ok ); 1167 dt = inR->getNextOccurence( cur, &ok );
1168 if ( !ok ) 1168 if ( !ok )
1169 dt = cur.addSecs( -62 ); 1169 dt = cur.addSecs( -62 );
1170 } 1170 }
1171 else 1171 else
1172 dt = inR->dtStart(); 1172 dt = inR->dtStart();
1173 if ( dt < cur || dt > end ) { 1173 if ( dt < cur || dt > end ) {
1174 remote->deleteIncidence( inR ); 1174 remote->deleteIncidence( inR );
1175 ++delFut; 1175 ++delFut;
1176 } 1176 }
1177 inR = er.next(); 1177 inR = er.next();
1178 } 1178 }
1179 } 1179 }
1180 bar.hide(); 1180 bar.hide();
1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1182 eventLSync->setReadOnly( false ); 1182 eventLSync->setReadOnly( false );
1183 eventLSync->setDtStart( mLastCalendarSync ); 1183 eventLSync->setDtStart( mLastCalendarSync );
1184 eventRSync->setDtStart( mLastCalendarSync ); 1184 eventRSync->setDtStart( mLastCalendarSync );
1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1189 eventLSync->setReadOnly( true ); 1189 eventLSync->setReadOnly( true );
1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1191 remote->addEvent( eventRSync ); 1191 remote->addEvent( eventRSync );
1192 QString mes; 1192 QString mes;
1193 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1193 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1194 QString delmess; 1194 QString delmess;
1195 if ( delFut ) { 1195 if ( delFut ) {
1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1197 mes += delmess; 1197 mes += delmess;
1198 } 1198 }
1199 if ( KOPrefs::instance()->mShowSyncSummary ) { 1199 if ( KOPrefs::instance()->mShowSyncSummary ) {
1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1201 } 1201 }
1202 qDebug( mes ); 1202 qDebug( mes );
1203 mCalendar->checkAlarmForIncidence( 0, true ); 1203 mCalendar->checkAlarmForIncidence( 0, true );
1204 return syncOK; 1204 return syncOK;
1205} 1205}
1206 1206
1207void CalendarView::setSyncDevice( QString s ) 1207void CalendarView::setSyncDevice( QString s )
1208{ 1208{
1209 mCurrentSyncDevice= s; 1209 mCurrentSyncDevice= s;
1210} 1210}
1211void CalendarView::setSyncName( QString s ) 1211void CalendarView::setSyncName( QString s )
1212{ 1212{
1213 mCurrentSyncName= s; 1213 mCurrentSyncName= s;
1214} 1214}
1215bool CalendarView::syncCalendar(QString filename, int mode) 1215bool CalendarView::syncCalendar(QString filename, int mode)
1216{ 1216{
1217 mGlobalSyncMode = SYNC_MODE_NORMAL; 1217 mGlobalSyncMode = SYNC_MODE_NORMAL;
1218 CalendarLocal* calendar = new CalendarLocal(); 1218 CalendarLocal* calendar = new CalendarLocal();
1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1220 FileStorage* storage = new FileStorage( calendar ); 1220 FileStorage* storage = new FileStorage( calendar );
1221 bool syncOK = false; 1221 bool syncOK = false;
1222 storage->setFileName( filename ); 1222 storage->setFileName( filename );
1223 // qDebug("loading ... "); 1223 // qDebug("loading ... ");
1224 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1224 if ( storage->load() ) {
1225 getEventViewerDialog()->setSyncMode( true ); 1225 getEventViewerDialog()->setSyncMode( true );
1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1227 getEventViewerDialog()->setSyncMode( false ); 1227 getEventViewerDialog()->setSyncMode( false );
1228 if ( syncOK ) { 1228 if ( syncOK ) {
1229 if ( KOPrefs::instance()->mWriteBackFile ) 1229 if ( KOPrefs::instance()->mWriteBackFile )
1230 { 1230 {
1231 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1231 storage->setSaveFormat( new ICalFormat() );
1232 storage->save(); 1232 storage->save();
1233 } 1233 }
1234 } 1234 }
1235 setModified( true ); 1235 setModified( true );
1236 } 1236 }
1237 delete storage; 1237 delete storage;
1238 delete calendar; 1238 delete calendar;
1239 if ( syncOK ) 1239 if ( syncOK )
1240 updateView(); 1240 updateView();
1241 return syncOK; 1241 return syncOK;
1242} 1242}
1243void CalendarView::syncPhone() 1243void CalendarView::syncPhone()
1244{ 1244{
1245 syncExternal( 1 ); 1245 syncExternal( 1 );
1246} 1246}
1247void CalendarView::syncExternal( int mode ) 1247void CalendarView::syncExternal( int mode )
1248{ 1248{
1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1250 //mCurrentSyncDevice = "sharp-DTM"; 1250 //mCurrentSyncDevice = "sharp-DTM";
1251 if ( KOPrefs::instance()->mAskForPreferences ) 1251 if ( KOPrefs::instance()->mAskForPreferences )
1252 edit_sync_options(); 1252 edit_sync_options();
1253 qApp->processEvents(); 1253 qApp->processEvents();
1254 CalendarLocal* calendar = new CalendarLocal(); 1254 CalendarLocal* calendar = new CalendarLocal();
1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1256 bool syncOK = false; 1256 bool syncOK = false;
1257 bool loadSuccess = false; 1257 bool loadSuccess = false;
1258 PhoneFormat* phoneFormat = 0; 1258 PhoneFormat* phoneFormat = 0;
1259#ifndef DESKTOP_VERSION 1259#ifndef DESKTOP_VERSION
1260 SharpFormat* sharpFormat = 0; 1260 SharpFormat* sharpFormat = 0;
1261 if ( mode == 0 ) { // sharp 1261 if ( mode == 0 ) { // sharp
1262 sharpFormat = new SharpFormat () ; 1262 sharpFormat = new SharpFormat () ;
1263 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1263 loadSuccess = sharpFormat->load( calendar, mCalendar );
1264 1264
1265 } else 1265 } else
1266#endif 1266#endif
1267 if ( mode == 1 ) { // phone 1267 if ( mode == 1 ) { // phone
1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1269 KOPrefs::instance()->mPhoneDevice, 1269 KOPrefs::instance()->mPhoneDevice,
1270 KOPrefs::instance()->mPhoneConnection, 1270 KOPrefs::instance()->mPhoneConnection,
1271 KOPrefs::instance()->mPhoneModel); 1271 KOPrefs::instance()->mPhoneModel);
1272 loadSuccess = phoneFormat->load( calendar,mCalendar); 1272 loadSuccess = phoneFormat->load( calendar,mCalendar);
1273 1273
1274 } else 1274 } else
1275 return; 1275 return;
1276 if ( loadSuccess ) { 1276 if ( loadSuccess ) {
1277 getEventViewerDialog()->setSyncMode( true ); 1277 getEventViewerDialog()->setSyncMode( true );
1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1279 getEventViewerDialog()->setSyncMode( false ); 1279 getEventViewerDialog()->setSyncMode( false );
1280 qApp->processEvents(); 1280 qApp->processEvents();
1281 if ( syncOK ) { 1281 if ( syncOK ) {
1282 if ( KOPrefs::instance()->mWriteBackFile ) 1282 if ( KOPrefs::instance()->mWriteBackFile )
1283 { 1283 {
1284 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1284 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1285 Incidence* inc = iL.first(); 1285 Incidence* inc = iL.first();
1286 if ( phoneFormat ) { 1286 if ( phoneFormat ) {
1287 while ( inc ) { 1287 while ( inc ) {
1288 inc->removeID(mCurrentSyncDevice); 1288 inc->removeID(mCurrentSyncDevice);
1289 inc = iL.next(); 1289 inc = iL.next();
1290 } 1290 }
1291 } 1291 }
1292#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1293 if ( sharpFormat ) 1293 if ( sharpFormat )
1294 sharpFormat->save(calendar); 1294 sharpFormat->save(calendar);
1295#endif 1295#endif
1296 if ( phoneFormat ) 1296 if ( phoneFormat )
1297 phoneFormat->save(calendar); 1297 phoneFormat->save(calendar);
1298 iL = calendar->rawIncidences(); 1298 iL = calendar->rawIncidences();
1299 inc = iL.first(); 1299 inc = iL.first();
1300 Incidence* loc; 1300 Incidence* loc;
1301 while ( inc ) { 1301 while ( inc ) {
1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1303 loc = mCalendar->incidence(inc->uid() ); 1303 loc = mCalendar->incidence(inc->uid() );
1304 if ( loc ) { 1304 if ( loc ) {
1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1307 } 1307 }
1308 } 1308 }
1309 inc = iL.next(); 1309 inc = iL.next();
1310 } 1310 }
1311 Incidence* lse = getLastSyncEvent(); 1311 Incidence* lse = getLastSyncEvent();
1312 if ( lse ) { 1312 if ( lse ) {
1313 lse->setReadOnly( false ); 1313 lse->setReadOnly( false );
1314 lse->setDescription( "" ); 1314 lse->setDescription( "" );
1315 lse->setReadOnly( true ); 1315 lse->setReadOnly( true );
1316 } 1316 }
1317 } 1317 }
1318 } 1318 }
1319 setModified( true ); 1319 setModified( true );
1320 } else { 1320 } else {
1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1323 question, i18n("Ok")) ; 1323 question, i18n("Ok")) ;
1324 1324
1325 } 1325 }
1326 delete calendar; 1326 delete calendar;
1327 updateView(); 1327 updateView();
1328 return ;//syncOK; 1328 return ;//syncOK;
1329 1329
1330} 1330}
1331void CalendarView::syncSharp() 1331void CalendarView::syncSharp()
1332{ 1332{
1333 syncExternal( 0 ); 1333 syncExternal( 0 );
1334 1334
1335} 1335}
1336 1336
1337 1337
1338//#include <kabc/stdaddressbook.h> 1338//#include <kabc/stdaddressbook.h>
1339bool CalendarView::importBday() 1339bool CalendarView::importBday()
1340{ 1340{
1341#if 0 1341#if 0
1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1343 KABC::AddressBook::Iterator it; 1343 KABC::AddressBook::Iterator it;
1344 int count = 0; 1344 int count = 0;
1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1346 ++count; 1346 ++count;
1347 } 1347 }
1348 QProgressBar bar(count,0 ); 1348 QProgressBar bar(count,0 );
1349 int w = 300; 1349 int w = 300;
1350 if ( QApplication::desktop()->width() < 320 ) 1350 if ( QApplication::desktop()->width() < 320 )
1351 w = 220; 1351 w = 220;
1352 int h = bar.sizeHint().height() ; 1352 int h = bar.sizeHint().height() ;
1353 int dw = QApplication::desktop()->width(); 1353 int dw = QApplication::desktop()->width();
1354 int dh = QApplication::desktop()->height(); 1354 int dh = QApplication::desktop()->height();
1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1356 bar.show(); 1356 bar.show();
1357 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1357 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1358 qApp->processEvents(); 1358 qApp->processEvents();
1359 count = 0; 1359 count = 0;
1360 int addCount = 0; 1360 int addCount = 0;
1361 KCal::Attendee* a = 0; 1361 KCal::Attendee* a = 0;
1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1363 if ( ! bar.isVisible() ) 1363 if ( ! bar.isVisible() )
1364 return false; 1364 return false;
1365 bar.setProgress( count++ ); 1365 bar.setProgress( count++ );
1366 qApp->processEvents(); 1366 qApp->processEvents();
1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1368 if ( (*it).birthday().date().isValid() ){ 1368 if ( (*it).birthday().date().isValid() ){
1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1371 ++addCount; 1371 ++addCount;
1372 } 1372 }
1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1374 if ( anni.isValid() ){ 1374 if ( anni.isValid() ){
1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1377 ++addCount; 1377 ++addCount;
1378 } 1378 }
1379 } 1379 }
1380 updateView(); 1380 updateView();
1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1382#endif 1382#endif
1383 return true; 1383 return true;
1384} 1384}
1385 1385
1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1387{ 1387{
1388 //qDebug("addAnni "); 1388 //qDebug("addAnni ");
1389 Event * ev = new Event(); 1389 Event * ev = new Event();
1390 if ( a ) { 1390 if ( a ) {
1391 ev->addAttendee( a ); 1391 ev->addAttendee( a );
1392 } 1392 }
1393 QString kind; 1393 QString kind;
1394 if ( birthday ) 1394 if ( birthday )
1395 kind = i18n( "Birthday" ); 1395 kind = i18n( "Birthday" );
1396 else 1396 else
1397 kind = i18n( "Anniversary" ); 1397 kind = i18n( "Anniversary" );
1398 ev->setSummary( name + " - " + kind ); 1398 ev->setSummary( name + " - " + kind );
1399 ev->setOrganizer( "nobody@nowhere" ); 1399 ev->setOrganizer( "nobody@nowhere" );
1400 ev->setCategories( kind ); 1400 ev->setCategories( kind );
1401 ev->setDtStart( QDateTime(date) ); 1401 ev->setDtStart( QDateTime(date) );
1402 ev->setDtEnd( QDateTime(date) ); 1402 ev->setDtEnd( QDateTime(date) );
1403 ev->setFloats( true ); 1403 ev->setFloats( true );
1404 Recurrence * rec = ev->recurrence(); 1404 Recurrence * rec = ev->recurrence();
1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1406 rec->addYearlyNum( date.month() ); 1406 rec->addYearlyNum( date.month() );
1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1408 delete ev; 1408 delete ev;
1409 return false; 1409 return false;
1410 } 1410 }
1411 return true; 1411 return true;
1412 1412
1413} 1413}
1414bool CalendarView::importQtopia( const QString &categories, 1414bool CalendarView::importQtopia( const QString &categories,
1415 const QString &datebook, 1415 const QString &datebook,
1416 const QString &todolist ) 1416 const QString &todolist )
1417{ 1417{
1418 1418
1419 QtopiaFormat qtopiaFormat; 1419 QtopiaFormat qtopiaFormat;
1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1424 1424
1425 updateView(); 1425 updateView();
1426 return true; 1426 return true;
1427 1427
1428#if 0 1428#if 0
1429 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1429 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1430 mCurrentSyncDevice = "qtopia-XML"; 1430 mCurrentSyncDevice = "qtopia-XML";
1431 if ( KOPrefs::instance()->mAskForPreferences ) 1431 if ( KOPrefs::instance()->mAskForPreferences )
1432 edit_sync_options(); 1432 edit_sync_options();
1433 qApp->processEvents(); 1433 qApp->processEvents();
1434 CalendarLocal* calendar = new CalendarLocal(); 1434 CalendarLocal* calendar = new CalendarLocal();
1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1436 bool syncOK = false; 1436 bool syncOK = false;
1437 QtopiaFormat qtopiaFormat; 1437 QtopiaFormat qtopiaFormat;
1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1439 bool loadOk = true; 1439 bool loadOk = true;
1440 if ( !categories.isEmpty() ) 1440 if ( !categories.isEmpty() )
1441 loadOk = qtopiaFormat.load( calendar, categories ); 1441 loadOk = qtopiaFormat.load( calendar, categories );
1442 if ( loadOk && !datebook.isEmpty() ) 1442 if ( loadOk && !datebook.isEmpty() )
1443 loadOk = qtopiaFormat.load( calendar, datebook ); 1443 loadOk = qtopiaFormat.load( calendar, datebook );
1444 if ( loadOk && !todolist.isEmpty() ) 1444 if ( loadOk && !todolist.isEmpty() )
1445 loadOk = qtopiaFormat.load( calendar, todolist ); 1445 loadOk = qtopiaFormat.load( calendar, todolist );
1446 1446
1447 if ( loadOk ) { 1447 if ( loadOk ) {
1448 getEventViewerDialog()->setSyncMode( true ); 1448 getEventViewerDialog()->setSyncMode( true );
1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1450 getEventViewerDialog()->setSyncMode( false ); 1450 getEventViewerDialog()->setSyncMode( false );
1451 qApp->processEvents(); 1451 qApp->processEvents();
1452 if ( syncOK ) { 1452 if ( syncOK ) {
1453 if ( KOPrefs::instance()->mWriteBackFile ) 1453 if ( KOPrefs::instance()->mWriteBackFile )
1454 { 1454 {
1455 // write back XML file 1455 // write back XML file
1456 1456
1457 } 1457 }
1458 setModified( true ); 1458 setModified( true );
1459 } 1459 }
1460 } else { 1460 } else {
1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1463 question, i18n("Ok")) ; 1463 question, i18n("Ok")) ;
1464 } 1464 }
1465 delete calendar; 1465 delete calendar;
1466 updateView(); 1466 updateView();
1467 return syncOK; 1467 return syncOK;
1468 1468
1469 1469
1470#endif 1470#endif
1471 1471
1472} 1472}
1473 1473
1474void CalendarView::setSyncEventsReadOnly() 1474void CalendarView::setSyncEventsReadOnly()
1475{ 1475{
1476 Event * ev; 1476 Event * ev;
1477 QPtrList<Event> eL = mCalendar->rawEvents(); 1477 QPtrList<Event> eL = mCalendar->rawEvents();
1478 ev = eL.first(); 1478 ev = eL.first();
1479 while ( ev ) { 1479 while ( ev ) {
1480 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1480 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1481 ev->setReadOnly( true ); 1481 ev->setReadOnly( true );
1482 ev = eL.next(); 1482 ev = eL.next();
1483 } 1483 }
1484} 1484}
1485bool CalendarView::openCalendar(QString filename, bool merge) 1485bool CalendarView::openCalendar(QString filename, bool merge)
1486{ 1486{
1487 1487
1488 if (filename.isEmpty()) { 1488 if (filename.isEmpty()) {
1489 return false; 1489 return false;
1490 } 1490 }
1491 1491
1492 if (!QFile::exists(filename)) { 1492 if (!QFile::exists(filename)) {
1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 globalFlagBlockAgenda = 1; 1497 globalFlagBlockAgenda = 1;
1498 if (!merge) mCalendar->close(); 1498 if (!merge) mCalendar->close();
1499 1499
1500 mStorage->setFileName( filename ); 1500 mStorage->setFileName( filename );
1501 1501
1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1502 if ( mStorage->load() ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 if ( filename != MainWindow::defaultFileName() )
1518 saveCalendar( MainWindow::defaultFileName() );
1519 loadedFileVersion = QDateTime::currentDateTime(); 1517 loadedFileVersion = QDateTime::currentDateTime();
1518 if ( filename != MainWindow::defaultFileName() ) {
1519 saveCalendar( MainWindow::defaultFileName() );
1520 watchSavedFile();
1521 }
1520 return true; 1522 return true;
1521 } else { 1523 } else {
1522 // while failing to load, the calendar object could 1524 // while failing to load, the calendar object could
1523 // have become partially populated. Clear it out. 1525 // have become partially populated. Clear it out.
1524 if ( !merge ) mCalendar->close(); 1526 if ( !merge ) mCalendar->close();
1525 1527
1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1528 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1527 1529
1528 globalFlagBlockAgenda = 2; 1530 globalFlagBlockAgenda = 2;
1529 updateView(); 1531 updateView();
1530 } 1532 }
1531 return false; 1533 return false;
1532} 1534}
1533void CalendarView::setLoadedFileVersion(QDateTime dt) 1535void CalendarView::setLoadedFileVersion(QDateTime dt)
1534{ 1536{
1535 loadedFileVersion = dt; 1537 loadedFileVersion = dt;
1536} 1538}
1537bool CalendarView::checkFileChanged(QString fn) 1539bool CalendarView::checkFileChanged(QString fn)
1538{ 1540{
1539 QFileInfo finf ( fn ); 1541 QFileInfo finf ( fn );
1540 if ( !finf.exists() ) 1542 if ( !finf.exists() )
1541 return true; 1543 return true;
1542 QDateTime dt = finf.lastModified (); 1544 QDateTime dt = finf.lastModified ();
1543 if ( dt <= loadedFileVersion ) 1545 if ( dt <= loadedFileVersion )
1544 return false; 1546 return false;
1545 return true; 1547 return true;
1546 1548
1547} 1549}
1548void CalendarView::watchSavedFile() 1550void CalendarView::watchSavedFile()
1549{ 1551{
1550 QFileInfo finf ( MainWindow::defaultFileName()); 1552 QFileInfo finf ( MainWindow::defaultFileName());
1551 if ( !finf.exists() ) 1553 if ( !finf.exists() )
1552 return; 1554 return;
1553 QDateTime dt = finf.lastModified (); 1555 QDateTime dt = finf.lastModified ();
1554 if ( dt < loadedFileVersion ) { 1556 if ( dt < loadedFileVersion ) {
1555 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1557 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1556 return; 1558 return;
1557 } 1559 }
1558 loadedFileVersion = dt; 1560 loadedFileVersion = dt;
1559} 1561}
1560 1562
1561bool CalendarView::checkFileVersion(QString fn) 1563bool CalendarView::checkFileVersion(QString fn)
1562{ 1564{
1563 QFileInfo finf ( fn ); 1565 QFileInfo finf ( fn );
1564 if ( !finf.exists() ) 1566 if ( !finf.exists() )
1565 return true; 1567 return true;
1566 QDateTime dt = finf.lastModified (); 1568 QDateTime dt = finf.lastModified ();
1567 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1569 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1568 //qDebug("file on disk version %s",dt.toString().latin1()); 1570 //qDebug("file on disk version %s",dt.toString().latin1());
1569 if ( dt <= loadedFileVersion ) 1571 if ( dt <= loadedFileVersion )
1570 return true; 1572 return true;
1571 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1573 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1572 i18n("KO/Pi Warning"),i18n("Overwrite"), 1574 i18n("KO/Pi Warning"),i18n("Overwrite"),
1573 i18n("Sync+save")); 1575 i18n("Sync+save"));
1574 1576
1575 if ( km == KMessageBox::Cancel ) 1577 if ( km == KMessageBox::Cancel )
1576 return false; 1578 return false;
1577 if ( km == KMessageBox::Yes ) 1579 if ( km == KMessageBox::Yes )
1578 return true; 1580 return true;
1579 1581
1580 setSyncDevice("deleteaftersync" ); 1582 setSyncDevice("deleteaftersync" );
1581 KOPrefs::instance()->mAskForPreferences = true; 1583 KOPrefs::instance()->mAskForPreferences = true;
1582 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1584 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1583 KOPrefs::instance()->mWriteBackFile = false; 1585 KOPrefs::instance()->mWriteBackFile = false;
1584 KOPrefs::instance()->mWriteBackExistingOnly = false; 1586 KOPrefs::instance()->mWriteBackExistingOnly = false;
1585 KOPrefs::instance()->mShowSyncSummary = false; 1587 KOPrefs::instance()->mShowSyncSummary = false;
1586 syncCalendar( fn, 3 ); 1588 syncCalendar( fn, 3 );
1587 Event * e = getLastSyncEvent(); 1589 Event * e = getLastSyncEvent();
1588 mCalendar->deleteEvent ( e ); 1590 mCalendar->deleteEvent ( e );
1589 updateView(); 1591 updateView();
1590 return true; 1592 return true;
1591} 1593}
1592 1594
1593bool CalendarView::saveCalendar( QString filename ) 1595bool CalendarView::saveCalendar( QString filename )
1594{ 1596{
1595 1597
1596 // Store back all unsaved data into calendar object 1598 // Store back all unsaved data into calendar object
1597 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1599 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1598 if ( mViewManager->currentView() ) 1600 if ( mViewManager->currentView() )
1599 mViewManager->currentView()->flushView(); 1601 mViewManager->currentView()->flushView();
1600 1602
1601 //mStorage->setFileName( filename ); 1603 //mStorage->setFileName( filename );
1602 1604
1603 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1605 mStorage->setSaveFormat( new ICalFormat() );
1604 mStorage->setFileName( filename ); 1606 mStorage->setFileName( filename );
1605 bool success; 1607 bool success;
1606 success = mStorage->save(); 1608 success = mStorage->save();
1607 if ( !success ) { 1609 if ( !success ) {
1608 return false; 1610 return false;
1609 } 1611 }
1610 1612
1611 return true; 1613 return true;
1612} 1614}
1613 1615
1614void CalendarView::closeCalendar() 1616void CalendarView::closeCalendar()
1615{ 1617{
1616 1618
1617 // child windows no longer valid 1619 // child windows no longer valid
1618 emit closingDown(); 1620 emit closingDown();
1619 1621
1620 mCalendar->close(); 1622 mCalendar->close();
1621 setModified(false); 1623 setModified(false);
1622 updateView(); 1624 updateView();
1623} 1625}
1624 1626
1625void CalendarView::archiveCalendar() 1627void CalendarView::archiveCalendar()
1626{ 1628{
1627 mDialogManager->showArchiveDialog(); 1629 mDialogManager->showArchiveDialog();
1628} 1630}
1629 1631
1630 1632
1631void CalendarView::readSettings() 1633void CalendarView::readSettings()
1632{ 1634{
1633 1635
1634 1636
1635 // mViewManager->showAgendaView(); 1637 // mViewManager->showAgendaView();
1636 QString str; 1638 QString str;
1637 //qDebug("CalendarView::readSettings() "); 1639 //qDebug("CalendarView::readSettings() ");
1638 // read settings from the KConfig, supplying reasonable 1640 // read settings from the KConfig, supplying reasonable
1639 // defaults where none are to be found 1641 // defaults where none are to be found
1640 KConfig *config = KOGlobals::config(); 1642 KConfig *config = KOGlobals::config();
1641#ifndef KORG_NOSPLITTER 1643#ifndef KORG_NOSPLITTER
1642 config->setGroup("KOrganizer Geometry"); 1644 config->setGroup("KOrganizer Geometry");
1643 1645
1644 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1646 QValueList<int> sizes = config->readIntListEntry("Separator1");
1645 if (sizes.count() != 2) { 1647 if (sizes.count() != 2) {
1646 sizes << mDateNavigator->minimumSizeHint().width(); 1648 sizes << mDateNavigator->minimumSizeHint().width();
1647 sizes << 300; 1649 sizes << 300;
1648 } 1650 }
1649 mPanner->setSizes(sizes); 1651 mPanner->setSizes(sizes);
1650 1652
1651 sizes = config->readIntListEntry("Separator2"); 1653 sizes = config->readIntListEntry("Separator2");
1652 if ( ( mResourceView && sizes.count() == 4 ) || 1654 if ( ( mResourceView && sizes.count() == 4 ) ||
1653 ( !mResourceView && sizes.count() == 3 ) ) { 1655 ( !mResourceView && sizes.count() == 3 ) ) {
1654 mLeftSplitter->setSizes(sizes); 1656 mLeftSplitter->setSizes(sizes);
1655 } 1657 }
1656#endif 1658#endif
1657 globalFlagBlockAgenda = 1; 1659 globalFlagBlockAgenda = 1;
1658 mViewManager->showAgendaView(); 1660 mViewManager->showAgendaView();
1659 //mViewManager->readSettings( config ); 1661 //mViewManager->readSettings( config );
1660 mTodoList->restoreLayout(config,QString("Todo Layout")); 1662 mTodoList->restoreLayout(config,QString("Todo Layout"));
1661 readFilterSettings(config); 1663 readFilterSettings(config);
1662 config->setGroup( "Views" ); 1664 config->setGroup( "Views" );
1663 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1665 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1664 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1666 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1665 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1667 else if ( dateCount == 7 ) mNavigator->selectWeek();
1666 else mNavigator->selectDates( dateCount ); 1668 else mNavigator->selectDates( dateCount );
1667 // mViewManager->readSettings( config ); 1669 // mViewManager->readSettings( config );
1668 updateConfig(); 1670 updateConfig();
1669 globalFlagBlockAgenda = 2; 1671 globalFlagBlockAgenda = 2;
1670 mViewManager->readSettings( config ); 1672 mViewManager->readSettings( config );
1671#ifdef DESKTOP_VERSION 1673#ifdef DESKTOP_VERSION
1672 config->setGroup("WidgetLayout"); 1674 config->setGroup("WidgetLayout");
1673 QStringList list; 1675 QStringList list;
1674 list = config->readListEntry("MainLayout"); 1676 list = config->readListEntry("MainLayout");
1675 int x,y,w,h; 1677 int x,y,w,h;
1676 if ( ! list.isEmpty() ) { 1678 if ( ! list.isEmpty() ) {
1677 x = list[0].toInt(); 1679 x = list[0].toInt();
1678 y = list[1].toInt(); 1680 y = list[1].toInt();
1679 w = list[2].toInt(); 1681 w = list[2].toInt();
1680 h = list[3].toInt(); 1682 h = list[3].toInt();
1681 topLevelWidget()->setGeometry(x,y,w,h); 1683 topLevelWidget()->setGeometry(x,y,w,h);
1682 1684
1683 } else { 1685 } else {
1684 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1686 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1685 } 1687 }
1686 list = config->readListEntry("EditEventLayout"); 1688 list = config->readListEntry("EditEventLayout");
1687 if ( ! list.isEmpty() ) { 1689 if ( ! list.isEmpty() ) {
1688 x = list[0].toInt(); 1690 x = list[0].toInt();
1689 y = list[1].toInt(); 1691 y = list[1].toInt();
1690 w = list[2].toInt(); 1692 w = list[2].toInt();
1691 h = list[3].toInt(); 1693 h = list[3].toInt();
1692 mEventEditor->setGeometry(x,y,w,h); 1694 mEventEditor->setGeometry(x,y,w,h);
1693 1695
1694 } 1696 }
1695 list = config->readListEntry("EditTodoLayout"); 1697 list = config->readListEntry("EditTodoLayout");
1696 if ( ! list.isEmpty() ) { 1698 if ( ! list.isEmpty() ) {
1697 x = list[0].toInt(); 1699 x = list[0].toInt();
1698 y = list[1].toInt(); 1700 y = list[1].toInt();
1699 w = list[2].toInt(); 1701 w = list[2].toInt();
1700 h = list[3].toInt(); 1702 h = list[3].toInt();
1701 mTodoEditor->setGeometry(x,y,w,h); 1703 mTodoEditor->setGeometry(x,y,w,h);
1702 1704
1703 } 1705 }
1704 list = config->readListEntry("ViewerLayout"); 1706 list = config->readListEntry("ViewerLayout");
1705 if ( ! list.isEmpty() ) { 1707 if ( ! list.isEmpty() ) {
1706 x = list[0].toInt(); 1708 x = list[0].toInt();
1707 y = list[1].toInt(); 1709 y = list[1].toInt();
1708 w = list[2].toInt(); 1710 w = list[2].toInt();
1709 h = list[3].toInt(); 1711 h = list[3].toInt();
1710 getEventViewerDialog()->setGeometry(x,y,w,h); 1712 getEventViewerDialog()->setGeometry(x,y,w,h);
1711 } 1713 }
1712#endif 1714#endif
1713 1715
1714} 1716}
1715 1717
1716 1718
1717void CalendarView::writeSettings() 1719void CalendarView::writeSettings()
1718{ 1720{
1719 // kdDebug() << "CalendarView::writeSettings" << endl; 1721 // kdDebug() << "CalendarView::writeSettings" << endl;
1720 1722
1721 KConfig *config = KOGlobals::config(); 1723 KConfig *config = KOGlobals::config();
1722 1724
1723#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1724 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1725 1727
1726 QValueList<int> list = mPanner->sizes(); 1728 QValueList<int> list = mPanner->sizes();
1727 config->writeEntry("Separator1",list); 1729 config->writeEntry("Separator1",list);
1728 1730
1729 list = mLeftSplitter->sizes(); 1731 list = mLeftSplitter->sizes();
1730 config->writeEntry("Separator2",list); 1732 config->writeEntry("Separator2",list);
1731#endif 1733#endif
1732 1734
1733 mViewManager->writeSettings( config ); 1735 mViewManager->writeSettings( config );
1734 mTodoList->saveLayout(config,QString("Todo Layout")); 1736 mTodoList->saveLayout(config,QString("Todo Layout"));
1735 mDialogManager->writeSettings( config ); 1737 mDialogManager->writeSettings( config );
1736 //KOPrefs::instance()->usrWriteConfig(); 1738 //KOPrefs::instance()->usrWriteConfig();
1737 KOPrefs::instance()->writeConfig(); 1739 KOPrefs::instance()->writeConfig();
1738 1740
1739 writeFilterSettings(config); 1741 writeFilterSettings(config);
1740 1742
1741 config->setGroup( "Views" ); 1743 config->setGroup( "Views" );
1742 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1744 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1743 1745
1744#ifdef DESKTOP_VERSION 1746#ifdef DESKTOP_VERSION
1745 config->setGroup("WidgetLayout"); 1747 config->setGroup("WidgetLayout");
1746 QStringList list ;//= config->readListEntry("MainLayout"); 1748 QStringList list ;//= config->readListEntry("MainLayout");
1747 int x,y,w,h; 1749 int x,y,w,h;
1748 QWidget* wid; 1750 QWidget* wid;
1749 wid = topLevelWidget(); 1751 wid = topLevelWidget();
1750 x = wid->geometry().x(); 1752 x = wid->geometry().x();
1751 y = wid->geometry().y(); 1753 y = wid->geometry().y();
1752 w = wid->width(); 1754 w = wid->width();
1753 h = wid->height(); 1755 h = wid->height();
1754 list.clear(); 1756 list.clear();
1755 list << QString::number( x ); 1757 list << QString::number( x );
1756 list << QString::number( y ); 1758 list << QString::number( y );
1757 list << QString::number( w ); 1759 list << QString::number( w );
1758 list << QString::number( h ); 1760 list << QString::number( h );
1759 config->writeEntry("MainLayout",list ); 1761 config->writeEntry("MainLayout",list );
1760 1762
1761 wid = mEventEditor; 1763 wid = mEventEditor;
1762 x = wid->geometry().x(); 1764 x = wid->geometry().x();
1763 y = wid->geometry().y(); 1765 y = wid->geometry().y();
1764 w = wid->width(); 1766 w = wid->width();
1765 h = wid->height(); 1767 h = wid->height();
1766 list.clear(); 1768 list.clear();
1767 list << QString::number( x ); 1769 list << QString::number( x );
1768 list << QString::number( y ); 1770 list << QString::number( y );
1769 list << QString::number( w ); 1771 list << QString::number( w );
1770 list << QString::number( h ); 1772 list << QString::number( h );
1771 config->writeEntry("EditEventLayout",list ); 1773 config->writeEntry("EditEventLayout",list );
1772 1774
1773 wid = mTodoEditor; 1775 wid = mTodoEditor;
1774 x = wid->geometry().x(); 1776 x = wid->geometry().x();
1775 y = wid->geometry().y(); 1777 y = wid->geometry().y();
1776 w = wid->width(); 1778 w = wid->width();
1777 h = wid->height(); 1779 h = wid->height();
1778 list.clear(); 1780 list.clear();
1779 list << QString::number( x ); 1781 list << QString::number( x );
1780 list << QString::number( y ); 1782 list << QString::number( y );
1781 list << QString::number( w ); 1783 list << QString::number( w );
1782 list << QString::number( h ); 1784 list << QString::number( h );
1783 config->writeEntry("EditTodoLayout",list ); 1785 config->writeEntry("EditTodoLayout",list );
1784 wid = getEventViewerDialog(); 1786 wid = getEventViewerDialog();
1785 x = wid->geometry().x(); 1787 x = wid->geometry().x();
1786 y = wid->geometry().y(); 1788 y = wid->geometry().y();
1787 w = wid->width(); 1789 w = wid->width();
1788 h = wid->height(); 1790 h = wid->height();
1789 list.clear(); 1791 list.clear();
1790 list << QString::number( x ); 1792 list << QString::number( x );
1791 list << QString::number( y ); 1793 list << QString::number( y );
1792 list << QString::number( w ); 1794 list << QString::number( w );
1793 list << QString::number( h ); 1795 list << QString::number( h );
1794 config->writeEntry("ViewerLayout",list ); 1796 config->writeEntry("ViewerLayout",list );
1795 wid = mDialogManager->getSearchDialog(); 1797 wid = mDialogManager->getSearchDialog();
1796 if ( wid ) { 1798 if ( wid ) {
1797 x = wid->geometry().x(); 1799 x = wid->geometry().x();
1798 y = wid->geometry().y(); 1800 y = wid->geometry().y();
1799 w = wid->width(); 1801 w = wid->width();
1800 h = wid->height(); 1802 h = wid->height();
1801 list.clear(); 1803 list.clear();
1802 list << QString::number( x ); 1804 list << QString::number( x );
1803 list << QString::number( y ); 1805 list << QString::number( y );
1804 list << QString::number( w ); 1806 list << QString::number( w );
1805 list << QString::number( h ); 1807 list << QString::number( h );
1806 config->writeEntry("SearchLayout",list ); 1808 config->writeEntry("SearchLayout",list );
1807 } 1809 }
1808#endif 1810#endif
1809 1811
1810 1812
1811 config->sync(); 1813 config->sync();
1812} 1814}
1813 1815
1814void CalendarView::readFilterSettings(KConfig *config) 1816void CalendarView::readFilterSettings(KConfig *config)
1815{ 1817{
1816 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1818 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1817 1819
1818 mFilters.clear(); 1820 mFilters.clear();
1819 1821
1820 config->setGroup("General"); 1822 config->setGroup("General");
1821 QStringList filterList = config->readListEntry("CalendarFilters"); 1823 QStringList filterList = config->readListEntry("CalendarFilters");
1822 1824
1823 QStringList::ConstIterator it = filterList.begin(); 1825 QStringList::ConstIterator it = filterList.begin();
1824 QStringList::ConstIterator end = filterList.end(); 1826 QStringList::ConstIterator end = filterList.end();
1825 while(it != end) { 1827 while(it != end) {
1826 // kdDebug() << " filter: " << (*it) << endl; 1828 // kdDebug() << " filter: " << (*it) << endl;
1827 1829
1828 CalFilter *filter; 1830 CalFilter *filter;
1829 filter = new CalFilter(*it); 1831 filter = new CalFilter(*it);
1830 config->setGroup("Filter_" + (*it)); 1832 config->setGroup("Filter_" + (*it));
1831 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1833 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1832 filter->setCriteria(config->readNumEntry("Criteria",0)); 1834 filter->setCriteria(config->readNumEntry("Criteria",0));
1833 filter->setCategoryList(config->readListEntry("CategoryList")); 1835 filter->setCategoryList(config->readListEntry("CategoryList"));
1834 mFilters.append(filter); 1836 mFilters.append(filter);
1835 1837
1836 ++it; 1838 ++it;
1837 } 1839 }
1838 1840
1839 if (mFilters.count() == 0) { 1841 if (mFilters.count() == 0) {
1840 CalFilter *filter = new CalFilter(i18n("Default")); 1842 CalFilter *filter = new CalFilter(i18n("Default"));
1841 mFilters.append(filter); 1843 mFilters.append(filter);
1842 } 1844 }
1843 mFilterView->updateFilters(); 1845 mFilterView->updateFilters();
1844 config->setGroup("FilterView"); 1846 config->setGroup("FilterView");
1845 1847
1846 mFilterView->blockSignals(true); 1848 mFilterView->blockSignals(true);
1847 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1849 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1848 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1850 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1849 mFilterView->blockSignals(false); 1851 mFilterView->blockSignals(false);
1850 // We do it manually to avoid it being done twice by the above calls 1852 // We do it manually to avoid it being done twice by the above calls
1851 updateFilter(); 1853 updateFilter();
1852} 1854}
1853 1855
1854void CalendarView::writeFilterSettings(KConfig *config) 1856void CalendarView::writeFilterSettings(KConfig *config)
1855{ 1857{
1856 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1858 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1857 1859
1858 QStringList filterList; 1860 QStringList filterList;
1859 1861
1860 CalFilter *filter = mFilters.first(); 1862 CalFilter *filter = mFilters.first();
1861 while(filter) { 1863 while(filter) {
1862 // kdDebug() << " fn: " << filter->name() << endl; 1864 // kdDebug() << " fn: " << filter->name() << endl;
1863 filterList << filter->name(); 1865 filterList << filter->name();
1864 config->setGroup("Filter_" + filter->name()); 1866 config->setGroup("Filter_" + filter->name());
1865 config->writeEntry("Criteria",filter->criteria()); 1867 config->writeEntry("Criteria",filter->criteria());
1866 config->writeEntry("CategoryList",filter->categoryList()); 1868 config->writeEntry("CategoryList",filter->categoryList());
1867 filter = mFilters.next(); 1869 filter = mFilters.next();
1868 } 1870 }
1869 config->setGroup("General"); 1871 config->setGroup("General");
1870 config->writeEntry("CalendarFilters",filterList); 1872 config->writeEntry("CalendarFilters",filterList);
1871 1873
1872 config->setGroup("FilterView"); 1874 config->setGroup("FilterView");
1873 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1875 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1874 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1876 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1875} 1877}
1876 1878
1877 1879
1878void CalendarView::goToday() 1880void CalendarView::goToday()
1879{ 1881{
1880 mNavigator->selectToday(); 1882 mNavigator->selectToday();
1881} 1883}
1882 1884
1883void CalendarView::goNext() 1885void CalendarView::goNext()
1884{ 1886{
1885 mNavigator->selectNext(); 1887 mNavigator->selectNext();
1886} 1888}
1887 1889
1888void CalendarView::goPrevious() 1890void CalendarView::goPrevious()
1889{ 1891{
1890 mNavigator->selectPrevious(); 1892 mNavigator->selectPrevious();
1891} 1893}
1892void CalendarView::goNextMonth() 1894void CalendarView::goNextMonth()
1893{ 1895{
1894 mNavigator->selectNextMonth(); 1896 mNavigator->selectNextMonth();
1895} 1897}
1896 1898
1897void CalendarView::goPreviousMonth() 1899void CalendarView::goPreviousMonth()
1898{ 1900{
1899 mNavigator->selectPreviousMonth(); 1901 mNavigator->selectPreviousMonth();
1900} 1902}
1901void CalendarView::writeLocale() 1903void CalendarView::writeLocale()
1902{ 1904{
1903 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1905 //KPimGlobalPrefs::instance()->setGlobalConfig();
1904#if 0 1906#if 0
1905 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1907 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1906 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1908 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1907 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1909 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1908 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1910 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1909 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1911 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1910 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1912 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1911 dummy = KOPrefs::instance()->mUserDateFormatShort; 1913 dummy = KOPrefs::instance()->mUserDateFormatShort;
1912 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1914 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1913 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1915 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1914 KOPrefs::instance()->mDaylightsavingStart, 1916 KOPrefs::instance()->mDaylightsavingStart,
1915 KOPrefs::instance()->mDaylightsavingEnd ); 1917 KOPrefs::instance()->mDaylightsavingEnd );
1916 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1918 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1917#endif 1919#endif
1918} 1920}
1919void CalendarView::updateConfig() 1921void CalendarView::updateConfig()
1920{ 1922{
1921 writeLocale(); 1923 writeLocale();
1922 if ( KOPrefs::instance()->mUseAppColors ) 1924 if ( KOPrefs::instance()->mUseAppColors )
1923 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1925 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1924 emit configChanged(); 1926 emit configChanged();
1925 mTodoList->updateConfig(); 1927 mTodoList->updateConfig();
1926 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1928 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1927 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1929 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1928 // To make the "fill window" configurations work 1930 // To make the "fill window" configurations work
1929 //mViewManager->raiseCurrentView(); 1931 //mViewManager->raiseCurrentView();
1930} 1932}
1931 1933
1932 1934
1933void CalendarView::eventChanged(Event *event) 1935void CalendarView::eventChanged(Event *event)
1934{ 1936{
1935 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1937 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1936 //updateUnmanagedViews(); 1938 //updateUnmanagedViews();
1937} 1939}
1938 1940
1939void CalendarView::eventAdded(Event *event) 1941void CalendarView::eventAdded(Event *event)
1940{ 1942{
1941 changeEventDisplay(event,KOGlobals::EVENTADDED); 1943 changeEventDisplay(event,KOGlobals::EVENTADDED);
1942} 1944}
1943 1945
1944void CalendarView::eventToBeDeleted(Event *) 1946void CalendarView::eventToBeDeleted(Event *)
1945{ 1947{
1946 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1948 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1947} 1949}
1948 1950
1949void CalendarView::eventDeleted() 1951void CalendarView::eventDeleted()
1950{ 1952{
1951 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1953 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1952} 1954}
1953void CalendarView::changeTodoDisplay(Todo *which, int action) 1955void CalendarView::changeTodoDisplay(Todo *which, int action)
1954{ 1956{
1955 changeIncidenceDisplay((Incidence *)which, action); 1957 changeIncidenceDisplay((Incidence *)which, action);
1956 mDateNavigator->updateView(); //LR 1958 mDateNavigator->updateView(); //LR
1957 //mDialogManager->updateSearchDialog(); 1959 //mDialogManager->updateSearchDialog();
1958 1960
1959 if (which) { 1961 if (which) {
1960 mViewManager->updateWNview(); 1962 mViewManager->updateWNview();
1961 //mTodoList->updateView(); 1963 //mTodoList->updateView();
1962 } 1964 }
1963 1965
1964} 1966}
1965 1967
1966void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1968void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1967{ 1969{
1968 updateUnmanagedViews(); 1970 updateUnmanagedViews();
1969 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1971 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1970 if ( action == KOGlobals::EVENTDELETED ) { //delete 1972 if ( action == KOGlobals::EVENTDELETED ) { //delete
1971 mCalendar->checkAlarmForIncidence( 0, true ); 1973 mCalendar->checkAlarmForIncidence( 0, true );
1972 if ( mEventViewerDialog ) 1974 if ( mEventViewerDialog )
1973 mEventViewerDialog->hide(); 1975 mEventViewerDialog->hide();
1974 } 1976 }
1975 else 1977 else
1976 mCalendar->checkAlarmForIncidence( which , false ); 1978 mCalendar->checkAlarmForIncidence( which , false );
1977} 1979}
1978 1980
1979// most of the changeEventDisplays() right now just call the view's 1981// most of the changeEventDisplays() right now just call the view's
1980// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1982// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1981void CalendarView::changeEventDisplay(Event *which, int action) 1983void CalendarView::changeEventDisplay(Event *which, int action)
1982{ 1984{
1983 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1985 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1984 changeIncidenceDisplay((Incidence *)which, action); 1986 changeIncidenceDisplay((Incidence *)which, action);
1985 mDateNavigator->updateView(); 1987 mDateNavigator->updateView();
1986 //mDialogManager->updateSearchDialog(); 1988 //mDialogManager->updateSearchDialog();
1987 1989
1988 if (which) { 1990 if (which) {
1989 // If there is an event view visible update the display 1991 // If there is an event view visible update the display
1990 mViewManager->currentView()->changeEventDisplay(which,action); 1992 mViewManager->currentView()->changeEventDisplay(which,action);
1991 // TODO: check, if update needed 1993 // TODO: check, if update needed
1992 // if (which->getTodoStatus()) { 1994 // if (which->getTodoStatus()) {
1993 mTodoList->updateView(); 1995 mTodoList->updateView();
1994 // } 1996 // }
1995 } else { 1997 } else {
1996 mViewManager->currentView()->updateView(); 1998 mViewManager->currentView()->updateView();
1997 } 1999 }
1998} 2000}
1999 2001
2000 2002
2001void CalendarView::updateTodoViews() 2003void CalendarView::updateTodoViews()
2002{ 2004{
2003 2005
2004 mTodoList->updateView(); 2006 mTodoList->updateView();
2005 mViewManager->currentView()->updateView(); 2007 mViewManager->currentView()->updateView();
2006 2008
2007} 2009}
2008 2010
2009 2011
2010void CalendarView::updateView(const QDate &start, const QDate &end) 2012void CalendarView::updateView(const QDate &start, const QDate &end)
2011{ 2013{
2012 mTodoList->updateView(); 2014 mTodoList->updateView();
2013 mViewManager->updateView(start, end); 2015 mViewManager->updateView(start, end);
2014 //mDateNavigator->updateView(); 2016 //mDateNavigator->updateView();
2015} 2017}
2016 2018
2017void CalendarView::updateView() 2019void CalendarView::updateView()
2018{ 2020{
2019 DateList tmpList = mNavigator->selectedDates(); 2021 DateList tmpList = mNavigator->selectedDates();
2020 2022
2021 // We assume that the navigator only selects consecutive days. 2023 // We assume that the navigator only selects consecutive days.
2022 updateView( tmpList.first(), tmpList.last() ); 2024 updateView( tmpList.first(), tmpList.last() );
2023} 2025}
2024 2026
2025void CalendarView::updateUnmanagedViews() 2027void CalendarView::updateUnmanagedViews()
2026{ 2028{
2027 mDateNavigator->updateDayMatrix(); 2029 mDateNavigator->updateDayMatrix();
2028} 2030}
2029 2031
2030int CalendarView::msgItemDelete() 2032int CalendarView::msgItemDelete()
2031{ 2033{
2032 return KMessageBox::warningContinueCancel(this, 2034 return KMessageBox::warningContinueCancel(this,
2033 i18n("This item will be\npermanently deleted."), 2035 i18n("This item will be\npermanently deleted."),
2034 i18n("KO/Pi Confirmation"),i18n("Delete")); 2036 i18n("KO/Pi Confirmation"),i18n("Delete"));
2035} 2037}
2036 2038
2037 2039
2038void CalendarView::edit_cut() 2040void CalendarView::edit_cut()
2039{ 2041{
2040 Event *anEvent=0; 2042 Event *anEvent=0;
2041 2043
2042 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2044 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2043 2045
2044 if (mViewManager->currentView()->isEventView()) { 2046 if (mViewManager->currentView()->isEventView()) {
2045 if ( incidence && incidence->type() == "Event" ) { 2047 if ( incidence && incidence->type() == "Event" ) {
2046 anEvent = static_cast<Event *>(incidence); 2048 anEvent = static_cast<Event *>(incidence);
2047 } 2049 }
2048 } 2050 }
2049 2051
2050 if (!anEvent) { 2052 if (!anEvent) {
2051 KNotifyClient::beep(); 2053 KNotifyClient::beep();
2052 return; 2054 return;
2053 } 2055 }
2054 DndFactory factory( mCalendar ); 2056 DndFactory factory( mCalendar );
2055 factory.cutEvent(anEvent); 2057 factory.cutEvent(anEvent);
2056 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2058 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2057} 2059}
2058 2060
2059void CalendarView::edit_copy() 2061void CalendarView::edit_copy()
2060{ 2062{
2061 Event *anEvent=0; 2063 Event *anEvent=0;
2062 2064
2063 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2065 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2064 2066
2065 if (mViewManager->currentView()->isEventView()) { 2067 if (mViewManager->currentView()->isEventView()) {
2066 if ( incidence && incidence->type() == "Event" ) { 2068 if ( incidence && incidence->type() == "Event" ) {
2067 anEvent = static_cast<Event *>(incidence); 2069 anEvent = static_cast<Event *>(incidence);
2068 } 2070 }
2069 } 2071 }
2070 2072
2071 if (!anEvent) { 2073 if (!anEvent) {
2072 KNotifyClient::beep(); 2074 KNotifyClient::beep();
2073 return; 2075 return;
2074 } 2076 }
2075 DndFactory factory( mCalendar ); 2077 DndFactory factory( mCalendar );
2076 factory.copyEvent(anEvent); 2078 factory.copyEvent(anEvent);
2077} 2079}
2078 2080
2079void CalendarView::edit_paste() 2081void CalendarView::edit_paste()
2080{ 2082{
2081 QDate date = mNavigator->selectedDates().first(); 2083 QDate date = mNavigator->selectedDates().first();
2082 2084
2083 DndFactory factory( mCalendar ); 2085 DndFactory factory( mCalendar );
2084 Event *pastedEvent = factory.pasteEvent( date ); 2086 Event *pastedEvent = factory.pasteEvent( date );
2085 2087
2086 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2088 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2087} 2089}
2088 2090
2089void CalendarView::edit_options() 2091void CalendarView::edit_options()
2090{ 2092{
2091 mDialogManager->showOptionsDialog(); 2093 mDialogManager->showOptionsDialog();
2092 //writeSettings(); 2094 //writeSettings();
2093} 2095}
2094void CalendarView::edit_sync_options() 2096void CalendarView::edit_sync_options()
2095{ 2097{
2096 //mDialogManager->showSyncOptions(); 2098 //mDialogManager->showSyncOptions();
2097 //KOPrefs::instance()->mSyncAlgoPrefs 2099 //KOPrefs::instance()->mSyncAlgoPrefs
2098 QDialog dia( this, "dia", true ); 2100 QDialog dia( this, "dia", true );
2099 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2101 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2100 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2102 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2101 QVBoxLayout lay ( &dia ); 2103 QVBoxLayout lay ( &dia );
2102 lay.setSpacing( 2 ); 2104 lay.setSpacing( 2 );
2103 lay.setMargin( 3 ); 2105 lay.setMargin( 3 );
2104 lay.addWidget(&gr); 2106 lay.addWidget(&gr);
2105 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2107 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2106 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2108 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2107 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2109 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2108 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2110 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2109 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2111 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2110 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2112 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2111 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2113 //QRadioButton both( i18n("Take both on conflict"), &gr );
2112 QPushButton pb ( "OK", &dia); 2114 QPushButton pb ( "OK", &dia);
2113 lay.addWidget( &pb ); 2115 lay.addWidget( &pb );
2114 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2116 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2115 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2117 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2116 case 0: 2118 case 0:
2117 loc.setChecked( true); 2119 loc.setChecked( true);
2118 break; 2120 break;
2119 case 1: 2121 case 1:
2120 rem.setChecked( true ); 2122 rem.setChecked( true );
2121 break; 2123 break;
2122 case 2: 2124 case 2:
2123 newest.setChecked( true); 2125 newest.setChecked( true);
2124 break; 2126 break;
2125 case 3: 2127 case 3:
2126 ask.setChecked( true); 2128 ask.setChecked( true);
2127 break; 2129 break;
2128 case 4: 2130 case 4:
2129 f_loc.setChecked( true); 2131 f_loc.setChecked( true);
2130 break; 2132 break;
2131 case 5: 2133 case 5:
2132 f_rem.setChecked( true); 2134 f_rem.setChecked( true);
2133 break; 2135 break;
2134 case 6: 2136 case 6:
2135 // both.setChecked( true); 2137 // both.setChecked( true);
2136 break; 2138 break;
2137 default: 2139 default:
2138 break; 2140 break;
2139 } 2141 }
2140 if ( dia.exec() ) { 2142 if ( dia.exec() ) {
2141 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2143 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2142 } 2144 }
2143 2145
2144} 2146}
2145 2147
2146void CalendarView::slotSelectPickerDate( QDate d) 2148void CalendarView::slotSelectPickerDate( QDate d)
2147{ 2149{
2148 mDateFrame->hide(); 2150 mDateFrame->hide();
2149 if ( mDatePickerMode == 1 ) { 2151 if ( mDatePickerMode == 1 ) {
2150 mNavigator->slotDaySelect( d ); 2152 mNavigator->slotDaySelect( d );
2151 } else if ( mDatePickerMode == 2 ) { 2153 } else if ( mDatePickerMode == 2 ) {
2152 if ( mMoveIncidence->type() == "Todo" ) { 2154 if ( mMoveIncidence->type() == "Todo" ) {
2153 Todo * to = (Todo *) mMoveIncidence; 2155 Todo * to = (Todo *) mMoveIncidence;
2154 QTime tim; 2156 QTime tim;
2155 if ( to->hasDueDate() ) 2157 if ( to->hasDueDate() )
2156 tim = to->dtDue().time(); 2158 tim = to->dtDue().time();
2157 else { 2159 else {
2158 tim = QTime ( 0,0,0 ); 2160 tim = QTime ( 0,0,0 );
2159 to->setFloats( true ); 2161 to->setFloats( true );
2160 to->setHasDueDate( true ); 2162 to->setHasDueDate( true );
2161 } 2163 }
2162 QDateTime dt ( d,tim ); 2164 QDateTime dt ( d,tim );
2163 to->setDtDue( dt ); 2165 to->setDtDue( dt );
2164 todoChanged( to ); 2166 todoChanged( to );
2165 } else { 2167 } else {
2166 QTime tim = mMoveIncidence->dtStart().time(); 2168 QTime tim = mMoveIncidence->dtStart().time();
2167 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2169 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2168 QDateTime dt ( d,tim ); 2170 QDateTime dt ( d,tim );
2169 mMoveIncidence->setDtStart( dt ); 2171 mMoveIncidence->setDtStart( dt );
2170 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2172 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2171 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2173 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2172 } 2174 }
2173 2175
2174 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2176 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2175 } 2177 }
2176} 2178}
2177 2179
2178void CalendarView::removeCategories() 2180void CalendarView::removeCategories()
2179{ 2181{
2180 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2182 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2181 QStringList catList = KOPrefs::instance()->mCustomCategories; 2183 QStringList catList = KOPrefs::instance()->mCustomCategories;
2182 QStringList catIncList; 2184 QStringList catIncList;
2183 QStringList newCatList; 2185 QStringList newCatList;
2184 Incidence* inc = incList.first(); 2186 Incidence* inc = incList.first();
2185 int i; 2187 int i;
2186 int count = 0; 2188 int count = 0;
2187 while ( inc ) { 2189 while ( inc ) {
2188 newCatList.clear(); 2190 newCatList.clear();
2189 catIncList = inc->categories() ; 2191 catIncList = inc->categories() ;
2190 for( i = 0; i< catIncList.count(); ++i ) { 2192 for( i = 0; i< catIncList.count(); ++i ) {
2191 if ( catList.contains (catIncList[i])) 2193 if ( catList.contains (catIncList[i]))
2192 newCatList.append( catIncList[i] ); 2194 newCatList.append( catIncList[i] );
2193 } 2195 }
2194 newCatList.sort(); 2196 newCatList.sort();
2195 inc->setCategories( newCatList.join(",") ); 2197 inc->setCategories( newCatList.join(",") );
2196 inc = incList.next(); 2198 inc = incList.next();
2197 } 2199 }
2198} 2200}
2199 2201
2200int CalendarView::addCategories() 2202int CalendarView::addCategories()
2201{ 2203{
2202 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2204 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2203 QStringList catList = KOPrefs::instance()->mCustomCategories; 2205 QStringList catList = KOPrefs::instance()->mCustomCategories;
2204 QStringList catIncList; 2206 QStringList catIncList;
2205 Incidence* inc = incList.first(); 2207 Incidence* inc = incList.first();
2206 int i; 2208 int i;
2207 int count = 0; 2209 int count = 0;
2208 while ( inc ) { 2210 while ( inc ) {
2209 catIncList = inc->categories() ; 2211 catIncList = inc->categories() ;
2210 for( i = 0; i< catIncList.count(); ++i ) { 2212 for( i = 0; i< catIncList.count(); ++i ) {
2211 if ( !catList.contains (catIncList[i])) { 2213 if ( !catList.contains (catIncList[i])) {
2212 catList.append( catIncList[i] ); 2214 catList.append( catIncList[i] );
2213 //qDebug("add cat %s ", catIncList[i].latin1()); 2215 //qDebug("add cat %s ", catIncList[i].latin1());
2214 ++count; 2216 ++count;
2215 } 2217 }
2216 } 2218 }
2217 inc = incList.next(); 2219 inc = incList.next();
2218 } 2220 }
2219 catList.sort(); 2221 catList.sort();
2220 KOPrefs::instance()->mCustomCategories = catList; 2222 KOPrefs::instance()->mCustomCategories = catList;
2221 return count; 2223 return count;
2222} 2224}
2223 2225
2224void CalendarView::manageCategories() 2226void CalendarView::manageCategories()
2225{ 2227{
2226 KOCatPrefs* cp = new KOCatPrefs(); 2228 KOCatPrefs* cp = new KOCatPrefs();
2227 cp->show(); 2229 cp->show();
2228 int w =cp->sizeHint().width() ; 2230 int w =cp->sizeHint().width() ;
2229 int h = cp->sizeHint().height() ; 2231 int h = cp->sizeHint().height() ;
2230 int dw = QApplication::desktop()->width(); 2232 int dw = QApplication::desktop()->width();
2231 int dh = QApplication::desktop()->height(); 2233 int dh = QApplication::desktop()->height();
2232 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2234 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2233 if ( !cp->exec() ) { 2235 if ( !cp->exec() ) {
2234 delete cp; 2236 delete cp;
2235 return; 2237 return;
2236 } 2238 }
2237 int count = 0; 2239 int count = 0;
2238 if ( cp->addCat() ) { 2240 if ( cp->addCat() ) {
2239 count = addCategories(); 2241 count = addCategories();
2240 if ( count ) { 2242 if ( count ) {
2241 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2243 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2242 writeSettings(); 2244 writeSettings();
2243 } 2245 }
2244 } else { 2246 } else {
2245 removeCategories(); 2247 removeCategories();
2246 updateView(); 2248 updateView();
2247 } 2249 }
2248 delete cp; 2250 delete cp;
2249} 2251}
2250 2252
2251void CalendarView::beamIncidence(Incidence * Inc) 2253void CalendarView::beamIncidence(Incidence * Inc)
2252{ 2254{
2253 QPtrList<Incidence> delSel ; 2255 QPtrList<Incidence> delSel ;
2254 delSel.append(Inc); 2256 delSel.append(Inc);
2255 beamIncidenceList( delSel ); 2257 beamIncidenceList( delSel );
2256} 2258}
2257void CalendarView::beamCalendar() 2259void CalendarView::beamCalendar()
2258{ 2260{
2259 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2261 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2260 //qDebug("beamCalendar() "); 2262 //qDebug("beamCalendar() ");
2261 beamIncidenceList( delSel ); 2263 beamIncidenceList( delSel );
2262} 2264}
2263void CalendarView::beamFilteredCalendar() 2265void CalendarView::beamFilteredCalendar()
2264{ 2266{
2265 QPtrList<Incidence> delSel = mCalendar->incidences(); 2267 QPtrList<Incidence> delSel = mCalendar->incidences();
2266 //qDebug("beamFilteredCalendar() "); 2268 //qDebug("beamFilteredCalendar() ");
2267 beamIncidenceList( delSel ); 2269 beamIncidenceList( delSel );
2268} 2270}
2269void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2271void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2270{ 2272{
2271 if ( beamDialog->exec () == QDialog::Rejected ) 2273 if ( beamDialog->exec () == QDialog::Rejected )
2272 return; 2274 return;
2273 2275
2274 QString fn = "/tmp/kopibeamfile"; 2276 QString fn = "/tmp/kopibeamfile";
2275 QString mes; 2277 QString mes;
2276 bool createbup = true; 2278 bool createbup = true;
2277 if ( createbup ) { 2279 if ( createbup ) {
2278 QString description = "\n"; 2280 QString description = "\n";
2279 CalendarLocal* cal = new CalendarLocal(); 2281 CalendarLocal* cal = new CalendarLocal();
2280 if ( beamDialog->beamLocal() ) 2282 if ( beamDialog->beamLocal() )
2281 cal->setLocalTime(); 2283 cal->setLocalTime();
2282 else 2284 else
2283 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2285 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2284 Incidence *incidence = delSel.first(); 2286 Incidence *incidence = delSel.first();
2285 bool addText = false; 2287 bool addText = false;
2286 if ( delSel.count() < 10 ) 2288 if ( delSel.count() < 10 )
2287 addText = true; 2289 addText = true;
2288 else { 2290 else {
2289 description.sprintf(i18n(" %d items?"),delSel.count() ); 2291 description.sprintf(i18n(" %d items?"),delSel.count() );
2290 } 2292 }
2291 while ( incidence ) { 2293 while ( incidence ) {
2292 Incidence *in = incidence->clone(); 2294 Incidence *in = incidence->clone();
2293 if ( addText ) 2295 if ( addText )
2294 description += in->summary() + "\n"; 2296 description += in->summary() + "\n";
2295 cal->addIncidence( in ); 2297 cal->addIncidence( in );
2296 incidence = delSel.next(); 2298 incidence = delSel.next();
2297 } 2299 }
2298 if ( beamDialog->beamVcal() ) { 2300 if ( beamDialog->beamVcal() ) {
2299 fn += ".vcs"; 2301 fn += ".vcs";
2300 FileStorage storage( cal, fn, new VCalFormat ); 2302 FileStorage storage( cal, fn, new VCalFormat );
2301 storage.save(); 2303 storage.save();
2302 } else { 2304 } else {
2303 fn += ".ics"; 2305 fn += ".ics";
2304 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2306 FileStorage storage( cal, fn, new ICalFormat( ) );
2305 storage.save(); 2307 storage.save();
2306 } 2308 }
2307 delete cal; 2309 delete cal;
2308 mes = i18n("KO/Pi: Ready for beaming"); 2310 mes = i18n("KO/Pi: Ready for beaming");
2309 setCaption(mes); 2311 setCaption(mes);
2310 2312
2311#ifndef DESKTOP_VERSION 2313#ifndef DESKTOP_VERSION
2312 Ir *ir = new Ir( this ); 2314 Ir *ir = new Ir( this );
2313 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2315 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2314 ir->send( fn, description, "text/x-vCalendar" ); 2316 ir->send( fn, description, "text/x-vCalendar" );
2315#endif 2317#endif
2316 } 2318 }
2317} 2319}
2318void CalendarView::beamDone( Ir *ir ) 2320void CalendarView::beamDone( Ir *ir )
2319{ 2321{
2320#ifndef DESKTOP_VERSION 2322#ifndef DESKTOP_VERSION
2321 delete ir; 2323 delete ir;
2322#endif 2324#endif
2323} 2325}
2324 2326
2325void CalendarView::moveIncidence(Incidence * inc ) 2327void CalendarView::moveIncidence(Incidence * inc )
2326{ 2328{
2327 if ( !inc ) return; 2329 if ( !inc ) return;
2328 // qDebug("showDatePickerForIncidence( ) "); 2330 // qDebug("showDatePickerForIncidence( ) ");
2329 if ( mDateFrame->isVisible() ) 2331 if ( mDateFrame->isVisible() )
2330 mDateFrame->hide(); 2332 mDateFrame->hide();
2331 else { 2333 else {
2332 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2334 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2333 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2335 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2334 int dw = QApplication::desktop()->width(); 2336 int dw = QApplication::desktop()->width();
2335 int dh = QApplication::desktop()->height(); 2337 int dh = QApplication::desktop()->height();
2336 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2338 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2337 mDateFrame->show(); 2339 mDateFrame->show();
2338 } 2340 }
2339 mDatePickerMode = 2; 2341 mDatePickerMode = 2;
2340 mMoveIncidence = inc ; 2342 mMoveIncidence = inc ;
2341 QDate da; 2343 QDate da;
2342 if ( mMoveIncidence->type() == "Todo" ) { 2344 if ( mMoveIncidence->type() == "Todo" ) {
2343 Todo * to = (Todo *) mMoveIncidence; 2345 Todo * to = (Todo *) mMoveIncidence;
2344 if ( to->hasDueDate() ) 2346 if ( to->hasDueDate() )
2345 da = to->dtDue().date(); 2347 da = to->dtDue().date();
2346 else 2348 else
2347 da = QDate::currentDate(); 2349 da = QDate::currentDate();
2348 } else { 2350 } else {
2349 da = mMoveIncidence->dtStart().date(); 2351 da = mMoveIncidence->dtStart().date();
2350 } 2352 }
2351 mDatePicker->setDate( da ); 2353 mDatePicker->setDate( da );
2352} 2354}
2353void CalendarView::showDatePicker( ) 2355void CalendarView::showDatePicker( )
2354{ 2356{
2355 //qDebug("CalendarView::showDatePicker( ) "); 2357 //qDebug("CalendarView::showDatePicker( ) ");
2356 if ( mDateFrame->isVisible() ) 2358 if ( mDateFrame->isVisible() )
2357 mDateFrame->hide(); 2359 mDateFrame->hide();
2358 else { 2360 else {
2359 int w =mDatePicker->sizeHint().width() ; 2361 int w =mDatePicker->sizeHint().width() ;
2360 int h = mDatePicker->sizeHint().height() ; 2362 int h = mDatePicker->sizeHint().height() ;
2361 int dw = QApplication::desktop()->width(); 2363 int dw = QApplication::desktop()->width();
2362 int dh = QApplication::desktop()->height(); 2364 int dh = QApplication::desktop()->height();
2363 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2365 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2364 mDateFrame->show(); 2366 mDateFrame->show();
2365 } 2367 }
2366 mDatePickerMode = 1; 2368 mDatePickerMode = 1;
2367 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2369 mDatePicker->setDate( mNavigator->selectedDates().first() );
2368} 2370}
2369 2371
2370void CalendarView::showEventEditor() 2372void CalendarView::showEventEditor()
2371{ 2373{
2372#ifdef DESKTOP_VERSION 2374#ifdef DESKTOP_VERSION
2373 mEventEditor->show(); 2375 mEventEditor->show();
2374#else 2376#else
2375 mEventEditor->showMaximized(); 2377 mEventEditor->showMaximized();
2376#endif 2378#endif
2377} 2379}
2378void CalendarView::showTodoEditor() 2380void CalendarView::showTodoEditor()
2379{ 2381{
2380#ifdef DESKTOP_VERSION 2382#ifdef DESKTOP_VERSION
2381 mTodoEditor->show(); 2383 mTodoEditor->show();
2382#else 2384#else
2383 mTodoEditor->showMaximized(); 2385 mTodoEditor->showMaximized();
2384#endif 2386#endif
2385} 2387}
2386void CalendarView::cancelIncidence(Incidence * inc ) 2388void CalendarView::cancelIncidence(Incidence * inc )
2387{ 2389{
2388 inc->setCancelled( ! inc->cancelled() ); 2390 inc->setCancelled( ! inc->cancelled() );
2389 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2391 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2390 updateView(); 2392 updateView();
2391} 2393}
2392void CalendarView::cloneIncidence(Incidence * orgInc ) 2394void CalendarView::cloneIncidence(Incidence * orgInc )
2393{ 2395{
2394 Incidence * newInc = orgInc->clone(); 2396 Incidence * newInc = orgInc->clone();
2395 newInc->recreate(); 2397 newInc->recreate();
2396 2398
2397 if ( newInc->type() == "Todo" ) { 2399 if ( newInc->type() == "Todo" ) {
2398 Todo* t = (Todo*) newInc; 2400 Todo* t = (Todo*) newInc;
2399 mTodoEditor->editTodo( t ); 2401 mTodoEditor->editTodo( t );
2400 showTodoEditor(); 2402 showTodoEditor();
2401 if ( mTodoEditor->exec() ) { 2403 if ( mTodoEditor->exec() ) {
2402 mCalendar->addTodo( t ); 2404 mCalendar->addTodo( t );
2403 updateView(); 2405 updateView();
2404 } else { 2406 } else {
2405 delete t; 2407 delete t;
2406 } 2408 }
2407 } 2409 }
2408 else { 2410 else {
2409 Event* e = (Event*) newInc; 2411 Event* e = (Event*) newInc;
2410 mEventEditor->editEvent( e ); 2412 mEventEditor->editEvent( e );
2411 showEventEditor(); 2413 showEventEditor();
2412 if ( mEventEditor->exec() ) { 2414 if ( mEventEditor->exec() ) {
2413 mCalendar->addEvent( e ); 2415 mCalendar->addEvent( e );
2414 updateView(); 2416 updateView();
2415 } else { 2417 } else {
2416 delete e; 2418 delete e;
2417 } 2419 }
2418 } 2420 }
2419} 2421}
2420 2422
2421void CalendarView::newEvent() 2423void CalendarView::newEvent()
2422{ 2424{
2423 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2425 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2424 KOAgendaView *aView = mViewManager->agendaView(); 2426 KOAgendaView *aView = mViewManager->agendaView();
2425 if (aView) { 2427 if (aView) {
2426 if (aView->selectionStart().isValid()) { 2428 if (aView->selectionStart().isValid()) {
2427 if (aView->selectedIsAllDay()) { 2429 if (aView->selectedIsAllDay()) {
2428 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2430 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2429 } else { 2431 } else {
2430 newEvent(aView->selectionStart(),aView->selectionEnd()); 2432 newEvent(aView->selectionStart(),aView->selectionEnd());
2431 } 2433 }
2432 return; 2434 return;
2433 } 2435 }
2434 } 2436 }
2435 2437
2436 QDate date = mNavigator->selectedDates().first(); 2438 QDate date = mNavigator->selectedDates().first();
2437 QDateTime current = QDateTime::currentDateTime(); 2439 QDateTime current = QDateTime::currentDateTime();
2438 if ( date <= current.date() ) { 2440 if ( date <= current.date() ) {
2439 int hour = current.time().hour() +1; 2441 int hour = current.time().hour() +1;
2440 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2442 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2441 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2443 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2442 } else 2444 } else
2443 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2445 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2444 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2446 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2445 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2447 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2446} 2448}
2447 2449
2448void CalendarView::newEvent(QDateTime fh) 2450void CalendarView::newEvent(QDateTime fh)
2449{ 2451{
2450 newEvent(fh, 2452 newEvent(fh,
2451 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2453 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2452} 2454}
2453 2455
2454void CalendarView::newEvent(QDate dt) 2456void CalendarView::newEvent(QDate dt)
2455{ 2457{
2456 newEvent(QDateTime(dt, QTime(0,0,0)), 2458 newEvent(QDateTime(dt, QTime(0,0,0)),
2457 QDateTime(dt, QTime(0,0,0)), true); 2459 QDateTime(dt, QTime(0,0,0)), true);
2458} 2460}
2459 2461
2460void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2462void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2461{ 2463{
2462 2464
2463 mEventEditor->newEvent(fromHint,toHint,allDay); 2465 mEventEditor->newEvent(fromHint,toHint,allDay);
2464 if ( mFilterView->filtersEnabled() ) { 2466 if ( mFilterView->filtersEnabled() ) {
2465 CalFilter *filter = mFilterView->selectedFilter(); 2467 CalFilter *filter = mFilterView->selectedFilter();
2466 if (filter && filter->showCategories()) { 2468 if (filter && filter->showCategories()) {
2467 mEventEditor->setCategories(filter->categoryList().join(",") ); 2469 mEventEditor->setCategories(filter->categoryList().join(",") );
2468 } 2470 }
2469 if ( filter ) 2471 if ( filter )
2470 mEventEditor->setSecrecy( filter->getSecrecy() ); 2472 mEventEditor->setSecrecy( filter->getSecrecy() );
2471 } 2473 }
2472 showEventEditor(); 2474 showEventEditor();
2473} 2475}
2474void CalendarView::todoAdded(Todo * t) 2476void CalendarView::todoAdded(Todo * t)
2475{ 2477{
2476 2478
2477 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2479 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2478 updateTodoViews(); 2480 updateTodoViews();
2479} 2481}
2480void CalendarView::todoChanged(Todo * t) 2482void CalendarView::todoChanged(Todo * t)
2481{ 2483{
2482 emit todoModified( t, 4 ); 2484 emit todoModified( t, 4 );
2483 // updateTodoViews(); 2485 // updateTodoViews();
2484} 2486}
2485void CalendarView::todoToBeDeleted(Todo *) 2487void CalendarView::todoToBeDeleted(Todo *)
2486{ 2488{
2487 //qDebug("todoToBeDeleted(Todo *) "); 2489 //qDebug("todoToBeDeleted(Todo *) ");
2488 updateTodoViews(); 2490 updateTodoViews();
2489} 2491}
2490void CalendarView::todoDeleted() 2492void CalendarView::todoDeleted()
2491{ 2493{
2492 //qDebug(" todoDeleted()"); 2494 //qDebug(" todoDeleted()");
2493 updateTodoViews(); 2495 updateTodoViews();
2494} 2496}
2495 2497
2496 2498
2497 2499
2498void CalendarView::newTodo() 2500void CalendarView::newTodo()
2499{ 2501{
2500 2502
2501 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2503 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2502 if ( mFilterView->filtersEnabled() ) { 2504 if ( mFilterView->filtersEnabled() ) {
2503 CalFilter *filter = mFilterView->selectedFilter(); 2505 CalFilter *filter = mFilterView->selectedFilter();
2504 if (filter && filter->showCategories()) { 2506 if (filter && filter->showCategories()) {
2505 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2507 mTodoEditor->setCategories(filter->categoryList().join(",") );
2506 } 2508 }
2507 if ( filter ) 2509 if ( filter )
2508 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2510 mTodoEditor->setSecrecy( filter->getSecrecy() );
2509 } 2511 }
2510 showTodoEditor(); 2512 showTodoEditor();
2511} 2513}
2512 2514
2513void CalendarView::newSubTodo() 2515void CalendarView::newSubTodo()
2514{ 2516{
2515 Todo *todo = selectedTodo(); 2517 Todo *todo = selectedTodo();
2516 if ( todo ) newSubTodo( todo ); 2518 if ( todo ) newSubTodo( todo );
2517} 2519}
2518 2520
2519void CalendarView::newSubTodo(Todo *parentEvent) 2521void CalendarView::newSubTodo(Todo *parentEvent)
2520{ 2522{
2521 2523
2522 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2524 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2523 showTodoEditor(); 2525 showTodoEditor();
2524} 2526}
2525 2527
2526void CalendarView::newFloatingEvent() 2528void CalendarView::newFloatingEvent()
2527{ 2529{
2528 DateList tmpList = mNavigator->selectedDates(); 2530 DateList tmpList = mNavigator->selectedDates();
2529 QDate date = tmpList.first(); 2531 QDate date = tmpList.first();
2530 2532
2531 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2533 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2532 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2534 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2533} 2535}
2534 2536
2535 2537
2536void CalendarView::editEvent( Event *event ) 2538void CalendarView::editEvent( Event *event )
2537{ 2539{
2538 2540
2539 if ( !event ) return; 2541 if ( !event ) return;
2540 if ( event->isReadOnly() ) { 2542 if ( event->isReadOnly() ) {
2541 showEvent( event ); 2543 showEvent( event );
2542 return; 2544 return;
2543 } 2545 }
2544 mEventEditor->editEvent( event , mFlagEditDescription); 2546 mEventEditor->editEvent( event , mFlagEditDescription);
2545 showEventEditor(); 2547 showEventEditor();
2546} 2548}
2547void CalendarView::editJournal( Journal *jour ) 2549void CalendarView::editJournal( Journal *jour )
2548{ 2550{
2549 if ( !jour ) return; 2551 if ( !jour ) return;
2550 mDialogManager->hideSearchDialog(); 2552 mDialogManager->hideSearchDialog();
2551 mViewManager->showJournalView(); 2553 mViewManager->showJournalView();
2552 mNavigator->slotDaySelect( jour->dtStart().date() ); 2554 mNavigator->slotDaySelect( jour->dtStart().date() );
2553} 2555}
2554void CalendarView::editTodo( Todo *todo ) 2556void CalendarView::editTodo( Todo *todo )
2555{ 2557{
2556 if ( !todo ) return; 2558 if ( !todo ) return;
2557 2559
2558 if ( todo->isReadOnly() ) { 2560 if ( todo->isReadOnly() ) {
2559 showTodo( todo ); 2561 showTodo( todo );
2560 return; 2562 return;
2561 } 2563 }
2562 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2564 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2563 showTodoEditor(); 2565 showTodoEditor();
2564 2566
2565} 2567}
2566 2568
2567KOEventViewerDialog* CalendarView::getEventViewerDialog() 2569KOEventViewerDialog* CalendarView::getEventViewerDialog()
2568{ 2570{
2569 if ( !mEventViewerDialog ) { 2571 if ( !mEventViewerDialog ) {
2570 mEventViewerDialog = new KOEventViewerDialog(this); 2572 mEventViewerDialog = new KOEventViewerDialog(this);
2571 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2573 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2572 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2574 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2573 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2575 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2574 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2576 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2575 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2577 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2576 viewManager(), SLOT( showAgendaView( bool ) ) ); 2578 viewManager(), SLOT( showAgendaView( bool ) ) );
2577 mEventViewerDialog->resize( 640, 480 ); 2579 mEventViewerDialog->resize( 640, 480 );
2578 2580
2579 } 2581 }
2580 return mEventViewerDialog; 2582 return mEventViewerDialog;
2581} 2583}
2582void CalendarView::showEvent(Event *event) 2584void CalendarView::showEvent(Event *event)
2583{ 2585{
2584 getEventViewerDialog()->setEvent(event); 2586 getEventViewerDialog()->setEvent(event);
2585 getEventViewerDialog()->showMe(); 2587 getEventViewerDialog()->showMe();
2586} 2588}
2587 2589
2588void CalendarView::showTodo(Todo *event) 2590void CalendarView::showTodo(Todo *event)
2589{ 2591{
2590 getEventViewerDialog()->setTodo(event); 2592 getEventViewerDialog()->setTodo(event);
2591 getEventViewerDialog()->showMe(); 2593 getEventViewerDialog()->showMe();
2592} 2594}
2593void CalendarView::showJournal( Journal *jour ) 2595void CalendarView::showJournal( Journal *jour )
2594{ 2596{
2595 getEventViewerDialog()->setJournal(jour); 2597 getEventViewerDialog()->setJournal(jour);
2596 getEventViewerDialog()->showMe(); 2598 getEventViewerDialog()->showMe();
2597 2599
2598} 2600}
2599// void CalendarView::todoModified (Todo *event, int changed) 2601// void CalendarView::todoModified (Todo *event, int changed)
2600// { 2602// {
2601// // if (mDialogList.find (event) != mDialogList.end ()) { 2603// // if (mDialogList.find (event) != mDialogList.end ()) {
2602// // kdDebug() << "Todo modified and open" << endl; 2604// // kdDebug() << "Todo modified and open" << endl;
2603// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2605// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2604// // temp->modified (changed); 2606// // temp->modified (changed);
2605 2607
2606// // } 2608// // }
2607 2609
2608// mViewManager->updateView(); 2610// mViewManager->updateView();
2609// } 2611// }
2610 2612
2611void CalendarView::appointment_show() 2613void CalendarView::appointment_show()
2612{ 2614{
2613 Event *anEvent = 0; 2615 Event *anEvent = 0;
2614 2616
2615 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2617 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2616 2618
2617 if (mViewManager->currentView()->isEventView()) { 2619 if (mViewManager->currentView()->isEventView()) {
2618 if ( incidence && incidence->type() == "Event" ) { 2620 if ( incidence && incidence->type() == "Event" ) {
2619 anEvent = static_cast<Event *>(incidence); 2621 anEvent = static_cast<Event *>(incidence);
2620 } 2622 }
2621 } 2623 }
2622 2624
2623 if (!anEvent) { 2625 if (!anEvent) {
2624 KNotifyClient::beep(); 2626 KNotifyClient::beep();
2625 return; 2627 return;
2626 } 2628 }
2627 2629
2628 showEvent(anEvent); 2630 showEvent(anEvent);
2629} 2631}
2630 2632
2631void CalendarView::appointment_edit() 2633void CalendarView::appointment_edit()
2632{ 2634{
2633 Event *anEvent = 0; 2635 Event *anEvent = 0;
2634 2636
2635 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2637 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2636 2638
2637 if (mViewManager->currentView()->isEventView()) { 2639 if (mViewManager->currentView()->isEventView()) {
2638 if ( incidence && incidence->type() == "Event" ) { 2640 if ( incidence && incidence->type() == "Event" ) {
2639 anEvent = static_cast<Event *>(incidence); 2641 anEvent = static_cast<Event *>(incidence);
2640 } 2642 }
2641 } 2643 }
2642 2644
2643 if (!anEvent) { 2645 if (!anEvent) {
2644 KNotifyClient::beep(); 2646 KNotifyClient::beep();
2645 return; 2647 return;
2646 } 2648 }
2647 2649
2648 editEvent(anEvent); 2650 editEvent(anEvent);
2649} 2651}
2650 2652
2651void CalendarView::appointment_delete() 2653void CalendarView::appointment_delete()
2652{ 2654{
2653 Event *anEvent = 0; 2655 Event *anEvent = 0;
2654 2656
2655 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2657 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2656 2658
2657 if (mViewManager->currentView()->isEventView()) { 2659 if (mViewManager->currentView()->isEventView()) {
2658 if ( incidence && incidence->type() == "Event" ) { 2660 if ( incidence && incidence->type() == "Event" ) {
2659 anEvent = static_cast<Event *>(incidence); 2661 anEvent = static_cast<Event *>(incidence);
2660 } 2662 }
2661 } 2663 }
2662 2664
2663 if (!anEvent) { 2665 if (!anEvent) {
2664 KNotifyClient::beep(); 2666 KNotifyClient::beep();
2665 return; 2667 return;
2666 } 2668 }
2667 2669
2668 deleteEvent(anEvent); 2670 deleteEvent(anEvent);
2669} 2671}
2670 2672
2671void CalendarView::todo_unsub(Todo *anTodo ) 2673void CalendarView::todo_unsub(Todo *anTodo )
2672{ 2674{
2673 // Todo *anTodo = selectedTodo(); 2675 // Todo *anTodo = selectedTodo();
2674 if (!anTodo) return; 2676 if (!anTodo) return;
2675 if (!anTodo->relatedTo()) return; 2677 if (!anTodo->relatedTo()) return;
2676 anTodo->relatedTo()->removeRelation(anTodo); 2678 anTodo->relatedTo()->removeRelation(anTodo);
2677 anTodo->setRelatedTo(0); 2679 anTodo->setRelatedTo(0);
2678 anTodo->updated(); 2680 anTodo->updated();
2679 anTodo->setRelatedToUid(""); 2681 anTodo->setRelatedToUid("");
2680 setModified(true); 2682 setModified(true);
2681 updateView(); 2683 updateView();
2682} 2684}
2683 2685
2684void CalendarView::deleteTodo(Todo *todo) 2686void CalendarView::deleteTodo(Todo *todo)
2685{ 2687{
2686 if (!todo) { 2688 if (!todo) {
2687 KNotifyClient::beep(); 2689 KNotifyClient::beep();
2688 return; 2690 return;
2689 } 2691 }
2690 if (KOPrefs::instance()->mConfirm) { 2692 if (KOPrefs::instance()->mConfirm) {
2691 switch (msgItemDelete()) { 2693 switch (msgItemDelete()) {
2692 case KMessageBox::Continue: // OK 2694 case KMessageBox::Continue: // OK
2693 if (!todo->relations().isEmpty()) { 2695 if (!todo->relations().isEmpty()) {
2694 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2696 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2695 i18n("Delete To-Do")); 2697 i18n("Delete To-Do"));
2696 } else { 2698 } else {
2697 checkExternalId( todo ); 2699 checkExternalId( todo );
2698 calendar()->deleteTodo(todo); 2700 calendar()->deleteTodo(todo);
2699 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2701 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2700 updateView(); 2702 updateView();
2701 } 2703 }
2702 break; 2704 break;
2703 } // switch 2705 } // switch
2704 } else { 2706 } else {
2705 if (!todo->relations().isEmpty()) { 2707 if (!todo->relations().isEmpty()) {
2706 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2708 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2707 i18n("Delete To-Do")); 2709 i18n("Delete To-Do"));
2708 } else { 2710 } else {
2709 checkExternalId( todo ); 2711 checkExternalId( todo );
2710 mCalendar->deleteTodo(todo); 2712 mCalendar->deleteTodo(todo);
2711 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2713 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2712 updateView(); 2714 updateView();
2713 } 2715 }
2714 } 2716 }
2715 emit updateSearchDialog(); 2717 emit updateSearchDialog();
2716} 2718}
2717void CalendarView::deleteJournal(Journal *jour) 2719void CalendarView::deleteJournal(Journal *jour)
2718{ 2720{
2719 if (!jour) { 2721 if (!jour) {
2720 KNotifyClient::beep(); 2722 KNotifyClient::beep();
2721 return; 2723 return;
2722 } 2724 }
2723 if (KOPrefs::instance()->mConfirm) { 2725 if (KOPrefs::instance()->mConfirm) {
2724 switch (msgItemDelete()) { 2726 switch (msgItemDelete()) {
2725 case KMessageBox::Continue: // OK 2727 case KMessageBox::Continue: // OK
2726 calendar()->deleteJournal(jour); 2728 calendar()->deleteJournal(jour);
2727 updateView(); 2729 updateView();
2728 break; 2730 break;
2729 } // switch 2731 } // switch
2730 } else { 2732 } else {
2731 calendar()->deleteJournal(jour);; 2733 calendar()->deleteJournal(jour);;
2732 updateView(); 2734 updateView();
2733 } 2735 }
2734 emit updateSearchDialog(); 2736 emit updateSearchDialog();
2735} 2737}
2736 2738
2737void CalendarView::deleteEvent(Event *anEvent) 2739void CalendarView::deleteEvent(Event *anEvent)
2738{ 2740{
2739 if (!anEvent) { 2741 if (!anEvent) {
2740 KNotifyClient::beep(); 2742 KNotifyClient::beep();
2741 return; 2743 return;
2742 } 2744 }
2743 2745
2744 if (anEvent->recurrence()->doesRecur()) { 2746 if (anEvent->recurrence()->doesRecur()) {
2745 QDate itemDate = mViewManager->currentSelectionDate(); 2747 QDate itemDate = mViewManager->currentSelectionDate();
2746 int km; 2748 int km;
2747 if (!itemDate.isValid()) { 2749 if (!itemDate.isValid()) {
2748 //kdDebug() << "Date Not Valid" << endl; 2750 //kdDebug() << "Date Not Valid" << endl;
2749 if (KOPrefs::instance()->mConfirm) { 2751 if (KOPrefs::instance()->mConfirm) {
2750 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2752 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2751 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2753 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2752 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2754 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2753 if ( km == KMessageBox::Continue ) 2755 if ( km == KMessageBox::Continue )
2754 km = KMessageBox::No; // No = all below 2756 km = KMessageBox::No; // No = all below
2755 } else 2757 } else
2756 km = KMessageBox::No; 2758 km = KMessageBox::No;
2757 } else { 2759 } else {
2758 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2760 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2759 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2761 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2760 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2762 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2761 i18n("KO/Pi Confirmation"),i18n("Current"), 2763 i18n("KO/Pi Confirmation"),i18n("Current"),
2762 i18n("All")); 2764 i18n("All"));
2763 } 2765 }
2764 switch(km) { 2766 switch(km) {
2765 2767
2766 case KMessageBox::No: // Continue // all 2768 case KMessageBox::No: // Continue // all
2767 //qDebug("KMessageBox::No "); 2769 //qDebug("KMessageBox::No ");
2768 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2770 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2769 schedule(Scheduler::Cancel,anEvent); 2771 schedule(Scheduler::Cancel,anEvent);
2770 2772
2771 checkExternalId( anEvent); 2773 checkExternalId( anEvent);
2772 mCalendar->deleteEvent(anEvent); 2774 mCalendar->deleteEvent(anEvent);
2773 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2775 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2774 break; 2776 break;
2775 2777
2776 // Disabled because it does not work 2778 // Disabled because it does not work
2777 //#if 0 2779 //#if 0
2778 case KMessageBox::Yes: // just this one 2780 case KMessageBox::Yes: // just this one
2779 //QDate qd = mNavigator->selectedDates().first(); 2781 //QDate qd = mNavigator->selectedDates().first();
2780 //if (!qd.isValid()) { 2782 //if (!qd.isValid()) {
2781 // kdDebug() << "no date selected, or invalid date" << endl; 2783 // kdDebug() << "no date selected, or invalid date" << endl;
2782 // KNotifyClient::beep(); 2784 // KNotifyClient::beep();
2783 // return; 2785 // return;
2784 //} 2786 //}
2785 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2787 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2786 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2788 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2787 anEvent->addExDate(itemDate); 2789 anEvent->addExDate(itemDate);
2788 int duration = anEvent->recurrence()->duration(); 2790 int duration = anEvent->recurrence()->duration();
2789 if ( duration > 0 ) { 2791 if ( duration > 0 ) {
2790 anEvent->recurrence()->setDuration( duration - 1 ); 2792 anEvent->recurrence()->setDuration( duration - 1 );
2791 } 2793 }
2792 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2794 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2793 } 2795 }
2794 break; 2796 break;
2795 //#endif 2797 //#endif
2796 } // switch 2798 } // switch
2797 } else { 2799 } else {
2798 if (KOPrefs::instance()->mConfirm) { 2800 if (KOPrefs::instance()->mConfirm) {
2799 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2801 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2800 i18n("\nAre you sure you want\nto delete this event?"), 2802 i18n("\nAre you sure you want\nto delete this event?"),
2801 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2803 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2802 case KMessageBox::Continue: // OK 2804 case KMessageBox::Continue: // OK
2803 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2805 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2804 schedule(Scheduler::Cancel,anEvent); 2806 schedule(Scheduler::Cancel,anEvent);
2805 checkExternalId( anEvent); 2807 checkExternalId( anEvent);
2806 mCalendar->deleteEvent(anEvent); 2808 mCalendar->deleteEvent(anEvent);
2807 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2809 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2808 break; 2810 break;
2809 } // switch 2811 } // switch
2810 } else { 2812 } else {
2811 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2813 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2812 schedule(Scheduler::Cancel,anEvent); 2814 schedule(Scheduler::Cancel,anEvent);
2813 checkExternalId( anEvent); 2815 checkExternalId( anEvent);
2814 mCalendar->deleteEvent(anEvent); 2816 mCalendar->deleteEvent(anEvent);
2815 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2817 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2816 } 2818 }
2817 } // if-else 2819 } // if-else
2818 emit updateSearchDialog(); 2820 emit updateSearchDialog();
2819} 2821}
2820 2822
2821bool CalendarView::deleteEvent(const QString &uid) 2823bool CalendarView::deleteEvent(const QString &uid)
2822{ 2824{
2823 Event *ev = mCalendar->event(uid); 2825 Event *ev = mCalendar->event(uid);
2824 if (ev) { 2826 if (ev) {
2825 deleteEvent(ev); 2827 deleteEvent(ev);
2826 return true; 2828 return true;
2827 } else { 2829 } else {
2828 return false; 2830 return false;
2829 } 2831 }
2830} 2832}
2831 2833
2832/*****************************************************************************/ 2834/*****************************************************************************/
2833 2835
2834void CalendarView::action_mail() 2836void CalendarView::action_mail()
2835{ 2837{
2836#ifndef KORG_NOMAIL 2838#ifndef KORG_NOMAIL
2837 KOMailClient mailClient; 2839 KOMailClient mailClient;
2838 2840
2839 Incidence *incidence = currentSelection(); 2841 Incidence *incidence = currentSelection();
2840 2842
2841 if (!incidence) { 2843 if (!incidence) {
2842 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2844 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2843 return; 2845 return;
2844 } 2846 }
2845 if(incidence->attendeeCount() == 0 ) { 2847 if(incidence->attendeeCount() == 0 ) {
2846 KMessageBox::sorry(this, 2848 KMessageBox::sorry(this,
2847 i18n("Can't generate mail:\nNo attendees defined.\n")); 2849 i18n("Can't generate mail:\nNo attendees defined.\n"));
2848 return; 2850 return;
2849 } 2851 }
2850 2852
2851 CalendarLocal cal_tmp; 2853 CalendarLocal cal_tmp;
2852 Event *event = 0; 2854 Event *event = 0;
2853 Event *ev = 0; 2855 Event *ev = 0;
2854 if ( incidence && incidence->type() == "Event" ) { 2856 if ( incidence && incidence->type() == "Event" ) {
2855 event = static_cast<Event *>(incidence); 2857 event = static_cast<Event *>(incidence);
2856 ev = new Event(*event); 2858 ev = new Event(*event);
2857 cal_tmp.addEvent(ev); 2859 cal_tmp.addEvent(ev);
2858 } 2860 }
2859 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2861 ICalFormat mForm();
2860 QString attachment = mForm.toString( &cal_tmp ); 2862 QString attachment = mForm.toString( &cal_tmp );
2861 if (ev) delete(ev); 2863 if (ev) delete(ev);
2862 2864
2863 mailClient.mailAttendees(currentSelection(), attachment); 2865 mailClient.mailAttendees(currentSelection(), attachment);
2864 2866
2865#endif 2867#endif
2866 2868
2867#if 0 2869#if 0
2868 Event *anEvent = 0; 2870 Event *anEvent = 0;
2869 if (mViewManager->currentView()->isEventView()) { 2871 if (mViewManager->currentView()->isEventView()) {
2870 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2872 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2871 } 2873 }
2872 2874
2873 if (!anEvent) { 2875 if (!anEvent) {
2874 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2876 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2875 return; 2877 return;
2876 } 2878 }
2877 if(anEvent->attendeeCount() == 0 ) { 2879 if(anEvent->attendeeCount() == 0 ) {
2878 KMessageBox::sorry(this, 2880 KMessageBox::sorry(this,
2879 i18n("Can't generate mail:\nNo attendees defined.\n")); 2881 i18n("Can't generate mail:\nNo attendees defined.\n"));
2880 return; 2882 return;
2881 } 2883 }
2882 2884
2883 mailobject.emailEvent(anEvent); 2885 mailobject.emailEvent(anEvent);
2884#endif 2886#endif
2885} 2887}
2886 2888
2887 2889
2888void CalendarView::schedule_publish(Incidence *incidence) 2890void CalendarView::schedule_publish(Incidence *incidence)
2889{ 2891{
2890 Event *event = 0; 2892 Event *event = 0;
2891 Todo *todo = 0; 2893 Todo *todo = 0;
2892 2894
2893 if (incidence == 0) { 2895 if (incidence == 0) {
2894 incidence = mViewManager->currentView()->selectedIncidences().first(); 2896 incidence = mViewManager->currentView()->selectedIncidences().first();
2895 if (incidence == 0) { 2897 if (incidence == 0) {
2896 incidence = mTodoList->selectedIncidences().first(); 2898 incidence = mTodoList->selectedIncidences().first();
2897 } 2899 }
2898 } 2900 }
2899 if ( incidence && incidence->type() == "Event" ) { 2901 if ( incidence && incidence->type() == "Event" ) {
2900 event = static_cast<Event *>(incidence); 2902 event = static_cast<Event *>(incidence);
2901 } else { 2903 } else {
2902 if ( incidence && incidence->type() == "Todo" ) { 2904 if ( incidence && incidence->type() == "Todo" ) {
2903 todo = static_cast<Todo *>(incidence); 2905 todo = static_cast<Todo *>(incidence);
2904 } 2906 }
2905 } 2907 }
2906 2908
2907 if (!event && !todo) { 2909 if (!event && !todo) {
2908 KMessageBox::sorry(this,i18n("No event selected.")); 2910 KMessageBox::sorry(this,i18n("No event selected."));
2909 return; 2911 return;
2910 } 2912 }
2911 2913
2912 PublishDialog *publishdlg = new PublishDialog(); 2914 PublishDialog *publishdlg = new PublishDialog();
2913 if (incidence->attendeeCount()>0) { 2915 if (incidence->attendeeCount()>0) {
2914 QPtrList<Attendee> attendees = incidence->attendees(); 2916 QPtrList<Attendee> attendees = incidence->attendees();
2915 attendees.first(); 2917 attendees.first();
2916 while ( attendees.current()!=0 ) { 2918 while ( attendees.current()!=0 ) {
2917 publishdlg->addAttendee(attendees.current()); 2919 publishdlg->addAttendee(attendees.current());
2918 attendees.next(); 2920 attendees.next();
2919 } 2921 }
2920 } 2922 }
2921 bool send = true; 2923 bool send = true;
2922 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2924 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2923 if ( publishdlg->exec() != QDialog::Accepted ) 2925 if ( publishdlg->exec() != QDialog::Accepted )
2924 send = false; 2926 send = false;
2925 } 2927 }
2926 if ( send ) { 2928 if ( send ) {
2927 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2929 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2928 if ( event ) { 2930 if ( event ) {
2929 Event *ev = new Event(*event); 2931 Event *ev = new Event(*event);
2930 ev->registerObserver(0); 2932 ev->registerObserver(0);
2931 ev->clearAttendees(); 2933 ev->clearAttendees();
2932 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2934 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2933 delete(ev); 2935 delete(ev);
2934 } 2936 }
2935 } else { 2937 } else {
2936 if ( todo ) { 2938 if ( todo ) {
2937 Todo *ev = new Todo(*todo); 2939 Todo *ev = new Todo(*todo);
2938 ev->registerObserver(0); 2940 ev->registerObserver(0);
2939 ev->clearAttendees(); 2941 ev->clearAttendees();
2940 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2942 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2941 delete(ev); 2943 delete(ev);
2942 } 2944 }
2943 } 2945 }
2944 } 2946 }
2945 } 2947 }
2946 delete publishdlg; 2948 delete publishdlg;
2947} 2949}
2948 2950
2949void CalendarView::schedule_request(Incidence *incidence) 2951void CalendarView::schedule_request(Incidence *incidence)
2950{ 2952{
2951 schedule(Scheduler::Request,incidence); 2953 schedule(Scheduler::Request,incidence);
2952} 2954}
2953 2955
2954void CalendarView::schedule_refresh(Incidence *incidence) 2956void CalendarView::schedule_refresh(Incidence *incidence)
2955{ 2957{
2956 schedule(Scheduler::Refresh,incidence); 2958 schedule(Scheduler::Refresh,incidence);
2957} 2959}
2958 2960
2959void CalendarView::schedule_cancel(Incidence *incidence) 2961void CalendarView::schedule_cancel(Incidence *incidence)
2960{ 2962{
2961 schedule(Scheduler::Cancel,incidence); 2963 schedule(Scheduler::Cancel,incidence);
2962} 2964}
2963 2965
2964void CalendarView::schedule_add(Incidence *incidence) 2966void CalendarView::schedule_add(Incidence *incidence)
2965{ 2967{
2966 schedule(Scheduler::Add,incidence); 2968 schedule(Scheduler::Add,incidence);
2967} 2969}
2968 2970
2969void CalendarView::schedule_reply(Incidence *incidence) 2971void CalendarView::schedule_reply(Incidence *incidence)
2970{ 2972{
2971 schedule(Scheduler::Reply,incidence); 2973 schedule(Scheduler::Reply,incidence);
2972} 2974}
2973 2975
2974void CalendarView::schedule_counter(Incidence *incidence) 2976void CalendarView::schedule_counter(Incidence *incidence)
2975{ 2977{
2976 schedule(Scheduler::Counter,incidence); 2978 schedule(Scheduler::Counter,incidence);
2977} 2979}
2978 2980
2979void CalendarView::schedule_declinecounter(Incidence *incidence) 2981void CalendarView::schedule_declinecounter(Incidence *incidence)
2980{ 2982{
2981 schedule(Scheduler::Declinecounter,incidence); 2983 schedule(Scheduler::Declinecounter,incidence);
2982} 2984}
2983 2985
2984void CalendarView::schedule_publish_freebusy(int daysToPublish) 2986void CalendarView::schedule_publish_freebusy(int daysToPublish)
2985{ 2987{
2986 QDateTime start = QDateTime::currentDateTime(); 2988 QDateTime start = QDateTime::currentDateTime();
2987 QDateTime end = start.addDays(daysToPublish); 2989 QDateTime end = start.addDays(daysToPublish);
2988 2990
2989 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2991 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2990 freebusy->setOrganizer(KOPrefs::instance()->email()); 2992 freebusy->setOrganizer(KOPrefs::instance()->email());
2991 2993
2992 2994
2993 PublishDialog *publishdlg = new PublishDialog(); 2995 PublishDialog *publishdlg = new PublishDialog();
2994 if ( publishdlg->exec() == QDialog::Accepted ) { 2996 if ( publishdlg->exec() == QDialog::Accepted ) {
2995 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2997 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2996 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2998 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2997 delete(freebusy); 2999 delete(freebusy);
2998 } 3000 }
2999 } 3001 }
3000 delete publishdlg; 3002 delete publishdlg;
3001} 3003}
3002 3004
3003void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3005void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3004{ 3006{
3005 Event *event = 0; 3007 Event *event = 0;
3006 Todo *todo = 0; 3008 Todo *todo = 0;
3007 3009
3008 if (incidence == 0) { 3010 if (incidence == 0) {
3009 incidence = mViewManager->currentView()->selectedIncidences().first(); 3011 incidence = mViewManager->currentView()->selectedIncidences().first();
3010 if (incidence == 0) { 3012 if (incidence == 0) {
3011 incidence = mTodoList->selectedIncidences().first(); 3013 incidence = mTodoList->selectedIncidences().first();
3012 } 3014 }
3013 } 3015 }
3014 if ( incidence && incidence->type() == "Event" ) { 3016 if ( incidence && incidence->type() == "Event" ) {
3015 event = static_cast<Event *>(incidence); 3017 event = static_cast<Event *>(incidence);
3016 } 3018 }
3017 if ( incidence && incidence->type() == "Todo" ) { 3019 if ( incidence && incidence->type() == "Todo" ) {
3018 todo = static_cast<Todo *>(incidence); 3020 todo = static_cast<Todo *>(incidence);
3019 } 3021 }
3020 3022
3021 if (!event && !todo) { 3023 if (!event && !todo) {
3022 KMessageBox::sorry(this,i18n("No event selected.")); 3024 KMessageBox::sorry(this,i18n("No event selected."));
3023 return; 3025 return;
3024 } 3026 }
3025 3027
3026 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3028 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3027 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3029 KMessageBox::sorry(this,i18n("The event has no attendees."));
3028 return; 3030 return;
3029 } 3031 }
3030 3032
3031 Event *ev = 0; 3033 Event *ev = 0;
3032 if (event) ev = new Event(*event); 3034 if (event) ev = new Event(*event);
3033 Todo *to = 0; 3035 Todo *to = 0;
3034 if (todo) to = new Todo(*todo); 3036 if (todo) to = new Todo(*todo);
3035 3037
3036 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3038 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3037 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3039 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3038 if (!me) { 3040 if (!me) {
3039 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3041 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3040 return; 3042 return;
3041 } 3043 }
3042 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3044 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3043 StatusDialog *statdlg = new StatusDialog(this); 3045 StatusDialog *statdlg = new StatusDialog(this);
3044 if (!statdlg->exec()==QDialog::Accepted) return; 3046 if (!statdlg->exec()==QDialog::Accepted) return;
3045 me->setStatus( statdlg->status() ); 3047 me->setStatus( statdlg->status() );
3046 delete(statdlg); 3048 delete(statdlg);
3047 } 3049 }
3048 Attendee *menew = new Attendee(*me); 3050 Attendee *menew = new Attendee(*me);
3049 if (ev) { 3051 if (ev) {
3050 ev->clearAttendees(); 3052 ev->clearAttendees();
3051 ev->addAttendee(menew,false); 3053 ev->addAttendee(menew,false);
3052 } else { 3054 } else {
3053 if (to) { 3055 if (to) {
3054 todo->clearAttendees(); 3056 todo->clearAttendees();
3055 todo->addAttendee(menew,false); 3057 todo->addAttendee(menew,false);
3056 } 3058 }
3057 } 3059 }
3058 } 3060 }
3059 3061
3060 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3062 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3061 if (ev) { 3063 if (ev) {
3062 if ( !dlg->addMessage(ev,method) ) delete(ev); 3064 if ( !dlg->addMessage(ev,method) ) delete(ev);
3063 } else { 3065 } else {
3064 if (to) { 3066 if (to) {
3065 if ( !dlg->addMessage(to,method) ) delete(to); 3067 if ( !dlg->addMessage(to,method) ) delete(to);
3066 } 3068 }
3067 } 3069 }
3068} 3070}
3069 3071
3070void CalendarView::openAddressbook() 3072void CalendarView::openAddressbook()
3071{ 3073{
3072 KRun::runCommand("kaddressbook"); 3074 KRun::runCommand("kaddressbook");
3073} 3075}
3074 3076
3075void CalendarView::setModified(bool modified) 3077void CalendarView::setModified(bool modified)
3076{ 3078{
3077 if ( modified ) 3079 if ( modified )
3078 emit signalmodified(); 3080 emit signalmodified();
3079 if (mModified != modified) { 3081 if (mModified != modified) {
3080 mModified = modified; 3082 mModified = modified;
3081 emit modifiedChanged(mModified); 3083 emit modifiedChanged(mModified);
3082 } 3084 }
3083} 3085}
3084 3086
3085bool CalendarView::isReadOnly() 3087bool CalendarView::isReadOnly()
3086{ 3088{
3087 return mReadOnly; 3089 return mReadOnly;
3088} 3090}
3089 3091
3090void CalendarView::setReadOnly(bool readOnly) 3092void CalendarView::setReadOnly(bool readOnly)
3091{ 3093{
3092 if (mReadOnly != readOnly) { 3094 if (mReadOnly != readOnly) {
3093 mReadOnly = readOnly; 3095 mReadOnly = readOnly;
3094 emit readOnlyChanged(mReadOnly); 3096 emit readOnlyChanged(mReadOnly);
3095 } 3097 }
3096} 3098}
3097 3099
3098bool CalendarView::isModified() 3100bool CalendarView::isModified()
3099{ 3101{
3100 return mModified; 3102 return mModified;
3101} 3103}
3102 3104
3103void CalendarView::printSetup() 3105void CalendarView::printSetup()
3104{ 3106{
3105#ifndef KORG_NOPRINTER 3107#ifndef KORG_NOPRINTER
3106 createPrinter(); 3108 createPrinter();
3107 3109
3108 mCalPrinter->setupPrinter(); 3110 mCalPrinter->setupPrinter();
3109#endif 3111#endif
3110} 3112}
3111 3113
3112void CalendarView::print() 3114void CalendarView::print()
3113{ 3115{
3114#ifndef KORG_NOPRINTER 3116#ifndef KORG_NOPRINTER
3115 createPrinter(); 3117 createPrinter();
3116 3118
3117 DateList tmpDateList = mNavigator->selectedDates(); 3119 DateList tmpDateList = mNavigator->selectedDates();
3118 mCalPrinter->print(CalPrinter::Month, 3120 mCalPrinter->print(CalPrinter::Month,
3119 tmpDateList.first(), tmpDateList.last()); 3121 tmpDateList.first(), tmpDateList.last());
3120#endif 3122#endif
3121} 3123}
3122 3124
3123void CalendarView::printPreview() 3125void CalendarView::printPreview()
3124{ 3126{
3125#ifndef KORG_NOPRINTER 3127#ifndef KORG_NOPRINTER
3126 kdDebug() << "CalendarView::printPreview()" << endl; 3128 kdDebug() << "CalendarView::printPreview()" << endl;
3127 3129
3128 createPrinter(); 3130 createPrinter();
3129 3131
3130 DateList tmpDateList = mNavigator->selectedDates(); 3132 DateList tmpDateList = mNavigator->selectedDates();
3131 3133
3132 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3134 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3133 tmpDateList.last()); 3135 tmpDateList.last());
3134#endif 3136#endif
3135} 3137}
3136 3138
3137void CalendarView::exportICalendar() 3139void CalendarView::exportICalendar()
3138{ 3140{
3139 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3141 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3140 3142
3141 // Force correct extension 3143 // Force correct extension
3142 if (filename.right(4) != ".ics") filename += ".ics"; 3144 if (filename.right(4) != ".ics") filename += ".ics";
3143 3145
3144 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3146 FileStorage storage( mCalendar, filename, new ICalFormat() );
3145 storage.save(); 3147 storage.save();
3146} 3148}
3147 3149
3148bool CalendarView::exportVCalendar( QString filename ) 3150bool CalendarView::exportVCalendar( QString filename )
3149{ 3151{
3150 if (mCalendar->journals().count() > 0) { 3152 if (mCalendar->journals().count() > 0) {
3151 int result = KMessageBox::warningContinueCancel(this, 3153 int result = KMessageBox::warningContinueCancel(this,
3152 i18n("The journal entries can not be\nexported to a vCalendar file."), 3154 i18n("The journal entries can not be\nexported to a vCalendar file."),
3153 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3155 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3154 true); 3156 true);
3155 if (result != KMessageBox::Continue) return false; 3157 if (result != KMessageBox::Continue) return false;
3156 } 3158 }
3157 3159
3158 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3160 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3159 3161
3160 // Force correct extension 3162 // Force correct extension
3161 if (filename.right(4) != ".vcs") filename += ".vcs"; 3163 if (filename.right(4) != ".vcs") filename += ".vcs";
3162 3164
3163 FileStorage storage( mCalendar, filename, new VCalFormat ); 3165 FileStorage storage( mCalendar, filename, new VCalFormat );
3164 return storage.save(); 3166 return storage.save();
3165 3167
3166} 3168}
3167 3169
3168void CalendarView::eventUpdated(Incidence *) 3170void CalendarView::eventUpdated(Incidence *)
3169{ 3171{
3170 setModified(); 3172 setModified();
3171 // Don't call updateView here. The code, which has caused the update of the 3173 // Don't call updateView here. The code, which has caused the update of the
3172 // event is responsible for updating the view. 3174 // event is responsible for updating the view.
3173 // updateView(); 3175 // updateView();
3174} 3176}
3175 3177
3176void CalendarView::adaptNavigationUnits() 3178void CalendarView::adaptNavigationUnits()
3177{ 3179{
3178 if (mViewManager->currentView()->isEventView()) { 3180 if (mViewManager->currentView()->isEventView()) {
3179 int days = mViewManager->currentView()->currentDateCount(); 3181 int days = mViewManager->currentView()->currentDateCount();
3180 if (days == 1) { 3182 if (days == 1) {
3181 emit changeNavStringPrev(i18n("&Previous Day")); 3183 emit changeNavStringPrev(i18n("&Previous Day"));
3182 emit changeNavStringNext(i18n("&Next Day")); 3184 emit changeNavStringNext(i18n("&Next Day"));
3183 } else { 3185 } else {
3184 emit changeNavStringPrev(i18n("&Previous Week")); 3186 emit changeNavStringPrev(i18n("&Previous Week"));
3185 emit changeNavStringNext(i18n("&Next Week")); 3187 emit changeNavStringNext(i18n("&Next Week"));
3186 } 3188 }
3187 } 3189 }
3188} 3190}
3189 3191
3190void CalendarView::processMainViewSelection( Incidence *incidence ) 3192void CalendarView::processMainViewSelection( Incidence *incidence )
3191{ 3193{
3192 if ( incidence ) mTodoList->clearSelection(); 3194 if ( incidence ) mTodoList->clearSelection();
3193 processIncidenceSelection( incidence ); 3195 processIncidenceSelection( incidence );
3194} 3196}
3195 3197
3196void CalendarView::processTodoListSelection( Incidence *incidence ) 3198void CalendarView::processTodoListSelection( Incidence *incidence )
3197{ 3199{
3198 if ( incidence && mViewManager->currentView() ) { 3200 if ( incidence && mViewManager->currentView() ) {
3199 mViewManager->currentView()->clearSelection(); 3201 mViewManager->currentView()->clearSelection();
3200 } 3202 }
3201 processIncidenceSelection( incidence ); 3203 processIncidenceSelection( incidence );
3202} 3204}
3203 3205
3204void CalendarView::processIncidenceSelection( Incidence *incidence ) 3206void CalendarView::processIncidenceSelection( Incidence *incidence )
3205{ 3207{
3206 if ( incidence == mSelectedIncidence ) return; 3208 if ( incidence == mSelectedIncidence ) return;
3207 3209
3208 mSelectedIncidence = incidence; 3210 mSelectedIncidence = incidence;
3209 3211
3210 emit incidenceSelected( mSelectedIncidence ); 3212 emit incidenceSelected( mSelectedIncidence );
3211 3213
3212 if ( incidence && incidence->type() == "Event" ) { 3214 if ( incidence && incidence->type() == "Event" ) {
3213 Event *event = static_cast<Event *>( incidence ); 3215 Event *event = static_cast<Event *>( incidence );
3214 if ( event->organizer() == KOPrefs::instance()->email() ) { 3216 if ( event->organizer() == KOPrefs::instance()->email() ) {
3215 emit organizerEventsSelected( true ); 3217 emit organizerEventsSelected( true );
3216 } else { 3218 } else {
3217 emit organizerEventsSelected(false); 3219 emit organizerEventsSelected(false);
3218 } 3220 }
3219 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3221 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3220 KOPrefs::instance()->email() ) ) { 3222 KOPrefs::instance()->email() ) ) {
3221 emit groupEventsSelected( true ); 3223 emit groupEventsSelected( true );
3222 } else { 3224 } else {
3223 emit groupEventsSelected(false); 3225 emit groupEventsSelected(false);
3224 } 3226 }
3225 return; 3227 return;
3226 } else { 3228 } else {
3227 if ( incidence && incidence->type() == "Todo" ) { 3229 if ( incidence && incidence->type() == "Todo" ) {
3228 emit todoSelected( true ); 3230 emit todoSelected( true );
3229 Todo *event = static_cast<Todo *>( incidence ); 3231 Todo *event = static_cast<Todo *>( incidence );
3230 if ( event->organizer() == KOPrefs::instance()->email() ) { 3232 if ( event->organizer() == KOPrefs::instance()->email() ) {
3231 emit organizerEventsSelected( true ); 3233 emit organizerEventsSelected( true );
3232 } else { 3234 } else {
3233 emit organizerEventsSelected(false); 3235 emit organizerEventsSelected(false);
3234 } 3236 }
3235 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3237 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3236 KOPrefs::instance()->email() ) ) { 3238 KOPrefs::instance()->email() ) ) {
3237 emit groupEventsSelected( true ); 3239 emit groupEventsSelected( true );
3238 } else { 3240 } else {
3239 emit groupEventsSelected(false); 3241 emit groupEventsSelected(false);
3240 } 3242 }
3241 return; 3243 return;
3242 } else { 3244 } else {
3243 emit todoSelected( false ); 3245 emit todoSelected( false );
3244 emit organizerEventsSelected(false); 3246 emit organizerEventsSelected(false);
3245 emit groupEventsSelected(false); 3247 emit groupEventsSelected(false);
3246 } 3248 }
3247 return; 3249 return;
3248 } 3250 }
3249 3251
3250 /* if ( incidence && incidence->type() == "Todo" ) { 3252 /* if ( incidence && incidence->type() == "Todo" ) {
3251 emit todoSelected( true ); 3253 emit todoSelected( true );
3252 } else { 3254 } else {
3253 emit todoSelected( false ); 3255 emit todoSelected( false );
3254 }*/ 3256 }*/
3255} 3257}
3256 3258
3257 3259
3258void CalendarView::checkClipboard() 3260void CalendarView::checkClipboard()
3259{ 3261{
3260#ifndef KORG_NODND 3262#ifndef KORG_NODND
3261 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3263 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3262 emit pasteEnabled(true); 3264 emit pasteEnabled(true);
3263 } else { 3265 } else {
3264 emit pasteEnabled(false); 3266 emit pasteEnabled(false);
3265 } 3267 }
3266#endif 3268#endif
3267} 3269}
3268 3270
3269void CalendarView::showDates(const DateList &selectedDates) 3271void CalendarView::showDates(const DateList &selectedDates)
3270{ 3272{
3271 // kdDebug() << "CalendarView::selectDates()" << endl; 3273 // kdDebug() << "CalendarView::selectDates()" << endl;
3272 3274
3273 if ( mViewManager->currentView() ) { 3275 if ( mViewManager->currentView() ) {
3274 updateView( selectedDates.first(), selectedDates.last() ); 3276 updateView( selectedDates.first(), selectedDates.last() );
3275 } else { 3277 } else {
3276 mViewManager->showAgendaView(); 3278 mViewManager->showAgendaView();
3277 } 3279 }
3278 3280
3279 QString selDates; 3281 QString selDates;
3280 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3282 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3281 if (selectedDates.first() < selectedDates.last() ) 3283 if (selectedDates.first() < selectedDates.last() )
3282 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3284 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3283 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3285 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3284 3286
3285} 3287}
3286 3288
3287QPtrList<CalFilter> CalendarView::filters() 3289QPtrList<CalFilter> CalendarView::filters()
3288{ 3290{
3289 return mFilters; 3291 return mFilters;
3290 3292
3291} 3293}
3292void CalendarView::editFilters() 3294void CalendarView::editFilters()
3293{ 3295{
3294 // kdDebug() << "CalendarView::editFilters()" << endl; 3296 // kdDebug() << "CalendarView::editFilters()" << endl;
3295 3297
3296 CalFilter *filter = mFilters.first(); 3298 CalFilter *filter = mFilters.first();
3297 while(filter) { 3299 while(filter) {
3298 kdDebug() << " Filter: " << filter->name() << endl; 3300 kdDebug() << " Filter: " << filter->name() << endl;
3299 filter = mFilters.next(); 3301 filter = mFilters.next();
3300 } 3302 }
3301 3303
3302 mDialogManager->showFilterEditDialog(&mFilters); 3304 mDialogManager->showFilterEditDialog(&mFilters);
3303} 3305}
3304void CalendarView::toggleFilter() 3306void CalendarView::toggleFilter()
3305{ 3307{
3306 showFilter(! mFilterView->isVisible()); 3308 showFilter(! mFilterView->isVisible());
3307} 3309}
3308 3310
3309KOFilterView *CalendarView::filterView() 3311KOFilterView *CalendarView::filterView()
3310{ 3312{
3311 return mFilterView; 3313 return mFilterView;
3312} 3314}
3313void CalendarView::selectFilter( int fil ) 3315void CalendarView::selectFilter( int fil )
3314{ 3316{
3315 mFilterView->setSelectedFilter( fil ); 3317 mFilterView->setSelectedFilter( fil );
3316} 3318}
3317void CalendarView::showFilter(bool visible) 3319void CalendarView::showFilter(bool visible)
3318{ 3320{
3319 if (visible) mFilterView->show(); 3321 if (visible) mFilterView->show();
3320 else mFilterView->hide(); 3322 else mFilterView->hide();
3321} 3323}
3322void CalendarView::toggleFilerEnabled( ) 3324void CalendarView::toggleFilerEnabled( )
3323{ 3325{
3324 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3326 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3325 if ( !mFilterView->filtersEnabled() ) 3327 if ( !mFilterView->filtersEnabled() )
3326 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3328 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3327 3329
3328} 3330}
3329void CalendarView::updateFilter() 3331void CalendarView::updateFilter()
3330{ 3332{
3331 CalFilter *filter = mFilterView->selectedFilter(); 3333 CalFilter *filter = mFilterView->selectedFilter();
3332 if (filter) { 3334 if (filter) {
3333 if (mFilterView->filtersEnabled()) { 3335 if (mFilterView->filtersEnabled()) {
3334 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3336 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3335 filter->setEnabled(true); 3337 filter->setEnabled(true);
3336 } 3338 }
3337 else filter->setEnabled(false); 3339 else filter->setEnabled(false);
3338 mCalendar->setFilter(filter); 3340 mCalendar->setFilter(filter);
3339 updateView(); 3341 updateView();
3340 } 3342 }
3341} 3343}
3342 3344
3343void CalendarView::filterEdited() 3345void CalendarView::filterEdited()
3344{ 3346{
3345 mFilterView->updateFilters(); 3347 mFilterView->updateFilters();
3346 updateFilter(); 3348 updateFilter();
3347 writeSettings(); 3349 writeSettings();
3348} 3350}
3349 3351
3350 3352
3351void CalendarView::takeOverEvent() 3353void CalendarView::takeOverEvent()
3352{ 3354{
3353 Incidence *incidence = currentSelection(); 3355 Incidence *incidence = currentSelection();
3354 3356
3355 if (!incidence) return; 3357 if (!incidence) return;
3356 3358
3357 incidence->setOrganizer(KOPrefs::instance()->email()); 3359 incidence->setOrganizer(KOPrefs::instance()->email());
3358 incidence->recreate(); 3360 incidence->recreate();
3359 incidence->setReadOnly(false); 3361 incidence->setReadOnly(false);
3360 3362
3361 updateView(); 3363 updateView();
3362} 3364}
3363 3365
3364void CalendarView::takeOverCalendar() 3366void CalendarView::takeOverCalendar()
3365{ 3367{
3366 // TODO: Create Calendar::allIncidences() function and use it here 3368 // TODO: Create Calendar::allIncidences() function and use it here
3367 3369
3368 QPtrList<Event> events = mCalendar->events(); 3370 QPtrList<Event> events = mCalendar->events();
3369 for(uint i=0; i<events.count(); ++i) { 3371 for(uint i=0; i<events.count(); ++i) {
3370 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3372 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3371 events.at(i)->recreate(); 3373 events.at(i)->recreate();
3372 events.at(i)->setReadOnly(false); 3374 events.at(i)->setReadOnly(false);
3373 } 3375 }
3374 3376
3375 QPtrList<Todo> todos = mCalendar->todos(); 3377 QPtrList<Todo> todos = mCalendar->todos();
3376 for(uint i=0; i<todos.count(); ++i) { 3378 for(uint i=0; i<todos.count(); ++i) {
3377 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3379 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3378 todos.at(i)->recreate(); 3380 todos.at(i)->recreate();
3379 todos.at(i)->setReadOnly(false); 3381 todos.at(i)->setReadOnly(false);
3380 } 3382 }
3381 3383
3382 QPtrList<Journal> journals = mCalendar->journals(); 3384 QPtrList<Journal> journals = mCalendar->journals();
3383 for(uint i=0; i<journals.count(); ++i) { 3385 for(uint i=0; i<journals.count(); ++i) {
3384 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3386 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3385 journals.at(i)->recreate(); 3387 journals.at(i)->recreate();
3386 journals.at(i)->setReadOnly(false); 3388 journals.at(i)->setReadOnly(false);
3387 } 3389 }
3388 3390
3389 updateView(); 3391 updateView();
3390} 3392}
3391 3393
3392void CalendarView::showIntro() 3394void CalendarView::showIntro()
3393{ 3395{
3394 kdDebug() << "To be implemented." << endl; 3396 kdDebug() << "To be implemented." << endl;
3395} 3397}
3396 3398
3397QWidgetStack *CalendarView::viewStack() 3399QWidgetStack *CalendarView::viewStack()
3398{ 3400{
3399 return mRightFrame; 3401 return mRightFrame;
3400} 3402}
3401 3403
3402QWidget *CalendarView::leftFrame() 3404QWidget *CalendarView::leftFrame()
3403{ 3405{
3404 return mLeftFrame; 3406 return mLeftFrame;
3405} 3407}
3406 3408
3407DateNavigator *CalendarView::dateNavigator() 3409DateNavigator *CalendarView::dateNavigator()
3408{ 3410{
3409 return mNavigator; 3411 return mNavigator;
3410} 3412}
3411 3413
3412KDateNavigator* CalendarView::dateNavigatorWidget() 3414KDateNavigator* CalendarView::dateNavigatorWidget()
3413{ 3415{
3414 return mDateNavigator; 3416 return mDateNavigator;
3415} 3417}
3416void CalendarView::toggleDateNavigatorWidget() 3418void CalendarView::toggleDateNavigatorWidget()
3417{ 3419{
3418 if (mDateNavigator->isVisible()) 3420 if (mDateNavigator->isVisible())
3419 mDateNavigator->hide(); 3421 mDateNavigator->hide();
3420 else 3422 else
3421 mDateNavigator->show(); 3423 mDateNavigator->show();
3422} 3424}
3423void CalendarView::addView(KOrg::BaseView *view) 3425void CalendarView::addView(KOrg::BaseView *view)
3424{ 3426{
3425 mViewManager->addView(view); 3427 mViewManager->addView(view);
3426} 3428}
3427 3429
3428void CalendarView::showView(KOrg::BaseView *view) 3430void CalendarView::showView(KOrg::BaseView *view)
3429{ 3431{
3430 mViewManager->showView(view, mLeftFrame->isVisible()); 3432 mViewManager->showView(view, mLeftFrame->isVisible());
3431} 3433}
3432 3434
3433Incidence *CalendarView::currentSelection() 3435Incidence *CalendarView::currentSelection()
3434{ 3436{
3435 return mViewManager->currentSelection(); 3437 return mViewManager->currentSelection();
3436} 3438}
3437void CalendarView::toggleAllDaySize() 3439void CalendarView::toggleAllDaySize()
3438{ 3440{
3439 /* 3441 /*
3440 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3442 if ( KOPrefs::instance()->mAllDaySize > 47 )
3441 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3443 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3442 else 3444 else
3443 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3445 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3444 */ 3446 */
3445 viewManager()->agendaView()->toggleAllDay(); 3447 viewManager()->agendaView()->toggleAllDay();
3446} 3448}
3447void CalendarView::toggleExpand() 3449void CalendarView::toggleExpand()
3448{ 3450{
3449 // if ( mLeftFrame->isHidden() ) { 3451 // if ( mLeftFrame->isHidden() ) {
3450 // mLeftFrame->show(); 3452 // mLeftFrame->show();
3451 // emit calendarViewExpanded( false ); 3453 // emit calendarViewExpanded( false );
3452 // } else { 3454 // } else {
3453 // mLeftFrame->hide(); 3455 // mLeftFrame->hide();
3454 // emit calendarViewExpanded( true ); 3456 // emit calendarViewExpanded( true );
3455 // } 3457 // }
3456 3458
3457 globalFlagBlockAgenda = 1; 3459 globalFlagBlockAgenda = 1;
3458 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3460 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3459 globalFlagBlockAgenda = 5; 3461 globalFlagBlockAgenda = 5;
3460 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3462 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3461 //mViewManager->showView( 0, true ); 3463 //mViewManager->showView( 0, true );
3462} 3464}
3463 3465
3464void CalendarView::calendarModified( bool modified, Calendar * ) 3466void CalendarView::calendarModified( bool modified, Calendar * )
3465{ 3467{
3466 setModified( modified ); 3468 setModified( modified );
3467} 3469}
3468 3470
3469Todo *CalendarView::selectedTodo() 3471Todo *CalendarView::selectedTodo()
3470{ 3472{
3471 Incidence *incidence = currentSelection(); 3473 Incidence *incidence = currentSelection();
3472 if ( incidence && incidence->type() == "Todo" ) { 3474 if ( incidence && incidence->type() == "Todo" ) {
3473 return static_cast<Todo *>( incidence ); 3475 return static_cast<Todo *>( incidence );
3474 } 3476 }
3475 3477
3476 incidence = mTodoList->selectedIncidences().first(); 3478 incidence = mTodoList->selectedIncidences().first();
3477 if ( incidence && incidence->type() == "Todo" ) { 3479 if ( incidence && incidence->type() == "Todo" ) {
3478 return static_cast<Todo *>( incidence ); 3480 return static_cast<Todo *>( incidence );
3479 } 3481 }
3480 3482
3481 return 0; 3483 return 0;
3482} 3484}
3483 3485
3484void CalendarView::dialogClosing(Incidence *in) 3486void CalendarView::dialogClosing(Incidence *in)
3485{ 3487{
3486 // mDialogList.remove(in); 3488 // mDialogList.remove(in);
3487} 3489}
3488 3490
3489void CalendarView::showIncidence() 3491void CalendarView::showIncidence()
3490{ 3492{
3491 Incidence *incidence = currentSelection(); 3493 Incidence *incidence = currentSelection();
3492 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3494 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3493 if ( incidence ) { 3495 if ( incidence ) {
3494 ShowIncidenceVisitor v; 3496 ShowIncidenceVisitor v;
3495 v.act( incidence, this ); 3497 v.act( incidence, this );
3496 } 3498 }
3497} 3499}
3498void CalendarView::editIncidenceDescription() 3500void CalendarView::editIncidenceDescription()
3499{ 3501{
3500 mFlagEditDescription = true; 3502 mFlagEditDescription = true;
3501 editIncidence(); 3503 editIncidence();
3502 mFlagEditDescription = false; 3504 mFlagEditDescription = false;
3503} 3505}
3504void CalendarView::editIncidence() 3506void CalendarView::editIncidence()
3505{ 3507{
3506 // qDebug("editIncidence() "); 3508 // qDebug("editIncidence() ");
3507 Incidence *incidence = currentSelection(); 3509 Incidence *incidence = currentSelection();
3508 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3510 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3509 if ( incidence ) { 3511 if ( incidence ) {
3510 EditIncidenceVisitor v; 3512 EditIncidenceVisitor v;
3511 v.act( incidence, this ); 3513 v.act( incidence, this );
3512 } 3514 }
3513} 3515}
3514 3516
3515void CalendarView::deleteIncidence() 3517void CalendarView::deleteIncidence()
3516{ 3518{
3517 Incidence *incidence = currentSelection(); 3519 Incidence *incidence = currentSelection();
3518 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3520 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3519 if ( incidence ) { 3521 if ( incidence ) {
3520 deleteIncidence(incidence); 3522 deleteIncidence(incidence);
3521 } 3523 }
3522} 3524}
3523 3525
3524void CalendarView::showIncidence(Incidence *incidence) 3526void CalendarView::showIncidence(Incidence *incidence)
3525{ 3527{
3526 if ( incidence ) { 3528 if ( incidence ) {
3527 ShowIncidenceVisitor v; 3529 ShowIncidenceVisitor v;
3528 v.act( incidence, this ); 3530 v.act( incidence, this );
3529 } 3531 }
3530} 3532}
3531 3533
3532void CalendarView::editIncidence(Incidence *incidence) 3534void CalendarView::editIncidence(Incidence *incidence)
3533{ 3535{
3534 if ( incidence ) { 3536 if ( incidence ) {
3535 3537
3536 EditIncidenceVisitor v; 3538 EditIncidenceVisitor v;
3537 v.act( incidence, this ); 3539 v.act( incidence, this );
3538 3540
3539 } 3541 }
3540} 3542}
3541 3543
3542void CalendarView::deleteIncidence(Incidence *incidence) 3544void CalendarView::deleteIncidence(Incidence *incidence)
3543{ 3545{
3544 //qDebug(" CalendarView::deleteIncidence "); 3546 //qDebug(" CalendarView::deleteIncidence ");
3545 if ( incidence ) { 3547 if ( incidence ) {
3546 DeleteIncidenceVisitor v; 3548 DeleteIncidenceVisitor v;
3547 v.act( incidence, this ); 3549 v.act( incidence, this );
3548 } 3550 }
3549} 3551}
3550 3552
3551 3553
3552void CalendarView::lookForOutgoingMessages() 3554void CalendarView::lookForOutgoingMessages()
3553{ 3555{
3554 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3556 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3555 ogd->loadMessages(); 3557 ogd->loadMessages();
3556} 3558}
3557 3559
3558void CalendarView::lookForIncomingMessages() 3560void CalendarView::lookForIncomingMessages()
3559{ 3561{
3560 IncomingDialog *icd = mDialogManager->incomingDialog(); 3562 IncomingDialog *icd = mDialogManager->incomingDialog();
3561 icd->retrieve(); 3563 icd->retrieve();
3562} 3564}
3563 3565
3564bool CalendarView::removeCompletedSubTodos( Todo* t ) 3566bool CalendarView::removeCompletedSubTodos( Todo* t )
3565{ 3567{
3566 bool deleteTodo = true; 3568 bool deleteTodo = true;
3567 QPtrList<Incidence> subTodos; 3569 QPtrList<Incidence> subTodos;
3568 Incidence *aTodo; 3570 Incidence *aTodo;
3569 subTodos = t->relations(); 3571 subTodos = t->relations();
3570 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3572 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3571 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3573 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3572 deleteTodo = false; 3574 deleteTodo = false;
3573 } 3575 }
3574 if ( deleteTodo ) { 3576 if ( deleteTodo ) {
3575 if ( t->isCompleted() ) { 3577 if ( t->isCompleted() ) {
3576 checkExternalId( t ); 3578 checkExternalId( t );
3577 mCalendar->deleteTodo( t ); 3579 mCalendar->deleteTodo( t );
3578 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3580 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3579 } 3581 }
3580 else 3582 else
3581 deleteTodo = false; 3583 deleteTodo = false;
3582 } 3584 }
3583 return deleteTodo; 3585 return deleteTodo;
3584 3586
3585} 3587}
3586void CalendarView::purgeCompleted() 3588void CalendarView::purgeCompleted()
3587{ 3589{
3588 int result = KMessageBox::warningContinueCancel(this, 3590 int result = KMessageBox::warningContinueCancel(this,
3589 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3591 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3590 3592
3591 if (result == KMessageBox::Continue) { 3593 if (result == KMessageBox::Continue) {
3592 3594
3593 QPtrList<Todo> todoCal; 3595 QPtrList<Todo> todoCal;
3594 QPtrList<Todo> rootTodos; 3596 QPtrList<Todo> rootTodos;
3595 //QPtrList<Incidence> rel; 3597 //QPtrList<Incidence> rel;
3596 Todo *aTodo;//, *rTodo; 3598 Todo *aTodo;//, *rTodo;
3597 Incidence *rIncidence; 3599 Incidence *rIncidence;
3598 bool childDelete = false; 3600 bool childDelete = false;
3599 bool deletedOne = true; 3601 bool deletedOne = true;
3600 todoCal = calendar()->todos(); 3602 todoCal = calendar()->todos();
3601 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3603 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3602 if ( !aTodo->relatedTo() ) 3604 if ( !aTodo->relatedTo() )
3603 rootTodos.append( aTodo ); 3605 rootTodos.append( aTodo );
3604 } 3606 }
3605 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3607 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3606 removeCompletedSubTodos( aTodo ); 3608 removeCompletedSubTodos( aTodo );
3607 } 3609 }
3608 3610
3609 updateView(); 3611 updateView();
3610 } 3612 }
3611} 3613}
3612 3614
3613void CalendarView::slotCalendarChanged() 3615void CalendarView::slotCalendarChanged()
3614{ 3616{
3615 ; 3617 ;
3616} 3618}
3617 3619
3618NavigatorBar *CalendarView::navigatorBar() 3620NavigatorBar *CalendarView::navigatorBar()
3619{ 3621{
3620 return mNavigatorBar; 3622 return mNavigatorBar;
3621} 3623}
3622 3624
3623 3625
3624 3626
3625void CalendarView::keyPressEvent ( QKeyEvent *e) 3627void CalendarView::keyPressEvent ( QKeyEvent *e)
3626{ 3628{
3627 //qDebug(" alendarView::keyPressEvent "); 3629 //qDebug(" alendarView::keyPressEvent ");
3628 e->ignore(); 3630 e->ignore();
3629} 3631}
3630 3632
3631//#include "calendarview.moc" 3633//#include "calendarview.moc"
3632 3634
3633//#include "calendarviewbase.moc" 3635//#include "calendarviewbase.moc"
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 0034715..e0623d5 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,573 +1,572 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = { 49const char *germanwords[][2] = {
50#include "wordsgerman.h" 50#include "wordsgerman.h"
51 "", "" 51 "", ""
52}; 52};
53 53
54KOPrefs *KOPrefs::mInstance = 0; 54KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 55static KStaticDeleter<KOPrefs> insd;
56 56
57KOPrefs::KOPrefs() : 57KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 58 KPimPrefs("korganizerrc")
59{ 59{
60 mCategoryColors.setAutoDelete(true); 60 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0; 61 mLocaleDict = 0;
62 fillMailDefaults(); 62 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 64 QColor defaultHolidayColor = QColor(255,0,0);
65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
68 QColor defaultTodoDueTodayColor = QColor(255,220,100); 68 QColor defaultTodoDueTodayColor = QColor(255,220,100);
69 QColor defaultTodoOverdueColor = QColor(255,153,125); 69 QColor defaultTodoOverdueColor = QColor(255,153,125);
70 70
71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
72 mDefaultViewFont = QFont("helvetica",10); 72 mDefaultViewFont = QFont("helvetica",10);
73 mDefaultMonthViewFont = QFont("helvetica",8); 73 mDefaultMonthViewFont = QFont("helvetica",8);
74 mMarcusBainsFont= QFont("helvetica",10); 74 mMarcusBainsFont= QFont("helvetica",10);
75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
76 mEditBoxFont = QFont("helvetica",12); 76 mEditBoxFont = QFont("helvetica",12);
77 mJornalViewFont = QFont("helvetica",12); 77 mJornalViewFont = QFont("helvetica",12);
78 78
79 KPrefs::setCurrentGroup("General"); 79 KPrefs::setCurrentGroup("General");
80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
81 81
82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
84 addItemBool("ShowIconSearch",&mShowIconSearch,true); 84 addItemBool("ShowIconSearch",&mShowIconSearch,true);
85 addItemBool("ShowIconList",&mShowIconList,true); 85 addItemBool("ShowIconList",&mShowIconList,true);
86 addItemBool("ShowIconDay1",&mShowIconDay1,true); 86 addItemBool("ShowIconDay1",&mShowIconDay1,true);
87 addItemBool("ShowIconDay5",&mShowIconDay5,true); 87 addItemBool("ShowIconDay5",&mShowIconDay5,true);
88 addItemBool("ShowIconDay7",&mShowIconDay7,true); 88 addItemBool("ShowIconDay7",&mShowIconDay7,true);
89 addItemBool("ShowIconMonth",&mShowIconMonth,true); 89 addItemBool("ShowIconMonth",&mShowIconMonth,true);
90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
92 addItemBool("ShowIconBack",&mShowIconBack,true); 92 addItemBool("ShowIconBack",&mShowIconBack,true);
93 addItemBool("ShowIconToday",&mShowIconToday,true); 93 addItemBool("ShowIconToday",&mShowIconToday,true);
94 addItemBool("ShowIconForward",&mShowIconForward,true); 94 addItemBool("ShowIconForward",&mShowIconForward,true);
95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
98 addItemBool("ShowIconNext",&mShowIconNext,true); 98 addItemBool("ShowIconNext",&mShowIconNext,true);
99 addItemBool("ShowIconJournal",&mShowIconJournal,true); 99 addItemBool("ShowIconJournal",&mShowIconJournal,true);
100 addItemBool("ShowIconStretch",&mShowIconStretch,true); 100 addItemBool("ShowIconStretch",&mShowIconStretch,true);
101 addItemBool("LanguageChanged",&mLanguageChanged,false); 101 addItemBool("LanguageChanged",&mLanguageChanged,false);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
113 addItemInt("Whats Next Days",&mWhatsNextDays,3); 113 addItemInt("Whats Next Days",&mWhatsNextDays,3);
114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
115 115
116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
118 addItemInt("AllDay Size",&mAllDaySize,28); 118 addItemInt("AllDay Size",&mAllDaySize,28);
119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
121 121
122 addItemStringList("LocationDefaults",&mLocationDefaults ); 122 addItemStringList("LocationDefaults",&mLocationDefaults );
123 addItemStringList("EventSummary User",&mEventSummaryUser); 123 addItemStringList("EventSummary User",&mEventSummaryUser);
124 addItemStringList("TodoSummary User",&mTodoSummaryUser); 124 addItemStringList("TodoSummary User",&mTodoSummaryUser);
125 125
126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
127 addItemBool("Enable Project View",&mEnableProjectView,false); 127 addItemBool("Enable Project View",&mEnableProjectView,false);
128 addItemBool("Auto Save",&mAutoSave,false); 128 addItemBool("Auto Save",&mAutoSave,false);
129 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 129 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
130 addItemBool("Confirm Deletes",&mConfirm,true); 130 addItemBool("Confirm Deletes",&mConfirm,true);
131 addItemString("Archive File",&mArchiveFile); 131 addItemString("Archive File",&mArchiveFile);
132 addItemString("Html Export File",&mHtmlExportFile, 132 addItemString("Html Export File",&mHtmlExportFile,
133 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 133 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
134 addItemBool("Html With Save",&mHtmlWithSave,false); 134 addItemBool("Html With Save",&mHtmlWithSave,false);
135 135
136 KPrefs::setCurrentGroup("Personal Settings"); 136 KPrefs::setCurrentGroup("Personal Settings");
137 137
138 addItemInt("Mail Client",&mMailClient,MailClientKMail); 138 addItemInt("Mail Client",&mMailClient,MailClientKMail);
139 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 139 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
140 addItemBool("Bcc",&mBcc,false); 140 addItemBool("Bcc",&mBcc,false);
141 141
142 KPrefs::setCurrentGroup("Time & Date"); 142 KPrefs::setCurrentGroup("Time & Date");
143 143
144 // addItemString("Time Zone",&mTimeZone,"+0100"); 144 // addItemString("Time Zone",&mTimeZone,"+0100");
145 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 145 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
146 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 146 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
147 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 147 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
148 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 148 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
149 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 149 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
150 150
151 151
152 addItemInt("Default Start Time",&mStartTime,10); 152 addItemInt("Default Start Time",&mStartTime,10);
153 addItemInt("Default Duration",&mDefaultDuration,2); 153 addItemInt("Default Duration",&mDefaultDuration,2);
154 addItemInt("Default Alarm Time",&mAlarmTime,3); 154 addItemInt("Default Alarm Time",&mAlarmTime,3);
155 addItemInt("Daylight Savings",&mDaylightSavings,0); 155 addItemInt("Daylight Savings",&mDaylightSavings,0);
156 KPrefs::setCurrentGroup("AlarmSettings"); 156 KPrefs::setCurrentGroup("AlarmSettings");
157 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 157 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
158 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 158 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
159 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 159 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
160 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 160 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
161 161
162 162
163 KPrefs::setCurrentGroup("Calendar"); 163 KPrefs::setCurrentGroup("Calendar");
164 164
165 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 165 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
166 166
167 KPrefs::setCurrentGroup("Fonts"); 167 KPrefs::setCurrentGroup("Fonts");
168 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 168 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
169 addItemFont("TimeBar Font",&mTimeBarFont); 169 addItemFont("TimeBar Font",&mTimeBarFont);
170 addItemFont("MonthView Font",&mMonthViewFont); 170 addItemFont("MonthView Font",&mMonthViewFont);
171 addItemFont("AgendaView Font",&mAgendaViewFont); 171 addItemFont("AgendaView Font",&mAgendaViewFont);
172 addItemFont("MarcusBains Font",&mMarcusBainsFont); 172 addItemFont("MarcusBains Font",&mMarcusBainsFont);
173 addItemFont("TimeLabels Font",&mTimeLabelsFont); 173 addItemFont("TimeLabels Font",&mTimeLabelsFont);
174 addItemFont("TodoView Font",&mTodoViewFont); 174 addItemFont("TodoView Font",&mTodoViewFont);
175 addItemFont("ListView Font",&mListViewFont); 175 addItemFont("ListView Font",&mListViewFont);
176 addItemFont("DateNavigator Font",&mDateNavigatorFont); 176 addItemFont("DateNavigator Font",&mDateNavigatorFont);
177 addItemFont("EditBox Font",&mEditBoxFont); 177 addItemFont("EditBox Font",&mEditBoxFont);
178 addItemFont("JournalView Font",&mJornalViewFont); 178 addItemFont("JournalView Font",&mJornalViewFont);
179 addItemFont("WhatsNextView Font",&mWhatsNextFont); 179 addItemFont("WhatsNextView Font",&mWhatsNextFont);
180 addItemFont("EventView Font",&mEventViewFont); 180 addItemFont("EventView Font",&mEventViewFont);
181 181
182// KPrefs::setCurrentGroup("SyncProfiles"); 182// KPrefs::setCurrentGroup("SyncProfiles");
183// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 183// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
184// addItemStringList("SyncProfileNames",&mSyncProfileNames); 184// addItemStringList("SyncProfileNames",&mSyncProfileNames);
185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
186 186
187 KPrefs::setCurrentGroup("RemoteSyncing"); 187 KPrefs::setCurrentGroup("RemoteSyncing");
188// addItemBool("UsePasswd",&mUsePassWd,false); 188// addItemBool("UsePasswd",&mUsePassWd,false);
189// addItemBool("WriteBackFile",&mWriteBackFile,true); 189// addItemBool("WriteBackFile",&mWriteBackFile,true);
190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
191// addItemBool("AskForPreferences",&mAskForPreferences,true); 191// addItemBool("AskForPreferences",&mAskForPreferences,true);
192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
194 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 194 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
195 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 195 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
196 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 196 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
197 addItemInt("LastSyncTime",&mLastSyncTime,0); 197 addItemInt("LastSyncTime",&mLastSyncTime,0);
198 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 198 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
199 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 199 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
200 200
201#ifdef _WIN32_ 201#ifdef _WIN32_
202 QString hdp= locateLocal("data","korganizer")+"\\\\"; 202 QString hdp= locateLocal("data","korganizer")+"\\\\";
203#else 203#else
204 QString hdp= locateLocal("data","korganizer")+"/"; 204 QString hdp= locateLocal("data","korganizer")+"/";
205#endif 205#endif
206// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 206// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
207// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 207// addItemString("RemoteUser",&mRemoteUser, "zaurus");
208// addItemString("RemotePassWd",&mRemotePassWd, ""); 208// addItemString("RemotePassWd",&mRemotePassWd, "");
209// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 209// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
210// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 210// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
211 211
212 212
213 KPrefs::setCurrentGroup("LoadSaveFileNames"); 213 KPrefs::setCurrentGroup("LoadSaveFileNames");
214 214
215 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 215 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
216 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 216 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
217 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 217 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
218 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 218 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
219 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 219 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
220 220
221 221
222 KPrefs::setCurrentGroup("Locale"); 222 KPrefs::setCurrentGroup("Locale");
223 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 223 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
224 addItemInt("PreferredTime",&mPreferredTime,0); 224 addItemInt("PreferredTime",&mPreferredTime,0);
225 addItemInt("PreferredDate",&mPreferredDate,0); 225 addItemInt("PreferredDate",&mPreferredDate,0);
226 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 226 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
227 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
228 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 227 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
229 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 228 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
230 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 229 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
231 230
232 231
233 KPrefs::setCurrentGroup("Colors"); 232 KPrefs::setCurrentGroup("Colors");
234 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 233 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
235 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 234 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
236 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 235 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
237 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 236 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
238 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 237 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
239 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 238 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
240 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 239 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
241 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 240 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
242 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 241 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
243 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 242 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
244 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 243 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
245 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 244 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
246 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 245 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
247 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 246 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
248 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 247 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
249 addItemBool("UseAppColors",&mUseAppColors,false); 248 addItemBool("UseAppColors",&mUseAppColors,false);
250 249
251 250
252 251
253 KPrefs::setCurrentGroup("Views"); 252 KPrefs::setCurrentGroup("Views");
254 addItemInt("Hour Size",&mHourSize,8); 253 addItemInt("Hour Size",&mHourSize,8);
255 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 254 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
256 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 255 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
257 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 256 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
258 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 257 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
259 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 258 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
260 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 259 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
261 addItemBool("Enable ToolTips",&mEnableToolTips,false); 260 addItemBool("Enable ToolTips",&mEnableToolTips,false);
262 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 261 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
263 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 262 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
264 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 263 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
265 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 264 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
266 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 265 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
267 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 266 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
268 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 267 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
269 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 268 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
270 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 269 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
271 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 270 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
272 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 271 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
273 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 272 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
274 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 273 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
275 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 274 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
276 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 275 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
277 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 276 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
278 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 277 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
279 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 278 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
280#ifdef DESKTOP_VERSION 279#ifdef DESKTOP_VERSION
281 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 280 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
282#else 281#else
283 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 282 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
284#endif 283#endif
285 addItemInt("Day Begins",&mDayBegins,7); 284 addItemInt("Day Begins",&mDayBegins,7);
286 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 285 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
287 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 286 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
288 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 287 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
289 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 288 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
290 289
291 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 290 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
292 addItemBool("Full View Month",&mFullViewMonth,true); 291 addItemBool("Full View Month",&mFullViewMonth,true);
293 addItemBool("Full View Todo",&mFullViewTodo,true); 292 addItemBool("Full View Todo",&mFullViewTodo,true);
294 addItemBool("Quick Todo",&mEnableQuickTodo,false); 293 addItemBool("Quick Todo",&mEnableQuickTodo,false);
295 294
296 addItemInt("Next X Days",&mNextXDays,3); 295 addItemInt("Next X Days",&mNextXDays,3);
297 296
298 KPrefs::setCurrentGroup("Printer"); 297 KPrefs::setCurrentGroup("Printer");
299 298
300 KPrefs::setCurrentGroup("Layout"); 299 KPrefs::setCurrentGroup("Layout");
301 300
302 addItemBool("CompactDialogs",&mCompactDialogs,false); 301 addItemBool("CompactDialogs",&mCompactDialogs,false);
303 addItemBool("VerticalScreen",&mVerticalScreen,true); 302 addItemBool("VerticalScreen",&mVerticalScreen,true);
304 303
305 KPrefs::setCurrentGroup("KOrganizer Plugins"); 304 KPrefs::setCurrentGroup("KOrganizer Plugins");
306 305
307 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 306 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
308 307
309 KPrefs::setCurrentGroup("Group Scheduling"); 308 KPrefs::setCurrentGroup("Group Scheduling");
310 309
311 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 310 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
312 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 311 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
313 addItemStringList("AdditionalMails",&mAdditionalMails,""); 312 addItemStringList("AdditionalMails",&mAdditionalMails,"");
314 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 313 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
315 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 314 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
316 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 315 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
317 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 316 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
318 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 317 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
319 318
320 KPrefs::setCurrentGroup( "Editors" ); 319 KPrefs::setCurrentGroup( "Editors" );
321 320
322 addItemStringList( "EventTemplates", &mEventTemplates ); 321 addItemStringList( "EventTemplates", &mEventTemplates );
323 addItemStringList( "TodoTemplates", &mTodoTemplates ); 322 addItemStringList( "TodoTemplates", &mTodoTemplates );
324 323
325 addItemInt("DestinationPolicy",&mDestination,standardDestination); 324 addItemInt("DestinationPolicy",&mDestination,standardDestination);
326 325
327 326
328 327
329} 328}
330 329
331 330
332KOPrefs::~KOPrefs() 331KOPrefs::~KOPrefs()
333{ 332{
334 if (mInstance == this) 333 if (mInstance == this)
335 mInstance = insd.setObject(0); 334 mInstance = insd.setObject(0);
336 setLocaleDict( 0 ); 335 setLocaleDict( 0 );
337 if ( mLocaleDict ) 336 if ( mLocaleDict )
338 delete mLocaleDict; 337 delete mLocaleDict;
339 //qDebug("KOPrefs::~KOPrefs() "); 338 //qDebug("KOPrefs::~KOPrefs() ");
340} 339}
341 340
342 341
343KOPrefs *KOPrefs::instance() 342KOPrefs *KOPrefs::instance()
344{ 343{
345 if (!mInstance) { 344 if (!mInstance) {
346 mInstance = insd.setObject(new KOPrefs()); 345 mInstance = insd.setObject(new KOPrefs());
347 mInstance->readConfig(); 346 mInstance->readConfig();
348 } 347 }
349 348
350 return mInstance; 349 return mInstance;
351} 350}
352 351
353void KOPrefs::usrSetDefaults() 352void KOPrefs::usrSetDefaults()
354{ 353{
355 354
356} 355}
357 356
358void KOPrefs::fillMailDefaults() 357void KOPrefs::fillMailDefaults()
359{ 358{
360 if (mName.isEmpty()) mName = i18n("Anonymous"); 359 if (mName.isEmpty()) mName = i18n("Anonymous");
361 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 360 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
362} 361}
363 362
364void KOPrefs::setTimeZoneIdDefault() 363void KOPrefs::setTimeZoneIdDefault()
365{ 364{
366 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 365 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
367} 366}
368 367
369void KOPrefs::setCategoryDefaults() 368void KOPrefs::setCategoryDefaults()
370{ 369{
371 mCustomCategories.clear(); 370 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 371 mCustomCategories = getDefaultList();
373 372
374 QStringList::Iterator it; 373 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 374 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 375 setCategoryColor(*it,mDefaultCategoryColor);
377 } 376 }
378} 377}
379 378
380QStringList KOPrefs::getDefaultList() 379QStringList KOPrefs::getDefaultList()
381{ 380{
382 QStringList retval ; 381 QStringList retval ;
383 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 382 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
384 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 383 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
385 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 384 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
386 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 385 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
387 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 386 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
388 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 387 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
389 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 388 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
390 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 389 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
391 retval.sort(); 390 retval.sort();
392 return retval; 391 return retval;
393} 392}
394 393
395void KOPrefs::usrReadConfig() 394void KOPrefs::usrReadConfig()
396{ 395{
397 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 396 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
398 mLocaleDict = 0; 397 mLocaleDict = 0;
399 // pending LR fix translation 398 // pending LR fix translation
400 // qDebug("KOPrefs::usrReadConfig() fix translation "); 399 // qDebug("KOPrefs::usrReadConfig() fix translation ");
401 if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { 400 if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) {
402 if ( mPreferredLanguage == 1 ) { 401 if ( mPreferredLanguage == 1 ) {
403 mLocaleDict = new QDict<QString>; 402 mLocaleDict = new QDict<QString>;
404 int i = 0; 403 int i = 0;
405 QString fw ( germanwords[i] [0]); 404 QString fw ( germanwords[i] [0]);
406 while ( !fw.isEmpty() ) { 405 while ( !fw.isEmpty() ) {
407 mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); 406 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
408 ++i; 407 ++i;
409 fw = germanwords[i] [0]; 408 fw = germanwords[i] [0];
410 } 409 }
411 410
412 setLocaleDict( mLocaleDict ); 411 setLocaleDict( mLocaleDict );
413 } else { 412 } else {
414 QString fileName ; 413 QString fileName ;
415 if ( mPreferredLanguage == 3 ) 414 if ( mPreferredLanguage == 3 )
416 fileName = MainWindow::resourcePath()+"usertranslation.txt"; 415 fileName = MainWindow::resourcePath()+"usertranslation.txt";
417 else if ( mPreferredLanguage == 2 ) 416 else if ( mPreferredLanguage == 2 )
418 fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; 417 fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
419 QFile file( fileName ); 418 QFile file( fileName );
420 if (file.open( IO_ReadOnly ) ) { 419 if (file.open( IO_ReadOnly ) ) {
421 QTextStream ts( &file ); 420 QTextStream ts( &file );
422 ts.setEncoding( QTextStream::Latin1 ); 421 ts.setEncoding( QTextStream::Latin1 );
423 //ts.setCodec( QTextCodec::latin1 ); 422 //ts.setCodec( QTextCodec::latin1 );
424 QString text = ts.read(); 423 QString text = ts.read();
425 file.close(); 424 file.close();
426 text.replace( QRegExp("\\\\n"), "\n" ); 425 text.replace( QRegExp("\\\\n"), "\n" );
427 QString line; 426 QString line;
428 QString we; 427 QString we;
429 QString wt; 428 QString wt;
430 int br = 0; 429 int br = 0;
431 int nbr; 430 int nbr;
432 nbr = text.find ( "},", br ); 431 nbr = text.find ( "},", br );
433 line = text.mid( br, nbr - br ); 432 line = text.mid( br, nbr - br );
434 br = nbr+1; 433 br = nbr+1;
435 int se, ee, st, et; 434 int se, ee, st, et;
436 mLocaleDict = new QDict<QString>; 435 mLocaleDict = new QDict<QString>;
437 QString end = "{ \"\",\"\" }"; 436 QString end = "{ \"\",\"\" }";
438 while ( (line != end) && (br > 1) ) { 437 while ( (line != end) && (br > 1) ) {
439 //qDebug("%d *%s* ", br, line.latin1()); 438 //qDebug("%d *%s* ", br, line.latin1());
440 se = line.find("\"")+1; 439 se = line.find("\"")+1;
441 et = line.findRev("\"",-1); 440 et = line.findRev("\"",-1);
442 ee = line.find("\",\""); 441 ee = line.find("\",\"");
443 st = ee+3; 442 st = ee+3;
444 we = line.mid( se, ee-se ); 443 we = line.mid( se, ee-se );
445 wt = line.mid( st, et-st ); 444 wt = line.mid( st, et-st );
446 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 445 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
447 mLocaleDict->insert( we, new QString (wt) ); 446 mLocaleDict->insert( we, new QString (wt) );
448 nbr = text.find ( "}", br ); 447 nbr = text.find ( "}", br );
449 line = text.mid( br, nbr - br ); 448 line = text.mid( br, nbr - br );
450 br = nbr+1; 449 br = nbr+1;
451 } 450 }
452 //qDebug("end *%s* ", end.latin1()); 451 //qDebug("end *%s* ", end.latin1());
453 452
454 setLocaleDict( mLocaleDict ); 453 setLocaleDict( mLocaleDict );
455 } else { 454 } else {
456 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 455 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
457 } 456 }
458 457
459 } 458 }
460 } 459 }
461 config()->setGroup("General"); 460 config()->setGroup("General");
462 461
463 mCustomCategories = config()->readListEntry("Custom Categories"); 462 mCustomCategories = config()->readListEntry("Custom Categories");
464 if ( KOPrefs::instance()->mLanguageChanged ) { 463 if ( KOPrefs::instance()->mLanguageChanged ) {
465 mLocationDefaults.clear(); 464 mLocationDefaults.clear();
466 mEventSummaryUser.clear(); 465 mEventSummaryUser.clear();
467 mTodoSummaryUser.clear(); 466 mTodoSummaryUser.clear();
468 } 467 }
469 if (mLocationDefaults.isEmpty()) { 468 if (mLocationDefaults.isEmpty()) {
470 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 469 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
471 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 470 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
472 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 471 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
473 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 472 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
474 mLocationDefaults.sort(); 473 mLocationDefaults.sort();
475 } 474 }
476 475
477 if (mEventSummaryUser.isEmpty()) { 476 if (mEventSummaryUser.isEmpty()) {
478 mEventSummaryUser = getDefaultList() ; 477 mEventSummaryUser = getDefaultList() ;
479 } 478 }
480 if (mTodoSummaryUser.isEmpty()) { 479 if (mTodoSummaryUser.isEmpty()) {
481 mTodoSummaryUser = getDefaultList() ; 480 mTodoSummaryUser = getDefaultList() ;
482 } 481 }
483 482
484 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 483 if (mCustomCategories.isEmpty()) setCategoryDefaults();
485 484
486 config()->setGroup("Personal Settings"); 485 config()->setGroup("Personal Settings");
487 mName = config()->readEntry("user_name",""); 486 mName = config()->readEntry("user_name","");
488 mEmail = config()->readEntry("user_email",""); 487 mEmail = config()->readEntry("user_email","");
489 fillMailDefaults(); 488 fillMailDefaults();
490 489
491 config()->setGroup("Category Colors"); 490 config()->setGroup("Category Colors");
492 QStringList::Iterator it; 491 QStringList::Iterator it;
493 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 492 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
494 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 493 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
495 494
496 } 495 }
497 496
498 if (mTimeZoneId.isEmpty()) { 497 if (mTimeZoneId.isEmpty()) {
499 setTimeZoneIdDefault(); 498 setTimeZoneIdDefault();
500 } 499 }
501 KPimPrefs::usrReadConfig(); 500 KPimPrefs::usrReadConfig();
502} 501}
503 502
504 503
505void KOPrefs::usrWriteConfig() 504void KOPrefs::usrWriteConfig()
506{ 505{
507 config()->setGroup("General"); 506 config()->setGroup("General");
508 config()->writeEntry("Custom Categories",mCustomCategories); 507 config()->writeEntry("Custom Categories",mCustomCategories);
509 508
510 config()->setGroup("Personal Settings"); 509 config()->setGroup("Personal Settings");
511 config()->writeEntry("user_name",mName); 510 config()->writeEntry("user_name",mName);
512 config()->writeEntry("user_email",mEmail); 511 config()->writeEntry("user_email",mEmail);
513 512
514 config()->setGroup("Category Colors"); 513 config()->setGroup("Category Colors");
515 QDictIterator<QColor> it(mCategoryColors); 514 QDictIterator<QColor> it(mCategoryColors);
516 while (it.current()) { 515 while (it.current()) {
517 config()->writeEntry(it.currentKey(),*(it.current())); 516 config()->writeEntry(it.currentKey(),*(it.current()));
518 ++it; 517 ++it;
519 } 518 }
520 519
521 520
522 KPimPrefs::usrWriteConfig(); 521 KPimPrefs::usrWriteConfig();
523} 522}
524 523
525void KOPrefs::setCategoryColor(QString cat,const QColor & color) 524void KOPrefs::setCategoryColor(QString cat,const QColor & color)
526{ 525{
527 mCategoryColors.replace(cat,new QColor(color)); 526 mCategoryColors.replace(cat,new QColor(color));
528} 527}
529 528
530QColor *KOPrefs::categoryColor(QString cat) 529QColor *KOPrefs::categoryColor(QString cat)
531{ 530{
532 QColor *color = 0; 531 QColor *color = 0;
533 532
534 if (!cat.isEmpty()) color = mCategoryColors[cat]; 533 if (!cat.isEmpty()) color = mCategoryColors[cat];
535 534
536 if (color) return color; 535 if (color) return color;
537 else return &mDefaultCategoryColor; 536 else return &mDefaultCategoryColor;
538} 537}
539 538
540void KOPrefs::setFullName(const QString &name) 539void KOPrefs::setFullName(const QString &name)
541{ 540{
542 mName = name; 541 mName = name;
543} 542}
544 543
545void KOPrefs::setEmail(const QString &email) 544void KOPrefs::setEmail(const QString &email)
546{ 545{
547 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 546 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
548 mEmail = email; 547 mEmail = email;
549} 548}
550 549
551QString KOPrefs::fullName() 550QString KOPrefs::fullName()
552{ 551{
553 if (mEmailControlCenter) { 552 if (mEmailControlCenter) {
554 KEMailSettings settings; 553 KEMailSettings settings;
555 return settings.getSetting(KEMailSettings::RealName); 554 return settings.getSetting(KEMailSettings::RealName);
556 } else { 555 } else {
557 return mName; 556 return mName;
558 } 557 }
559} 558}
560 559
561QString KOPrefs::email() 560QString KOPrefs::email()
562{ 561{
563 if (mEmailControlCenter) { 562 if (mEmailControlCenter) {
564 KEMailSettings settings; 563 KEMailSettings settings;
565 return settings.getSetting(KEMailSettings::EmailAddress); 564 return settings.getSetting(KEMailSettings::EmailAddress);
566 } else { 565 } else {
567 return mEmail; 566 return mEmail;
568 } 567 }
569} 568}
570KConfig* KOPrefs::getConfig() 569KConfig* KOPrefs::getConfig()
571{ 570{
572 return config(); 571 return config();
573} 572}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 696433e..7abd741 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,313 +1,312 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h> 26#include <qdict.h>
27 27
28#include <libkdepim/kpimprefs.h> 28#include <libkdepim/kpimprefs.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35class KOPrefs : public KPimPrefs 35class KOPrefs : public KPimPrefs
36{ 36{
37 public: 37 public:
38 enum { FormatVCalendar, FormatICalendar }; 38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 43 enum { standardDestination, askDestination };
44 44
45 virtual ~KOPrefs(); 45 virtual ~KOPrefs();
46 46
47 /** Get instance of KOPrefs. It is made sure that there is only one 47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 48 instance. */
49 static KOPrefs *instance(); 49 static KOPrefs *instance();
50 50
51 /** Set preferences to default values */ 51 /** Set preferences to default values */
52 void usrSetDefaults(); 52 void usrSetDefaults();
53 53
54 /** Read preferences from config file */ 54 /** Read preferences from config file */
55 void usrReadConfig(); 55 void usrReadConfig();
56 56
57 /** Write preferences to config file */ 57 /** Write preferences to config file */
58 void usrWriteConfig(); 58 void usrWriteConfig();
59 void setCategoryDefaults(); 59 void setCategoryDefaults();
60 60
61 protected: 61 protected:
62 void setTimeZoneIdDefault(); 62 void setTimeZoneIdDefault();
63 63
64 /** Fill empty mail fields with default values. */ 64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults(); 65 void fillMailDefaults();
66 66
67 private: 67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs 68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */ 69 object. */
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict; 73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 74 QStringList getDefaultList();
75 public: 75 public:
76 // preferences data 76 // preferences data
77 KConfig* getConfig(); 77 KConfig* getConfig();
78 void setFullName(const QString &); 78 void setFullName(const QString &);
79 QString fullName(); 79 QString fullName();
80 void setEmail(const QString &); 80 void setEmail(const QString &);
81 QString email(); 81 QString email();
82 82
83 QString mAdditional; 83 QString mAdditional;
84 84
85 bool mEmailControlCenter; 85 bool mEmailControlCenter;
86 86
87 bool mBcc; 87 bool mBcc;
88 bool mAutoSave; 88 bool mAutoSave;
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
100 //int mTimeZoneOffset; // e.g. -240 min 100 //int mTimeZoneOffset; // e.g. -240 min
101 int mStartTime; 101 int mStartTime;
102 int mDefaultDuration; 102 int mDefaultDuration;
103 int mAlarmTime; 103 int mAlarmTime;
104 int mDaylightSavings; 104 int mDaylightSavings;
105 105
106 int mWorkingHoursStart; 106 int mWorkingHoursStart;
107 int mWorkingHoursEnd; 107 int mWorkingHoursEnd;
108 bool mExcludeHolidays; 108 bool mExcludeHolidays;
109 bool mExcludeSaturdays; 109 bool mExcludeSaturdays;
110 bool mMarcusBainsShowSeconds; 110 bool mMarcusBainsShowSeconds;
111 111
112 QFont mTimeBarFont; 112 QFont mTimeBarFont;
113 QFont mMonthViewFont; 113 QFont mMonthViewFont;
114 QFont mAgendaViewFont; 114 QFont mAgendaViewFont;
115 QFont mMarcusBainsFont; 115 QFont mMarcusBainsFont;
116 QFont mTimeLabelsFont; 116 QFont mTimeLabelsFont;
117 QFont mTodoViewFont; 117 QFont mTodoViewFont;
118 QFont mListViewFont; 118 QFont mListViewFont;
119 QFont mDateNavigatorFont; 119 QFont mDateNavigatorFont;
120 QFont mEditBoxFont; 120 QFont mEditBoxFont;
121 QFont mJornalViewFont; 121 QFont mJornalViewFont;
122 QFont mWhatsNextFont; 122 QFont mWhatsNextFont;
123 QFont mEventViewFont; 123 QFont mEventViewFont;
124 124
125 125
126 126
127 127
128 QColor mHolidayColor; 128 QColor mHolidayColor;
129 QColor mHighlightColor; 129 QColor mHighlightColor;
130 QColor mEventColor; 130 QColor mEventColor;
131 QColor mAgendaBgColor; 131 QColor mAgendaBgColor;
132 QColor mWorkingHoursColor; 132 QColor mWorkingHoursColor;
133 QColor mTodoDueTodayColor; 133 QColor mTodoDueTodayColor;
134 QColor mTodoOverdueColor; 134 QColor mTodoOverdueColor;
135 QColor mMonthViewEvenColor; 135 QColor mMonthViewEvenColor;
136 QColor mMonthViewOddColor; 136 QColor mMonthViewOddColor;
137 QColor mMonthViewHolidayColor; 137 QColor mMonthViewHolidayColor;
138 bool mMonthViewUsesDayColors; 138 bool mMonthViewUsesDayColors;
139 bool mMonthViewSatSunTog; 139 bool mMonthViewSatSunTog;
140 QColor mAppColor1; 140 QColor mAppColor1;
141 QColor mAppColor2; 141 QColor mAppColor2;
142 bool mUseAppColors; 142 bool mUseAppColors;
143 143
144 int mDayBegins; 144 int mDayBegins;
145 int mHourSize; 145 int mHourSize;
146 int mAllDaySize; 146 int mAllDaySize;
147 bool mShowFullMenu; 147 bool mShowFullMenu;
148 bool mDailyRecur; 148 bool mDailyRecur;
149 bool mWeeklyRecur; 149 bool mWeeklyRecur;
150 bool mMonthDailyRecur; 150 bool mMonthDailyRecur;
151 bool mMonthWeeklyRecur; 151 bool mMonthWeeklyRecur;
152 bool mMonthShowIcons; 152 bool mMonthShowIcons;
153 bool mMonthShowShort; 153 bool mMonthShowShort;
154 bool mEnableToolTips; 154 bool mEnableToolTips;
155 bool mEnableMonthScroll; 155 bool mEnableMonthScroll;
156 bool mFullViewMonth; 156 bool mFullViewMonth;
157 bool mMonthViewUsesCategoryColor; 157 bool mMonthViewUsesCategoryColor;
158 bool mFullViewTodo; 158 bool mFullViewTodo;
159 bool mShowCompletedTodo; 159 bool mShowCompletedTodo;
160 bool mMarcusBainsEnabled; 160 bool mMarcusBainsEnabled;
161 int mNextXDays; 161 int mNextXDays;
162 int mWhatsNextDays; 162 int mWhatsNextDays;
163 int mWhatsNextPrios; 163 int mWhatsNextPrios;
164 bool mEnableQuickTodo; 164 bool mEnableQuickTodo;
165 bool mLanguageChanged; 165 bool mLanguageChanged;
166 166
167 bool mCompactDialogs; 167 bool mCompactDialogs;
168 bool mVerticalScreen; 168 bool mVerticalScreen;
169 169
170 bool mShowIconNewTodo; 170 bool mShowIconNewTodo;
171 bool mShowIconNewEvent; 171 bool mShowIconNewEvent;
172 bool mShowIconSearch; 172 bool mShowIconSearch;
173 bool mShowIconList; 173 bool mShowIconList;
174 bool mShowIconDay1; 174 bool mShowIconDay1;
175 bool mShowIconDay5; 175 bool mShowIconDay5;
176 bool mShowIconDay7; 176 bool mShowIconDay7;
177 bool mShowIconMonth; 177 bool mShowIconMonth;
178 bool mShowIconTodoview; 178 bool mShowIconTodoview;
179 bool mShowIconBackFast; 179 bool mShowIconBackFast;
180 bool mShowIconBack; 180 bool mShowIconBack;
181 bool mShowIconToday; 181 bool mShowIconToday;
182 bool mShowIconForward; 182 bool mShowIconForward;
183 bool mShowIconForwardFast; 183 bool mShowIconForwardFast;
184 bool mShowIconWhatsThis; 184 bool mShowIconWhatsThis;
185 bool mShowIconNextDays; 185 bool mShowIconNextDays;
186 bool mShowIconNext; 186 bool mShowIconNext;
187 bool mShowIconJournal; 187 bool mShowIconJournal;
188 188
189 bool mShowIconStretch; 189 bool mShowIconStretch;
190 190
191 bool mToolBarHor; 191 bool mToolBarHor;
192 bool mToolBarUp; 192 bool mToolBarUp;
193 bool mToolBarMiniIcons; 193 bool mToolBarMiniIcons;
194 194
195 bool mAskForQuit; 195 bool mAskForQuit;
196 bool mUsePassWd; 196 bool mUsePassWd;
197 bool mWriteBackFile; 197 bool mWriteBackFile;
198 int mWriteBackInFuture; 198 int mWriteBackInFuture;
199 bool mAskForPreferences; 199 bool mAskForPreferences;
200 bool mShowSyncSummary; 200 bool mShowSyncSummary;
201 bool mShowSyncEvents; 201 bool mShowSyncEvents;
202 bool mShowTodoInAgenda; 202 bool mShowTodoInAgenda;
203 bool mWriteBackExistingOnly; 203 bool mWriteBackExistingOnly;
204 204
205 QString mRemoteIP; 205 QString mRemoteIP;
206 QString mRemoteUser; 206 QString mRemoteUser;
207 QString mRemotePassWd; 207 QString mRemotePassWd;
208 QString mRemoteFile; 208 QString mRemoteFile;
209 QString mLocalTempFile; 209 QString mLocalTempFile;
210 QString mPhoneDevice; 210 QString mPhoneDevice;
211 QString mPhoneConnection; 211 QString mPhoneConnection;
212 QString mPhoneModel; 212 QString mPhoneModel;
213 213
214 int mLastSyncTime; 214 int mLastSyncTime;
215 int mSyncAlgoPrefs; 215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 217 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 218 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 219 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 220 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 221 QColor *categoryColor(QString cat);
222 222
223 QString mArchiveFile; 223 QString mArchiveFile;
224 QString mHtmlExportFile; 224 QString mHtmlExportFile;
225 bool mHtmlWithSave; 225 bool mHtmlWithSave;
226 226
227 QStringList mSelectedPlugins; 227 QStringList mSelectedPlugins;
228 228
229 QString mLastImportFile; 229 QString mLastImportFile;
230 QString mLastVcalFile; 230 QString mLastVcalFile;
231 QString mLastSaveFile; 231 QString mLastSaveFile;
232 QString mLastLoadFile; 232 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 233 QString mLastSyncedLocalFile;
234 234
235 235
236 QString mDefaultAlarmFile; 236 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 237 int mIMIPScheduler;
238 int mIMIPSend; 238 int mIMIPSend;
239 QStringList mAdditionalMails; 239 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 240 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 241 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 242 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 243 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 244 int mIMIPAutoFreeBusyReply;
245 245
246 QStringList mTodoTemplates; 246 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 247 QStringList mEventTemplates;
248 248
249 int mDestination; 249 int mDestination;
250 250
251 251
252 bool mEditOnDoubleClick; 252 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 253 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 254 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 255 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 256 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 257 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 258 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 259 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 260 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 261 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 262 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 263 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 264 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 265 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 266 bool mMonthViewUsesForegroundColor;
267 267
268 bool mHightlightDateTimeEdit; 268 bool mHightlightDateTimeEdit;
269 bool mUseQuicksave;
270 bool mShortDateInViewer; 269 bool mShortDateInViewer;
271 270
272 QStringList mLocationDefaults; 271 QStringList mLocationDefaults;
273 QStringList mEventSummaryUser; 272 QStringList mEventSummaryUser;
274 QStringList mTodoSummaryUser; 273 QStringList mTodoSummaryUser;
275 274
276 bool mUseInternalAlarmNotification; 275 bool mUseInternalAlarmNotification;
277 int mAlarmPlayBeeps; 276 int mAlarmPlayBeeps;
278 int mAlarmSuspendTime; 277 int mAlarmSuspendTime;
279 int mAlarmSuspendCount; 278 int mAlarmSuspendCount;
280 int mAlarmBeepInterval; 279 int mAlarmBeepInterval;
281 280
282 QString mPassiveSyncPort; 281 QString mPassiveSyncPort;
283 QString mActiveSyncPort; 282 QString mActiveSyncPort;
284 QString mActiveSyncIP; 283 QString mActiveSyncIP;
285 284
286 285
287 //US I copied the following settings into KPimGlobalPrefs 286 //US I copied the following settings into KPimGlobalPrefs
288 // that allows us later to easily remove the settings from here. 287 // that allows us later to easily remove the settings from here.
289 int mPreferredDate; 288 int mPreferredDate;
290 QString mUserDateFormatLong; 289 QString mUserDateFormatLong;
291 QString mUserDateFormatShort; 290 QString mUserDateFormatShort;
292 int mPreferredLanguage; 291 int mPreferredLanguage;
293 int mPreferredTime; 292 int mPreferredTime;
294 bool mWeekStartsOnSunday; 293 bool mWeekStartsOnSunday;
295 QString mTimeZoneId; 294 QString mTimeZoneId;
296 bool mUseDaylightsaving; 295 bool mUseDaylightsaving;
297 int mDaylightsavingStart; 296 int mDaylightsavingStart;
298 int mDaylightsavingEnd; 297 int mDaylightsavingEnd;
299 298
300 299
301 private: 300 private:
302 QDict<QColor> mCategoryColors; 301 QDict<QColor> mCategoryColors;
303 QColor mDefaultCategoryColor; 302 QColor mDefaultCategoryColor;
304 303
305 QFont mDefaultTimeBarFont; 304 QFont mDefaultTimeBarFont;
306 QFont mDefaultViewFont; 305 QFont mDefaultViewFont;
307 QFont mDefaultMonthViewFont; 306 QFont mDefaultMonthViewFont;
308 307
309 QString mName; 308 QString mName;
310 QString mEmail; 309 QString mEmail;
311}; 310};
312 311
313#endif 312#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 5aa75f5..43ee2d7 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1187,1427 +1187,1316 @@ void MainWindow::about()
1187 i18n("KOrganizer/Platform-independent\n") + 1187 i18n("KOrganizer/Platform-independent\n") +
1188 "(KO/Pi) " + version + " - " + 1188 "(KO/Pi) " + version + " - " +
1189 1189
1190#ifdef DESKTOP_VERSION 1190#ifdef DESKTOP_VERSION
1191 i18n("Desktop Edition\n") + 1191 i18n("Desktop Edition\n") +
1192#else 1192#else
1193 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1193 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1194#endif 1194#endif
1195 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1195 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1196} 1196}
1197void MainWindow::keyBindings() 1197void MainWindow::keyBindings()
1198{ 1198{
1199 QString cap = i18n("Key bindings KOrganizer/Pi"); 1199 QString cap = i18n("Key bindings KOrganizer/Pi");
1200 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1200 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1201 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1201 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1202 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1202 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1203 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1203 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1204 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1204 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1205 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1205 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1206 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1206 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1207 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1207 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1208 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1208 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1209 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1209 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1210 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1210 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1211 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1211 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1212 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1212 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1213 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1213 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1214 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1214 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1215 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1215 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1216 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1216 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1217 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1217 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1218 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1218 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1219 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1219 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1220 i18n("<p><h3>In agenda view:</h3></p>\n") + 1220 i18n("<p><h3>In agenda view:</h3></p>\n") +
1221 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1221 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1222 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1222 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1223 i18n("<p><h3>In todo view:</h3></p>\n") + 1223 i18n("<p><h3>In todo view:</h3></p>\n") +
1224 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1224 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1225 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1225 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1226 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1226 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1227 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1227 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1228 i18n("<p><h3>In list view:</h3></p>\n") + 1228 i18n("<p><h3>In list view:</h3></p>\n") +
1229 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1229 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1230 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1230 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1231 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1231 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1232 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1232 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1233 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1233 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1234 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1234 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1235 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1235 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1236 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1236 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1237 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1237 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1238 i18n("<p><b>E</b>: Edit item</p>\n") + 1238 i18n("<p><b>E</b>: Edit item</p>\n") +
1239 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1239 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1240 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1240 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1241 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1241 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1242 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1242 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1243 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1243 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1244 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1244 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1245 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1245 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1246 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1246 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1247 i18n("<p><b>White</b>: Item readonly</p>\n"); 1247 i18n("<p><b>White</b>: Item readonly</p>\n");
1248 displayText( text, cap); 1248 displayText( text, cap);
1249 1249
1250} 1250}
1251void MainWindow::aboutAutoSaving() 1251void MainWindow::aboutAutoSaving()
1252{ 1252{
1253 QMessageBox* msg; 1253 QMessageBox* msg;
1254 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1254 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1255 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1255 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1256 QMessageBox::Ok, 1256 QMessageBox::Ok,
1257 QMessageBox::NoButton, 1257 QMessageBox::NoButton,
1258 QMessageBox::NoButton); 1258 QMessageBox::NoButton);
1259 msg->exec(); 1259 msg->exec();
1260 delete msg; 1260 delete msg;
1261 1261
1262 1262
1263} 1263}
1264void MainWindow::aboutKnownBugs() 1264void MainWindow::aboutKnownBugs()
1265{ 1265{
1266 QMessageBox* msg; 1266 QMessageBox* msg;
1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1268 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1268 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1271 i18n("\nor report them in the bugtracker on\n") + 1271 i18n("\nor report them in the bugtracker on\n") +
1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1273 QMessageBox::NoIcon, 1273 QMessageBox::NoIcon,
1274 QMessageBox::Ok, 1274 QMessageBox::Ok,
1275 QMessageBox::NoButton, 1275 QMessageBox::NoButton,
1276 QMessageBox::NoButton); 1276 QMessageBox::NoButton);
1277 msg->exec(); 1277 msg->exec();
1278 delete msg; 1278 delete msg;
1279 1279
1280} 1280}
1281 1281
1282QString MainWindow::defaultFileName() 1282QString MainWindow::defaultFileName()
1283{ 1283{
1284 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1284 return locateLocal( "data", "korganizer/mycalendar.ics" );
1285} 1285}
1286QString MainWindow::syncFileName() 1286QString MainWindow::syncFileName()
1287{ 1287{
1288#ifdef _WIN32_ 1288#ifdef _WIN32_
1289 return locateLocal( "tmp", "synccalendar.ics" ); 1289 return locateLocal( "tmp", "synccalendar.ics" );
1290#else 1290#else
1291 return QString( "/tmp/kopitempfile.ics" ); 1291 return QString( "/tmp/kopitempfile.ics" );
1292#endif 1292#endif
1293} 1293}
1294 1294
1295void MainWindow::processIncidenceSelection( Incidence *incidence ) 1295void MainWindow::processIncidenceSelection( Incidence *incidence )
1296{ 1296{
1297 if ( !incidence ) { 1297 if ( !incidence ) {
1298 enableIncidenceActions( false ); 1298 enableIncidenceActions( false );
1299 1299
1300 mNewSubTodoAction->setEnabled( false ); 1300 mNewSubTodoAction->setEnabled( false );
1301 setCaptionToDates(); 1301 setCaptionToDates();
1302 return; 1302 return;
1303 1303
1304 } 1304 }
1305 1305
1306 //KGlobal::locale()->formatDateTime(nextA, true); 1306 //KGlobal::locale()->formatDateTime(nextA, true);
1307 QString startString = ""; 1307 QString startString = "";
1308 if ( incidence->type() != "Todo" ) { 1308 if ( incidence->type() != "Todo" ) {
1309 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1309 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1310 if ( incidence->doesFloat() ) { 1310 if ( incidence->doesFloat() ) {
1311 startString += ": "+incidence->dtStartDateStr( true ); 1311 startString += ": "+incidence->dtStartDateStr( true );
1312 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1312 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1313 1313
1314 } else { 1314 } else {
1315 startString = ": "+incidence->dtStartStr(true); 1315 startString = ": "+incidence->dtStartStr(true);
1316 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1316 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1317 1317
1318 } 1318 }
1319 1319
1320 } else { 1320 } else {
1321 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1321 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1322 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1322 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1323 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1323 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1324 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1324 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1325 } 1325 }
1326 1326
1327 } 1327 }
1328 else 1328 else
1329 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1329 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1330 if ( !incidence->location().isEmpty() ) 1330 if ( !incidence->location().isEmpty() )
1331 startString += " (" +incidence->location()+")"; 1331 startString += " (" +incidence->location()+")";
1332 setCaption( incidence->summary()+startString); 1332 setCaption( incidence->summary()+startString);
1333 1333
1334 enableIncidenceActions( true ); 1334 enableIncidenceActions( true );
1335 1335
1336 if ( incidence->type() == "Event" ) { 1336 if ( incidence->type() == "Event" ) {
1337 mShowAction->setText( i18n("Show Event...") ); 1337 mShowAction->setText( i18n("Show Event...") );
1338 mEditAction->setText( i18n("Edit Event...") ); 1338 mEditAction->setText( i18n("Edit Event...") );
1339 mDeleteAction->setText( i18n("Delete Event...") ); 1339 mDeleteAction->setText( i18n("Delete Event...") );
1340 1340
1341 mNewSubTodoAction->setEnabled( false ); 1341 mNewSubTodoAction->setEnabled( false );
1342 } else if ( incidence->type() == "Todo" ) { 1342 } else if ( incidence->type() == "Todo" ) {
1343 mShowAction->setText( i18n("Show Todo...") ); 1343 mShowAction->setText( i18n("Show Todo...") );
1344 mEditAction->setText( i18n("Edit Todo...") ); 1344 mEditAction->setText( i18n("Edit Todo...") );
1345 mDeleteAction->setText( i18n("Delete Todo...") ); 1345 mDeleteAction->setText( i18n("Delete Todo...") );
1346 1346
1347 mNewSubTodoAction->setEnabled( true ); 1347 mNewSubTodoAction->setEnabled( true );
1348 } else { 1348 } else {
1349 mShowAction->setText( i18n("Show...") ); 1349 mShowAction->setText( i18n("Show...") );
1350 mShowAction->setText( i18n("Edit...") ); 1350 mShowAction->setText( i18n("Edit...") );
1351 mShowAction->setText( i18n("Delete...") ); 1351 mShowAction->setText( i18n("Delete...") );
1352 1352
1353 mNewSubTodoAction->setEnabled( false ); 1353 mNewSubTodoAction->setEnabled( false );
1354 } 1354 }
1355} 1355}
1356 1356
1357void MainWindow::enableIncidenceActions( bool enabled ) 1357void MainWindow::enableIncidenceActions( bool enabled )
1358{ 1358{
1359 mShowAction->setEnabled( enabled ); 1359 mShowAction->setEnabled( enabled );
1360 mEditAction->setEnabled( enabled ); 1360 mEditAction->setEnabled( enabled );
1361 mDeleteAction->setEnabled( enabled ); 1361 mDeleteAction->setEnabled( enabled );
1362} 1362}
1363 1363
1364void MainWindow::importOL() 1364void MainWindow::importOL()
1365{ 1365{
1366#ifdef _WIN32_ 1366#ifdef _WIN32_
1367 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1367 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1368 id->exec(); 1368 id->exec();
1369 delete id; 1369 delete id;
1370 mView->updateView(); 1370 mView->updateView();
1371#endif 1371#endif
1372} 1372}
1373void MainWindow::importBday() 1373void MainWindow::importBday()
1374{ 1374{
1375 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1375 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1376 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1376 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1377 i18n("Import!"), i18n("Cancel"), 0, 1377 i18n("Import!"), i18n("Cancel"), 0,
1378 0, 1 ); 1378 0, 1 );
1379 if ( result == 0 ) { 1379 if ( result == 0 ) {
1380 mView->importBday(); 1380 mView->importBday();
1381 1381
1382 } 1382 }
1383 1383
1384 1384
1385} 1385}
1386void MainWindow::importQtopia() 1386void MainWindow::importQtopia()
1387{ 1387{
1388#ifndef DESKTOP_VERSION 1388#ifndef DESKTOP_VERSION
1389 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1389 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1390 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1390 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1391 i18n("Import!"), i18n("Cancel"), 0, 1391 i18n("Import!"), i18n("Cancel"), 0,
1392 0, 1 ); 1392 0, 1 );
1393 if ( result == 0 ) { 1393 if ( result == 0 ) {
1394 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1394 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1395 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1395 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1396 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1396 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1397 mView->importQtopia( categories, datebook, todolist ); 1397 mView->importQtopia( categories, datebook, todolist );
1398 } 1398 }
1399#else 1399#else
1400 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1400 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1401 i18n("Not supported \non desktop!\n"), 1401 i18n("Not supported \non desktop!\n"),
1402 i18n("Ok"), i18n("Cancel"), 0, 1402 i18n("Ok"), i18n("Cancel"), 0,
1403 0, 1 ); 1403 0, 1 );
1404 1404
1405#endif 1405#endif
1406} 1406}
1407 1407
1408void MainWindow::saveOnClose() 1408void MainWindow::saveOnClose()
1409{ 1409{
1410 KOPrefs *p = KOPrefs::instance(); 1410 KOPrefs *p = KOPrefs::instance();
1411 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1411 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1412 p->mToolBarUp = iconToolBar->x() > width()/2 || 1412 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1413 iconToolBar->y() > height()/2; 1413 iconToolBar->y() > height()/2;
1414 mView->writeSettings(); 1414 mView->writeSettings();
1415 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1415 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1416 save(); 1416 save();
1417} 1417}
1418void MainWindow::slotModifiedChanged( bool changed ) 1418void MainWindow::slotModifiedChanged( bool changed )
1419{ 1419{
1420 if ( mBlockAtStartup ) 1420 if ( mBlockAtStartup )
1421 return; 1421 return;
1422 int msec; 1422 int msec;
1423 // we store the changes after 1 minute, 1423 // we store the changes after 1 minute,
1424 // and for safety reasons after 10 minutes again 1424 // and for safety reasons after 10 minutes again
1425 if ( !mBlockSaveFlag ) 1425 if ( !mBlockSaveFlag )
1426 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1426 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1427 else 1427 else
1428 msec = 1000 * 600; 1428 msec = 1000 * 600;
1429 mSaveTimer.start( msec, true ); // 1 minute 1429 mSaveTimer.start( msec, true ); // 1 minute
1430 qDebug("KO: Saving File in %d secs!", msec/1000); 1430 qDebug("KO: Saving File in %d secs!", msec/1000);
1431 mCalendarModifiedFlag = true; 1431 mCalendarModifiedFlag = true;
1432} 1432}
1433void MainWindow::save() 1433void MainWindow::save()
1434{ 1434{
1435 if ( mBlockSaveFlag ) 1435 if ( mBlockSaveFlag )
1436 return; 1436 return;
1437 bool store = mBlockSaveFlag; 1437 bool store = mBlockSaveFlag;
1438 mBlockSaveFlag = true; 1438 mBlockSaveFlag = true;
1439 if ( mView->checkFileVersion( defaultFileName()) ) { 1439 if ( mView->checkFileVersion( defaultFileName()) ) {
1440 1440
1441 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1441 QTime neededSaveTime = QDateTime::currentDateTime().time();
1442 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1442 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1443 qDebug("KO: Start saving data to file!"); 1443 qDebug("KO: Start saving data to file!");
1444 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1444 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1445 mView->saveCalendar( defaultFileName() ); 1445 mView->saveCalendar( defaultFileName() );
1446 1446
1447 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1447 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1448 mView->watchSavedFile(); 1448 mView->watchSavedFile();
1449 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1449 qDebug("KO: Needed %d ms for saving.",msNeeded );
1450 QString savemes; 1450 QString savemes;
1451 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1451 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1452 setCaption(savemes); 1452 setCaption(savemes);
1453 } else 1453 } else
1454 setCaption(i18n("Saving cancelled!")); 1454 setCaption(i18n("Saving cancelled!"));
1455 mCalendarModifiedFlag = false; 1455 mCalendarModifiedFlag = false;
1456 mBlockSaveFlag = store; 1456 mBlockSaveFlag = store;
1457} 1457}
1458 1458
1459void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1459void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1460{ 1460{
1461 if ( !e->isAutoRepeat() ) { 1461 if ( !e->isAutoRepeat() ) {
1462 mFlagKeyPressed = false; 1462 mFlagKeyPressed = false;
1463 } 1463 }
1464} 1464}
1465void MainWindow::keyPressEvent ( QKeyEvent * e ) 1465void MainWindow::keyPressEvent ( QKeyEvent * e )
1466{ 1466{
1467 qApp->processEvents(); 1467 qApp->processEvents();
1468 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1468 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1469 e->ignore(); 1469 e->ignore();
1470 // qDebug(" ignore %d",e->isAutoRepeat() ); 1470 // qDebug(" ignore %d",e->isAutoRepeat() );
1471 return; 1471 return;
1472 } 1472 }
1473 if (! e->isAutoRepeat() ) 1473 if (! e->isAutoRepeat() )
1474 mFlagKeyPressed = true; 1474 mFlagKeyPressed = true;
1475 KOPrefs *p = KOPrefs::instance(); 1475 KOPrefs *p = KOPrefs::instance();
1476 bool showSelectedDates = false; 1476 bool showSelectedDates = false;
1477 int size; 1477 int size;
1478 int pro = 0; 1478 int pro = 0;
1479 //qDebug("MainWindow::keyPressEvent "); 1479 //qDebug("MainWindow::keyPressEvent ");
1480 switch ( e->key() ) { 1480 switch ( e->key() ) {
1481 case Qt::Key_Right: 1481 case Qt::Key_Right:
1482 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1482 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1483 mView->goNextMonth(); 1483 mView->goNextMonth();
1484 else 1484 else
1485 mView->goNext(); 1485 mView->goNext();
1486 showSelectedDates = true; 1486 showSelectedDates = true;
1487 break; 1487 break;
1488 case Qt::Key_Left: 1488 case Qt::Key_Left:
1489 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1489 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1490 mView->goPreviousMonth(); 1490 mView->goPreviousMonth();
1491 else 1491 else
1492 mView->goPrevious(); 1492 mView->goPrevious();
1493 showSelectedDates = true; 1493 showSelectedDates = true;
1494 break; 1494 break;
1495 case Qt::Key_Down: 1495 case Qt::Key_Down:
1496 mView->viewManager()->agendaView()->scrollOneHourDown(); 1496 mView->viewManager()->agendaView()->scrollOneHourDown();
1497 break; 1497 break;
1498 case Qt::Key_Up: 1498 case Qt::Key_Up:
1499 mView->viewManager()->agendaView()->scrollOneHourUp(); 1499 mView->viewManager()->agendaView()->scrollOneHourUp();
1500 break; 1500 break;
1501 case Qt::Key_I: 1501 case Qt::Key_I:
1502 mView->showIncidence(); 1502 mView->showIncidence();
1503 break; 1503 break;
1504 case Qt::Key_Delete: 1504 case Qt::Key_Delete:
1505 case Qt::Key_Backspace: 1505 case Qt::Key_Backspace:
1506 mView->deleteIncidence(); 1506 mView->deleteIncidence();
1507 break; 1507 break;
1508 case Qt::Key_D: 1508 case Qt::Key_D:
1509 mView->viewManager()->showDayView(); 1509 mView->viewManager()->showDayView();
1510 showSelectedDates = true; 1510 showSelectedDates = true;
1511 break; 1511 break;
1512 case Qt::Key_O: 1512 case Qt::Key_O:
1513 mView->toggleFilerEnabled( ); 1513 mView->toggleFilerEnabled( );
1514 break; 1514 break;
1515 case Qt::Key_0: 1515 case Qt::Key_0:
1516 case Qt::Key_1: 1516 case Qt::Key_1:
1517 case Qt::Key_2: 1517 case Qt::Key_2:
1518 case Qt::Key_3: 1518 case Qt::Key_3:
1519 case Qt::Key_4: 1519 case Qt::Key_4:
1520 case Qt::Key_5: 1520 case Qt::Key_5:
1521 case Qt::Key_6: 1521 case Qt::Key_6:
1522 case Qt::Key_7: 1522 case Qt::Key_7:
1523 case Qt::Key_8: 1523 case Qt::Key_8:
1524 case Qt::Key_9: 1524 case Qt::Key_9:
1525 pro = e->key()-48; 1525 pro = e->key()-48;
1526 if ( pro == 0 ) 1526 if ( pro == 0 )
1527 pro = 10; 1527 pro = 10;
1528 if ( e->state() == Qt::ControlButton) 1528 if ( e->state() == Qt::ControlButton)
1529 pro += 10; 1529 pro += 10;
1530 break; 1530 break;
1531 case Qt::Key_M: 1531 case Qt::Key_M:
1532 mView->viewManager()->showMonthView(); 1532 mView->viewManager()->showMonthView();
1533 showSelectedDates = true; 1533 showSelectedDates = true;
1534 break; 1534 break;
1535 case Qt::Key_Insert: 1535 case Qt::Key_Insert:
1536 mView->newEvent(); 1536 mView->newEvent();
1537 break; 1537 break;
1538 case Qt::Key_S : 1538 case Qt::Key_S :
1539 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1539 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1540 mView->newSubTodo(); 1540 mView->newSubTodo();
1541 else 1541 else
1542 mView->dialogManager()->showSearchDialog(); 1542 mView->dialogManager()->showSearchDialog();
1543 break; 1543 break;
1544 case Qt::Key_Y : 1544 case Qt::Key_Y :
1545 case Qt::Key_Z : 1545 case Qt::Key_Z :
1546 mView->viewManager()->showWorkWeekView(); 1546 mView->viewManager()->showWorkWeekView();
1547 showSelectedDates = true; 1547 showSelectedDates = true;
1548 break; 1548 break;
1549 case Qt::Key_U : 1549 case Qt::Key_U :
1550 mView->viewManager()->showWeekView(); 1550 mView->viewManager()->showWeekView();
1551 showSelectedDates = true; 1551 showSelectedDates = true;
1552 break; 1552 break;
1553 case Qt::Key_H : 1553 case Qt::Key_H :
1554 keyBindings(); 1554 keyBindings();
1555 break; 1555 break;
1556 case Qt::Key_W: 1556 case Qt::Key_W:
1557 mView->viewManager()->showWhatsNextView(); 1557 mView->viewManager()->showWhatsNextView();
1558 break; 1558 break;
1559 case Qt::Key_L: 1559 case Qt::Key_L:
1560 mView->viewManager()->showListView(); 1560 mView->viewManager()->showListView();
1561 break; 1561 break;
1562 case Qt::Key_N: 1562 case Qt::Key_N:
1563 mView->viewManager()->showNextXView(); 1563 mView->viewManager()->showNextXView();
1564 showSelectedDates = true; 1564 showSelectedDates = true;
1565 break; 1565 break;
1566 case Qt::Key_V: 1566 case Qt::Key_V:
1567 mView->viewManager()->showTodoView(); 1567 mView->viewManager()->showTodoView();
1568 break; 1568 break;
1569 case Qt::Key_C: 1569 case Qt::Key_C:
1570 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1570 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1571 break; 1571 break;
1572 case Qt::Key_P: 1572 case Qt::Key_P:
1573 mView->showDatePicker( ); 1573 mView->showDatePicker( );
1574 break; 1574 break;
1575 case Qt::Key_F: 1575 case Qt::Key_F:
1576 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1576 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1577 mView->editFilters(); 1577 mView->editFilters();
1578 else 1578 else
1579 mView->toggleFilter(); 1579 mView->toggleFilter();
1580 break; 1580 break;
1581 case Qt::Key_X: 1581 case Qt::Key_X:
1582 mView->toggleDateNavigatorWidget(); 1582 mView->toggleDateNavigatorWidget();
1583 break; 1583 break;
1584 case Qt::Key_Space: 1584 case Qt::Key_Space:
1585 mView->toggleExpand(); 1585 mView->toggleExpand();
1586 break; 1586 break;
1587 case Qt::Key_A: 1587 case Qt::Key_A:
1588 mView->toggleAllDaySize(); 1588 mView->toggleAllDaySize();
1589 break; 1589 break;
1590 case Qt::Key_T: 1590 case Qt::Key_T:
1591 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1591 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1592 mView->newTodo(); 1592 mView->newTodo();
1593 else { 1593 else {
1594 mView->goToday(); 1594 mView->goToday();
1595 showSelectedDates = true; 1595 showSelectedDates = true;
1596 } 1596 }
1597 break; 1597 break;
1598 case Qt::Key_J: 1598 case Qt::Key_J:
1599 mView->viewManager()->showJournalView(); 1599 mView->viewManager()->showJournalView();
1600 break; 1600 break;
1601 case Qt::Key_B: 1601 case Qt::Key_B:
1602 mView->editIncidenceDescription();; 1602 mView->editIncidenceDescription();;
1603 break; 1603 break;
1604 // case Qt::Key_Return: 1604 // case Qt::Key_Return:
1605 case Qt::Key_E: 1605 case Qt::Key_E:
1606 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1606 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1607 mView->newEvent(); 1607 mView->newEvent();
1608 else 1608 else
1609 mView->editIncidence(); 1609 mView->editIncidence();
1610 break; 1610 break;
1611 case Qt::Key_Plus: 1611 case Qt::Key_Plus:
1612 size = p->mHourSize +2; 1612 size = p->mHourSize +2;
1613 if ( size <= 18 ) 1613 if ( size <= 18 )
1614 configureAgenda( size ); 1614 configureAgenda( size );
1615 break; 1615 break;
1616 case Qt::Key_Minus: 1616 case Qt::Key_Minus:
1617 size = p->mHourSize - 2; 1617 size = p->mHourSize - 2;
1618 if ( size >= 4 ) 1618 if ( size >= 4 )
1619 configureAgenda( size ); 1619 configureAgenda( size );
1620 break; 1620 break;
1621 1621
1622 1622
1623 default: 1623 default:
1624 e->ignore(); 1624 e->ignore();
1625 } 1625 }
1626 if ( pro > 0 ) { 1626 if ( pro > 0 ) {
1627 mView->selectFilter( pro-1 ); 1627 mView->selectFilter( pro-1 );
1628 } 1628 }
1629 if ( showSelectedDates ) { 1629 if ( showSelectedDates ) {
1630 ;// setCaptionToDates(); 1630 ;// setCaptionToDates();
1631 } 1631 }
1632 1632
1633} 1633}
1634 1634
1635void MainWindow::fillFilterMenu() 1635void MainWindow::fillFilterMenu()
1636{ 1636{
1637 selectFilterMenu->clear(); 1637 selectFilterMenu->clear();
1638 bool disable = false; 1638 bool disable = false;
1639 if ( mView->filterView()->filtersEnabled() ) { 1639 if ( mView->filterView()->filtersEnabled() ) {
1640 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1640 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1641 } 1641 }
1642 else { 1642 else {
1643 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1643 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1644 disable = true; 1644 disable = true;
1645 } 1645 }
1646 selectFilterMenu->insertSeparator(); 1646 selectFilterMenu->insertSeparator();
1647 QPtrList<CalFilter> fili = mView->filters(); 1647 QPtrList<CalFilter> fili = mView->filters();
1648 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1648 CalFilter *curfilter = mView->filterView()->selectedFilter();
1649 CalFilter *filter = fili.first(); 1649 CalFilter *filter = fili.first();
1650 int iii = 1; 1650 int iii = 1;
1651 while(filter) { 1651 while(filter) {
1652 selectFilterMenu->insertItem( filter->name(), iii ); 1652 selectFilterMenu->insertItem( filter->name(), iii );
1653 if ( filter == curfilter) 1653 if ( filter == curfilter)
1654 selectFilterMenu->setItemChecked( iii, true ); 1654 selectFilterMenu->setItemChecked( iii, true );
1655 if ( disable ) 1655 if ( disable )
1656 selectFilterMenu->setItemEnabled( iii, false ); 1656 selectFilterMenu->setItemEnabled( iii, false );
1657 filter = fili.next(); 1657 filter = fili.next();
1658 ++iii; 1658 ++iii;
1659 } 1659 }
1660} 1660}
1661void MainWindow::selectFilter( int fil ) 1661void MainWindow::selectFilter( int fil )
1662{ 1662{
1663 if ( fil == 0 ) { 1663 if ( fil == 0 ) {
1664 mView->toggleFilerEnabled( ); 1664 mView->toggleFilerEnabled( );
1665 } else { 1665 } else {
1666 mView->selectFilter( fil-1 ); 1666 mView->selectFilter( fil-1 );
1667 } 1667 }
1668} 1668}
1669void MainWindow::configureToolBar( int item ) 1669void MainWindow::configureToolBar( int item )
1670{ 1670{
1671 1671
1672 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1672 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1673 KOPrefs *p = KOPrefs::instance(); 1673 KOPrefs *p = KOPrefs::instance();
1674 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1674 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1675 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1675 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1676 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1676 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1677 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1677 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1678 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1678 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1679 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1679 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1680 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1680 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1681 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1681 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1682 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1682 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1683 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1683 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1684 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1684 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1685 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1685 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1686 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1686 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1687 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1687 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1688 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1688 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1689 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1689 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1690 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1690 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1691 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1691 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1692 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1692 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1693 // initActions(); 1693 // initActions();
1694} 1694}
1695 1695
1696void MainWindow::setCaptionToDates() 1696void MainWindow::setCaptionToDates()
1697{ 1697{
1698 QString selDates; 1698 QString selDates;
1699 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1699 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1700 if (mView->startDate() < mView->endDate() ) 1700 if (mView->startDate() < mView->endDate() )
1701 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1701 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1702 setCaption( i18n("Dates: ") + selDates ); 1702 setCaption( i18n("Dates: ") + selDates );
1703 1703
1704} 1704}
1705// parameter item == 0: reinit 1705// parameter item == 0: reinit
1706void MainWindow::configureAgenda( int item ) 1706void MainWindow::configureAgenda( int item )
1707{ 1707{
1708 1708
1709 KOPrefs *p = KOPrefs::instance(); 1709 KOPrefs *p = KOPrefs::instance();
1710 1710
1711 int i; 1711 int i;
1712 if ( item == 1 ) { 1712 if ( item == 1 ) {
1713 mView->toggleAllDaySize(); 1713 mView->toggleAllDaySize();
1714 return; 1714 return;
1715 } 1715 }
1716 // do not allow 4 for widgets higher than 480 1716 // do not allow 4 for widgets higher than 480
1717 // if ( QApplication::desktop()->height() > 480 ) { 1717 // if ( QApplication::desktop()->height() > 480 ) {
1718// if ( item == 4 ) 1718// if ( item == 4 )
1719// item = 6; 1719// item = 6;
1720// } 1720// }
1721 for ( i = 4; i <= 18; i= i+2 ) 1721 for ( i = 4; i <= 18; i= i+2 )
1722 configureAgendaMenu->setItemChecked( i, false ); 1722 configureAgendaMenu->setItemChecked( i, false );
1723 configureAgendaMenu->setItemChecked( item, true ); 1723 configureAgendaMenu->setItemChecked( item, true );
1724 if ( p->mHourSize == item ) 1724 if ( p->mHourSize == item )
1725 return; 1725 return;
1726 p->mHourSize=item; 1726 p->mHourSize=item;
1727 mView->viewManager()->agendaView()->updateConfig(); 1727 mView->viewManager()->agendaView()->updateConfig();
1728} 1728}
1729 1729
1730void MainWindow::saveCalendar() 1730void MainWindow::saveCalendar()
1731{ 1731{
1732 QString fn = KOPrefs::instance()->mLastSaveFile; 1732 QString fn = KOPrefs::instance()->mLastSaveFile;
1733 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1733 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1734 1734
1735 if ( fn == "" ) 1735 if ( fn == "" )
1736 return; 1736 return;
1737 QFileInfo info; 1737 QFileInfo info;
1738 info.setFile( fn ); 1738 info.setFile( fn );
1739 QString mes; 1739 QString mes;
1740 bool createbup = true; 1740 bool createbup = true;
1741 if ( info. exists() ) { 1741 if ( info. exists() ) {
1742 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1742 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1743 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1743 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1744 i18n("Overwrite!"), i18n("Cancel"), 0, 1744 i18n("Overwrite!"), i18n("Cancel"), 0,
1745 0, 1 ); 1745 0, 1 );
1746 if ( result != 0 ) { 1746 if ( result != 0 ) {
1747 createbup = false; 1747 createbup = false;
1748 } 1748 }
1749 } 1749 }
1750 if ( createbup ) { 1750 if ( createbup ) {
1751 mView->saveCalendar( fn ); 1751 mView->saveCalendar( fn );
1752 mes = i18n("KO/Pi:Saved %1").arg(fn); 1752 mes = i18n("KO/Pi:Saved %1").arg(fn);
1753 KOPrefs::instance()->mLastSaveFile = fn; 1753 KOPrefs::instance()->mLastSaveFile = fn;
1754 setCaption(mes); 1754 setCaption(mes);
1755 } 1755 }
1756} 1756}
1757void MainWindow::loadCalendar() 1757void MainWindow::loadCalendar()
1758{ 1758{
1759 1759
1760 QString fn = KOPrefs::instance()->mLastLoadFile; 1760 QString fn = KOPrefs::instance()->mLastLoadFile;
1761 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1761 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1762 1762
1763 if ( fn == "" ) 1763 if ( fn == "" )
1764 return; 1764 return;
1765 QFileInfo info; 1765 QFileInfo info;
1766 info.setFile( fn ); 1766 info.setFile( fn );
1767 QString mess; 1767 QString mess;
1768 bool loadbup = true; 1768 bool loadbup = true;
1769 if ( info. exists() ) { 1769 if ( info. exists() ) {
1770 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1770 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1771 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1771 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1772 mess, 1772 mess,
1773 i18n("Load!"), i18n("Cancel"), 0, 1773 i18n("Load!"), i18n("Cancel"), 0,
1774 0, 1 ); 1774 0, 1 );
1775 if ( result != 0 ) { 1775 if ( result != 0 ) {
1776 loadbup = false; 1776 loadbup = false;
1777 } 1777 }
1778 } else { 1778 } else {
1779 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1779 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1780 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1780 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1781 0, 1 ); 1781 0, 1 );
1782 1782
1783 return; 1783 return;
1784 } 1784 }
1785 if ( loadbup ) { 1785 if ( loadbup ) {
1786 mView->openCalendar( fn ); 1786 mView->openCalendar( fn );
1787 KOPrefs::instance()->mLastLoadFile = fn; 1787 KOPrefs::instance()->mLastLoadFile = fn;
1788 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1788 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1789 setCaption(mess); 1789 setCaption(mess);
1790 } 1790 }
1791 1791
1792} 1792}
1793void MainWindow::quickImportIcal() 1793void MainWindow::quickImportIcal()
1794{ 1794{
1795 importFile( KOPrefs::instance()->mLastImportFile, false ); 1795 importFile( KOPrefs::instance()->mLastImportFile, false );
1796} 1796}
1797void MainWindow::importFile( QString fn, bool quick ) 1797void MainWindow::importFile( QString fn, bool quick )
1798{ 1798{
1799 QFileInfo info; 1799 QFileInfo info;
1800 info.setFile( fn ); 1800 info.setFile( fn );
1801 QString mess; 1801 QString mess;
1802 bool loadbup = true; 1802 bool loadbup = true;
1803 if ( !info. exists() ) { 1803 if ( !info. exists() ) {
1804 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1804 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1805 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1805 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1806 mess ); 1806 mess );
1807 return; 1807 return;
1808 } 1808 }
1809 int result = 0; 1809 int result = 0;
1810 if ( !quick ) { 1810 if ( !quick ) {
1811 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 )); 1811 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 ));
1812 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1812 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1813 mess, 1813 mess,
1814 "Import", "Cancel", 0, 1814 "Import", "Cancel", 0,
1815 0, 1 ); 1815 0, 1 );
1816 } 1816 }
1817 if ( result == 0 ) { 1817 if ( result == 0 ) {
1818 if ( mView->openCalendar( fn, true )) { 1818 if ( mView->openCalendar( fn, true )) {
1819 KOPrefs::instance()->mLastImportFile = fn; 1819 KOPrefs::instance()->mLastImportFile = fn;
1820 setCaption(i18n("Imported file successfully")); 1820 setCaption(i18n("Imported file successfully"));
1821 } else { 1821 } else {
1822 setCaption(i18n("Error importing file")); 1822 setCaption(i18n("Error importing file"));
1823 } 1823 }
1824 } 1824 }
1825} 1825}
1826 1826
1827void MainWindow::importIcal() 1827void MainWindow::importIcal()
1828{ 1828{
1829 1829
1830 QString fn =KOPrefs::instance()->mLastImportFile; 1830 QString fn =KOPrefs::instance()->mLastImportFile;
1831 1831
1832 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1832 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1833 if ( fn == "" ) 1833 if ( fn == "" )
1834 return; 1834 return;
1835 importFile( fn, true ); 1835 importFile( fn, true );
1836 1836
1837} 1837}
1838 1838
1839void MainWindow::exportVCalendar() 1839void MainWindow::exportVCalendar()
1840{ 1840{
1841 QString fn = KOPrefs::instance()->mLastVcalFile; 1841 QString fn = KOPrefs::instance()->mLastVcalFile;
1842 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1842 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1843 if ( fn == "" ) 1843 if ( fn == "" )
1844 return; 1844 return;
1845 QFileInfo info; 1845 QFileInfo info;
1846 info.setFile( fn ); 1846 info.setFile( fn );
1847 QString mes; 1847 QString mes;
1848 bool createbup = true; 1848 bool createbup = true;
1849 if ( info. exists() ) { 1849 if ( info. exists() ) {
1850 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1850 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1851 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1851 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1852 i18n("Overwrite!"), i18n("Cancel"), 0, 1852 i18n("Overwrite!"), i18n("Cancel"), 0,
1853 0, 1 ); 1853 0, 1 );
1854 if ( result != 0 ) { 1854 if ( result != 0 ) {
1855 createbup = false; 1855 createbup = false;
1856 } 1856 }
1857 } 1857 }
1858 if ( createbup ) { 1858 if ( createbup ) {
1859 if ( mView->exportVCalendar( fn ) ) { 1859 if ( mView->exportVCalendar( fn ) ) {
1860 KOPrefs::instance()->mLastVcalFile = fn; 1860 KOPrefs::instance()->mLastVcalFile = fn;
1861 if ( fn.length() > 20 ) 1861 if ( fn.length() > 20 )
1862 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1862 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1863 else 1863 else
1864 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1864 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1865 setCaption(mes); 1865 setCaption(mes);
1866 } 1866 }
1867 } 1867 }
1868 1868
1869} 1869}
1870QString MainWindow::getPassword( ) 1870QString MainWindow::getPassword( )
1871{ 1871{
1872 QString retfile = ""; 1872 QString retfile = "";
1873 QDialog dia ( this, "input-dialog", true ); 1873 QDialog dia ( this, "input-dialog", true );
1874 QLineEdit lab ( &dia ); 1874 QLineEdit lab ( &dia );
1875 lab.setEchoMode( QLineEdit::Password ); 1875 lab.setEchoMode( QLineEdit::Password );
1876 QVBoxLayout lay( &dia ); 1876 QVBoxLayout lay( &dia );
1877 lay.setMargin(7); 1877 lay.setMargin(7);
1878 lay.setSpacing(7); 1878 lay.setSpacing(7);
1879 lay.addWidget( &lab); 1879 lay.addWidget( &lab);
1880 dia.setFixedSize( 230,50 ); 1880 dia.setFixedSize( 230,50 );
1881 dia.setCaption( i18n("Enter password") ); 1881 dia.setCaption( i18n("Enter password") );
1882 QPushButton pb ( "OK", &dia); 1882 QPushButton pb ( "OK", &dia);
1883 lay.addWidget( &pb ); 1883 lay.addWidget( &pb );
1884 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1884 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1885 dia.show(); 1885 dia.show();
1886 int res = dia.exec(); 1886 int res = dia.exec();
1887 if ( res ) 1887 if ( res )
1888 retfile = lab.text(); 1888 retfile = lab.text();
1889 dia.hide(); 1889 dia.hide();
1890 qApp->processEvents(); 1890 qApp->processEvents();
1891 return retfile; 1891 return retfile;
1892 1892
1893} 1893}
1894 1894
1895void MainWindow::enableQuick() 1895void MainWindow::enableQuick()
1896{ 1896{
1897 QString passWordPiSync = "bhdrvmk"; 1897 QString passWordPiSync = "bhdrvmk";
1898 QString retfile = ""; 1898 QString retfile = "";
1899 QDialog dia ( this, "input-dialog", true ); 1899 QDialog dia ( this, "input-dialog", true );
1900 QLineEdit lab ( &dia ); 1900 QLineEdit lab ( &dia );
1901 QVBoxLayout lay( &dia ); 1901 QVBoxLayout lay( &dia );
1902 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1902 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1903 lay.setMargin(7); 1903 lay.setMargin(7);
1904 lay.setSpacing(7); 1904 lay.setSpacing(7);
1905 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1905 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1906 lay.addWidget( &label); 1906 lay.addWidget( &label);
1907 lay.addWidget( &lab); 1907 lay.addWidget( &lab);
1908 1908
1909 QLineEdit lepw ( &dia ); 1909 QLineEdit lepw ( &dia );
1910 lepw.setText( "abc" ); 1910 lepw.setText( "abc" );
1911 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 1911 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
1912 lay.addWidget( &label2); 1912 lay.addWidget( &label2);
1913 lay.addWidget( &lepw); 1913 lay.addWidget( &lepw);
1914 dia.setFixedSize( 230,80 ); 1914 dia.setFixedSize( 230,80 );
1915 dia.setCaption( i18n("Enter port for Pi-Sync") ); 1915 dia.setCaption( i18n("Enter port for Pi-Sync") );
1916 QPushButton pb ( "OK", &dia); 1916 QPushButton pb ( "OK", &dia);
1917 lay.addWidget( &pb ); 1917 lay.addWidget( &pb );
1918 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1918 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1919 dia.show(); 1919 dia.show();
1920 int res = dia.exec(); 1920 int res = dia.exec();
1921 if ( res ) 1921 if ( res )
1922 retfile = lab.text(); 1922 retfile = lab.text();
1923 else 1923 else
1924 return; 1924 return;
1925 dia.hide(); 1925 dia.hide();
1926 passWordPiSync = lepw.text(); 1926 passWordPiSync = lepw.text();
1927 qApp->processEvents(); 1927 qApp->processEvents();
1928 KOPrefs::instance()->mPassiveSyncPort = retfile; 1928 KOPrefs::instance()->mPassiveSyncPort = retfile;
1929 bool ok; 1929 bool ok;
1930 Q_UINT16 port = retfile.toUInt(&ok); 1930 Q_UINT16 port = retfile.toUInt(&ok);
1931 if ( ! ok ) { 1931 if ( ! ok ) {
1932 KMessageBox::information( this, i18n("No valid port")); 1932 KMessageBox::information( this, i18n("No valid port"));
1933 return; 1933 return;
1934 } 1934 }
1935 //qDebug("port %d ", port); 1935 //qDebug("port %d ", port);
1936 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1936 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
1937 mServerSocket->setFileName( defaultFileName() ); 1937 mServerSocket->setFileName( defaultFileName() );
1938 //qDebug("connected "); 1938 //qDebug("connected ");
1939 if ( !mServerSocket->ok() ) { 1939 if ( !mServerSocket->ok() ) {
1940 qWarning("Failed to bind to port %d", port); 1940 qWarning("Failed to bind to port %d", port);
1941 delete mServerSocket; 1941 delete mServerSocket;
1942 mServerSocket = 0; 1942 mServerSocket = 0;
1943 return; 1943 return;
1944 } 1944 }
1945 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); 1945 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
1946 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); 1946 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
1947} 1947}
1948 1948
1949void MainWindow::getFile( bool success ) 1949void MainWindow::getFile( bool success )
1950{ 1950{
1951 if ( ! success ) { 1951 if ( ! success ) {
1952 setCaption( i18n("Error receiving file. Nothing changed!") ); 1952 setCaption( i18n("Error receiving file. Nothing changed!") );
1953 return; 1953 return;
1954 } 1954 }
1955 // pending adjust time for watchSavedFile() 1955 mView->watchSavedFile();
1956 //mView->watchSavedFile();
1957 mView->openCalendar( defaultFileName() ); 1956 mView->openCalendar( defaultFileName() );
1958 setCaption( i18n("Pi-Sync successful!") ); 1957 setCaption( i18n("Pi-Sync successful!") );
1959 1958
1960} 1959}
1961 1960
1962 1961
1963void MainWindow::syncPi() 1962void MainWindow::syncPi()
1964{ 1963{
1965 qApp->processEvents(); 1964 qApp->processEvents();
1966 performQuickQuick();
1967}
1968
1969void MainWindow::performQuickQuick()
1970{
1971 bool ok; 1965 bool ok;
1972 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 1966 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
1973 if ( ! ok ) { 1967 if ( ! ok ) {
1974 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1968 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1975 return; 1969 return;
1976 } 1970 }
1977 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); 1971 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
1978 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1972 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1979 setCaption( i18n("Sending request for remote file ...") ); 1973 setCaption( i18n("Sending request for remote file ...") );
1980 commandSocket->readFile( syncFileName() ); 1974 commandSocket->readFile( syncFileName() );
1981} 1975}
1976
1982void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) 1977void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
1983{ 1978{
1984 qDebug("MainWindow::deleteCommandSocket %d", state); 1979 qDebug("MainWindow::deleteCommandSocket %d", state);
1985 1980
1986 //enum { success, errorW, errorR, quiet }; 1981 //enum { success, errorW, errorR, quiet };
1987 if ( state == KCommandSocket::errorR ) { 1982 if ( state == KCommandSocket::errorR ) {
1988 setCaption( i18n("ERROR: Receiving remote file failed.") ); 1983 setCaption( i18n("ERROR: Receiving remote file failed.") );
1989 delete s; 1984 delete s;
1990 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 1985 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
1991 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1986 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1992 commandSocket->sendStop(); 1987 commandSocket->sendStop();
1993 return; 1988 return;
1994 1989
1995 } else if ( state == KCommandSocket::errorW ) { 1990 } else if ( state == KCommandSocket::errorW ) {
1996 setCaption( i18n("ERROR:Writing back file failed.") ); 1991 setCaption( i18n("ERROR:Writing back file failed.") );
1997 1992
1998 } else if ( state == KCommandSocket::successR ) { 1993 } else if ( state == KCommandSocket::successR ) {
1999 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1994 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
2000 1995
2001 } else if ( state == KCommandSocket::successW ) { 1996 } else if ( state == KCommandSocket::successW ) {
2002 setCaption( i18n("Pi-Sync succesful!") ); 1997 setCaption( i18n("Pi-Sync succesful!") );
2003 } 1998 }
2004 1999
2005 delete s; 2000 delete s;
2006} 2001}
2007 2002
2008void MainWindow::readFileFromSocket() 2003void MainWindow::readFileFromSocket()
2009{ 2004{
2010 QString fileName = syncFileName(); 2005 QString fileName = syncFileName();
2011 setCaption( i18n("Remote file saved to temp file.") ); 2006 setCaption( i18n("Remote file saved to temp file.") );
2012 if ( ! syncWithFile( fileName , true ) ) { 2007 if ( ! syncWithFile( fileName , true ) ) {
2013 setCaption( i18n("Syncing failed.") ); 2008 setCaption( i18n("Syncing failed.") );
2014 qDebug("Syncing failed "); 2009 qDebug("Syncing failed ");
2015 return; 2010 return;
2016 } 2011 }
2017 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2012 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2018 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2013 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2019 if ( KOPrefs::instance()->mWriteBackFile ) 2014 if ( KOPrefs::instance()->mWriteBackFile )
2020 commandSocket->writeFile( fileName ); 2015 commandSocket->writeFile( fileName );
2021 else { 2016 else {
2022 commandSocket->sendStop(); 2017 commandSocket->sendStop();
2023 setCaption( i18n("Pi-Sync succesful!") ); 2018 setCaption( i18n("Pi-Sync succesful!") );
2024 } 2019 }
2025} 2020}
2026 2021
2027void MainWindow::syncLocalFile() 2022void MainWindow::syncLocalFile()
2028{ 2023{
2029 2024
2030 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2025 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2031 2026
2032 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2027 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2033 if ( fn == "" ) 2028 if ( fn == "" )
2034 return; 2029 return;
2035 //mView->setSyncDevice("local-file" ); 2030 //mView->setSyncDevice("local-file" );
2036 if ( syncWithFile( fn, false ) ) { 2031 if ( syncWithFile( fn, false ) ) {
2037 // Event* e = mView->getLastSyncEvent(); 2032 // Event* e = mView->getLastSyncEvent();
2038// e->setReadOnly( false ); 2033// e->setReadOnly( false );
2039// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2034// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2040// e->setReadOnly( true ); 2035// e->setReadOnly( true );
2041 } 2036 }
2042 2037
2043} 2038}
2044 2039
2045bool MainWindow::syncWithFile( QString fn , bool quick ) 2040bool MainWindow::syncWithFile( QString fn , bool quick )
2046{ 2041{
2047 bool ret = false; 2042 bool ret = false;
2048 QFileInfo info; 2043 QFileInfo info;
2049 info.setFile( fn ); 2044 info.setFile( fn );
2050 QString mess; 2045 QString mess;
2051 bool loadbup = true; 2046 bool loadbup = true;
2052 if ( !info. exists() ) { 2047 if ( !info. exists() ) {
2053 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2048 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2054 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2049 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2055 mess ); 2050 mess );
2056 return ret; 2051 return ret;
2057 } 2052 }
2058 int result = 0; 2053 int result = 0;
2059 if ( !quick ) { 2054 if ( !quick ) {
2060 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2055 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2061 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2056 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2062 mess, 2057 mess,
2063 i18n("Sync"), i18n("Cancel"), 0, 2058 i18n("Sync"), i18n("Cancel"), 0,
2064 0, 1 ); 2059 0, 1 );
2065 if ( result ) 2060 if ( result )
2066 return false; 2061 return false;
2067 } 2062 }
2068 if ( KOPrefs::instance()->mAskForPreferences ) 2063 if ( KOPrefs::instance()->mAskForPreferences )
2069 mView->edit_sync_options(); 2064 mView->edit_sync_options();
2070 if ( result == 0 ) { 2065 if ( result == 0 ) {
2071 //qDebug("Now sycing ... "); 2066 //qDebug("Now sycing ... ");
2072 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2067 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2073 setCaption( i18n("Synchronization successful") ); 2068 setCaption( i18n("Synchronization successful") );
2074 else 2069 else
2075 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2070 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2076 if ( ! quick ) 2071 if ( ! quick )
2077 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2072 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2078 slotModifiedChanged( true ); 2073 slotModifiedChanged( true );
2079 } 2074 }
2080 return ret; 2075 return ret;
2081} 2076}
2082void MainWindow::quickSyncLocalFile() 2077void MainWindow::quickSyncLocalFile()
2083{ 2078{
2084 //mView->setSyncDevice("local-file" ); 2079 //mView->setSyncDevice("local-file" );
2085 //qDebug("quickSyncLocalFile() "); 2080 //qDebug("quickSyncLocalFile() ");
2086 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2081 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2087 // Event* e = mView->getLastSyncEvent(); 2082 // Event* e = mView->getLastSyncEvent();
2088// e->setReadOnly( false ); 2083// e->setReadOnly( false );
2089// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2084// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2090// e->setReadOnly( true ); 2085// e->setReadOnly( true );
2091 2086
2092 } 2087 }
2093} 2088}
2094 2089
2095void MainWindow::confSync() 2090void MainWindow::confSync()
2096{ 2091{
2097 mView->confSync(); 2092 mView->confSync();
2098 fillSyncMenu(); 2093 fillSyncMenu();
2099} 2094}
2100void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2095void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2101{ 2096{
2102 QString question; 2097 QString question;
2103 if ( ask ) { 2098 if ( ask ) {
2104 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2099 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2105 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2100 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2106 question, 2101 question,
2107 i18n("Yes"), i18n("No"), 2102 i18n("Yes"), i18n("No"),
2108 0, 0 ) != 0 ) 2103 0, 0 ) != 0 )
2109 return; 2104 return;
2110 } 2105 }
2111 QString command = prof->getPreSyncCommand(); 2106 QString command = prof->getPreSyncCommand();
2112 int fi; 2107 int fi;
2113 if ( (fi = command.find("$PWD$")) > 0 ) { 2108 if ( (fi = command.find("$PWD$")) > 0 ) {
2114 QString pwd = getPassword(); 2109 QString pwd = getPassword();
2115 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2110 command = command.left( fi )+ pwd + command.mid( fi+5 );
2116 2111
2117 } 2112 }
2118 int maxlen = 30; 2113 int maxlen = 30;
2119 if ( QApplication::desktop()->width() > 320 ) 2114 if ( QApplication::desktop()->width() > 320 )
2120 maxlen += 25; 2115 maxlen += 25;
2121 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2116 setCaption ( i18n( "Copy remote file to local machine..." ) );
2122 int fileSize = 0; 2117 int fileSize = 0;
2123 int result = system ( command ); 2118 int result = system ( command );
2124 // 0 : okay 2119 // 0 : okay
2125 // 256: no such file or dir 2120 // 256: no such file or dir
2126 // 2121 //
2127 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2122 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2128 if ( result != 0 ) { 2123 if ( result != 0 ) {
2129 int len = maxlen; 2124 int len = maxlen;
2130 while ( len < command.length() ) { 2125 while ( len < command.length() ) {
2131 command.insert( len , "\n" ); 2126 command.insert( len , "\n" );
2132 len += maxlen +2; 2127 len += maxlen +2;
2133 } 2128 }
2134 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2129 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2135 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2130 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2136 question, 2131 question,
2137 i18n("Okay!")) ; 2132 i18n("Okay!")) ;
2138 setCaption ("KO/Pi"); 2133 setCaption ("KO/Pi");
2139 return; 2134 return;
2140 } 2135 }
2141 setCaption ( i18n( "Copying succeed." ) ); 2136 setCaption ( i18n( "Copying succeed." ) );
2142 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2137 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2143 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2138 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2144// Event* e = mView->getLastSyncEvent(); 2139// Event* e = mView->getLastSyncEvent();
2145// e->setReadOnly( false ); 2140// e->setReadOnly( false );
2146// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2141// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2147// e->setReadOnly( true ); 2142// e->setReadOnly( true );
2148 if ( KOPrefs::instance()->mWriteBackFile ) { 2143 if ( KOPrefs::instance()->mWriteBackFile ) {
2149 command = prof->getPostSyncCommand(); 2144 command = prof->getPostSyncCommand();
2150 int fi; 2145 int fi;
2151 if ( (fi = command.find("$PWD$")) > 0 ) { 2146 if ( (fi = command.find("$PWD$")) > 0 ) {
2152 QString pwd = getPassword(); 2147 QString pwd = getPassword();
2153 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2148 command = command.left( fi )+ pwd + command.mid( fi+5 );
2154 2149
2155 } 2150 }
2156 setCaption ( i18n( "Writing back file ..." ) ); 2151 setCaption ( i18n( "Writing back file ..." ) );
2157 result = system ( command ); 2152 result = system ( command );
2158 qDebug("KO: Writing back file result: %d ", result); 2153 qDebug("KO: Writing back file result: %d ", result);
2159 if ( result != 0 ) { 2154 if ( result != 0 ) {
2160 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2155 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2161 return; 2156 return;
2162 } else { 2157 } else {
2163 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2158 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2164 } 2159 }
2165 } 2160 }
2166 } 2161 }
2167 return; 2162 return;
2168} 2163}
2169void MainWindow::syncSSH()
2170{
2171 // not used anymore
2172 QTime timer;
2173 timer.start();
2174 //qDebug("MainWindow::syncssh() ");
2175 KOPrefs *p = KOPrefs::instance();
2176 QString localFile = p->mLocalTempFile;
2177 QString remoteIP = p->mRemoteIP;
2178 QString remoteUser = p->mRemoteUser;
2179 QString remoteFile = p->mRemoteFile;
2180 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2181 remoteUser += ":" + p->mRemotePassWd;
2182
2183 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2184 i18n("IP: " ) +remoteIP +"\n" +
2185 i18n("User: " ) + remoteUser +"\n" ;
2186 int maxlen = 30;
2187 if ( QApplication::desktop()->width() > 320 )
2188 maxlen += 25;
2189 if ( remoteFile.length() > maxlen )
2190 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2191 else
2192 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2193 if ( localFile.length() > maxlen )
2194 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2195 else
2196 question += i18n("Local temp file:\n " ) + localFile +"\n";
2197
2198 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2199 question,
2200 i18n("Yes"), i18n("No"),
2201 0, 0 ) != 0 )
2202 return;
2203 // if ( !p->mUsePassWd ) {
2204 // QString pass = getPassword();
2205 // if ( pass.length() > 0 )
2206 // remoteUser += ":" + pass;
2207 // }
2208 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2209 setCaption ( i18n( "Copy remote file to local machine..." ) );
2210 int fileSize = 0;
2211 int result = system ( command );
2212 // 0 : okay
2213 // 256: no such file or dir
2214 //
2215 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2216 if ( result != 0 ) {
2217 int len = maxlen;
2218 while ( len < command.length() ) {
2219 command.insert( len , "\n" );
2220 len += maxlen +2;
2221 }
2222 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2223 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2224 question,
2225 i18n("Okay!")) ;
2226 setCaption ("KO/Pi");
2227 return;
2228 }
2229
2230
2231 setCaption ( i18n( "Copying succeed." ) );
2232 //mView->setSyncDevice("ssh-scp" );
2233 if ( syncWithFile(localFile , true ) ) {
2234// Event* e = mView->getLastSyncEvent();
2235// e->setReadOnly( false );
2236// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2237// e->setReadOnly( true );
2238 if ( KOPrefs::instance()->mWriteBackFile ) {
2239 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2240 setCaption ( i18n( "Writing back file ..." ) );
2241 result = system ( command );
2242 if ( result != 0 ) {
2243 int len = maxlen;
2244 while ( len < command.length() ) {
2245 command.insert( len , "\n" );
2246 len += maxlen +2;
2247 }
2248 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2249 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2250 question,
2251 i18n("Okay!")) ;
2252 setCaption ("KO/Pi");
2253 return;
2254 } else {
2255 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2256 }
2257 }
2258 }
2259 return;
2260#if 0
2261 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2262 while ( timer.elapsed() < 5000 )
2263 qApp->processEvents();
2264
2265 qDebug("MainWindow::merging) ");
2266 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2267 while ( mBlockSaveFlag )
2268 qApp->processEvents();
2269 save();
2270 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2271#endif
2272
2273}
2274
2275 2164
2276void MainWindow::syncSharp() 2165void MainWindow::syncSharp()
2277{ 2166{
2278 if ( mCalendarModifiedFlag ) 2167 if ( mCalendarModifiedFlag )
2279 save(); 2168 save();
2280 mView->syncSharp(); 2169 mView->syncSharp();
2281 slotModifiedChanged( true ); 2170 slotModifiedChanged( true );
2282 2171
2283} 2172}
2284void MainWindow::syncPhone() 2173void MainWindow::syncPhone()
2285{ 2174{
2286 if ( mCalendarModifiedFlag ) 2175 if ( mCalendarModifiedFlag )
2287 save(); 2176 save();
2288 mView->syncPhone(); 2177 mView->syncPhone();
2289 slotModifiedChanged( true ); 2178 slotModifiedChanged( true );
2290 2179
2291} 2180}
2292 2181
2293void MainWindow::printSel( ) 2182void MainWindow::printSel( )
2294{ 2183{
2295 mView->viewManager()->agendaView()->agenda()->printSelection(); 2184 mView->viewManager()->agendaView()->agenda()->printSelection();
2296} 2185}
2297 2186
2298void MainWindow::printCal() 2187void MainWindow::printCal()
2299{ 2188{
2300 mView->print();//mCp->showDialog(); 2189 mView->print();//mCp->showDialog();
2301} 2190}
2302 2191
2303 2192
2304 2193
2305KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2194KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2306{ 2195{
2307 mPassWord = pw; 2196 mPassWord = pw;
2308 mSocket = 0; 2197 mSocket = 0;
2309 mSyncActionDialog = 0; 2198 mSyncActionDialog = 0;
2310}; 2199};
2311 2200
2312void KServerSocket::newConnection ( int socket ) 2201void KServerSocket::newConnection ( int socket )
2313{ 2202{
2314 // qDebug("KServerSocket:New connection %d ", socket); 2203 // qDebug("KServerSocket:New connection %d ", socket);
2315 if ( mSocket ) { 2204 if ( mSocket ) {
2316 qDebug("KServerSocket::newConnection Socket deleted! "); 2205 qDebug("KServerSocket::newConnection Socket deleted! ");
2317 delete mSocket; 2206 delete mSocket;
2318 mSocket = 0; 2207 mSocket = 0;
2319 } 2208 }
2320 mSocket = new QSocket( this ); 2209 mSocket = new QSocket( this );
2321 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2210 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2322 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2211 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2323 mSocket->setSocket( socket ); 2212 mSocket->setSocket( socket );
2324} 2213}
2325 2214
2326void KServerSocket::discardClient() 2215void KServerSocket::discardClient()
2327{ 2216{
2328 //qDebug(" KServerSocket::discardClient()"); 2217 //qDebug(" KServerSocket::discardClient()");
2329 if ( mSocket ) { 2218 if ( mSocket ) {
2330 delete mSocket; 2219 delete mSocket;
2331 mSocket = 0; 2220 mSocket = 0;
2332 } 2221 }
2333 //emit endConnect(); 2222 //emit endConnect();
2334} 2223}
2335void KServerSocket::readClient() 2224void KServerSocket::readClient()
2336{ 2225{
2337 if ( mSocket == 0 ) { 2226 if ( mSocket == 0 ) {
2338 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2227 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2339 return; 2228 return;
2340 } 2229 }
2341 //qDebug("KServerSocket readClient()"); 2230 //qDebug("KServerSocket readClient()");
2342 if ( mSocket->canReadLine() ) { 2231 if ( mSocket->canReadLine() ) {
2343 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2232 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2344 if ( tokens[0] == "GET" ) { 2233 if ( tokens[0] == "GET" ) {
2345 if ( tokens[1] == mPassWord ) 2234 if ( tokens[1] == mPassWord )
2346 //emit sendFile( mSocket ); 2235 //emit sendFile( mSocket );
2347 send_file(); 2236 send_file();
2348 else { 2237 else {
2349 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2238 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2350 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2239 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2351 } 2240 }
2352 } 2241 }
2353 if ( tokens[0] == "PUT" ) { 2242 if ( tokens[0] == "PUT" ) {
2354 if ( tokens[1] == mPassWord ) 2243 if ( tokens[1] == mPassWord )
2355 //emit getFile( mSocket ); 2244 //emit getFile( mSocket );
2356 get_file(); 2245 get_file();
2357 else { 2246 else {
2358 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2247 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2359 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2248 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2360 } 2249 }
2361 } 2250 }
2362 if ( tokens[0] == "STOP" ) { 2251 if ( tokens[0] == "STOP" ) {
2363 //emit endConnect(); 2252 //emit endConnect();
2364 end_connect(); 2253 end_connect();
2365 } 2254 }
2366 } 2255 }
2367} 2256}
2368void KServerSocket::end_connect() 2257void KServerSocket::end_connect()
2369{ 2258{
2370 delete mSyncActionDialog; 2259 delete mSyncActionDialog;
2371 mSyncActionDialog = 0; 2260 mSyncActionDialog = 0;
2372} 2261}
2373void KServerSocket::send_file() 2262void KServerSocket::send_file()
2374{ 2263{
2375 //qDebug("MainWindow::sendFile(QSocket* s) "); 2264 //qDebug("MainWindow::sendFile(QSocket* s) ");
2376 if ( mSyncActionDialog ) 2265 if ( mSyncActionDialog )
2377 delete mSyncActionDialog; 2266 delete mSyncActionDialog;
2378 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 2267 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2379 mSyncActionDialog->setCaption(i18n("Received sync request")); 2268 mSyncActionDialog->setCaption(i18n("Received sync request"));
2380 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); 2269 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog );
2381 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 2270 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2382 lay->addWidget( label); 2271 lay->addWidget( label);
2383 lay->setMargin(7); 2272 lay->setMargin(7);
2384 lay->setSpacing(7); 2273 lay->setSpacing(7);
2385 mSyncActionDialog->setFixedSize( 230, 120); 2274 mSyncActionDialog->setFixedSize( 230, 120);
2386 mSyncActionDialog->show(); 2275 mSyncActionDialog->show();
2387 qDebug("KSS::saving ... "); 2276 qDebug("KSS::saving ... ");
2388 emit saveFile(); 2277 emit saveFile();
2389 qApp->processEvents(); 2278 qApp->processEvents();
2390 QString fileName = mFileName; 2279 QString fileName = mFileName;
2391 QFile file( fileName ); 2280 QFile file( fileName );
2392 if (!file.open( IO_ReadOnly ) ) { 2281 if (!file.open( IO_ReadOnly ) ) {
2393 delete mSyncActionDialog; 2282 delete mSyncActionDialog;
2394 mSyncActionDialog = 0; 2283 mSyncActionDialog = 0;
2395 qDebug("KSS::error open file "); 2284 qDebug("KSS::error open file ");
2396 mSocket->close(); 2285 mSocket->close();
2397 if ( mSocket->state() == QSocket::Idle ) 2286 if ( mSocket->state() == QSocket::Idle )
2398 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2287 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2399 return ; 2288 return ;
2400 2289
2401 } 2290 }
2402 mSyncActionDialog->setCaption( i18n("Sending file...") ); 2291 mSyncActionDialog->setCaption( i18n("Sending file...") );
2403 QTextStream ts( &file ); 2292 QTextStream ts( &file );
2404 ts.setCodec( QTextCodec::codecForName("utf8") ); 2293 ts.setCodec( QTextCodec::codecForName("utf8") );
2405 QTextStream os( mSocket ); 2294 QTextStream os( mSocket );
2406 os.setCodec( QTextCodec::codecForName("utf8") ); 2295 os.setCodec( QTextCodec::codecForName("utf8") );
2407 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2296 //os.setEncoding( QTextStream::UnicodeUTF8 );
2408 while ( ! ts.atEnd() ) { 2297 while ( ! ts.atEnd() ) {
2409 os << ts.readLine() << "\n"; 2298 os << ts.readLine() << "\n";
2410 } 2299 }
2411 //os << ts.read(); 2300 //os << ts.read();
2412 file.close(); 2301 file.close();
2413 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 2302 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2414 mSocket->close(); 2303 mSocket->close();
2415 if ( mSocket->state() == QSocket::Idle ) 2304 if ( mSocket->state() == QSocket::Idle )
2416 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2305 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2417} 2306}
2418void KServerSocket::get_file() 2307void KServerSocket::get_file()
2419{ 2308{
2420 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 2309 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2421 2310
2422 piTime.start(); 2311 piTime.start();
2423 piFileString = ""; 2312 piFileString = "";
2424 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 2313 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2425} 2314}
2426 2315
2427 2316
2428void KServerSocket::readBackFileFromSocket() 2317void KServerSocket::readBackFileFromSocket()
2429{ 2318{
2430 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2319 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2431 while ( mSocket->canReadLine () ) { 2320 while ( mSocket->canReadLine () ) {
2432 piTime.restart(); 2321 piTime.restart();
2433 QString line = mSocket->readLine (); 2322 QString line = mSocket->readLine ();
2434 piFileString += line; 2323 piFileString += line;
2435 //qDebug("readline: %s ", line.latin1()); 2324 //qDebug("readline: %s ", line.latin1());
2436 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2325 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2437 2326
2438 } 2327 }
2439 if ( piTime.elapsed () < 3000 ) { 2328 if ( piTime.elapsed () < 3000 ) {
2440 // wait for more 2329 // wait for more
2441 //qDebug("waitformore "); 2330 //qDebug("waitformore ");
2442 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2331 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2443 return; 2332 return;
2444 } 2333 }
2445 QString fileName = mFileName; 2334 QString fileName = mFileName;
2446 QFile file ( fileName ); 2335 QFile file ( fileName );
2447 if (!file.open( IO_WriteOnly ) ) { 2336 if (!file.open( IO_WriteOnly ) ) {
2448 delete mSyncActionDialog; 2337 delete mSyncActionDialog;
2449 mSyncActionDialog = 0; 2338 mSyncActionDialog = 0;
2450 qDebug("error open cal file "); 2339 qDebug("error open cal file ");
2451 piFileString = ""; 2340 piFileString = "";
2452 emit file_received( false ); 2341 emit file_received( false );
2453 return ; 2342 return ;
2454 2343
2455 } 2344 }
2456 2345
2457 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2346 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2458 QTextStream ts ( &file ); 2347 QTextStream ts ( &file );
2459 ts.setCodec( QTextCodec::codecForName("utf8") ); 2348 ts.setCodec( QTextCodec::codecForName("utf8") );
2460 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 2349 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2461 ts << piFileString; 2350 ts << piFileString;
2462 mSocket->close(); 2351 mSocket->close();
2463 if ( mSocket->state() == QSocket::Idle ) 2352 if ( mSocket->state() == QSocket::Idle )
2464 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2353 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2465 file.close(); 2354 file.close();
2466 delete mSyncActionDialog; 2355 delete mSyncActionDialog;
2467 mSyncActionDialog = 0; 2356 mSyncActionDialog = 0;
2468 piFileString = ""; 2357 piFileString = "";
2469 emit file_received( true ); 2358 emit file_received( true );
2470 2359
2471} 2360}
2472 2361
2473KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 2362KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2474{ 2363{
2475 mPassWord = password; 2364 mPassWord = password;
2476 mSocket = 0; 2365 mSocket = 0;
2477 mPort = port; 2366 mPort = port;
2478 mHost = host; 2367 mHost = host;
2479 2368
2480 mRetVal = quiet; 2369 mRetVal = quiet;
2481 mTimerSocket = new QTimer ( this ); 2370 mTimerSocket = new QTimer ( this );
2482 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 2371 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2483} 2372}
2484void KCommandSocket::readFile( QString fn ) 2373void KCommandSocket::readFile( QString fn )
2485{ 2374{
2486 if ( !mSocket ) { 2375 if ( !mSocket ) {
2487 mSocket = new QSocket( this ); 2376 mSocket = new QSocket( this );
2488 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 2377 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2489 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2378 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2490 } 2379 }
2491 mFileString = ""; 2380 mFileString = "";
2492 mFileName = fn; 2381 mFileName = fn;
2493 mFirst = true; 2382 mFirst = true;
2494 mSocket->connectToHost( mHost, mPort ); 2383 mSocket->connectToHost( mHost, mPort );
2495 QTextStream os( mSocket ); 2384 QTextStream os( mSocket );
2496 os.setEncoding( QTextStream::UnicodeUTF8 ); 2385 os.setEncoding( QTextStream::UnicodeUTF8 );
2497 os << "GET " << mPassWord << "\r\n"; 2386 os << "GET " << mPassWord << "\r\n";
2498 mTimerSocket->start( 10000 ); 2387 mTimerSocket->start( 10000 );
2499} 2388}
2500 2389
2501void KCommandSocket::writeFile( QString fileName ) 2390void KCommandSocket::writeFile( QString fileName )
2502{ 2391{
2503 if ( !mSocket ) { 2392 if ( !mSocket ) {
2504 mSocket = new QSocket( this ); 2393 mSocket = new QSocket( this );
2505 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2394 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2506 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 2395 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2507 } 2396 }
2508 mFileName = fileName ; 2397 mFileName = fileName ;
2509 mSocket->connectToHost( mHost, mPort ); 2398 mSocket->connectToHost( mHost, mPort );
2510} 2399}
2511void KCommandSocket::writeFileToSocket() 2400void KCommandSocket::writeFileToSocket()
2512{ 2401{
2513 QFile file2( mFileName ); 2402 QFile file2( mFileName );
2514 if (!file2.open( IO_ReadOnly ) ) { 2403 if (!file2.open( IO_ReadOnly ) ) {
2515 mRetVal= errorW; 2404 mRetVal= errorW;
2516 mSocket->close(); 2405 mSocket->close();
2517 if ( mSocket->state() == QSocket::Idle ) 2406 if ( mSocket->state() == QSocket::Idle )
2518 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2407 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2519 return ; 2408 return ;
2520 } 2409 }
2521 QTextStream ts2( &file2 ); 2410 QTextStream ts2( &file2 );
2522 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2411 ts2.setCodec( QTextCodec::codecForName("utf8") );
2523 QTextStream os2( mSocket ); 2412 QTextStream os2( mSocket );
2524 os2.setCodec( QTextCodec::codecForName("utf8") ); 2413 os2.setCodec( QTextCodec::codecForName("utf8") );
2525 os2 << "PUT " << mPassWord << "\r\n";; 2414 os2 << "PUT " << mPassWord << "\r\n";;
2526 while ( ! ts2.atEnd() ) { 2415 while ( ! ts2.atEnd() ) {
2527 os2 << ts2.readLine() << "\n"; 2416 os2 << ts2.readLine() << "\n";
2528 } 2417 }
2529 mRetVal= successW; 2418 mRetVal= successW;
2530 file2.close(); 2419 file2.close();
2531 mSocket->close(); 2420 mSocket->close();
2532 if ( mSocket->state() == QSocket::Idle ) 2421 if ( mSocket->state() == QSocket::Idle )
2533 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2422 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2534} 2423}
2535void KCommandSocket::sendStop() 2424void KCommandSocket::sendStop()
2536{ 2425{
2537 if ( !mSocket ) { 2426 if ( !mSocket ) {
2538 mSocket = new QSocket( this ); 2427 mSocket = new QSocket( this );
2539 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2428 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2540 } 2429 }
2541 mSocket->connectToHost( mHost, mPort ); 2430 mSocket->connectToHost( mHost, mPort );
2542 QTextStream os2( mSocket ); 2431 QTextStream os2( mSocket );
2543 os2.setCodec( QTextCodec::codecForName("utf8") ); 2432 os2.setCodec( QTextCodec::codecForName("utf8") );
2544 os2 << "STOP\r\n"; 2433 os2 << "STOP\r\n";
2545 mSocket->close(); 2434 mSocket->close();
2546 if ( mSocket->state() == QSocket::Idle ) 2435 if ( mSocket->state() == QSocket::Idle )
2547 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2436 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2548} 2437}
2549 2438
2550void KCommandSocket::startReadFileFromSocket() 2439void KCommandSocket::startReadFileFromSocket()
2551{ 2440{
2552 if ( ! mFirst ) 2441 if ( ! mFirst )
2553 return; 2442 return;
2554 mFirst = false; 2443 mFirst = false;
2555 mTimerSocket->stop(); 2444 mTimerSocket->stop();
2556 mFileString = ""; 2445 mFileString = "";
2557 mTime.start(); 2446 mTime.start();
2558 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 2447 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2559 2448
2560} 2449}
2561void KCommandSocket::readFileFromSocket() 2450void KCommandSocket::readFileFromSocket()
2562{ 2451{
2563 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 2452 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2564 while ( mSocket->canReadLine () ) { 2453 while ( mSocket->canReadLine () ) {
2565 mTime.restart(); 2454 mTime.restart();
2566 QString line = mSocket->readLine (); 2455 QString line = mSocket->readLine ();
2567 mFileString += line; 2456 mFileString += line;
2568 //qDebug("readline: %s ", line.latin1()); 2457 //qDebug("readline: %s ", line.latin1());
2569 } 2458 }
2570 if ( mTime.elapsed () < 3000 ) { 2459 if ( mTime.elapsed () < 3000 ) {
2571 // wait for more 2460 // wait for more
2572 //qDebug("waitformore "); 2461 //qDebug("waitformore ");
2573 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 2462 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2574 return; 2463 return;
2575 } 2464 }
2576 QString fileName = mFileName; 2465 QString fileName = mFileName;
2577 QFile file ( fileName ); 2466 QFile file ( fileName );
2578 if (!file.open( IO_WriteOnly ) ) { 2467 if (!file.open( IO_WriteOnly ) ) {
2579 mFileString = ""; 2468 mFileString = "";
2580 mRetVal = errorR; 2469 mRetVal = errorR;
2581 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2470 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2582 deleteSocket(); 2471 deleteSocket();
2583 return ; 2472 return ;
2584 2473
2585 } 2474 }
2586 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2475 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2587 QTextStream ts ( &file ); 2476 QTextStream ts ( &file );
2588 ts.setCodec( QTextCodec::codecForName("utf8") ); 2477 ts.setCodec( QTextCodec::codecForName("utf8") );
2589 ts << mFileString; 2478 ts << mFileString;
2590 file.close(); 2479 file.close();
2591 mFileString = ""; 2480 mFileString = "";
2592 mRetVal = successR; 2481 mRetVal = successR;
2593 mSocket->close(); 2482 mSocket->close();
2594 // if state is not idle, deleteSocket(); is called via 2483 // if state is not idle, deleteSocket(); is called via
2595 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2484 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2596 if ( mSocket->state() == QSocket::Idle ) 2485 if ( mSocket->state() == QSocket::Idle )
2597 deleteSocket(); 2486 deleteSocket();
2598} 2487}
2599 2488
2600void KCommandSocket::deleteSocket() 2489void KCommandSocket::deleteSocket()
2601{ 2490{
2602 if ( mTimerSocket->isActive () ) { 2491 if ( mTimerSocket->isActive () ) {
2603 mTimerSocket->stop(); 2492 mTimerSocket->stop();
2604 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 2493 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2605 mRetVal = errorR; 2494 mRetVal = errorR;
2606 } 2495 }
2607 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 2496 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2608 if ( mSocket) 2497 if ( mSocket)
2609 delete mSocket; 2498 delete mSocket;
2610 mSocket = 0; 2499 mSocket = 0;
2611 emit commandFinished( this, mRetVal ); 2500 emit commandFinished( this, mRetVal );
2612} 2501}
2613 2502
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 4da371e..ba627b9 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,210 +1,208 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qsocket.h> 8#include <qsocket.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h> 24#include <qserversocket.h>
25#include <qsocket.h> 25#include <qsocket.h>
26#include <qnetworkprotocol.h> 26#include <qnetworkprotocol.h>
27 27
28class KServerSocket : public QServerSocket 28class KServerSocket : public QServerSocket
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32public: 32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34 34
35 void newConnection ( int socket ) ; 35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;}; 36 void setFileName( QString fn ) {mFileName = fn;};
37 37
38signals: 38signals:
39 //void sendFile(QSocket*); 39 //void sendFile(QSocket*);
40 //void getFile(QSocket*); 40 //void getFile(QSocket*);
41 void file_received( bool ); 41 void file_received( bool );
42 //void file_sent(); 42 //void file_sent();
43 void saveFile(); 43 void saveFile();
44 void endConnect(); 44 void endConnect();
45private slots: 45private slots:
46 void discardClient(); 46 void discardClient();
47 void readClient(); 47 void readClient();
48 void readBackFileFromSocket(); 48 void readBackFileFromSocket();
49 private : 49 private :
50 void send_file(); 50 void send_file();
51 void get_file(); 51 void get_file();
52 void end_connect(); 52 void end_connect();
53 QDialog* mSyncActionDialog; 53 QDialog* mSyncActionDialog;
54 QSocket* mSocket; 54 QSocket* mSocket;
55 QString mPassWord; 55 QString mPassWord;
56 QString mFileName; 56 QString mFileName;
57 QTime piTime; 57 QTime piTime;
58 QString piFileString; 58 QString piFileString;
59}; 59};
60 60
61class KCommandSocket : public QObject 61class KCommandSocket : public QObject
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 enum state { successR, errorR, successW, errorW, quiet }; 65 enum state { successR, errorR, successW, errorW, quiet };
66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
67 void readFile( QString ); 67 void readFile( QString );
68 void writeFile( QString ); 68 void writeFile( QString );
69 void sendStop(); 69 void sendStop();
70 70
71 71
72signals: 72signals:
73 void commandFinished( KCommandSocket*, int ); 73 void commandFinished( KCommandSocket*, int );
74private slots: 74private slots:
75 void startReadFileFromSocket(); 75 void startReadFileFromSocket();
76 void readFileFromSocket(); 76 void readFileFromSocket();
77 void deleteSocket(); 77 void deleteSocket();
78 void writeFileToSocket(); 78 void writeFileToSocket();
79 private : 79 private :
80 QSocket* mSocket; 80 QSocket* mSocket;
81 QString mPassWord; 81 QString mPassWord;
82 Q_UINT16 mPort; 82 Q_UINT16 mPort;
83 QString mHost; 83 QString mHost;
84 QString mFileName; 84 QString mFileName;
85 QTimer* mTimerSocket; 85 QTimer* mTimerSocket;
86 int mRetVal; 86 int mRetVal;
87 QTime mTime; 87 QTime mTime;
88 QString mFileString; 88 QString mFileString;
89 bool mFirst; 89 bool mFirst;
90}; 90};
91 91
92namespace KCal { 92namespace KCal {
93class CalendarLocal; 93class CalendarLocal;
94} 94}
95 95
96using namespace KCal; 96using namespace KCal;
97 97
98class MainWindow : public QMainWindow 98class MainWindow : public QMainWindow
99{ 99{
100 Q_OBJECT 100 Q_OBJECT
101 public: 101 public:
102 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 102 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
103 ~MainWindow(); 103 ~MainWindow();
104 public slots: 104 public slots:
105 virtual void showMaximized (); 105 virtual void showMaximized ();
106 void configureAgenda( int ); 106 void configureAgenda( int );
107 void recieve( const QCString& msg, const QByteArray& data ); 107 void recieve( const QCString& msg, const QByteArray& data );
108 static QString defaultFileName(); 108 static QString defaultFileName();
109 static QString syncFileName(); 109 static QString syncFileName();
110 static QString resourcePath(); 110 static QString resourcePath();
111 protected slots: 111 protected slots:
112 void setCaptionToDates(); 112 void setCaptionToDates();
113 int ringSync(); 113 int ringSync();
114 void multiSync( bool askforPrefs = false ); 114 void multiSync( bool askforPrefs = false );
115 void about(); 115 void about();
116 void licence(); 116 void licence();
117 void faq(); 117 void faq();
118 void usertrans(); 118 void usertrans();
119 void features(); 119 void features();
120 void synchowto(); 120 void synchowto();
121 void whatsNew(); 121 void whatsNew();
122 void keyBindings(); 122 void keyBindings();
123 void aboutAutoSaving();; 123 void aboutAutoSaving();;
124 void aboutKnownBugs(); 124 void aboutKnownBugs();
125 125
126 void processIncidenceSelection( Incidence * ); 126 void processIncidenceSelection( Incidence * );
127 127
128 void importQtopia(); 128 void importQtopia();
129 void importBday(); 129 void importBday();
130 void importOL(); 130 void importOL();
131 void importIcal(); 131 void importIcal();
132 void importFile( QString, bool ); 132 void importFile( QString, bool );
133 void quickImportIcal(); 133 void quickImportIcal();
134 134
135 void slotModifiedChanged( bool ); 135 void slotModifiedChanged( bool );
136 136
137 void save(); 137 void save();
138 void configureToolBar( int ); 138 void configureToolBar( int );
139 void printSel(); 139 void printSel();
140 void printCal(); 140 void printCal();
141 void saveCalendar(); 141 void saveCalendar();
142 void loadCalendar(); 142 void loadCalendar();
143 void exportVCalendar(); 143 void exportVCalendar();
144 void fillFilterMenu(); 144 void fillFilterMenu();
145 void selectFilter( int ); 145 void selectFilter( int );
146 146
147 void slotSyncMenu( int ); 147 void slotSyncMenu( int );
148 void syncSSH();
149 void confSync(); 148 void confSync();
150 void syncSharp(); 149 void syncSharp();
151 void syncPhone(); 150 void syncPhone();
152 void syncPi(); 151 void syncPi();
153 void syncLocalFile(); 152 void syncLocalFile();
154 bool syncWithFile( QString, bool ); 153 bool syncWithFile( QString, bool );
155 void quickSyncLocalFile(); 154 void quickSyncLocalFile();
156 155
157 156
158 protected: 157 protected:
159 void displayText( QString, QString); 158 void displayText( QString, QString);
160 void displayFile( QString, QString); 159 void displayFile( QString, QString);
161 160
162 void enableIncidenceActions( bool ); 161 void enableIncidenceActions( bool );
163 162
164 private slots: 163 private slots:
165 QSocket* piSocket; 164 QSocket* piSocket;
166 QString piFileString; 165 QString piFileString;
167 QTime piTime; 166 QTime piTime;
168 void deleteCommandSocket(KCommandSocket* s, int state ); 167 void deleteCommandSocket(KCommandSocket* s, int state );
169 void fillSyncMenu(); 168 void fillSyncMenu();
170 void getFile( bool ); 169 void getFile( bool );
171 void readFileFromSocket(); 170 void readFileFromSocket();
172 private: 171 private:
173 //QTimer* mTimerCommandSocket; 172 //QTimer* mTimerCommandSocket;
174 QString mPassWordPiSync; 173 QString mPassWordPiSync;
175 KServerSocket * mServerSocket; 174 KServerSocket * mServerSocket;
176 bool mClosed; 175 bool mClosed;
177 void saveOnClose(); 176 void saveOnClose();
178 int mCurrentSyncProfile; 177 int mCurrentSyncProfile;
179 void enableQuick(); 178 void enableQuick();
180 void performQuickQuick();
181 void syncRemote( KSyncProfile* , bool ask = true); 179 void syncRemote( KSyncProfile* , bool ask = true);
182 bool mFlagKeyPressed; 180 bool mFlagKeyPressed;
183 bool mBlockAtStartup; 181 bool mBlockAtStartup;
184 QPEToolBar *iconToolBar; 182 QPEToolBar *iconToolBar;
185 void initActions(); 183 void initActions();
186 void setDefaultPreferences(); 184 void setDefaultPreferences();
187 void keyPressEvent ( QKeyEvent * ) ; 185 void keyPressEvent ( QKeyEvent * ) ;
188 void keyReleaseEvent ( QKeyEvent * ) ; 186 void keyReleaseEvent ( QKeyEvent * ) ;
189 QPopupMenu *configureToolBarMenu; 187 QPopupMenu *configureToolBarMenu;
190 QPopupMenu *selectFilterMenu; 188 QPopupMenu *selectFilterMenu;
191 QPopupMenu *configureAgendaMenu, *syncMenu; 189 QPopupMenu *configureAgendaMenu, *syncMenu;
192 CalendarLocal *mCalendar; 190 CalendarLocal *mCalendar;
193 CalendarView *mView; 191 CalendarView *mView;
194 QString getPassword(); 192 QString getPassword();
195 QAction *mNewSubTodoAction; 193 QAction *mNewSubTodoAction;
196 194
197 QAction *mShowAction; 195 QAction *mShowAction;
198 QAction *mEditAction; 196 QAction *mEditAction;
199 QAction *mDeleteAction; 197 QAction *mDeleteAction;
200 void closeEvent( QCloseEvent* ce ); 198 void closeEvent( QCloseEvent* ce );
201 SimpleAlarmClient mAlarmClient; 199 SimpleAlarmClient mAlarmClient;
202 QTimer mSaveTimer; 200 QTimer mSaveTimer;
203 bool mBlockSaveFlag; 201 bool mBlockSaveFlag;
204 bool mCalendarModifiedFlag; 202 bool mCalendarModifiedFlag;
205 QPixmap loadPixmap( QString ); 203 QPixmap loadPixmap( QString );
206 QDialog * mSyncActionDialog; 204 QDialog * mSyncActionDialog;
207}; 205};
208 206
209 207
210#endif 208#endif
diff --git a/libkcal/calstorage.h b/libkcal/calstorage.h
index 72972ea..82c8682 100644
--- a/libkcal/calstorage.h
+++ b/libkcal/calstorage.h
@@ -1,52 +1,52 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_CALSTORAGE_H 20#ifndef KCAL_CALSTORAGE_H
21#define KCAL_CALSTORAGE_H 21#define KCAL_CALSTORAGE_H
22 22
23namespace KCal { 23namespace KCal {
24 24
25class Calendar; 25class Calendar;
26 26
27/** 27/**
28 This class provides the interface to the storage of a calendar. 28 This class provides the interface to the storage of a calendar.
29*/ 29*/
30class CalStorage 30class CalStorage
31{ 31{
32 public: 32 public:
33 CalStorage( Calendar *calendar ) 33 CalStorage( Calendar *calendar )
34 { 34 {
35 mCalendar = calendar; 35 mCalendar = calendar;
36 } 36 }
37 virtual ~CalStorage() {} 37 virtual ~CalStorage() {}
38 38
39 Calendar *calendar() const { return mCalendar; } 39 Calendar *calendar() const { return mCalendar; }
40 40
41 virtual bool open() = 0; 41 virtual bool open() = 0;
42 virtual bool load(bool = false ) = 0; 42 virtual bool load( ) = 0;
43 virtual bool save() = 0; 43 virtual bool save() = 0;
44 virtual bool close() = 0; 44 virtual bool close() = 0;
45 45
46 private: 46 private:
47 Calendar *mCalendar; 47 Calendar *mCalendar;
48}; 48};
49 49
50} 50}
51 51
52#endif 52#endif
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp
index 00c15d9..a139124 100644
--- a/libkcal/filestorage.cpp
+++ b/libkcal/filestorage.cpp
@@ -1,140 +1,140 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28 28
29#include "calendar.h" 29#include "calendar.h"
30#include "vcaldrag.h" 30#include "vcaldrag.h"
31#include "vcalformat.h" 31#include "vcalformat.h"
32#include "icalformat.h" 32#include "icalformat.h"
33 33
34#include "filestorage.h" 34#include "filestorage.h"
35 35
36using namespace KCal; 36using namespace KCal;
37 37
38FileStorage::FileStorage( Calendar *cal, const QString &fileName, 38FileStorage::FileStorage( Calendar *cal, const QString &fileName,
39 CalFormat *format ) 39 CalFormat *format )
40 : CalStorage( cal ), 40 : CalStorage( cal ),
41 mFileName( fileName ), 41 mFileName( fileName ),
42 mSaveFormat( format ) 42 mSaveFormat( format )
43{ 43{
44} 44}
45 45
46FileStorage::~FileStorage() 46FileStorage::~FileStorage()
47{ 47{
48 delete mSaveFormat; 48 delete mSaveFormat;
49} 49}
50 50
51void FileStorage::setFileName( const QString &fileName ) 51void FileStorage::setFileName( const QString &fileName )
52{ 52{
53 mFileName = fileName; 53 mFileName = fileName;
54} 54}
55 55
56QString FileStorage::fileName()const 56QString FileStorage::fileName()const
57{ 57{
58 return mFileName; 58 return mFileName;
59} 59}
60 60
61 61
62void FileStorage::setSaveFormat( CalFormat *format ) 62void FileStorage::setSaveFormat( CalFormat *format )
63{ 63{
64 delete mSaveFormat; 64 delete mSaveFormat;
65 mSaveFormat = format; 65 mSaveFormat = format;
66} 66}
67 67
68CalFormat *FileStorage::saveFormat()const 68CalFormat *FileStorage::saveFormat()const
69{ 69{
70 return mSaveFormat; 70 return mSaveFormat;
71} 71}
72 72
73 73
74bool FileStorage::open() 74bool FileStorage::open()
75{ 75{
76 return true; 76 return true;
77} 77}
78 78
79bool FileStorage::load( bool quick ) 79bool FileStorage::load( )
80{ 80{
81 kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl; 81 kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl;
82 82
83 // do we want to silently accept this, or make some noise? Dunno... 83 // do we want to silently accept this, or make some noise? Dunno...
84 // it is a semantical thing vs. a practical thing. 84 // it is a semantical thing vs. a practical thing.
85 if (mFileName.isEmpty()) return false; 85 if (mFileName.isEmpty()) return false;
86 86
87 // Always try to load with iCalendar. It will detect, if it is actually a 87 // Always try to load with iCalendar. It will detect, if it is actually a
88 // vCalendar file. 88 // vCalendar file.
89 ICalFormat iCal (quick ); 89 ICalFormat iCal;
90 90
91 bool success = iCal.load( calendar(), mFileName); 91 bool success = iCal.load( calendar(), mFileName);
92 92
93 if ( !success ) { 93 if ( !success ) {
94 if ( iCal.exception() ) { 94 if ( iCal.exception() ) {
95// kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl; 95// kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl;
96 if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) { 96 if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) {
97 // Expected non vCalendar file, but detected vCalendar 97 // Expected non vCalendar file, but detected vCalendar
98 kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl; 98 kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl;
99 VCalFormat vCal; 99 VCalFormat vCal;
100 success = vCal.load( calendar(), mFileName ); 100 success = vCal.load( calendar(), mFileName );
101 calendar()->setLoadedProductId( vCal.productId() ); 101 calendar()->setLoadedProductId( vCal.productId() );
102 } else { 102 } else {
103 return false; 103 return false;
104 } 104 }
105 } else { 105 } else {
106 kdDebug(5800) << "Warning! There should be set an exception." << endl; 106 kdDebug(5800) << "Warning! There should be set an exception." << endl;
107 return false; 107 return false;
108 } 108 }
109 } else { 109 } else {
110// kdDebug(5800) << "---Success" << endl; 110// kdDebug(5800) << "---Success" << endl;
111 calendar()->setLoadedProductId( iCal.loadedProductId() ); 111 calendar()->setLoadedProductId( iCal.loadedProductId() );
112 } 112 }
113 113
114 calendar()->setModified( false ); 114 calendar()->setModified( false );
115 115
116 return true; 116 return true;
117} 117}
118 118
119bool FileStorage::save() 119bool FileStorage::save()
120{ 120{
121 if ( mFileName.isEmpty() ) return false; 121 if ( mFileName.isEmpty() ) return false;
122 122
123 bool success; 123 bool success;
124 124
125 if ( mSaveFormat ) { 125 if ( mSaveFormat ) {
126 success = mSaveFormat->save( calendar(), mFileName); 126 success = mSaveFormat->save( calendar(), mFileName);
127 } else { 127 } else {
128 ICalFormat iCal; 128 ICalFormat iCal;
129 success = iCal.save( calendar(), mFileName); 129 success = iCal.save( calendar(), mFileName);
130 } 130 }
131 131
132 if ( success ) calendar()->setModified( false ); 132 if ( success ) calendar()->setModified( false );
133 133
134 return success; 134 return success;
135} 135}
136 136
137bool FileStorage::close() 137bool FileStorage::close()
138{ 138{
139 return true; 139 return true;
140} 140}
diff --git a/libkcal/filestorage.h b/libkcal/filestorage.h
index e9dc15e..17010ac 100644
--- a/libkcal/filestorage.h
+++ b/libkcal/filestorage.h
@@ -1,58 +1,58 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_FILESTORAGE_H 20#ifndef KCAL_FILESTORAGE_H
21#define KCAL_FILESTORAGE_H 21#define KCAL_FILESTORAGE_H
22 22
23#include "calstorage.h" 23#include "calstorage.h"
24 24
25namespace KCal { 25namespace KCal {
26 26
27/** 27/**
28 This class provides a calendar storage as a local file. 28 This class provides a calendar storage as a local file.
29*/ 29*/
30class FileStorage : public CalStorage 30class FileStorage : public CalStorage
31{ 31{
32 public: 32 public:
33 FileStorage( Calendar *, const QString &fileName = QString::null, 33 FileStorage( Calendar *, const QString &fileName = QString::null,
34 CalFormat *format = 0 ); 34 CalFormat *format = 0 );
35 virtual ~FileStorage(); 35 virtual ~FileStorage();
36 36
37 void setFileName( const QString &mFileName ); 37 void setFileName( const QString &mFileName );
38 QString fileName()const; 38 QString fileName()const;
39 39
40 /** 40 /**
41 FileStorage takes ownership of format object. 41 FileStorage takes ownership of format object.
42 */ 42 */
43 void setSaveFormat( CalFormat * ); 43 void setSaveFormat( CalFormat * );
44 CalFormat *saveFormat()const; 44 CalFormat *saveFormat()const;
45 45
46 bool open(); 46 bool open();
47 bool load(bool quick = false ); 47 bool load( );
48 bool save(); 48 bool save();
49 bool close(); 49 bool close();
50 50
51 private: 51 private:
52 QString mFileName; 52 QString mFileName;
53 CalFormat *mSaveFormat; 53 CalFormat *mSaveFormat;
54}; 54};
55 55
56} 56}
57 57
58#endif 58#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index f2e7dfc..3a2aac6 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -1,480 +1,460 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qclipboard.h> 25#include <qclipboard.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qtextcodec.h> 28#include <qtextcodec.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35extern "C" { 35extern "C" {
36 #include <ical.h> 36 #include <ical.h>
37 #include <icalss.h> 37 #include <icalss.h>
38 #include <icalparser.h> 38 #include <icalparser.h>
39 #include <icalrestriction.h> 39 #include <icalrestriction.h>
40} 40}
41 41
42#include "calendar.h" 42#include "calendar.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44#include "journal.h" 44#include "journal.h"
45 45
46#include "icalformat.h" 46#include "icalformat.h"
47#include "icalformatimpl.h" 47#include "icalformatimpl.h"
48 48
49#define _ICAL_VERSION "2.0" 49#define _ICAL_VERSION "2.0"
50 50
51using namespace KCal; 51using namespace KCal;
52 52
53ICalFormat::ICalFormat(bool quick ) 53ICalFormat::ICalFormat( )
54{ 54{
55 mQuicksave = false; //quick;
56 mImpl = new ICalFormatImpl( this ); 55 mImpl = new ICalFormatImpl( this );
57 tzOffsetMin = 0; 56 tzOffsetMin = 0;
58 //qDebug("new ICalFormat() "); 57 //qDebug("new ICalFormat() ");
59} 58}
60 59
61ICalFormat::~ICalFormat() 60ICalFormat::~ICalFormat()
62{ 61{
63 delete mImpl; 62 delete mImpl;
64 //qDebug("delete ICalFormat "); 63 //qDebug("delete ICalFormat ");
65} 64}
66 65
67bool ICalFormat::load( Calendar *calendar, const QString &fileName) 66bool ICalFormat::load( Calendar *calendar, const QString &fileName)
68{ 67{
69 68
70 clearException(); 69 clearException();
71 70
72 QFile file( fileName ); 71 QFile file( fileName );
73 if (!file.open( IO_ReadOnly ) ) { 72 if (!file.open( IO_ReadOnly ) ) {
74 setException(new ErrorFormat(ErrorFormat::LoadError)); 73 setException(new ErrorFormat(ErrorFormat::LoadError));
75 return false; 74 return false;
76 } 75 }
77 QTextStream ts( &file ); 76 QTextStream ts( &file );
78 QString text; 77 QString text;
79#if 0 78
80 if ( !mQuicksave ) {
81 qDebug("KO: No quickload!");
82 ts.setEncoding( QTextStream::Latin1 );
83 text = ts.read();
84 } else {
85 ts.setCodec( QTextCodec::codecForName("utf8") );
86 text = ts.read();
87 }
88#endif
89 ts.setEncoding( QTextStream::Latin1 ); 79 ts.setEncoding( QTextStream::Latin1 );
90 text = ts.read(); 80 text = ts.read();
91 file.close(); 81 file.close();
92 82
93 return fromString( calendar, text ); 83 return fromString( calendar, text );
94} 84}
95 85
96//#include <qdatetime.h> 86//#include <qdatetime.h>
97bool ICalFormat::save( Calendar *calendar, const QString &fileName ) 87bool ICalFormat::save( Calendar *calendar, const QString &fileName )
98{ 88{
99 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl; 89 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl;
100 //qDebug("ICalFormat::save "); 90 //qDebug("ICalFormat::save ");
101 clearException(); 91 clearException();
102 QString text = toString( calendar ); 92 QString text = toString( calendar );
103 //return false; 93 //return false;
104 // qDebug("to string takes ms: %d ",is.elapsed() ); 94 // qDebug("to string takes ms: %d ",is.elapsed() );
105 if ( text.isNull() ) return false; 95 if ( text.isNull() ) return false;
106 96
107 // TODO: write backup file 97 // TODO: write backup file
108 //is.restart(); 98 //is.restart();
109 QFile file( fileName ); 99 QFile file( fileName );
110 if (!file.open( IO_WriteOnly ) ) { 100 if (!file.open( IO_WriteOnly ) ) {
111 setException(new ErrorFormat(ErrorFormat::SaveError, 101 setException(new ErrorFormat(ErrorFormat::SaveError,
112 i18n("Could not open file '%1'").arg(fileName))); 102 i18n("Could not open file '%1'").arg(fileName)));
113 return false; 103 return false;
114 } 104 }
115 QTextStream ts( &file ); 105 QTextStream ts( &file );
116 106
117// #ifdef DESKTOP_VERSION
118// mQuicksave = false;
119// #endif
120// if ( mQuicksave ) {
121// ts << text.utf8();
122// } else {
123// ts.setEncoding( QTextStream::Latin1 );
124// ts << text;
125// //ts << text.latin1();
126// }
127 ts.setEncoding( QTextStream::Latin1 ); 107 ts.setEncoding( QTextStream::Latin1 );
128 ts << text; 108 ts << text;
129 file.close(); 109 file.close();
130 //qDebug("saving file takes ms: %d ", is.elapsed() ); 110 //qDebug("saving file takes ms: %d ", is.elapsed() );
131 return true; 111 return true;
132} 112}
133 113
134bool ICalFormat::fromString( Calendar *cal, const QString &text ) 114bool ICalFormat::fromString( Calendar *cal, const QString &text )
135{ 115{
136 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 116 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
137 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1()); 117 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1());
138 // Get first VCALENDAR component. 118 // Get first VCALENDAR component.
139 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components 119 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components
140 icalcomponent *calendar; 120 icalcomponent *calendar;
141 121
142 //calendar = icalcomponent_new_from_string( text.local8Bit().data()); 122 //calendar = icalcomponent_new_from_string( text.local8Bit().data());
143 // good calendar = icalcomponent_new_from_string( text.utf8().data()); 123 // good calendar = icalcomponent_new_from_string( text.utf8().data());
144 calendar = icalcomponent_new_from_string( (char*)text.latin1()); 124 calendar = icalcomponent_new_from_string( (char*)text.latin1());
145 if (!calendar) { 125 if (!calendar) {
146 setException(new ErrorFormat(ErrorFormat::ParseErrorIcal)); 126 setException(new ErrorFormat(ErrorFormat::ParseErrorIcal));
147 return false; 127 return false;
148 } 128 }
149 129
150 bool success = true; 130 bool success = true;
151 131
152 if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) { 132 if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) {
153 setException(new ErrorFormat(ErrorFormat::NoCalendar)); 133 setException(new ErrorFormat(ErrorFormat::NoCalendar));
154 success = false; 134 success = false;
155 } else { 135 } else {
156 // put all objects into their proper places 136 // put all objects into their proper places
157 if ( !mImpl->populate( cal, calendar ) ) { 137 if ( !mImpl->populate( cal, calendar ) ) {
158 if ( !exception() ) { 138 if ( !exception() ) {
159 setException(new ErrorFormat(ErrorFormat::ParseErrorKcal)); 139 setException(new ErrorFormat(ErrorFormat::ParseErrorKcal));
160 } 140 }
161 success = false; 141 success = false;
162 } else 142 } else
163 mLoadedProductId = mImpl->loadedProductId(); 143 mLoadedProductId = mImpl->loadedProductId();
164 } 144 }
165 145
166 icalcomponent_free( calendar ); 146 icalcomponent_free( calendar );
167 147
168 return success; 148 return success;
169} 149}
170 150
171Incidence *ICalFormat::fromString( const QString &text ) 151Incidence *ICalFormat::fromString( const QString &text )
172{ 152{
173 CalendarLocal cal( mTimeZoneId ); 153 CalendarLocal cal( mTimeZoneId );
174 fromString(&cal, text); 154 fromString(&cal, text);
175 155
176 Incidence *ical = 0; 156 Incidence *ical = 0;
177 QPtrList<Event> elist = cal.events(); 157 QPtrList<Event> elist = cal.events();
178 if ( elist.count() > 0 ) { 158 if ( elist.count() > 0 ) {
179 ical = elist.first(); 159 ical = elist.first();
180 } else { 160 } else {
181 QPtrList<Todo> tlist = cal.todos(); 161 QPtrList<Todo> tlist = cal.todos();
182 if ( tlist.count() > 0 ) { 162 if ( tlist.count() > 0 ) {
183 ical = tlist.first(); 163 ical = tlist.first();
184 } else { 164 } else {
185 QPtrList<Journal> jlist = cal.journals(); 165 QPtrList<Journal> jlist = cal.journals();
186 if ( jlist.count() > 0 ) { 166 if ( jlist.count() > 0 ) {
187 ical = jlist.first(); 167 ical = jlist.first();
188 } 168 }
189 } 169 }
190 } 170 }
191 return ical; 171 return ical;
192} 172}
193#include <qapp.h> 173#include <qapp.h>
194 174
195QString ICalFormat::toString( Calendar *cal ) 175QString ICalFormat::toString( Calendar *cal )
196{ 176{
197 177
198 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 178 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
199 179
200 icalcomponent *calendar = mImpl->createCalendarComponent(cal); 180 icalcomponent *calendar = mImpl->createCalendarComponent(cal);
201 181
202 icalcomponent *component; 182 icalcomponent *component;
203 183
204 // todos 184 // todos
205 QPtrList<Todo> todoList = cal->rawTodos(); 185 QPtrList<Todo> todoList = cal->rawTodos();
206 QPtrListIterator<Todo> qlt(todoList); 186 QPtrListIterator<Todo> qlt(todoList);
207 for (; qlt.current(); ++qlt) { 187 for (; qlt.current(); ++qlt) {
208 component = mImpl->writeTodo(qlt.current()); 188 component = mImpl->writeTodo(qlt.current());
209 icalcomponent_add_component(calendar,component); 189 icalcomponent_add_component(calendar,component);
210 //qDebug(" todos "); 190 //qDebug(" todos ");
211 qApp->processEvents(); 191 qApp->processEvents();
212 } 192 }
213 // events 193 // events
214 QPtrList<Event> events = cal->rawEvents(); 194 QPtrList<Event> events = cal->rawEvents();
215 Event *ev; 195 Event *ev;
216 for(ev=events.first();ev;ev=events.next()) { 196 for(ev=events.first();ev;ev=events.next()) {
217 component = mImpl->writeEvent(ev); 197 component = mImpl->writeEvent(ev);
218 icalcomponent_add_component(calendar,component); 198 icalcomponent_add_component(calendar,component);
219 //qDebug("events "); 199 //qDebug("events ");
220 qApp->processEvents(); 200 qApp->processEvents();
221 } 201 }
222 202
223 // journals 203 // journals
224 QPtrList<Journal> journals = cal->journals(); 204 QPtrList<Journal> journals = cal->journals();
225 Journal *j; 205 Journal *j;
226 for(j=journals.first();j;j=journals.next()) { 206 for(j=journals.first();j;j=journals.next()) {
227 component = mImpl->writeJournal(j); 207 component = mImpl->writeJournal(j);
228 icalcomponent_add_component(calendar,component); 208 icalcomponent_add_component(calendar,component);
229 //qDebug("journals "); 209 //qDebug("journals ");
230 qApp->processEvents(); 210 qApp->processEvents();
231 } 211 }
232 const char *text; 212 const char *text;
233 QString ret =""; 213 QString ret ="";
234 text = icalcomponent_as_ical_string( calendar ); 214 text = icalcomponent_as_ical_string( calendar );
235 qApp->processEvents(); 215 qApp->processEvents();
236 216
237 // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n"; 217 // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n";
238 218
239 219
240 if ( text ) { 220 if ( text ) {
241 ret = QString ( text ); 221 ret = QString ( text );
242 } 222 }
243 icalcomponent_free( calendar ); 223 icalcomponent_free( calendar );
244 224
245 if (!text) { 225 if (!text) {
246 setException(new ErrorFormat(ErrorFormat::SaveError, 226 setException(new ErrorFormat(ErrorFormat::SaveError,
247 i18n("libical error"))); 227 i18n("libical error")));
248 return QString::null; 228 return QString::null;
249 } 229 }
250 230
251 return ret; 231 return ret;
252} 232}
253 233
254QString ICalFormat::toICalString( Incidence *incidence ) 234QString ICalFormat::toICalString( Incidence *incidence )
255{ 235{
256 CalendarLocal cal( mTimeZoneId ); 236 CalendarLocal cal( mTimeZoneId );
257 cal.addIncidence( incidence->clone() ); 237 cal.addIncidence( incidence->clone() );
258 return toString( &cal ); 238 return toString( &cal );
259} 239}
260 240
261QString ICalFormat::toString( Incidence *incidence ) 241QString ICalFormat::toString( Incidence *incidence )
262{ 242{
263 icalcomponent *component; 243 icalcomponent *component;
264 244
265 component = mImpl->writeIncidence( incidence ); 245 component = mImpl->writeIncidence( incidence );
266 246
267 const char *text = icalcomponent_as_ical_string( component ); 247 const char *text = icalcomponent_as_ical_string( component );
268 248
269 icalcomponent_free( component ); 249 icalcomponent_free( component );
270 250
271 return QString::fromLocal8Bit( text ); 251 return QString::fromLocal8Bit( text );
272} 252}
273 253
274QString ICalFormat::toString( Recurrence *recurrence ) 254QString ICalFormat::toString( Recurrence *recurrence )
275{ 255{
276 icalproperty *property; 256 icalproperty *property;
277 property = mImpl->writeRecurrenceRule( recurrence ); 257 property = mImpl->writeRecurrenceRule( recurrence );
278 const char *text = icalproperty_as_ical_string( property ); 258 const char *text = icalproperty_as_ical_string( property );
279 icalproperty_free( property ); 259 icalproperty_free( property );
280 return QString::fromLocal8Bit( text ); 260 return QString::fromLocal8Bit( text );
281} 261}
282/* 262/*
283bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule ) 263bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule )
284{ 264{
285 bool success = true; 265 bool success = true;
286 icalerror_clear_errno(); 266 icalerror_clear_errno();
287 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule ); 267 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule );
288 if ( icalerrno != ICAL_NO_ERROR ) { 268 if ( icalerrno != ICAL_NO_ERROR ) {
289 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl; 269 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl;
290 success = false; 270 success = false;
291 } 271 }
292 272
293 if ( success ) { 273 if ( success ) {
294 mImpl->readRecurrence( recur, recurrence ); 274 mImpl->readRecurrence( recur, recurrence );
295 } 275 }
296 276
297 return success; 277 return success;
298} 278}
299*/ 279*/
300 280
301QString ICalFormat::createScheduleMessage(IncidenceBase *incidence, 281QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
302 Scheduler::Method method) 282 Scheduler::Method method)
303{ 283{
304 icalcomponent *message = mImpl->createScheduleComponent(incidence,method); 284 icalcomponent *message = mImpl->createScheduleComponent(incidence,method);
305 285
306 QString messageText = icalcomponent_as_ical_string(message); 286 QString messageText = icalcomponent_as_ical_string(message);
307 287
308 288
309 289
310 return messageText; 290 return messageText;
311} 291}
312 292
313ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, 293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
314 const QString &messageText ) 294 const QString &messageText )
315{ 295{
316 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
317 clearException(); 297 clearException();
318 298
319 if (messageText.isEmpty()) return 0; 299 if (messageText.isEmpty()) return 0;
320 300
321 icalcomponent *message; 301 icalcomponent *message;
322 message = icalparser_parse_string(messageText.local8Bit()); 302 message = icalparser_parse_string(messageText.local8Bit());
323 303
324 if (!message) return 0; 304 if (!message) return 0;
325 305
326 icalproperty *m = icalcomponent_get_first_property(message, 306 icalproperty *m = icalcomponent_get_first_property(message,
327 ICAL_METHOD_PROPERTY); 307 ICAL_METHOD_PROPERTY);
328 308
329 if (!m) return 0; 309 if (!m) return 0;
330 310
331 icalcomponent *c; 311 icalcomponent *c;
332 312
333 IncidenceBase *incidence = 0; 313 IncidenceBase *incidence = 0;
334 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); 314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT);
335 if (c) { 315 if (c) {
336 incidence = mImpl->readEvent(c); 316 incidence = mImpl->readEvent(c);
337 } 317 }
338 318
339 if (!incidence) { 319 if (!incidence) {
340 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); 320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT);
341 if (c) { 321 if (c) {
342 incidence = mImpl->readTodo(c); 322 incidence = mImpl->readTodo(c);
343 } 323 }
344 } 324 }
345 325
346 if (!incidence) { 326 if (!incidence) {
347 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); 327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT);
348 if (c) { 328 if (c) {
349 incidence = mImpl->readFreeBusy(c); 329 incidence = mImpl->readFreeBusy(c);
350 } 330 }
351 } 331 }
352 332
353 if (!incidence) { 333 if (!incidence) {
354 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; 334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl;
355 return 0; 335 return 0;
356 } 336 }
357 337
358 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; 338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl;
359 339
360 icalproperty_method icalmethod = icalproperty_get_method(m); 340 icalproperty_method icalmethod = icalproperty_get_method(m);
361 Scheduler::Method method; 341 Scheduler::Method method;
362 342
363 switch (icalmethod) { 343 switch (icalmethod) {
364 case ICAL_METHOD_PUBLISH: 344 case ICAL_METHOD_PUBLISH:
365 method = Scheduler::Publish; 345 method = Scheduler::Publish;
366 break; 346 break;
367 case ICAL_METHOD_REQUEST: 347 case ICAL_METHOD_REQUEST:
368 method = Scheduler::Request; 348 method = Scheduler::Request;
369 break; 349 break;
370 case ICAL_METHOD_REFRESH: 350 case ICAL_METHOD_REFRESH:
371 method = Scheduler::Refresh; 351 method = Scheduler::Refresh;
372 break; 352 break;
373 case ICAL_METHOD_CANCEL: 353 case ICAL_METHOD_CANCEL:
374 method = Scheduler::Cancel; 354 method = Scheduler::Cancel;
375 break; 355 break;
376 case ICAL_METHOD_ADD: 356 case ICAL_METHOD_ADD:
377 method = Scheduler::Add; 357 method = Scheduler::Add;
378 break; 358 break;
379 case ICAL_METHOD_REPLY: 359 case ICAL_METHOD_REPLY:
380 method = Scheduler::Reply; 360 method = Scheduler::Reply;
381 break; 361 break;
382 case ICAL_METHOD_COUNTER: 362 case ICAL_METHOD_COUNTER:
383 method = Scheduler::Counter; 363 method = Scheduler::Counter;
384 break; 364 break;
385 case ICAL_METHOD_DECLINECOUNTER: 365 case ICAL_METHOD_DECLINECOUNTER:
386 method = Scheduler::Declinecounter; 366 method = Scheduler::Declinecounter;
387 break; 367 break;
388 default: 368 default:
389 method = Scheduler::NoMethod; 369 method = Scheduler::NoMethod;
390 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; 370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
391 break; 371 break;
392 } 372 }
393 373
394 374
395 if (!icalrestriction_check(message)) { 375 if (!icalrestriction_check(message)) {
396 setException(new ErrorFormat(ErrorFormat::Restriction, 376 setException(new ErrorFormat(ErrorFormat::Restriction,
397 Scheduler::translatedMethodName(method) + ": " + 377 Scheduler::translatedMethodName(method) + ": " +
398 mImpl->extractErrorProperty(c))); 378 mImpl->extractErrorProperty(c)));
399 return 0; 379 return 0;
400 } 380 }
401 381
402 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); 382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
403 383
404 Incidence *existingIncidence = cal->event(incidence->uid()); 384 Incidence *existingIncidence = cal->event(incidence->uid());
405 if (existingIncidence) { 385 if (existingIncidence) {
406 // TODO: check, if cast is required, or if it can be done by virtual funcs. 386 // TODO: check, if cast is required, or if it can be done by virtual funcs.
407 if (existingIncidence->type() == "Todo") { 387 if (existingIncidence->type() == "Todo") {
408 Todo *todo = static_cast<Todo *>(existingIncidence); 388 Todo *todo = static_cast<Todo *>(existingIncidence);
409 icalcomponent_add_component(calendarComponent, 389 icalcomponent_add_component(calendarComponent,
410 mImpl->writeTodo(todo)); 390 mImpl->writeTodo(todo));
411 } 391 }
412 if (existingIncidence->type() == "Event") { 392 if (existingIncidence->type() == "Event") {
413 Event *event = static_cast<Event *>(existingIncidence); 393 Event *event = static_cast<Event *>(existingIncidence);
414 icalcomponent_add_component(calendarComponent, 394 icalcomponent_add_component(calendarComponent,
415 mImpl->writeEvent(event)); 395 mImpl->writeEvent(event));
416 } 396 }
417 } else { 397 } else {
418 calendarComponent = 0; 398 calendarComponent = 0;
419 } 399 }
420 qDebug("icalclassify commented out "); 400 qDebug("icalclassify commented out ");
421 ScheduleMessage::Status status; 401 ScheduleMessage::Status status;
422#if 0 402#if 0
423 403
424 icalclass result = icalclassify(message,calendarComponent,(char *)""); 404 icalclass result = icalclassify(message,calendarComponent,(char *)"");
425 405
426 406
427 407
428 switch (result) { 408 switch (result) {
429 case ICAL_PUBLISH_NEW_CLASS: 409 case ICAL_PUBLISH_NEW_CLASS:
430 status = ScheduleMessage::PublishNew; 410 status = ScheduleMessage::PublishNew;
431 break; 411 break;
432 case ICAL_OBSOLETE_CLASS: 412 case ICAL_OBSOLETE_CLASS:
433 status = ScheduleMessage::Obsolete; 413 status = ScheduleMessage::Obsolete;
434 break; 414 break;
435 case ICAL_REQUEST_NEW_CLASS: 415 case ICAL_REQUEST_NEW_CLASS:
436 status = ScheduleMessage::RequestNew; 416 status = ScheduleMessage::RequestNew;
437 break; 417 break;
438 case ICAL_REQUEST_UPDATE_CLASS: 418 case ICAL_REQUEST_UPDATE_CLASS:
439 status = ScheduleMessage::RequestUpdate; 419 status = ScheduleMessage::RequestUpdate;
440 break; 420 break;
441 case ICAL_UNKNOWN_CLASS: 421 case ICAL_UNKNOWN_CLASS:
442 default: 422 default:
443 status = ScheduleMessage::Unknown; 423 status = ScheduleMessage::Unknown;
444 break; 424 break;
445 } 425 }
446#endif 426#endif
447 status = ScheduleMessage::RequestUpdate; 427 status = ScheduleMessage::RequestUpdate;
448 return new ScheduleMessage(incidence,method,status); 428 return new ScheduleMessage(incidence,method,status);
449} 429}
450 430
451void ICalFormat::setTimeZone( const QString &id, bool utc ) 431void ICalFormat::setTimeZone( const QString &id, bool utc )
452{ 432{
453 433
454 434
455 mTimeZoneId = id; 435 mTimeZoneId = id;
456 mUtc = utc; 436 mUtc = utc;
457 437
458 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); 438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId);
459 439
460 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); 440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin);
461} 441}
462 442
463QString ICalFormat::timeZoneId() const 443QString ICalFormat::timeZoneId() const
464{ 444{
465 return mTimeZoneId; 445 return mTimeZoneId;
466} 446}
467 447
468bool ICalFormat::utc() const 448bool ICalFormat::utc() const
469{ 449{
470 return mUtc; 450 return mUtc;
471} 451}
472int ICalFormat::timeOffset() 452int ICalFormat::timeOffset()
473{ 453{
474 return tzOffsetMin; 454 return tzOffsetMin;
475} 455}
476const char *ICalFormat::tzString() 456const char *ICalFormat::tzString()
477{ 457{
478 const char* ret = (const char* ) mTzString; 458 const char* ret = (const char* ) mTzString;
479 return ret; 459 return ret;
480} 460}
diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h
index 236efbf..485ab6e 100644
--- a/libkcal/icalformat.h
+++ b/libkcal/icalformat.h
@@ -1,116 +1,115 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef ICALFORMAT_H 20#ifndef ICALFORMAT_H
21#define ICALFORMAT_H 21#define ICALFORMAT_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24 24
25#include "scheduler.h" 25#include "scheduler.h"
26 26
27#include "calformat.h" 27#include "calformat.h"
28 28
29namespace KCal { 29namespace KCal {
30 30
31class ICalFormatImpl; 31class ICalFormatImpl;
32 32
33/** 33/**
34 This class implements the iCalendar format. It provides methods for 34 This class implements the iCalendar format. It provides methods for
35 loading/saving/converting iCalendar format data into the internal KOrganizer 35 loading/saving/converting iCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short iCalendar format implementation 38 @short iCalendar format implementation
39*/ 39*/
40class ICalFormat : public CalFormat { 40class ICalFormat : public CalFormat {
41 public: 41 public:
42 /** Create new iCalendar format. */ 42 /** Create new iCalendar format. */
43 ICalFormat( bool quick = false ); 43 ICalFormat( );
44 virtual ~ICalFormat(); 44 virtual ~ICalFormat();
45 45
46 /** 46 /**
47 Loads a calendar on disk in iCalendar format into calendar. 47 Loads a calendar on disk in iCalendar format into calendar.
48 Returns true if successful, else returns false. Provides more error 48 Returns true if successful, else returns false. Provides more error
49 information by exception(). 49 information by exception().
50 @param calendar Calendar object to be filled. 50 @param calendar Calendar object to be filled.
51 @param fileName The name of the calendar file on disk. 51 @param fileName The name of the calendar file on disk.
52 */ 52 */
53 bool load( Calendar *, const QString &fileName ); 53 bool load( Calendar *, const QString &fileName );
54 /** 54 /**
55 Writes out the calendar to disk in iCalendar format. Returns true if 55 Writes out the calendar to disk in iCalendar format. Returns true if
56 successful and false on error. 56 successful and false on error.
57 57
58 @param calendar The Calendar object to be written. 58 @param calendar The Calendar object to be written.
59 @param fileName The name of the calendar file on disk. 59 @param fileName The name of the calendar file on disk.
60 */ 60 */
61 bool save( Calendar *, const QString &fileName ); 61 bool save( Calendar *, const QString &fileName );
62 62
63 /** 63 /**
64 Parse string and populate calendar with that information. 64 Parse string and populate calendar with that information.
65 */ 65 */
66 bool fromString( Calendar *, const QString & ); 66 bool fromString( Calendar *, const QString & );
67 /** 67 /**
68 Parse string and return first ical component. 68 Parse string and return first ical component.
69 */ 69 */
70 Incidence *fromString( const QString & ); 70 Incidence *fromString( const QString & );
71 /** 71 /**
72 Return calendar information as string. 72 Return calendar information as string.
73 */ 73 */
74 QString toString( Calendar * ); 74 QString toString( Calendar * );
75 /** 75 /**
76 Return incidence as full iCalendar formatted text. 76 Return incidence as full iCalendar formatted text.
77 */ 77 */
78 QString toICalString( Incidence * ); 78 QString toICalString( Incidence * );
79 /** 79 /**
80 Return incidence as iCalendar formatted text. 80 Return incidence as iCalendar formatted text.
81 */ 81 */
82 QString toString( Incidence * ); 82 QString toString( Incidence * );
83 /** 83 /**
84 Return recurrence as iCalendar formatted text. 84 Return recurrence as iCalendar formatted text.
85 */ 85 */
86 QString toString( Recurrence * ); 86 QString toString( Recurrence * );
87 /** 87 /**
88 Parse string and fill recurrence object with 88 Parse string and fill recurrence object with
89 that information 89 that information
90 */ 90 */
91 //bool fromString ( Recurrence *, const QString& ); 91 //bool fromString ( Recurrence *, const QString& );
92 92
93 /** Create a scheduling message for event \a e using method \m */ 93 /** Create a scheduling message for event \a e using method \m */
94 QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m); 94 QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m);
95 /** Parse scheduling message provided as string \s */ 95 /** Parse scheduling message provided as string \s */
96 ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s); 96 ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s);
97 97
98 /** Set id of used time zone and whether this time zone is UTC or not. */ 98 /** Set id of used time zone and whether this time zone is UTC or not. */
99 void setTimeZone( const QString &id, bool utc ); 99 void setTimeZone( const QString &id, bool utc );
100 QString timeZoneId() const; 100 QString timeZoneId() const;
101 int timeOffset(); 101 int timeOffset();
102 const char * tzString(); 102 const char * tzString();
103 bool utc() const; 103 bool utc() const;
104 104
105 private: 105 private:
106 ICalFormatImpl *mImpl; 106 ICalFormatImpl *mImpl;
107 bool mQuicksave;
108 QString mTimeZoneId; 107 QString mTimeZoneId;
109 QCString mTzString; 108 QCString mTzString;
110 int tzOffsetMin; 109 int tzOffsetMin;
111 bool mUtc; 110 bool mUtc;
112}; 111};
113 112
114} 113}
115 114
116#endif 115#endif