summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 58b3d70..fd68dc4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -108,51 +108,49 @@
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132#define SYNC_MODE_NORMAL 0 132
133#define SYNC_MODE_SHARP 1
134#define SYNC_MODE_QTOPIA 2
135 133
136class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
137{ 135{
138 public: 136 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
141 { 139 {
142 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 145 lay->addWidget( format );
148 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 151 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 154 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 156 lay->addWidget( ok );
@@ -706,164 +704,165 @@ void CalendarView::confSync()
706//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
708 706
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 713
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 715{
718 716
719 //void setZaurusId(int id); 717 //void setZaurusId(int id);
720 // int zaurusId() const; 718 // int zaurusId() const;
721 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
722 // int zaurusUid() const; 720 // int zaurusUid() const;
723 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
724 // int zaurusStat() const; 722 // int zaurusStat() const;
725 // 0 equal 723 // 0 equal
726 // 1 take local 724 // 1 take local
727 // 2 take remote 725 // 2 take remote
728 // 3 cancel 726 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
730 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
731 bool remCh, locCh; 729 bool remCh, locCh;
732 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
733 locCh = ( local->zaurusStat() != local->revision() ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
734 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
735 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
736 //qDebug("both not changed "); 734 //qDebug("both not changed ");
737 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
738 } else { 736 } else {
739 if ( locCh ) { 737 if ( locCh ) {
740 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
741 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
742 if ( !remCh ) 740 if ( !remCh )
743 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
744 } else { 742 } else {
745 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
746 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
747 if ( remCh ) 745 if ( remCh )
748 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
749 747
750 } 748 }
751 } 749 }
752 full = true; 750 full = true;
753 if ( mode < 3 ) 751 if ( mode < SYNC_PREF_ASK )
754 mode = 3; 752 mode = SYNC_PREF_ASK;
755 } else { 753 } else {
756 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
757 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
758 return 0; 756 return 0;
759 757
760 } 758 }
761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
762 760
763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
765 //full = true; //debug only 763 //full = true; //debug only
766 if ( full ) { 764 if ( full ) {
767 bool equ = false; 765 bool equ = false;
768 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
769 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
770 } 768 }
771 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
772 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
773 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
774 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
775 if ( equ ) { 773 if ( equ ) {
776 //qDebug("equal "); 774 //qDebug("equal ");
777 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
778 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
779 } 777 }
780 if ( mode < 4 ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
781 return 0; 779 return 0;
782 780
783 }//else //debug only 781 }//else //debug only
784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
785 } 783 }
786 int result; 784 int result;
787 bool localIsNew; 785 bool localIsNew;
788 if ( full && mode < 2 ) 786 if ( full && mode < SYNC_PREF_NEWEST )
789 mode = 3; 787 mode = SYNC_PREF_ASK;
790 788
791 switch( mode ) { 789 switch( mode ) {
792 case 0: 790 case SYNC_PREF_LOCAL:
793 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
794 return 1; 792 return 1;
795 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
796 return 2; 794 return 2;
797 return 1; 795 return 1;
798 break; 796 break;
799 case 1: 797 case SYNC_PREF_REMOTE:
800 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
801 return 1; 799 return 1;
802 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
803 return 2; 801 return 2;
804 return 2; 802 return 2;
805 break; 803 break;
806 case 2: 804 case SYNC_PREF_NEWEST:
807 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
808 return 1; 806 return 1;
809 else 807 else
810 return 2; 808 return 2;
811 break; 809 break;
812 case 3: 810 case SYNC_PREF_ASK:
813 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
814 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
815 return 1; 813 return 1;
816 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
817 return 2; 815 return 2;
818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
819 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
820 if ( localIsNew ) 818 if ( localIsNew )
821 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
822 else 820 else
823 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
824 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
825 if ( localIsNew ) 823 if ( localIsNew )
826 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
827 else 825 else
828 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
829 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
830 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
831 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
832 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
833 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
834 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
835 return result; 833 return result;
836 834
837 break; 835 break;
838 case 4: 836 case SYNC_PREF_FORCE_LOCAL:
839 return 1; 837 return 1;
840 break; 838 break;
841 case 5: 839 case SYNC_PREF_FORCE_REMOTE:
842 return 2; 840 return 2;
843 break; 841 break;
844 842
845 default: 843 default:
844 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 845 break;
847 } 846 }
848 return 0; 847 return 0;
849} 848}
850Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
851{ 850{
852 Event* lse; 851 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 854 if (!lse) {
856 lse = new Event(); 855 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
864 } 863 }
865 864
866 return lse; 865 return lse;
867 866
868} 867}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
@@ -975,103 +974,103 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
975 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
976 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
977 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
978 maxrev = inR->revision(); 977 maxrev = inR->revision();
979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
980 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
981 if ( take == 3 ) 980 if ( take == 3 )
982 return false; 981 return false;
983 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
984 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
985 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
986 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
987 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
988 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
989 ++changedRemote; 988 ++changedRemote;
990 } else { 989 } else {
991 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
992 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
993 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
994 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
995 ++changedLocal; 994 ++changedLocal;
996 } 995 }
997 } 996 }
998 } else { // no conflict 997 } else { // no conflict
999 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1000 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1001 QString pref = "e"; 1000 QString pref = "e";
1002 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1003 pref = "t"; 1002 pref = "t";
1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1005 inR->setZaurusStat( -3 ); 1004 inR->setZaurusStat( SYNC_TEMPSTATE_DELETE );
1006 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1007 ++deletedEventR; 1006 ++deletedEventR;
1008 } else { 1007 } else {
1009 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1010 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1011 ++addedEvent; 1010 ++addedEvent;
1012 } 1011 }
1013 } else { 1012 } else {
1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1015 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1016 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1017 ++addedEvent; 1016 ++addedEvent;
1018 } else { 1017 } else {
1019 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1020 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1021 ++deletedEventR; 1020 ++deletedEventR;
1022 } 1021 }
1023 } 1022 }
1024 } 1023 }
1025 } 1024 }
1026 inR = er.next(); 1025 inR = er.next();
1027 } 1026 }
1028 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1029 inL = el.first(); 1028 inL = el.first();
1030 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1031 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1032 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1033 bar.show(); 1032 bar.show();
1034 incCounter = 0; 1033 incCounter = 0;
1035 1034
1036 while ( inL ) { 1035 while ( inL ) {
1037 1036
1038 qApp->processEvents(); 1037 qApp->processEvents();
1039 if ( ! bar.isVisible() ) 1038 if ( ! bar.isVisible() )
1040 return false; 1039 return false;
1041 if ( incCounter % modulo == 0 ) 1040 if ( incCounter % modulo == 0 )
1042 bar.setProgress( incCounter ); 1041 bar.setProgress( incCounter );
1043 ++incCounter; 1042 ++incCounter;
1044 uid = inL->uid(); 1043 uid = inL->uid();
1045 bool skipIncidence = false; 1044 bool skipIncidence = false;
1046 if ( uid.left(21) == QString("last-syncEvent-device") ) 1045 if ( uid.left(21) == QString("last-syncEvent-device") )
1047 skipIncidence = true; 1046 skipIncidence = true;
1048 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) 1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1049 skipIncidence = true; 1048 skipIncidence = true;
1050 if ( !skipIncidence ) { 1049 if ( !skipIncidence ) {
1051 inR = remote->incidence( uid ); 1050 inR = remote->incidence( uid );
1052 if ( ! inR ) { 1051 if ( ! inR ) {
1053 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1053 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1055 local->deleteIncidence( inL ); 1054 local->deleteIncidence( inL );
1056 ++deletedEventL; 1055 ++deletedEventL;
1057 } else { 1056 } else {
1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1059 inL->setZaurusId( -1 ); 1058 inL->setZaurusId( -1 );
1060 ++addedEventR; 1059 ++addedEventR;
1061 inL->setLastModified( modifiedCalendar ); 1060 inL->setLastModified( modifiedCalendar );
1062 remote->addIncidence( inL->clone() ); 1061 remote->addIncidence( inL->clone() );
1063 } 1062 }
1064 } 1063 }
1065 } else { 1064 } else {
1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1067 checkSharpEvent(eventLSyncSharp, inL); 1066 checkSharpEvent(eventLSyncSharp, inL);
1068 local->deleteIncidence( inL ); 1067 local->deleteIncidence( inL );
1069 ++deletedEventL; 1068 ++deletedEventL;
1070 } else { 1069 } else {
1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1072 ++addedEventR; 1071 ++addedEventR;
1073 inL->setLastModified( modifiedCalendar ); 1072 inL->setLastModified( modifiedCalendar );
1074 remote->addIncidence( inL->clone() ); 1073 remote->addIncidence( inL->clone() );
1075 } 1074 }
1076 } 1075 }
1077 } 1076 }
@@ -1120,78 +1119,80 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1120 storage->setFileName( filename ); 1119 storage->setFileName( filename );
1121 // qDebug("loading ... "); 1120 // qDebug("loading ... ");
1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1123 getEventViewerDialog()->setSyncMode( true ); 1122 getEventViewerDialog()->setSyncMode( true );
1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1125 getEventViewerDialog()->setSyncMode( false ); 1124 getEventViewerDialog()->setSyncMode( false );
1126 if ( syncOK ) { 1125 if ( syncOK ) {
1127 if ( KOPrefs::instance()->mWriteBackFile ) 1126 if ( KOPrefs::instance()->mWriteBackFile )
1128 { 1127 {
1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1130 storage->save(); 1129 storage->save();
1131 } 1130 }
1132 } 1131 }
1133 setModified( true ); 1132 setModified( true );
1134 } 1133 }
1135 delete storage; 1134 delete storage;
1136 delete calendar; 1135 delete calendar;
1137 if ( syncOK ) 1136 if ( syncOK )
1138 updateView(); 1137 updateView();
1139 return syncOK; 1138 return syncOK;
1140} 1139}
1141void CalendarView::syncSharp() 1140void CalendarView::syncSharp()
1142{ 1141{
1143#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1144 mGlobalSyncMode = SYNC_MODE_SHARP; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1145 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1146 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1147 edit_sync_options(); 1146 edit_sync_options();
1148 qApp->processEvents(); 1147 qApp->processEvents();
1149 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1151 bool syncOK = false; 1150 bool syncOK = false;
1152 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1153 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1154 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1156 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1157 qApp->processEvents(); 1156 qApp->processEvents();
1158 if ( syncOK ) { 1157 if ( syncOK ) {
1159 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1160 { 1159 {
1161 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1162 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1162 /* obsolete
1163 while ( inc ) { 1163 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1165 inc = iL.next();
1166 } 1166 }
1167 */
1167 // pending: clean last sync event description 1168 // pending: clean last sync event description
1168 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1169 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1170 inc = iL.first(); 1171 inc = iL.first();
1171 Incidence* loc; 1172 Incidence* loc;
1172 while ( inc ) { 1173 while ( inc ) {
1173 if ( inc->zaurusStat() == -4 ) { 1174 if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) {
1174 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1175 if ( loc ) { 1176 if ( loc ) {
1176 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1177 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1178 } 1179 }
1179 } 1180 }
1180 inc = iL.next(); 1181 inc = iL.next();
1181 } 1182 }
1182 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1183 if ( lse ) { 1184 if ( lse ) {
1184 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1185 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1186 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1187 } 1188 }
1188 } 1189 }
1189 } 1190 }
1190 setModified( true ); 1191 setModified( true );
1191 } else { 1192 } else {
1192 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1193 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1194 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1195 1196
1196 } 1197 }
1197 delete calendar; 1198 delete calendar;