summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-27 12:27:39 (UTC)
committer zautrix <zautrix>2004-10-27 12:27:39 (UTC)
commit2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff)
tree1ebab5dc6d00cb09720789897ce2c86df05cc9ab /korganizer
parentf73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff)
downloadkdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip
kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz
kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2
completed KDE AB sync. but will it work ...?
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp15
-rw-r--r--korganizer/calendarview.h1
2 files changed, 6 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 326db88..6e61351 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -802,513 +802,513 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( localMod > remoteMod ) 806 if ( localMod > remoteMod )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
813 if ( lastSync > remoteMod ) 813 if ( lastSync > remoteMod )
814 return 1; 814 return 1;
815 if ( lastSync > localMod ) 815 if ( lastSync > localMod )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
818 localIsNew = localMod >= remoteMod; 818 localIsNew = localMod >= remoteMod;
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872 872
873// we check, if the to delete event has a id for a profile 873// we check, if the to delete event has a id for a profile
874// if yes, we set this id in the profile to delete 874// if yes, we set this id in the profile to delete
875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
876{ 876{
877 if ( lastSync.count() == 0 ) { 877 if ( lastSync.count() == 0 ) {
878 //qDebug(" lastSync.count() == 0"); 878 //qDebug(" lastSync.count() == 0");
879 return; 879 return;
880 } 880 }
881 if ( toDelete->type() == "Journal" ) 881 if ( toDelete->type() == "Journal" )
882 return; 882 return;
883 883
884 Event* eve = lastSync.first(); 884 Event* eve = lastSync.first();
885 885
886 while ( eve ) { 886 while ( eve ) {
887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
888 if ( !id.isEmpty() ) { 888 if ( !id.isEmpty() ) {
889 QString des = eve->description(); 889 QString des = eve->description();
890 QString pref = "e"; 890 QString pref = "e";
891 if ( toDelete->type() == "Todo" ) 891 if ( toDelete->type() == "Todo" )
892 pref = "t"; 892 pref = "t";
893 des += pref+ id + ","; 893 des += pref+ id + ",";
894 eve->setReadOnly( false ); 894 eve->setReadOnly( false );
895 eve->setDescription( des ); 895 eve->setDescription( des );
896 //qDebug("setdes %s ", des.latin1()); 896 //qDebug("setdes %s ", des.latin1());
897 eve->setReadOnly( true ); 897 eve->setReadOnly( true );
898 } 898 }
899 eve = lastSync.next(); 899 eve = lastSync.next();
900 } 900 }
901 901
902} 902}
903void CalendarView::checkExternalId( Incidence * inc ) 903void CalendarView::checkExternalId( Incidence * inc )
904{ 904{
905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
906 checkExternSyncEvent( lastSync, inc ); 906 checkExternSyncEvent( lastSync, inc );
907 907
908} 908}
909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
910{ 910{
911 bool syncOK = true; 911 bool syncOK = true;
912 int addedEvent = 0; 912 int addedEvent = 0;
913 int addedEventR = 0; 913 int addedEventR = 0;
914 int deletedEventR = 0; 914 int deletedEventR = 0;
915 int deletedEventL = 0; 915 int deletedEventL = 0;
916 int changedLocal = 0; 916 int changedLocal = 0;
917 int changedRemote = 0; 917 int changedRemote = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncKDE ) { 930 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync;; 939 QDateTime modifiedCalendar = mLastCalendarSync;;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncKDE ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 int w = 300; 990 int w = 300;
991 if ( QApplication::desktop()->width() < 320 ) 991 if ( QApplication::desktop()->width() < 320 )
992 w = 220; 992 w = 220;
993 int h = bar.sizeHint().height() ; 993 int h = bar.sizeHint().height() ;
994 int dw = QApplication::desktop()->width(); 994 int dw = QApplication::desktop()->width();
995 int dh = QApplication::desktop()->height(); 995 int dh = QApplication::desktop()->height();
996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
997 bar.show(); 997 bar.show();
998 int modulo = (er.count()/10)+1; 998 int modulo = (er.count()/10)+1;
999 int incCounter = 0; 999 int incCounter = 0;
1000 while ( inR ) { 1000 while ( inR ) {
1001 if ( ! bar.isVisible() ) 1001 if ( ! bar.isVisible() )
1002 return false; 1002 return false;
1003 if ( incCounter % modulo == 0 ) 1003 if ( incCounter % modulo == 0 )
1004 bar.setProgress( incCounter ); 1004 bar.setProgress( incCounter );
1005 ++incCounter; 1005 ++incCounter;
1006 uid = inR->uid(); 1006 uid = inR->uid();
1007 bool skipIncidence = false; 1007 bool skipIncidence = false;
1008 if ( uid.left(15) == QString("last-syncEvent-") ) 1008 if ( uid.left(15) == QString("last-syncEvent-") )
1009 skipIncidence = true; 1009 skipIncidence = true;
1010 QString idS; 1010 QString idS;
1011 qApp->processEvents(); 1011 qApp->processEvents();
1012 if ( !skipIncidence ) { 1012 if ( !skipIncidence ) {
1013 inL = local->incidence( uid ); 1013 inL = local->incidence( uid );
1014 if ( inL ) { // maybe conflict - same uid in both calendars 1014 if ( inL ) { // maybe conflict - same uid in both calendars
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1017 if ( take == 3 )
1018 return false; 1018 return false;
1019 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1022 else
1023 idS = inR->IDStr(); 1023 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1024 remote->deleteIncidence( inR );
1025 inR = inL->clone(); 1025 inR = inL->clone();
1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1028 inR->setIDStr( idS ); 1028 inR->setIDStr( idS );
1029 remote->addIncidence( inR ); 1029 remote->addIncidence( inR );
1030 if ( mSyncKDE ) 1030 if ( mSyncManager->syncWithDesktop() )
1031 inR->setPilotId( 2 ); 1031 inR->setPilotId( 2 );
1032 ++changedRemote; 1032 ++changedRemote;
1033 } else { 1033 } else {
1034 idS = inL->IDStr(); 1034 idS = inL->IDStr();
1035 int pid = inL->pilotId(); 1035 int pid = inL->pilotId();
1036 local->deleteIncidence( inL ); 1036 local->deleteIncidence( inL );
1037 inL = inR->clone(); 1037 inL = inR->clone();
1038 if ( mSyncKDE ) 1038 if ( mSyncManager->syncWithDesktop() )
1039 inL->setPilotId( pid ); 1039 inL->setPilotId( pid );
1040 inL->setIDStr( idS ); 1040 inL->setIDStr( idS );
1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1044 } 1044 }
1045 local->addIncidence( inL ); 1045 local->addIncidence( inL );
1046 ++changedLocal; 1046 ++changedLocal;
1047 } 1047 }
1048 } 1048 }
1049 } else { // no conflict 1049 } else { // no conflict
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 QString des = eventLSync->description(); 1051 QString des = eventLSync->description();
1052 QString pref = "e"; 1052 QString pref = "e";
1053 if ( inR->type() == "Todo" ) 1053 if ( inR->type() == "Todo" )
1054 pref = "t"; 1054 pref = "t";
1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1057 //remote->deleteIncidence( inR ); 1057 //remote->deleteIncidence( inR );
1058 ++deletedEventR; 1058 ++deletedEventR;
1059 } else { 1059 } else {
1060 inR->setLastModified( modifiedCalendar ); 1060 inR->setLastModified( modifiedCalendar );
1061 inL = inR->clone(); 1061 inL = inR->clone();
1062 inL->setIDStr( ":" ); 1062 inL->setIDStr( ":" );
1063 local->addIncidence( inL ); 1063 local->addIncidence( inL );
1064 ++addedEvent; 1064 ++addedEvent;
1065 } 1065 }
1066 } else { 1066 } else {
1067 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1067 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1068 inR->setLastModified( modifiedCalendar ); 1068 inR->setLastModified( modifiedCalendar );
1069 inL = inR->clone(); 1069 inL = inR->clone();
1070 inL->setIDStr( ":" ); 1070 inL->setIDStr( ":" );
1071 local->addIncidence( inL ); 1071 local->addIncidence( inL );
1072 ++addedEvent; 1072 ++addedEvent;
1073 } else { 1073 } else {
1074 checkExternSyncEvent(eventRSyncSharp, inR); 1074 checkExternSyncEvent(eventRSyncSharp, inR);
1075 remote->deleteIncidence( inR ); 1075 remote->deleteIncidence( inR );
1076 ++deletedEventR; 1076 ++deletedEventR;
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 } 1080 }
1081 inR = er.next(); 1081 inR = er.next();
1082 } 1082 }
1083 QPtrList<Incidence> el = local->rawIncidences(); 1083 QPtrList<Incidence> el = local->rawIncidences();
1084 inL = el.first(); 1084 inL = el.first();
1085 modulo = (el.count()/10)+1; 1085 modulo = (el.count()/10)+1;
1086 bar.setCaption (i18n("Add / remove events") ); 1086 bar.setCaption (i18n("Add / remove events") );
1087 bar.setTotalSteps ( el.count() ) ; 1087 bar.setTotalSteps ( el.count() ) ;
1088 bar.show(); 1088 bar.show();
1089 incCounter = 0; 1089 incCounter = 0;
1090 1090
1091 while ( inL ) { 1091 while ( inL ) {
1092 1092
1093 qApp->processEvents(); 1093 qApp->processEvents();
1094 if ( ! bar.isVisible() ) 1094 if ( ! bar.isVisible() )
1095 return false; 1095 return false;
1096 if ( incCounter % modulo == 0 ) 1096 if ( incCounter % modulo == 0 )
1097 bar.setProgress( incCounter ); 1097 bar.setProgress( incCounter );
1098 ++incCounter; 1098 ++incCounter;
1099 uid = inL->uid(); 1099 uid = inL->uid();
1100 bool skipIncidence = false; 1100 bool skipIncidence = false;
1101 if ( uid.left(15) == QString("last-syncEvent-") ) 1101 if ( uid.left(15) == QString("last-syncEvent-") )
1102 skipIncidence = true; 1102 skipIncidence = true;
1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1104 skipIncidence = true; 1104 skipIncidence = true;
1105 if ( !skipIncidence ) { 1105 if ( !skipIncidence ) {
1106 inR = remote->incidence( uid ); 1106 inR = remote->incidence( uid );
1107 if ( ! inR ) { 1107 if ( ! inR ) {
1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1110 checkExternSyncEvent(eventLSyncSharp, inL); 1110 checkExternSyncEvent(eventLSyncSharp, inL);
1111 local->deleteIncidence( inL ); 1111 local->deleteIncidence( inL );
1112 ++deletedEventL; 1112 ++deletedEventL;
1113 } else { 1113 } else {
1114 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1114 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1115 inL->removeID(mCurrentSyncDevice ); 1115 inL->removeID(mCurrentSyncDevice );
1116 ++addedEventR; 1116 ++addedEventR;
1117 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1117 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1118 inL->setLastModified( modifiedCalendar ); 1118 inL->setLastModified( modifiedCalendar );
1119 inR = inL->clone(); 1119 inR = inL->clone();
1120 inR->setIDStr( ":" ); 1120 inR->setIDStr( ":" );
1121 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1121 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1122 remote->addIncidence( inR ); 1122 remote->addIncidence( inR );
1123 } 1123 }
1124 } 1124 }
1125 } else { 1125 } else {
1126 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1126 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1127 checkExternSyncEvent(eventLSyncSharp, inL); 1127 checkExternSyncEvent(eventLSyncSharp, inL);
1128 local->deleteIncidence( inL ); 1128 local->deleteIncidence( inL );
1129 ++deletedEventL; 1129 ++deletedEventL;
1130 } else { 1130 } else {
1131 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1131 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1132 ++addedEventR; 1132 ++addedEventR;
1133 inL->setLastModified( modifiedCalendar ); 1133 inL->setLastModified( modifiedCalendar );
1134 inR = inL->clone(); 1134 inR = inL->clone();
1135 inR->setIDStr( ":" ); 1135 inR->setIDStr( ":" );
1136 remote->addIncidence( inR ); 1136 remote->addIncidence( inR );
1137 } 1137 }
1138 } 1138 }
1139 } 1139 }
1140 } 1140 }
1141 } 1141 }
1142 inL = el.next(); 1142 inL = el.next();
1143 } 1143 }
1144 int delFut = 0; 1144 int delFut = 0;
1145 int remRem = 0; 1145 int remRem = 0;
1146 if ( mSyncManager->mWriteBackInFuture ) { 1146 if ( mSyncManager->mWriteBackInFuture ) {
1147 er = remote->rawIncidences(); 1147 er = remote->rawIncidences();
1148 remRem = er.count(); 1148 remRem = er.count();
1149 inR = er.first(); 1149 inR = er.first();
1150 QDateTime dt; 1150 QDateTime dt;
1151 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1151 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1152 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1152 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1153 while ( inR ) { 1153 while ( inR ) {
1154 if ( inR->type() == "Todo" ) { 1154 if ( inR->type() == "Todo" ) {
1155 Todo * t = (Todo*)inR; 1155 Todo * t = (Todo*)inR;
1156 if ( t->hasDueDate() ) 1156 if ( t->hasDueDate() )
1157 dt = t->dtDue(); 1157 dt = t->dtDue();
1158 else 1158 else
1159 dt = cur.addSecs( 62 ); 1159 dt = cur.addSecs( 62 );
1160 } 1160 }
1161 else if (inR->type() == "Event" ) { 1161 else if (inR->type() == "Event" ) {
1162 bool ok; 1162 bool ok;
1163 dt = inR->getNextOccurence( cur, &ok ); 1163 dt = inR->getNextOccurence( cur, &ok );
1164 if ( !ok ) 1164 if ( !ok )
1165 dt = cur.addSecs( -62 ); 1165 dt = cur.addSecs( -62 );
1166 } 1166 }
1167 else 1167 else
1168 dt = inR->dtStart(); 1168 dt = inR->dtStart();
1169 if ( dt < cur || dt > end ) { 1169 if ( dt < cur || dt > end ) {
1170 remote->deleteIncidence( inR ); 1170 remote->deleteIncidence( inR );
1171 ++delFut; 1171 ++delFut;
1172 } 1172 }
1173 inR = er.next(); 1173 inR = er.next();
1174 } 1174 }
1175 } 1175 }
1176 bar.hide(); 1176 bar.hide();
1177 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1177 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1178 eventLSync->setReadOnly( false ); 1178 eventLSync->setReadOnly( false );
1179 eventLSync->setDtStart( mLastCalendarSync ); 1179 eventLSync->setDtStart( mLastCalendarSync );
1180 eventRSync->setDtStart( mLastCalendarSync ); 1180 eventRSync->setDtStart( mLastCalendarSync );
1181 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1181 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1182 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1182 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1183 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1183 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1184 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1184 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1185 eventLSync->setReadOnly( true ); 1185 eventLSync->setReadOnly( true );
1186 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... 1186 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1187 remote->addEvent( eventRSync ); 1187 remote->addEvent( eventRSync );
1188 else 1188 else
1189 delete eventRSync; 1189 delete eventRSync;
1190 QString mes; 1190 QString mes;
1191 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 ); 1191 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 );
1192 QString delmess; 1192 QString delmess;
1193 if ( delFut ) { 1193 if ( delFut ) {
1194 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1194 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1195 mes += delmess; 1195 mes += delmess;
1196 } 1196 }
1197 if ( mSyncManager->mShowSyncSummary ) { 1197 if ( mSyncManager->mShowSyncSummary ) {
1198 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1198 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1199 } 1199 }
1200 qDebug( mes ); 1200 qDebug( mes );
1201 mCalendar->checkAlarmForIncidence( 0, true ); 1201 mCalendar->checkAlarmForIncidence( 0, true );
1202 return syncOK; 1202 return syncOK;
1203} 1203}
1204 1204
1205void CalendarView::setSyncDevice( QString s ) 1205void CalendarView::setSyncDevice( QString s )
1206{ 1206{
1207 mCurrentSyncDevice= s; 1207 mCurrentSyncDevice= s;
1208} 1208}
1209void CalendarView::setSyncName( QString s ) 1209void CalendarView::setSyncName( QString s )
1210{ 1210{
1211 mCurrentSyncName= s; 1211 mCurrentSyncName= s;
1212} 1212}
1213bool CalendarView::syncCalendar(QString filename, int mode) 1213bool CalendarView::syncCalendar(QString filename, int mode)
1214{ 1214{
1215 //qDebug("syncCalendar %s ", filename.latin1()); 1215 //qDebug("syncCalendar %s ", filename.latin1());
1216 mGlobalSyncMode = SYNC_MODE_NORMAL; 1216 mGlobalSyncMode = SYNC_MODE_NORMAL;
1217 CalendarLocal* calendar = new CalendarLocal(); 1217 CalendarLocal* calendar = new CalendarLocal();
1218 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1218 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1219 FileStorage* storage = new FileStorage( calendar ); 1219 FileStorage* storage = new FileStorage( calendar );
1220 bool syncOK = false; 1220 bool syncOK = false;
1221 storage->setFileName( filename ); 1221 storage->setFileName( filename );
1222 // qDebug("loading ... "); 1222 // qDebug("loading ... ");
1223 if ( storage->load() ) { 1223 if ( storage->load() ) {
1224 getEventViewerDialog()->setSyncMode( true ); 1224 getEventViewerDialog()->setSyncMode( true );
1225 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1225 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1226 getEventViewerDialog()->setSyncMode( false ); 1226 getEventViewerDialog()->setSyncMode( false );
1227 if ( syncOK ) { 1227 if ( syncOK ) {
1228 if ( mSyncManager->mWriteBackFile ) 1228 if ( mSyncManager->mWriteBackFile )
1229 { 1229 {
1230 storage->setSaveFormat( new ICalFormat() ); 1230 storage->setSaveFormat( new ICalFormat() );
1231 storage->save(); 1231 storage->save();
1232 } 1232 }
1233 } 1233 }
1234 setModified( true ); 1234 setModified( true );
1235 } 1235 }
1236 delete storage; 1236 delete storage;
1237 delete calendar; 1237 delete calendar;
1238 if ( syncOK ) 1238 if ( syncOK )
1239 updateView(); 1239 updateView();
1240 return syncOK; 1240 return syncOK;
1241} 1241}
1242 1242
1243void CalendarView::syncExternal( int mode ) 1243void CalendarView::syncExternal( int mode )
1244{ 1244{
1245 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1245 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1246 1246
1247 qApp->processEvents(); 1247 qApp->processEvents();
1248 CalendarLocal* calendar = new CalendarLocal(); 1248 CalendarLocal* calendar = new CalendarLocal();
1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1250 bool syncOK = false; 1250 bool syncOK = false;
1251 bool loadSuccess = false; 1251 bool loadSuccess = false;
1252 PhoneFormat* phoneFormat = 0; 1252 PhoneFormat* phoneFormat = 0;
1253 emit tempDisableBR(true); 1253 emit tempDisableBR(true);
1254#ifndef DESKTOP_VERSION 1254#ifndef DESKTOP_VERSION
1255 SharpFormat* sharpFormat = 0; 1255 SharpFormat* sharpFormat = 0;
1256 if ( mode == 0 ) { // sharp 1256 if ( mode == 0 ) { // sharp
1257 sharpFormat = new SharpFormat () ; 1257 sharpFormat = new SharpFormat () ;
1258 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1258 loadSuccess = sharpFormat->load( calendar, mCalendar );
1259 1259
1260 } else 1260 } else
1261#endif 1261#endif
1262 if ( mode == 1 ) { // phone 1262 if ( mode == 1 ) { // phone
1263 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1263 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1264 mSyncManager->mPhoneDevice, 1264 mSyncManager->mPhoneDevice,
1265 mSyncManager->mPhoneConnection, 1265 mSyncManager->mPhoneConnection,
1266 mSyncManager->mPhoneModel); 1266 mSyncManager->mPhoneModel);
1267 loadSuccess = phoneFormat->load( calendar,mCalendar); 1267 loadSuccess = phoneFormat->load( calendar,mCalendar);
1268 1268
1269 } else { 1269 } else {
1270 emit tempDisableBR(false); 1270 emit tempDisableBR(false);
1271 return; 1271 return;
1272 } 1272 }
1273 if ( loadSuccess ) { 1273 if ( loadSuccess ) {
1274 getEventViewerDialog()->setSyncMode( true ); 1274 getEventViewerDialog()->setSyncMode( true );
1275 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1275 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1276 getEventViewerDialog()->setSyncMode( false ); 1276 getEventViewerDialog()->setSyncMode( false );
1277 qApp->processEvents(); 1277 qApp->processEvents();
1278 if ( syncOK ) { 1278 if ( syncOK ) {
1279 if ( mSyncManager->mWriteBackFile ) 1279 if ( mSyncManager->mWriteBackFile )
1280 { 1280 {
1281 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1281 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1282 Incidence* inc = iL.first(); 1282 Incidence* inc = iL.first();
1283 if ( phoneFormat ) { 1283 if ( phoneFormat ) {
1284 while ( inc ) { 1284 while ( inc ) {
1285 inc->removeID(mCurrentSyncDevice); 1285 inc->removeID(mCurrentSyncDevice);
1286 inc = iL.next(); 1286 inc = iL.next();
1287 } 1287 }
1288 } 1288 }
1289#ifndef DESKTOP_VERSION 1289#ifndef DESKTOP_VERSION
1290 if ( sharpFormat ) 1290 if ( sharpFormat )
1291 sharpFormat->save(calendar); 1291 sharpFormat->save(calendar);
1292#endif 1292#endif
1293 if ( phoneFormat ) 1293 if ( phoneFormat )
1294 phoneFormat->save(calendar); 1294 phoneFormat->save(calendar);
1295 iL = calendar->rawIncidences(); 1295 iL = calendar->rawIncidences();
1296 inc = iL.first(); 1296 inc = iL.first();
1297 Incidence* loc; 1297 Incidence* loc;
1298 while ( inc ) { 1298 while ( inc ) {
1299 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1299 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1300 loc = mCalendar->incidence(inc->uid() ); 1300 loc = mCalendar->incidence(inc->uid() );
1301 if ( loc ) { 1301 if ( loc ) {
1302 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1302 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1303 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1303 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1304 } 1304 }
1305 } 1305 }
1306 inc = iL.next(); 1306 inc = iL.next();
1307 } 1307 }
1308 Incidence* lse = getLastSyncEvent(); 1308 Incidence* lse = getLastSyncEvent();
1309 if ( lse ) { 1309 if ( lse ) {
1310 lse->setReadOnly( false ); 1310 lse->setReadOnly( false );
1311 lse->setDescription( "" ); 1311 lse->setDescription( "" );
1312 lse->setReadOnly( true ); 1312 lse->setReadOnly( true );
1313 } 1313 }
1314 } 1314 }
@@ -3620,161 +3620,158 @@ void CalendarView::editIncidence()
3620 Incidence *incidence = currentSelection(); 3620 Incidence *incidence = currentSelection();
3621 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3621 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3622 if ( incidence ) { 3622 if ( incidence ) {
3623 EditIncidenceVisitor v; 3623 EditIncidenceVisitor v;
3624 v.act( incidence, this ); 3624 v.act( incidence, this );
3625 } 3625 }
3626} 3626}
3627 3627
3628void CalendarView::deleteIncidence() 3628void CalendarView::deleteIncidence()
3629{ 3629{
3630 Incidence *incidence = currentSelection(); 3630 Incidence *incidence = currentSelection();
3631 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3631 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3632 if ( incidence ) { 3632 if ( incidence ) {
3633 deleteIncidence(incidence); 3633 deleteIncidence(incidence);
3634 } 3634 }
3635} 3635}
3636 3636
3637void CalendarView::showIncidence(Incidence *incidence) 3637void CalendarView::showIncidence(Incidence *incidence)
3638{ 3638{
3639 if ( incidence ) { 3639 if ( incidence ) {
3640 ShowIncidenceVisitor v; 3640 ShowIncidenceVisitor v;
3641 v.act( incidence, this ); 3641 v.act( incidence, this );
3642 } 3642 }
3643} 3643}
3644 3644
3645void CalendarView::editIncidence(Incidence *incidence) 3645void CalendarView::editIncidence(Incidence *incidence)
3646{ 3646{
3647 if ( incidence ) { 3647 if ( incidence ) {
3648 3648
3649 EditIncidenceVisitor v; 3649 EditIncidenceVisitor v;
3650 v.act( incidence, this ); 3650 v.act( incidence, this );
3651 3651
3652 } 3652 }
3653} 3653}
3654 3654
3655void CalendarView::deleteIncidence(Incidence *incidence) 3655void CalendarView::deleteIncidence(Incidence *incidence)
3656{ 3656{
3657 //qDebug(" CalendarView::deleteIncidence "); 3657 //qDebug(" CalendarView::deleteIncidence ");
3658 if ( incidence ) { 3658 if ( incidence ) {
3659 DeleteIncidenceVisitor v; 3659 DeleteIncidenceVisitor v;
3660 v.act( incidence, this ); 3660 v.act( incidence, this );
3661 } 3661 }
3662} 3662}
3663 3663
3664 3664
3665void CalendarView::lookForOutgoingMessages() 3665void CalendarView::lookForOutgoingMessages()
3666{ 3666{
3667 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3667 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3668 ogd->loadMessages(); 3668 ogd->loadMessages();
3669} 3669}
3670 3670
3671void CalendarView::lookForIncomingMessages() 3671void CalendarView::lookForIncomingMessages()
3672{ 3672{
3673 IncomingDialog *icd = mDialogManager->incomingDialog(); 3673 IncomingDialog *icd = mDialogManager->incomingDialog();
3674 icd->retrieve(); 3674 icd->retrieve();
3675} 3675}
3676 3676
3677bool CalendarView::removeCompletedSubTodos( Todo* t ) 3677bool CalendarView::removeCompletedSubTodos( Todo* t )
3678{ 3678{
3679 bool deleteTodo = true; 3679 bool deleteTodo = true;
3680 QPtrList<Incidence> subTodos; 3680 QPtrList<Incidence> subTodos;
3681 Incidence *aTodo; 3681 Incidence *aTodo;
3682 subTodos = t->relations(); 3682 subTodos = t->relations();
3683 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3683 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3684 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3684 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3685 deleteTodo = false; 3685 deleteTodo = false;
3686 } 3686 }
3687 if ( deleteTodo ) { 3687 if ( deleteTodo ) {
3688 if ( t->isCompleted() ) { 3688 if ( t->isCompleted() ) {
3689 checkExternalId( t ); 3689 checkExternalId( t );
3690 mCalendar->deleteTodo( t ); 3690 mCalendar->deleteTodo( t );
3691 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3691 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3692 } 3692 }
3693 else 3693 else
3694 deleteTodo = false; 3694 deleteTodo = false;
3695 } 3695 }
3696 return deleteTodo; 3696 return deleteTodo;
3697 3697
3698} 3698}
3699void CalendarView::purgeCompleted() 3699void CalendarView::purgeCompleted()
3700{ 3700{
3701 int result = KMessageBox::warningContinueCancel(this, 3701 int result = KMessageBox::warningContinueCancel(this,
3702 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3702 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3703 3703
3704 if (result == KMessageBox::Continue) { 3704 if (result == KMessageBox::Continue) {
3705 3705
3706 QPtrList<Todo> todoCal; 3706 QPtrList<Todo> todoCal;
3707 QPtrList<Todo> rootTodos; 3707 QPtrList<Todo> rootTodos;
3708 //QPtrList<Incidence> rel; 3708 //QPtrList<Incidence> rel;
3709 Todo *aTodo;//, *rTodo; 3709 Todo *aTodo;//, *rTodo;
3710 Incidence *rIncidence; 3710 Incidence *rIncidence;
3711 bool childDelete = false; 3711 bool childDelete = false;
3712 bool deletedOne = true; 3712 bool deletedOne = true;
3713 todoCal = calendar()->todos(); 3713 todoCal = calendar()->todos();
3714 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3714 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3715 if ( !aTodo->relatedTo() ) 3715 if ( !aTodo->relatedTo() )
3716 rootTodos.append( aTodo ); 3716 rootTodos.append( aTodo );
3717 } 3717 }
3718 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3718 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3719 removeCompletedSubTodos( aTodo ); 3719 removeCompletedSubTodos( aTodo );
3720 } 3720 }
3721 3721
3722 updateView(); 3722 updateView();
3723 } 3723 }
3724} 3724}
3725 3725
3726void CalendarView::slotCalendarChanged() 3726void CalendarView::slotCalendarChanged()
3727{ 3727{
3728 ; 3728 ;
3729} 3729}
3730 3730
3731NavigatorBar *CalendarView::navigatorBar() 3731NavigatorBar *CalendarView::navigatorBar()
3732{ 3732{
3733 return mNavigatorBar; 3733 return mNavigatorBar;
3734} 3734}
3735 3735
3736 3736
3737 3737
3738void CalendarView::keyPressEvent ( QKeyEvent *e) 3738void CalendarView::keyPressEvent ( QKeyEvent *e)
3739{ 3739{
3740 //qDebug(" alendarView::keyPressEvent "); 3740 //qDebug(" alendarView::keyPressEvent ");
3741 e->ignore(); 3741 e->ignore();
3742} 3742}
3743 3743
3744 3744
3745bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3745bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3746{ 3746{
3747 // mSyncManager = manager; 3747 // mSyncManager = manager;
3748 mSyncKDE = false;
3749 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3748 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3750 qDebug("SyncKDE request detected!"); 3749 qDebug("SyncKDE request detected!");
3751 mSyncKDE = true;
3752 } 3750 }
3753 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3751 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3754 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3752 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3755 return syncCalendar( filename, mode ); 3753 return syncCalendar( filename, mode );
3756} 3754}
3757bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3755bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3758{ 3756{
3759 mSyncKDE = false;
3760 //mSyncManager = manager; 3757 //mSyncManager = manager;
3761 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3758 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3762 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3759 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3763 if ( resource == "sharp" ) 3760 if ( resource == "sharp" )
3764 syncExternal( 0 ); 3761 syncExternal( 0 );
3765 if ( resource == "phone" ) 3762 if ( resource == "phone" )
3766 syncExternal( 1 ); 3763 syncExternal( 1 );
3767 // pending setmodified 3764 // pending setmodified
3768 return true; 3765 return true;
3769} 3766}
3770void CalendarView::setSyncManager(KSyncManager* manager) 3767void CalendarView::setSyncManager(KSyncManager* manager)
3771{ 3768{
3772 mSyncManager = manager; 3769 mSyncManager = manager;
3773} 3770}
3774 3771
3775void CalendarView::removeSyncInfo( QString syncProfile) 3772void CalendarView::removeSyncInfo( QString syncProfile)
3776{ 3773{
3777 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3774 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3778 mCalendar->removeSyncInfo( syncProfile ); 3775 mCalendar->removeSyncInfo( syncProfile );
3779 3776
3780} 3777}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index acc20d6..437a51c 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -364,243 +364,242 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
364 void takeOverCalendar(); 364 void takeOverCalendar();
365 365
366 /** query whether or not the calendar is "dirty". */ 366 /** query whether or not the calendar is "dirty". */
367 bool isModified(); 367 bool isModified();
368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
369 void setModified(bool modified=true); 369 void setModified(bool modified=true);
370 370
371 /** query if the calendar is read-only. */ 371 /** query if the calendar is read-only. */
372 bool isReadOnly(); 372 bool isReadOnly();
373 /** set state of calendar to read-only */ 373 /** set state of calendar to read-only */
374 void setReadOnly(bool readOnly=true); 374 void setReadOnly(bool readOnly=true);
375 375
376 void eventUpdated(Incidence *); 376 void eventUpdated(Incidence *);
377 377
378 /* iTIP scheduling actions */ 378 /* iTIP scheduling actions */
379 void schedule_publish(Incidence *incidence = 0); 379 void schedule_publish(Incidence *incidence = 0);
380 void schedule_request(Incidence *incidence = 0); 380 void schedule_request(Incidence *incidence = 0);
381 void schedule_refresh(Incidence *incidence = 0); 381 void schedule_refresh(Incidence *incidence = 0);
382 void schedule_cancel(Incidence *incidence = 0); 382 void schedule_cancel(Incidence *incidence = 0);
383 void schedule_add(Incidence *incidence = 0); 383 void schedule_add(Incidence *incidence = 0);
384 void schedule_reply(Incidence *incidence = 0); 384 void schedule_reply(Incidence *incidence = 0);
385 void schedule_counter(Incidence *incidence = 0); 385 void schedule_counter(Incidence *incidence = 0);
386 void schedule_declinecounter(Incidence *incidence = 0); 386 void schedule_declinecounter(Incidence *incidence = 0);
387 void schedule_publish_freebusy(int daysToPublish = 30); 387 void schedule_publish_freebusy(int daysToPublish = 30);
388 388
389 void openAddressbook(); 389 void openAddressbook();
390 390
391 void editFilters(); 391 void editFilters();
392 void toggleFilerEnabled(); 392 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 393 QPtrList<CalFilter> filters();
394 void toggleFilter(); 394 void toggleFilter();
395 void showFilter(bool visible); 395 void showFilter(bool visible);
396 void updateFilter(); 396 void updateFilter();
397 void filterEdited(); 397 void filterEdited();
398 void selectFilter( int ); 398 void selectFilter( int );
399 KOFilterView *filterView(); 399 KOFilterView *filterView();
400 400
401 void showIntro(); 401 void showIntro();
402 402
403 /** Move the curdatepient view date to today */ 403 /** Move the curdatepient view date to today */
404 void goToday(); 404 void goToday();
405 405
406 /** Move to the next date(s) in the current view */ 406 /** Move to the next date(s) in the current view */
407 void goNext(); 407 void goNext();
408 408
409 /** Move to the previous date(s) in the current view */ 409 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 410 void goPrevious();
411 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 412 void goNextMonth();
413 413
414 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 415 void goPreviousMonth();
416 416
417 void toggleExpand(); 417 void toggleExpand();
418 void toggleDateNavigatorWidget(); 418 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 419 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 420 void dialogClosing(Incidence *);
421 421
422 /** Look for new messages in the inbox */ 422 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 423 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 424 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 425 void lookForOutgoingMessages();
426 426
427 void processMainViewSelection( Incidence * ); 427 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 428 void processTodoListSelection( Incidence * );
429 429
430 void processIncidenceSelection( Incidence * ); 430 void processIncidenceSelection( Incidence * );
431 431
432 void purgeCompleted(); 432 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 433 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 434 void slotCalendarChanged();
435 bool importBday(); 435 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 437 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 438 const QString &datebookFile,
439 const QString &tasklistFile ); 439 const QString &tasklistFile );
440 void syncExternal( int mode ); 440 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 441 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 442 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 443 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 protected slots: 453 protected slots:
454 void timerAlarm(); 454 void timerAlarm();
455 void suspendAlarm(); 455 void suspendAlarm();
456 void beamDone( Ir *ir ); 456 void beamDone( Ir *ir );
457 /** Select a view or adapt the current view to display the specified dates. */ 457 /** Select a view or adapt the current view to display the specified dates. */
458 void showDates( const KCal::DateList & ); 458 void showDates( const KCal::DateList & );
459 void selectWeekNum ( int ); 459 void selectWeekNum ( int );
460 460
461 public: 461 public:
462 // show a standard warning 462 // show a standard warning
463 // returns KMsgBox::yesNoCancel() 463 // returns KMsgBox::yesNoCancel()
464 int msgCalModified(); 464 int msgCalModified();
465 virtual bool sync(KSyncManager* manager, QString filename, int mode); 465 virtual bool sync(KSyncManager* manager, QString filename, int mode);
466 466
467 virtual bool syncExternal(KSyncManager* manager, QString resource); 467 virtual bool syncExternal(KSyncManager* manager, QString resource);
468 virtual void removeSyncInfo( QString syncProfile); 468 virtual void removeSyncInfo( QString syncProfile);
469 void setSyncManager(KSyncManager* manager); 469 void setSyncManager(KSyncManager* manager);
470 void setLoadedFileVersion(QDateTime); 470 void setLoadedFileVersion(QDateTime);
471 bool checkFileVersion(QString fn); 471 bool checkFileVersion(QString fn);
472 bool checkFileChanged(QString fn); 472 bool checkFileChanged(QString fn);
473 Event* getLastSyncEvent(); 473 Event* getLastSyncEvent();
474 /** Adapt navigation units correpsonding to step size of navigation of the 474 /** Adapt navigation units correpsonding to step size of navigation of the
475 * current view. 475 * current view.
476 */ 476 */
477 void adaptNavigationUnits(); 477 void adaptNavigationUnits();
478 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 478 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
479 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 479 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
480 //Attendee* getYourAttendee(Event *event); 480 //Attendee* getYourAttendee(Event *event);
481 protected: 481 protected:
482 void schedule(Scheduler::Method, Incidence *incidence = 0); 482 void schedule(Scheduler::Method, Incidence *incidence = 0);
483 483
484 // returns KMsgBox::OKCandel() 484 // returns KMsgBox::OKCandel()
485 int msgItemDelete(); 485 int msgItemDelete();
486 void showEventEditor(); 486 void showEventEditor();
487 void showTodoEditor(); 487 void showTodoEditor();
488 void writeLocale(); 488 void writeLocale();
489 Todo *selectedTodo(); 489 Todo *selectedTodo();
490 490
491 private: 491 private:
492 bool mSyncKDE;
493 KSyncManager* mSyncManager; 492 KSyncManager* mSyncManager;
494 AlarmDialog * mAlarmDialog; 493 AlarmDialog * mAlarmDialog;
495 QString mAlarmNotification; 494 QString mAlarmNotification;
496 QString mSuspendAlarmNotification; 495 QString mSuspendAlarmNotification;
497 QTimer* mSuspendTimer; 496 QTimer* mSuspendTimer;
498 QTimer* mAlarmTimer; 497 QTimer* mAlarmTimer;
499 QTimer* mRecheckAlarmTimer; 498 QTimer* mRecheckAlarmTimer;
500 void computeAlarm( QString ); 499 void computeAlarm( QString );
501 void startAlarm( QString, QString ); 500 void startAlarm( QString, QString );
502 void setSyncEventsReadOnly(); 501 void setSyncEventsReadOnly();
503 502
504 QDateTime loadedFileVersion; 503 QDateTime loadedFileVersion;
505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 504 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
506 void checkExternalId( Incidence * inc ); 505 void checkExternalId( Incidence * inc );
507 int mGlobalSyncMode; 506 int mGlobalSyncMode;
508 QString mCurrentSyncDevice; 507 QString mCurrentSyncDevice;
509 QString mCurrentSyncName; 508 QString mCurrentSyncName;
510 KOBeamPrefs* beamDialog; 509 KOBeamPrefs* beamDialog;
511 void init(); 510 void init();
512 int mDatePickerMode; 511 int mDatePickerMode;
513 bool mFlagEditDescription; 512 bool mFlagEditDescription;
514 QDateTime mLastCalendarSync; 513 QDateTime mLastCalendarSync;
515 void createPrinter(); 514 void createPrinter();
516 515
517 void calendarModified( bool, Calendar * ); 516 void calendarModified( bool, Calendar * );
518 517
519 CalPrinter *mCalPrinter; 518 CalPrinter *mCalPrinter;
520 519
521 QSplitter *mPanner; 520 QSplitter *mPanner;
522 QSplitter *mLeftSplitter; 521 QSplitter *mLeftSplitter;
523 QWidget *mLeftFrame; 522 QWidget *mLeftFrame;
524 QWidgetStack *mRightFrame; 523 QWidgetStack *mRightFrame;
525 524
526 KDatePicker* mDatePicker; 525 KDatePicker* mDatePicker;
527 QVBox* mDateFrame; 526 QVBox* mDateFrame;
528 NavigatorBar *mNavigatorBar; 527 NavigatorBar *mNavigatorBar;
529 528
530 KDateNavigator *mDateNavigator; // widget showing small month view. 529 KDateNavigator *mDateNavigator; // widget showing small month view.
531 530
532 KOFilterView *mFilterView; 531 KOFilterView *mFilterView;
533 532
534 ResourceView *mResourceView; 533 ResourceView *mResourceView;
535 534
536 // calendar object for this viewing instance 535 // calendar object for this viewing instance
537 Calendar *mCalendar; 536 Calendar *mCalendar;
538 537
539 CalendarResourceManager *mResourceManager; 538 CalendarResourceManager *mResourceManager;
540 539
541 FileStorage *mStorage; 540 FileStorage *mStorage;
542 541
543 DateNavigator *mNavigator; 542 DateNavigator *mNavigator;
544 543
545 KOViewManager *mViewManager; 544 KOViewManager *mViewManager;
546 KODialogManager *mDialogManager; 545 KODialogManager *mDialogManager;
547 546
548 // Calendar filters 547 // Calendar filters
549 QPtrList<CalFilter> mFilters; 548 QPtrList<CalFilter> mFilters;
550 549
551 // various housekeeping variables. 550 // various housekeeping variables.
552 bool mModified; // flag indicating if calendar is modified 551 bool mModified; // flag indicating if calendar is modified
553 bool mReadOnly; // flag indicating if calendar is read-only 552 bool mReadOnly; // flag indicating if calendar is read-only
554 QDate mSaveSingleDate; 553 QDate mSaveSingleDate;
555 554
556 Incidence *mSelectedIncidence; 555 Incidence *mSelectedIncidence;
557 Incidence *mMoveIncidence; 556 Incidence *mMoveIncidence;
558 KOTodoView *mTodoList; 557 KOTodoView *mTodoList;
559 KOEventEditor * mEventEditor; 558 KOEventEditor * mEventEditor;
560 KOTodoEditor * mTodoEditor; 559 KOTodoEditor * mTodoEditor;
561 KOEventViewerDialog * mEventViewerDialog; 560 KOEventViewerDialog * mEventViewerDialog;
562 void keyPressEvent ( QKeyEvent *e) ; 561 void keyPressEvent ( QKeyEvent *e) ;
563 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 562 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
564}; 563};
565 564
566 565
567class CalendarViewVisitor : public Incidence::Visitor 566class CalendarViewVisitor : public Incidence::Visitor
568{ 567{
569 public: 568 public:
570 CalendarViewVisitor() : mView( 0 ) {} 569 CalendarViewVisitor() : mView( 0 ) {}
571 570
572 bool act( Incidence *incidence, CalendarView *view ) 571 bool act( Incidence *incidence, CalendarView *view )
573 { 572 {
574 mView = view; 573 mView = view;
575 return incidence->accept( *this ); 574 return incidence->accept( *this );
576 } 575 }
577 576
578 protected: 577 protected:
579 CalendarView *mView; 578 CalendarView *mView;
580}; 579};
581 580
582class ShowIncidenceVisitor : public CalendarViewVisitor 581class ShowIncidenceVisitor : public CalendarViewVisitor
583{ 582{
584 protected: 583 protected:
585 bool visit( Event *event ) { mView->showEvent( event ); return true; } 584 bool visit( Event *event ) { mView->showEvent( event ); return true; }
586 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 585 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
587 bool visit( Journal * j ) { mView->showJournal( j );return true; } 586 bool visit( Journal * j ) { mView->showJournal( j );return true; }
588}; 587};
589 588
590class EditIncidenceVisitor : public CalendarViewVisitor 589class EditIncidenceVisitor : public CalendarViewVisitor
591{ 590{
592 protected: 591 protected:
593 bool visit( Event *event ) { mView->editEvent( event ); return true; } 592 bool visit( Event *event ) { mView->editEvent( event ); return true; }
594 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 593 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
595 bool visit( Journal *j ) { mView->editJournal( j); return true; } 594 bool visit( Journal *j ) { mView->editJournal( j); return true; }
596}; 595};
597 596
598class DeleteIncidenceVisitor : public CalendarViewVisitor 597class DeleteIncidenceVisitor : public CalendarViewVisitor
599{ 598{
600 protected: 599 protected:
601 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 600 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
602 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 601 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
603 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 602 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
604}; 603};
605 604
606#endif 605#endif