-rw-r--r-- | korganizer/calendarview.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c75632..8e83723 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -601,351 +601,353 @@ void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | |||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | QDateTime localMod = local->lastModified(); | ||
730 | QDateTime remoteMod = remote->lastModified(); | ||
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 731 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 732 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 733 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | //if ( remCh ) | 734 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 735 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 736 | locCh = ( localMod > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 737 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 738 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 739 | lastSync = localMod.addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | 740 | if ( mode <= SYNC_PREF_ASK ) |
739 | return 0; | 741 | return 0; |
740 | } else { | 742 | } else { |
741 | if ( locCh ) { | 743 | if ( locCh ) { |
742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 744 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
743 | lastSync = local->lastModified().addDays( -1 ); | 745 | lastSync = localMod.addDays( -1 ); |
744 | if ( !remCh ) | 746 | if ( !remCh ) |
745 | remote->setLastModified( lastSync.addDays( -1 ) ); | 747 | remoteMod = ( lastSync.addDays( -1 ) ); |
746 | } else { | 748 | } else { |
747 | //qDebug(" not loc changed "); | 749 | //qDebug(" not loc changed "); |
748 | lastSync = local->lastModified().addDays( 1 ); | 750 | lastSync = localMod.addDays( 1 ); |
749 | if ( remCh ) | 751 | if ( remCh ) |
750 | remote->setLastModified( lastSync.addDays( 1 ) ); | 752 | remoteMod =( lastSync.addDays( 1 ) ); |
751 | 753 | ||
752 | } | 754 | } |
753 | } | 755 | } |
754 | full = true; | 756 | full = true; |
755 | if ( mode < SYNC_PREF_ASK ) | 757 | if ( mode < SYNC_PREF_ASK ) |
756 | mode = SYNC_PREF_ASK; | 758 | mode = SYNC_PREF_ASK; |
757 | } else { | 759 | } else { |
758 | if ( local->lastModified() == remote->lastModified() ) | 760 | if ( localMod == remoteMod ) |
759 | if ( local->revision() == remote->revision() ) | 761 | if ( local->revision() == remote->revision() ) |
760 | return 0; | 762 | return 0; |
761 | 763 | ||
762 | } | 764 | } |
763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 765 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
764 | 766 | ||
765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 767 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 768 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
767 | //full = true; //debug only | 769 | //full = true; //debug only |
768 | if ( full ) { | 770 | if ( full ) { |
769 | bool equ = false; | 771 | bool equ = false; |
770 | if ( local->type() == "Event" ) { | 772 | if ( local->type() == "Event" ) { |
771 | equ = (*((Event*) local) == *((Event*) remote)); | 773 | equ = (*((Event*) local) == *((Event*) remote)); |
772 | } | 774 | } |
773 | else if ( local->type() =="Todo" ) | 775 | else if ( local->type() =="Todo" ) |
774 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 776 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
775 | else if ( local->type() =="Journal" ) | 777 | else if ( local->type() =="Journal" ) |
776 | equ = (*((Journal*) local) == *((Journal*) remote)); | 778 | equ = (*((Journal*) local) == *((Journal*) remote)); |
777 | if ( equ ) { | 779 | if ( equ ) { |
778 | //qDebug("equal "); | 780 | //qDebug("equal "); |
779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
780 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 782 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
781 | } | 783 | } |
782 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 784 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
783 | return 0; | 785 | return 0; |
784 | 786 | ||
785 | }//else //debug only | 787 | }//else //debug only |
786 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 788 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
787 | } | 789 | } |
788 | int result; | 790 | int result; |
789 | bool localIsNew; | 791 | bool localIsNew; |
790 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 792 | //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() ); |
791 | 793 | ||
792 | if ( full && mode < SYNC_PREF_NEWEST ) | 794 | if ( full && mode < SYNC_PREF_NEWEST ) |
793 | mode = SYNC_PREF_ASK; | 795 | mode = SYNC_PREF_ASK; |
794 | 796 | ||
795 | switch( mode ) { | 797 | switch( mode ) { |
796 | case SYNC_PREF_LOCAL: | 798 | case SYNC_PREF_LOCAL: |
797 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remoteMod ) |
798 | return 1; | 800 | return 1; |
799 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > localMod ) |
800 | return 2; | 802 | return 2; |
801 | return 1; | 803 | return 1; |
802 | break; | 804 | break; |
803 | case SYNC_PREF_REMOTE: | 805 | case SYNC_PREF_REMOTE: |
804 | if ( lastSync > remote->lastModified() ) | 806 | if ( lastSync > remoteMod ) |
805 | return 1; | 807 | return 1; |
806 | if ( lastSync > local->lastModified() ) | 808 | if ( lastSync > localMod ) |
807 | return 2; | 809 | return 2; |
808 | return 2; | 810 | return 2; |
809 | break; | 811 | break; |
810 | case SYNC_PREF_NEWEST: | 812 | case SYNC_PREF_NEWEST: |
811 | if ( local->lastModified() > remote->lastModified() ) | 813 | if ( localMod > remoteMod ) |
812 | return 1; | 814 | return 1; |
813 | else | 815 | else |
814 | return 2; | 816 | return 2; |
815 | break; | 817 | break; |
816 | case SYNC_PREF_ASK: | 818 | case SYNC_PREF_ASK: |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | if ( lastSync > remote->lastModified() ) | 820 | if ( lastSync > remoteMod ) |
819 | return 1; | 821 | return 1; |
820 | if ( lastSync > local->lastModified() ) | 822 | if ( lastSync > localMod ) |
821 | return 2; | 823 | return 2; |
822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 824 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
823 | localIsNew = local->lastModified() >= remote->lastModified(); | 825 | localIsNew = localMod >= remoteMod; |
824 | if ( localIsNew ) | 826 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
826 | else | 828 | else |
827 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
828 | getEventViewerDialog()->setIncidence(local); | 830 | getEventViewerDialog()->setIncidence(local); |
829 | if ( localIsNew ) | 831 | if ( localIsNew ) |
830 | getEventViewerDialog()->setColorMode( 2 ); | 832 | getEventViewerDialog()->setColorMode( 2 ); |
831 | else | 833 | else |
832 | getEventViewerDialog()->setColorMode( 1 ); | 834 | getEventViewerDialog()->setColorMode( 1 ); |
833 | getEventViewerDialog()->addIncidence(remote); | 835 | getEventViewerDialog()->addIncidence(remote); |
834 | getEventViewerDialog()->setColorMode( 0 ); | 836 | getEventViewerDialog()->setColorMode( 0 ); |
835 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 837 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
836 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 838 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
837 | getEventViewerDialog()->showMe(); | 839 | getEventViewerDialog()->showMe(); |
838 | result = getEventViewerDialog()->executeS( localIsNew ); | 840 | result = getEventViewerDialog()->executeS( localIsNew ); |
839 | return result; | 841 | return result; |
840 | 842 | ||
841 | break; | 843 | break; |
842 | case SYNC_PREF_FORCE_LOCAL: | 844 | case SYNC_PREF_FORCE_LOCAL: |
843 | return 1; | 845 | return 1; |
844 | break; | 846 | break; |
845 | case SYNC_PREF_FORCE_REMOTE: | 847 | case SYNC_PREF_FORCE_REMOTE: |
846 | return 2; | 848 | return 2; |
847 | break; | 849 | break; |
848 | 850 | ||
849 | default: | 851 | default: |
850 | // SYNC_PREF_TAKE_BOTH not implemented | 852 | // SYNC_PREF_TAKE_BOTH not implemented |
851 | break; | 853 | break; |
852 | } | 854 | } |
853 | return 0; | 855 | return 0; |
854 | } | 856 | } |
855 | Event* CalendarView::getLastSyncEvent() | 857 | Event* CalendarView::getLastSyncEvent() |
856 | { | 858 | { |
857 | Event* lse; | 859 | Event* lse; |
858 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 860 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
859 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
860 | if (!lse) { | 862 | if (!lse) { |
861 | lse = new Event(); | 863 | lse = new Event(); |
862 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 864 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | QString sum = ""; | 865 | QString sum = ""; |
864 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 866 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
865 | sum = "E: "; | 867 | sum = "E: "; |
866 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 868 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
867 | lse->setDtStart( mLastCalendarSync ); | 869 | lse->setDtStart( mLastCalendarSync ); |
868 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 870 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
869 | lse->setCategories( i18n("SyncEvent") ); | 871 | lse->setCategories( i18n("SyncEvent") ); |
870 | lse->setReadOnly( true ); | 872 | lse->setReadOnly( true ); |
871 | mCalendar->addEvent( lse ); | 873 | mCalendar->addEvent( lse ); |
872 | } | 874 | } |
873 | 875 | ||
874 | return lse; | 876 | return lse; |
875 | 877 | ||
876 | } | 878 | } |
877 | // probaly useless | 879 | // probaly useless |
878 | void CalendarView::setupExternSyncProfiles() | 880 | void CalendarView::setupExternSyncProfiles() |
879 | { | 881 | { |
880 | Event* lse; | 882 | Event* lse; |
881 | mExternLastSyncEvent.clear(); | 883 | mExternLastSyncEvent.clear(); |
882 | int i; | 884 | int i; |
883 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 885 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
884 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 886 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
885 | if ( lse ) | 887 | if ( lse ) |
886 | mExternLastSyncEvent.append( lse ); | 888 | mExternLastSyncEvent.append( lse ); |
887 | else | 889 | else |
888 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 890 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
889 | } | 891 | } |
890 | 892 | ||
891 | } | 893 | } |
892 | // we check, if the to delete event has a id for a profile | 894 | // we check, if the to delete event has a id for a profile |
893 | // if yes, we set this id in the profile to delete | 895 | // if yes, we set this id in the profile to delete |
894 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 896 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
895 | { | 897 | { |
896 | if ( lastSync.count() == 0 ) { | 898 | if ( lastSync.count() == 0 ) { |
897 | //qDebug(" lastSync.count() == 0"); | 899 | //qDebug(" lastSync.count() == 0"); |
898 | return; | 900 | return; |
899 | } | 901 | } |
900 | if ( toDelete->type() == "Journal" ) | 902 | if ( toDelete->type() == "Journal" ) |
901 | return; | 903 | return; |
902 | 904 | ||
903 | Event* eve = lastSync.first(); | 905 | Event* eve = lastSync.first(); |
904 | 906 | ||
905 | while ( eve ) { | 907 | while ( eve ) { |
906 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 908 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
907 | if ( !id.isEmpty() ) { | 909 | if ( !id.isEmpty() ) { |
908 | QString des = eve->description(); | 910 | QString des = eve->description(); |
909 | QString pref = "e"; | 911 | QString pref = "e"; |
910 | if ( toDelete->type() == "Todo" ) | 912 | if ( toDelete->type() == "Todo" ) |
911 | pref = "t"; | 913 | pref = "t"; |
912 | des += pref+ id + ","; | 914 | des += pref+ id + ","; |
913 | eve->setReadOnly( false ); | 915 | eve->setReadOnly( false ); |
914 | eve->setDescription( des ); | 916 | eve->setDescription( des ); |
915 | //qDebug("setdes %s ", des.latin1()); | 917 | //qDebug("setdes %s ", des.latin1()); |
916 | eve->setReadOnly( true ); | 918 | eve->setReadOnly( true ); |
917 | } | 919 | } |
918 | eve = lastSync.next(); | 920 | eve = lastSync.next(); |
919 | } | 921 | } |
920 | 922 | ||
921 | } | 923 | } |
922 | void CalendarView::checkExternalId( Incidence * inc ) | 924 | void CalendarView::checkExternalId( Incidence * inc ) |
923 | { | 925 | { |
924 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 926 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
925 | checkExternSyncEvent( lastSync, inc ); | 927 | checkExternSyncEvent( lastSync, inc ); |
926 | 928 | ||
927 | } | 929 | } |
928 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 930 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
929 | { | 931 | { |
930 | bool syncOK = true; | 932 | bool syncOK = true; |
931 | int addedEvent = 0; | 933 | int addedEvent = 0; |
932 | int addedEventR = 0; | 934 | int addedEventR = 0; |
933 | int deletedEventR = 0; | 935 | int deletedEventR = 0; |
934 | int deletedEventL = 0; | 936 | int deletedEventL = 0; |
935 | int changedLocal = 0; | 937 | int changedLocal = 0; |
936 | int changedRemote = 0; | 938 | int changedRemote = 0; |
937 | //QPtrList<Event> el = local->rawEvents(); | 939 | //QPtrList<Event> el = local->rawEvents(); |
938 | Event* eventR; | 940 | Event* eventR; |
939 | QString uid; | 941 | QString uid; |
940 | int take; | 942 | int take; |
941 | Event* eventL; | 943 | Event* eventL; |
942 | Event* eventRSync; | 944 | Event* eventRSync; |
943 | Event* eventLSync; | 945 | Event* eventLSync; |
944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 946 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 947 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
946 | bool fullDateRange = false; | 948 | bool fullDateRange = false; |
947 | local->resetTempSyncStat(); | 949 | local->resetTempSyncStat(); |
948 | mLastCalendarSync = QDateTime::currentDateTime(); | 950 | mLastCalendarSync = QDateTime::currentDateTime(); |
949 | QDateTime modifiedCalendar = mLastCalendarSync;; | 951 | QDateTime modifiedCalendar = mLastCalendarSync;; |
950 | eventLSync = getLastSyncEvent(); | 952 | eventLSync = getLastSyncEvent(); |
951 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 953 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |