summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp44
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
@@ -717,119 +717,121 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
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() );