author | zautrix <zautrix> | 2005-02-09 20:56:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-09 20:56:06 (UTC) |
commit | ab7725c4517a1f6c145075edcff0bdafe105f0ea (patch) (unidiff) | |
tree | e1a230bcb5c31ca695bbebc40ff80874f2f13380 /korganizer | |
parent | a9eff860d8399a198a9fdc04e09ed369097fc745 (diff) | |
download | kdepimpi-ab7725c4517a1f6c145075edcff0bdafe105f0ea.zip kdepimpi-ab7725c4517a1f6c145075edcff0bdafe105f0ea.tar.gz kdepimpi-ab7725c4517a1f6c145075edcff0bdafe105f0ea.tar.bz2 |
fixes
-rw-r--r-- | korganizer/calendarview.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a9de65a..7c8316f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -846,769 +846,770 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | Event* CalendarView::getLastSyncEvent() | 848 | Event* CalendarView::getLastSyncEvent() |
849 | { | 849 | { |
850 | Event* lse; | 850 | Event* lse; |
851 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 851 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
852 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 852 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
853 | if (!lse) { | 853 | if (!lse) { |
854 | lse = new Event(); | 854 | lse = new Event(); |
855 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 855 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
856 | QString sum = ""; | 856 | QString sum = ""; |
857 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 857 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
858 | sum = "E: "; | 858 | sum = "E: "; |
859 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 859 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
860 | lse->setDtStart( mLastCalendarSync ); | 860 | lse->setDtStart( mLastCalendarSync ); |
861 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 861 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
862 | lse->setCategories( i18n("SyncEvent") ); | 862 | lse->setCategories( i18n("SyncEvent") ); |
863 | lse->setReadOnly( true ); | 863 | lse->setReadOnly( true ); |
864 | mCalendar->addEvent( lse ); | 864 | mCalendar->addEvent( lse ); |
865 | } | 865 | } |
866 | 866 | ||
867 | return lse; | 867 | return lse; |
868 | 868 | ||
869 | } | 869 | } |
870 | 870 | ||
871 | // we check, if the to delete event has a id for a profile | 871 | // we check, if the to delete event has a id for a profile |
872 | // if yes, we set this id in the profile to delete | 872 | // if yes, we set this id in the profile to delete |
873 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 873 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
874 | { | 874 | { |
875 | if ( lastSync.count() == 0 ) { | 875 | if ( lastSync.count() == 0 ) { |
876 | //qDebug(" lastSync.count() == 0"); | 876 | //qDebug(" lastSync.count() == 0"); |
877 | return; | 877 | return; |
878 | } | 878 | } |
879 | if ( toDelete->type() == "Journal" ) | 879 | if ( toDelete->type() == "Journal" ) |
880 | return; | 880 | return; |
881 | 881 | ||
882 | Event* eve = lastSync.first(); | 882 | Event* eve = lastSync.first(); |
883 | 883 | ||
884 | while ( eve ) { | 884 | while ( eve ) { |
885 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 885 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
886 | if ( !id.isEmpty() ) { | 886 | if ( !id.isEmpty() ) { |
887 | QString des = eve->description(); | 887 | QString des = eve->description(); |
888 | QString pref = "e"; | 888 | QString pref = "e"; |
889 | if ( toDelete->type() == "Todo" ) | 889 | if ( toDelete->type() == "Todo" ) |
890 | pref = "t"; | 890 | pref = "t"; |
891 | des += pref+ id + ","; | 891 | des += pref+ id + ","; |
892 | eve->setReadOnly( false ); | 892 | eve->setReadOnly( false ); |
893 | eve->setDescription( des ); | 893 | eve->setDescription( des ); |
894 | //qDebug("setdes %s ", des.latin1()); | 894 | //qDebug("setdes %s ", des.latin1()); |
895 | eve->setReadOnly( true ); | 895 | eve->setReadOnly( true ); |
896 | } | 896 | } |
897 | eve = lastSync.next(); | 897 | eve = lastSync.next(); |
898 | } | 898 | } |
899 | 899 | ||
900 | } | 900 | } |
901 | void CalendarView::checkExternalId( Incidence * inc ) | 901 | void CalendarView::checkExternalId( Incidence * inc ) |
902 | { | 902 | { |
903 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 903 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
904 | checkExternSyncEvent( lastSync, inc ); | 904 | checkExternSyncEvent( lastSync, inc ); |
905 | 905 | ||
906 | } | 906 | } |
907 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 907 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
908 | { | 908 | { |
909 | bool syncOK = true; | 909 | bool syncOK = true; |
910 | int addedEvent = 0; | 910 | int addedEvent = 0; |
911 | int addedEventR = 0; | 911 | int addedEventR = 0; |
912 | int deletedEventR = 0; | 912 | int deletedEventR = 0; |
913 | int deletedEventL = 0; | 913 | int deletedEventL = 0; |
914 | int changedLocal = 0; | 914 | int changedLocal = 0; |
915 | int changedRemote = 0; | 915 | int changedRemote = 0; |
916 | int filteredIN = 0; | 916 | int filteredIN = 0; |
917 | int filteredOUT = 0; | 917 | int filteredOUT = 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 ( mSyncManager->syncWithDesktop() ) { | 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("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("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 || mSyncManager->syncWithDesktop()) { | 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 ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= 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("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("KO: 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 | // ************** setting up filter ************* | 990 | // ************** setting up filter ************* |
991 | CalFilter *filterIN = 0; | 991 | CalFilter *filterIN = 0; |
992 | CalFilter *filterOUT = 0; | 992 | CalFilter *filterOUT = 0; |
993 | CalFilter *filter = mFilters.first(); | 993 | CalFilter *filter = mFilters.first(); |
994 | while(filter) { | 994 | while(filter) { |
995 | if ( filter->name() == mSyncManager->mFilterInCal ) | 995 | if ( filter->name() == mSyncManager->mFilterInCal ) |
996 | filterIN = filter; | 996 | filterIN = filter; |
997 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 997 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
998 | filterOUT = filter; | 998 | filterOUT = filter; |
999 | filter = mFilters.next(); | 999 | filter = mFilters.next(); |
1000 | } | 1000 | } |
1001 | int w = 300; | 1001 | int w = 300; |
1002 | if ( QApplication::desktop()->width() < 320 ) | 1002 | if ( QApplication::desktop()->width() < 320 ) |
1003 | w = 220; | 1003 | w = 220; |
1004 | int h = bar.sizeHint().height() ; | 1004 | int h = bar.sizeHint().height() ; |
1005 | int dw = QApplication::desktop()->width(); | 1005 | int dw = QApplication::desktop()->width(); |
1006 | int dh = QApplication::desktop()->height(); | 1006 | int dh = QApplication::desktop()->height(); |
1007 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1007 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1008 | bar.show(); | 1008 | bar.show(); |
1009 | int modulo = (er.count()/10)+1; | 1009 | int modulo = (er.count()/10)+1; |
1010 | int incCounter = 0; | 1010 | int incCounter = 0; |
1011 | while ( inR ) { | 1011 | while ( inR ) { |
1012 | if ( ! bar.isVisible() ) | 1012 | if ( ! bar.isVisible() ) |
1013 | return false; | 1013 | return false; |
1014 | if ( incCounter % modulo == 0 ) | 1014 | if ( incCounter % modulo == 0 ) |
1015 | bar.setProgress( incCounter ); | 1015 | bar.setProgress( incCounter ); |
1016 | ++incCounter; | 1016 | ++incCounter; |
1017 | uid = inR->uid(); | 1017 | uid = inR->uid(); |
1018 | bool skipIncidence = false; | 1018 | bool skipIncidence = false; |
1019 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1019 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1020 | skipIncidence = true; | 1020 | skipIncidence = true; |
1021 | QString idS; | 1021 | QString idS; |
1022 | qApp->processEvents(); | 1022 | qApp->processEvents(); |
1023 | if ( !skipIncidence ) { | 1023 | if ( !skipIncidence ) { |
1024 | inL = local->incidence( uid ); | 1024 | inL = local->incidence( uid ); |
1025 | if ( inL ) { // maybe conflict - same uid in both calendars | 1025 | if ( inL ) { // maybe conflict - same uid in both calendars |
1026 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1026 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1027 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1027 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1028 | if ( take == 3 ) | 1028 | if ( take == 3 ) |
1029 | return false; | 1029 | return false; |
1030 | if ( take == 1 ) {// take local ********************** | 1030 | if ( take == 1 ) {// take local ********************** |
1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1033 | else | 1033 | else |
1034 | idS = inR->IDStr(); | 1034 | idS = inR->IDStr(); |
1035 | remote->deleteIncidence( inR ); | 1035 | remote->deleteIncidence( inR ); |
1036 | inR = inL->clone(); | 1036 | inR = inL->clone(); |
1037 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1037 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1038 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1038 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1039 | inR->setIDStr( idS ); | 1039 | inR->setIDStr( idS ); |
1040 | remote->addIncidence( inR ); | 1040 | remote->addIncidence( inR ); |
1041 | if ( mSyncManager->syncWithDesktop() ) | 1041 | if ( mSyncManager->syncWithDesktop() ) |
1042 | inR->setPilotId( 2 ); | 1042 | inR->setPilotId( 2 ); |
1043 | ++changedRemote; | 1043 | ++changedRemote; |
1044 | } else {// take remote ********************** | 1044 | } else {// take remote ********************** |
1045 | idS = inL->IDStr(); | 1045 | idS = inL->IDStr(); |
1046 | int pid = inL->pilotId(); | 1046 | int pid = inL->pilotId(); |
1047 | local->deleteIncidence( inL ); | 1047 | local->deleteIncidence( inL ); |
1048 | inL = inR->clone(); | 1048 | inL = inR->clone(); |
1049 | if ( mSyncManager->syncWithDesktop() ) | 1049 | if ( mSyncManager->syncWithDesktop() ) |
1050 | inL->setPilotId( pid ); | 1050 | inL->setPilotId( pid ); |
1051 | inL->setIDStr( idS ); | 1051 | inL->setIDStr( idS ); |
1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1055 | } | 1055 | } |
1056 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1057 | ++changedLocal; | 1057 | ++changedLocal; |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } else { // no conflict ********** add or delete remote | 1060 | } else { // no conflict ********** add or delete remote |
1061 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1061 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1063 | QString des = eventLSync->description(); | 1063 | QString des = eventLSync->description(); |
1064 | QString pref = "e"; | 1064 | QString pref = "e"; |
1065 | if ( inR->type() == "Todo" ) | 1065 | if ( inR->type() == "Todo" ) |
1066 | pref = "t"; | 1066 | pref = "t"; |
1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1069 | //remote->deleteIncidence( inR ); | 1069 | //remote->deleteIncidence( inR ); |
1070 | ++deletedEventR; | 1070 | ++deletedEventR; |
1071 | } else { | 1071 | } else { |
1072 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1073 | inL = inR->clone(); | 1073 | inL = inR->clone(); |
1074 | inL->setIDStr( ":" ); | 1074 | inL->setIDStr( ":" ); |
1075 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1075 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1076 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1076 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1077 | local->addIncidence( inL ); | 1077 | local->addIncidence( inL ); |
1078 | ++addedEvent; | 1078 | ++addedEvent; |
1079 | 1079 | ||
1080 | } | 1080 | } |
1081 | } else { | 1081 | } else { |
1082 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1082 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1083 | inR->setLastModified( modifiedCalendar ); | 1083 | inR->setLastModified( modifiedCalendar ); |
1084 | inL = inR->clone(); | 1084 | inL = inR->clone(); |
1085 | inL->setIDStr( ":" ); | 1085 | inL->setIDStr( ":" ); |
1086 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1087 | ++addedEvent; |
1088 | 1088 | ||
1089 | } else { | 1089 | } else { |
1090 | checkExternSyncEvent(eventRSyncSharp, inR); | 1090 | checkExternSyncEvent(eventRSyncSharp, inR); |
1091 | remote->deleteIncidence( inR ); | 1091 | remote->deleteIncidence( inR ); |
1092 | ++deletedEventR; | 1092 | ++deletedEventR; |
1093 | } | 1093 | } |
1094 | } | 1094 | } |
1095 | } else { | 1095 | } else { |
1096 | ++filteredIN; | 1096 | ++filteredIN; |
1097 | } | 1097 | } |
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | inR = er.next(); | 1100 | inR = er.next(); |
1101 | } | 1101 | } |
1102 | QPtrList<Incidence> el = local->rawIncidences(); | 1102 | QPtrList<Incidence> el = local->rawIncidences(); |
1103 | inL = el.first(); | 1103 | inL = el.first(); |
1104 | modulo = (el.count()/10)+1; | 1104 | modulo = (el.count()/10)+1; |
1105 | bar.setCaption (i18n("Add / remove events") ); | 1105 | bar.setCaption (i18n("Add / remove events") ); |
1106 | bar.setTotalSteps ( el.count() ) ; | 1106 | bar.setTotalSteps ( el.count() ) ; |
1107 | bar.show(); | 1107 | bar.show(); |
1108 | incCounter = 0; | 1108 | incCounter = 0; |
1109 | 1109 | ||
1110 | while ( inL ) { | 1110 | while ( inL ) { |
1111 | 1111 | ||
1112 | qApp->processEvents(); | 1112 | qApp->processEvents(); |
1113 | if ( ! bar.isVisible() ) | 1113 | if ( ! bar.isVisible() ) |
1114 | return false; | 1114 | return false; |
1115 | if ( incCounter % modulo == 0 ) | 1115 | if ( incCounter % modulo == 0 ) |
1116 | bar.setProgress( incCounter ); | 1116 | bar.setProgress( incCounter ); |
1117 | ++incCounter; | 1117 | ++incCounter; |
1118 | uid = inL->uid(); | 1118 | uid = inL->uid(); |
1119 | bool skipIncidence = false; | 1119 | bool skipIncidence = false; |
1120 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1120 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1121 | skipIncidence = true; | 1121 | skipIncidence = true; |
1122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1123 | skipIncidence = true; | 1123 | skipIncidence = true; |
1124 | if ( !skipIncidence ) { | 1124 | if ( !skipIncidence ) { |
1125 | inR = remote->incidence( uid ); | 1125 | inR = remote->incidence( uid ); |
1126 | if ( ! inR ) { | 1126 | if ( ! inR ) { |
1127 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1127 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1128 | // no conflict ********** add or delete local | 1128 | // no conflict ********** add or delete local |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1130 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1130 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1131 | checkExternSyncEvent(eventLSyncSharp, inL); | 1131 | checkExternSyncEvent(eventLSyncSharp, inL); |
1132 | local->deleteIncidence( inL ); | 1132 | local->deleteIncidence( inL ); |
1133 | ++deletedEventL; | 1133 | ++deletedEventL; |
1134 | } else { | 1134 | } else { |
1135 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1135 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1136 | inL->removeID(mCurrentSyncDevice ); | 1136 | inL->removeID(mCurrentSyncDevice ); |
1137 | ++addedEventR; | 1137 | ++addedEventR; |
1138 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1138 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1139 | inL->setLastModified( modifiedCalendar ); | 1139 | inL->setLastModified( modifiedCalendar ); |
1140 | inR = inL->clone(); | 1140 | inR = inL->clone(); |
1141 | inR->setIDStr( ":" ); | 1141 | inR->setIDStr( ":" ); |
1142 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1142 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1143 | remote->addIncidence( inR ); | 1143 | remote->addIncidence( inR ); |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | } else { | 1146 | } else { |
1147 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1147 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1148 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1149 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1150 | ++deletedEventL; |
1151 | } else { | 1151 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | ++addedEventR; | 1153 | ++addedEventR; |
1154 | inL->setLastModified( modifiedCalendar ); | 1154 | inL->setLastModified( modifiedCalendar ); |
1155 | inR = inL->clone(); | 1155 | inR = inL->clone(); |
1156 | inR->setIDStr( ":" ); | 1156 | inR->setIDStr( ":" ); |
1157 | remote->addIncidence( inR ); | 1157 | remote->addIncidence( inR ); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | } else { | 1161 | } else { |
1162 | ++filteredOUT; | 1162 | ++filteredOUT; |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } | 1165 | } |
1166 | inL = el.next(); | 1166 | inL = el.next(); |
1167 | } | 1167 | } |
1168 | int delFut = 0; | 1168 | int delFut = 0; |
1169 | int remRem = 0; | 1169 | int remRem = 0; |
1170 | if ( mSyncManager->mWriteBackInFuture ) { | 1170 | if ( mSyncManager->mWriteBackInFuture ) { |
1171 | er = remote->rawIncidences(); | 1171 | er = remote->rawIncidences(); |
1172 | remRem = er.count(); | 1172 | remRem = er.count(); |
1173 | inR = er.first(); | 1173 | inR = er.first(); |
1174 | QDateTime dt; | 1174 | QDateTime dt; |
1175 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1175 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1176 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1176 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1177 | while ( inR ) { | 1177 | while ( inR ) { |
1178 | if ( inR->type() == "Todo" ) { | 1178 | if ( inR->type() == "Todo" ) { |
1179 | Todo * t = (Todo*)inR; | 1179 | Todo * t = (Todo*)inR; |
1180 | if ( t->hasDueDate() ) | 1180 | if ( t->hasDueDate() ) |
1181 | dt = t->dtDue(); | 1181 | dt = t->dtDue(); |
1182 | else | 1182 | else |
1183 | dt = cur.addSecs( 62 ); | 1183 | dt = cur.addSecs( 62 ); |
1184 | } | 1184 | } |
1185 | else if (inR->type() == "Event" ) { | 1185 | else if (inR->type() == "Event" ) { |
1186 | bool ok; | 1186 | bool ok; |
1187 | dt = inR->getNextOccurence( cur, &ok ); | 1187 | dt = inR->getNextOccurence( cur, &ok ); |
1188 | if ( !ok ) | 1188 | if ( !ok ) |
1189 | dt = cur.addSecs( -62 ); | 1189 | dt = cur.addSecs( -62 ); |
1190 | } | 1190 | } |
1191 | else | 1191 | else |
1192 | dt = inR->dtStart(); | 1192 | dt = inR->dtStart(); |
1193 | if ( dt < cur || dt > end ) { | 1193 | if ( dt < cur || dt > end ) { |
1194 | remote->deleteIncidence( inR ); | 1194 | remote->deleteIncidence( inR ); |
1195 | ++delFut; | 1195 | ++delFut; |
1196 | } | 1196 | } |
1197 | inR = er.next(); | 1197 | inR = er.next(); |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | bar.hide(); | 1200 | bar.hide(); |
1201 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1201 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1202 | eventLSync->setReadOnly( false ); | 1202 | eventLSync->setReadOnly( false ); |
1203 | eventLSync->setDtStart( mLastCalendarSync ); | 1203 | eventLSync->setDtStart( mLastCalendarSync ); |
1204 | eventRSync->setDtStart( mLastCalendarSync ); | 1204 | eventRSync->setDtStart( mLastCalendarSync ); |
1205 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1205 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1206 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1206 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1207 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1207 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1208 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1208 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1209 | eventLSync->setReadOnly( true ); | 1209 | eventLSync->setReadOnly( true ); |
1210 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1210 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1211 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1211 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1212 | remote->addEvent( eventRSync ); | 1212 | remote->addEvent( eventRSync ); |
1213 | else | 1213 | else |
1214 | delete eventRSync; | 1214 | delete eventRSync; |
1215 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1215 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1216 | QString mes; | 1216 | QString mes; |
1217 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1217 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1218 | QString delmess; | 1218 | QString delmess; |
1219 | if ( delFut ) { | 1219 | if ( delFut ) { |
1220 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1220 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1221 | mes += delmess; | 1221 | mes += delmess; |
1222 | } | 1222 | } |
1223 | mes = i18n("Local calendar changed!\n") +mes; | 1223 | mes = i18n("Local calendar changed!\n") +mes; |
1224 | mCalendar->checkAlarmForIncidence( 0, true ); | 1224 | mCalendar->checkAlarmForIncidence( 0, true ); |
1225 | qDebug( mes ); | 1225 | qDebug( mes ); |
1226 | if ( mSyncManager->mShowSyncSummary ) { | 1226 | if ( mSyncManager->mShowSyncSummary ) { |
1227 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1227 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1228 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1228 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1229 | qDebug("KO: WB cancelled "); | 1229 | qDebug("KO: WB cancelled "); |
1230 | return false; | 1230 | mSyncManager->mWriteBackFile = false; |
1231 | return syncOK; | ||
1231 | } | 1232 | } |
1232 | } | 1233 | } |
1233 | return syncOK; | 1234 | return syncOK; |
1234 | } | 1235 | } |
1235 | 1236 | ||
1236 | void CalendarView::setSyncDevice( QString s ) | 1237 | void CalendarView::setSyncDevice( QString s ) |
1237 | { | 1238 | { |
1238 | mCurrentSyncDevice= s; | 1239 | mCurrentSyncDevice= s; |
1239 | } | 1240 | } |
1240 | void CalendarView::setSyncName( QString s ) | 1241 | void CalendarView::setSyncName( QString s ) |
1241 | { | 1242 | { |
1242 | mCurrentSyncName= s; | 1243 | mCurrentSyncName= s; |
1243 | } | 1244 | } |
1244 | bool CalendarView::syncCalendar(QString filename, int mode) | 1245 | bool CalendarView::syncCalendar(QString filename, int mode) |
1245 | { | 1246 | { |
1246 | //qDebug("syncCalendar %s ", filename.latin1()); | 1247 | //qDebug("syncCalendar %s ", filename.latin1()); |
1247 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1248 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1248 | CalendarLocal* calendar = new CalendarLocal(); | 1249 | CalendarLocal* calendar = new CalendarLocal(); |
1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1250 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1250 | FileStorage* storage = new FileStorage( calendar ); | 1251 | FileStorage* storage = new FileStorage( calendar ); |
1251 | bool syncOK = false; | 1252 | bool syncOK = false; |
1252 | storage->setFileName( filename ); | 1253 | storage->setFileName( filename ); |
1253 | // qDebug("loading ... "); | 1254 | // qDebug("loading ... "); |
1254 | if ( storage->load() ) { | 1255 | if ( storage->load() ) { |
1255 | getEventViewerDialog()->setSyncMode( true ); | 1256 | getEventViewerDialog()->setSyncMode( true ); |
1256 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1257 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1257 | getEventViewerDialog()->setSyncMode( false ); | 1258 | getEventViewerDialog()->setSyncMode( false ); |
1258 | if ( syncOK ) { | 1259 | if ( syncOK ) { |
1259 | if ( mSyncManager->mWriteBackFile ) | 1260 | if ( mSyncManager->mWriteBackFile ) |
1260 | { | 1261 | { |
1261 | storage->setSaveFormat( new ICalFormat() ); | 1262 | storage->setSaveFormat( new ICalFormat() ); |
1262 | storage->save(); | 1263 | storage->save(); |
1263 | } | 1264 | } |
1264 | } | 1265 | } |
1265 | setModified( true ); | 1266 | setModified( true ); |
1266 | } | 1267 | } |
1267 | delete storage; | 1268 | delete storage; |
1268 | delete calendar; | 1269 | delete calendar; |
1269 | if ( syncOK ) | 1270 | if ( syncOK ) |
1270 | updateView(); | 1271 | updateView(); |
1271 | return syncOK; | 1272 | return syncOK; |
1272 | } | 1273 | } |
1273 | 1274 | ||
1274 | void CalendarView::syncExternal( int mode ) | 1275 | void CalendarView::syncExternal( int mode ) |
1275 | { | 1276 | { |
1276 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1277 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1277 | 1278 | ||
1278 | qApp->processEvents(); | 1279 | qApp->processEvents(); |
1279 | CalendarLocal* calendar = new CalendarLocal(); | 1280 | CalendarLocal* calendar = new CalendarLocal(); |
1280 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1281 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1281 | bool syncOK = false; | 1282 | bool syncOK = false; |
1282 | bool loadSuccess = false; | 1283 | bool loadSuccess = false; |
1283 | PhoneFormat* phoneFormat = 0; | 1284 | PhoneFormat* phoneFormat = 0; |
1284 | emit tempDisableBR(true); | 1285 | emit tempDisableBR(true); |
1285 | #ifndef DESKTOP_VERSION | 1286 | #ifndef DESKTOP_VERSION |
1286 | SharpFormat* sharpFormat = 0; | 1287 | SharpFormat* sharpFormat = 0; |
1287 | if ( mode == 0 ) { // sharp | 1288 | if ( mode == 0 ) { // sharp |
1288 | sharpFormat = new SharpFormat () ; | 1289 | sharpFormat = new SharpFormat () ; |
1289 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1290 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1290 | 1291 | ||
1291 | } else | 1292 | } else |
1292 | #endif | 1293 | #endif |
1293 | if ( mode == 1 ) { // phone | 1294 | if ( mode == 1 ) { // phone |
1294 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1295 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1295 | mSyncManager->mPhoneDevice, | 1296 | mSyncManager->mPhoneDevice, |
1296 | mSyncManager->mPhoneConnection, | 1297 | mSyncManager->mPhoneConnection, |
1297 | mSyncManager->mPhoneModel); | 1298 | mSyncManager->mPhoneModel); |
1298 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1299 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1299 | 1300 | ||
1300 | } else { | 1301 | } else { |
1301 | emit tempDisableBR(false); | 1302 | emit tempDisableBR(false); |
1302 | return; | 1303 | return; |
1303 | } | 1304 | } |
1304 | if ( loadSuccess ) { | 1305 | if ( loadSuccess ) { |
1305 | getEventViewerDialog()->setSyncMode( true ); | 1306 | getEventViewerDialog()->setSyncMode( true ); |
1306 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1307 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1307 | getEventViewerDialog()->setSyncMode( false ); | 1308 | getEventViewerDialog()->setSyncMode( false ); |
1308 | qApp->processEvents(); | 1309 | qApp->processEvents(); |
1309 | if ( syncOK ) { | 1310 | if ( syncOK ) { |
1310 | if ( mSyncManager->mWriteBackFile ) | 1311 | if ( mSyncManager->mWriteBackFile ) |
1311 | { | 1312 | { |
1312 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1313 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1313 | Incidence* inc = iL.first(); | 1314 | Incidence* inc = iL.first(); |
1314 | if ( phoneFormat ) { | 1315 | if ( phoneFormat ) { |
1315 | while ( inc ) { | 1316 | while ( inc ) { |
1316 | inc->removeID(mCurrentSyncDevice); | 1317 | inc->removeID(mCurrentSyncDevice); |
1317 | inc = iL.next(); | 1318 | inc = iL.next(); |
1318 | } | 1319 | } |
1319 | } | 1320 | } |
1320 | #ifndef DESKTOP_VERSION | 1321 | #ifndef DESKTOP_VERSION |
1321 | if ( sharpFormat ) | 1322 | if ( sharpFormat ) |
1322 | sharpFormat->save(calendar); | 1323 | sharpFormat->save(calendar); |
1323 | #endif | 1324 | #endif |
1324 | if ( phoneFormat ) | 1325 | if ( phoneFormat ) |
1325 | phoneFormat->save(calendar); | 1326 | phoneFormat->save(calendar); |
1326 | iL = calendar->rawIncidences(); | 1327 | iL = calendar->rawIncidences(); |
1327 | inc = iL.first(); | 1328 | inc = iL.first(); |
1328 | Incidence* loc; | 1329 | Incidence* loc; |
1329 | while ( inc ) { | 1330 | while ( inc ) { |
1330 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1331 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1331 | loc = mCalendar->incidence(inc->uid() ); | 1332 | loc = mCalendar->incidence(inc->uid() ); |
1332 | if ( loc ) { | 1333 | if ( loc ) { |
1333 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1334 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1334 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1335 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1335 | } | 1336 | } |
1336 | } | 1337 | } |
1337 | inc = iL.next(); | 1338 | inc = iL.next(); |
1338 | } | 1339 | } |
1339 | Incidence* lse = getLastSyncEvent(); | 1340 | Incidence* lse = getLastSyncEvent(); |
1340 | if ( lse ) { | 1341 | if ( lse ) { |
1341 | lse->setReadOnly( false ); | 1342 | lse->setReadOnly( false ); |
1342 | lse->setDescription( "" ); | 1343 | lse->setDescription( "" ); |
1343 | lse->setReadOnly( true ); | 1344 | lse->setReadOnly( true ); |
1344 | } | 1345 | } |
1345 | } | 1346 | } |
1346 | } else { | 1347 | } else { |
1347 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1348 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1348 | } | 1349 | } |
1349 | setModified( true ); | 1350 | setModified( true ); |
1350 | } else { | 1351 | } else { |
1351 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1352 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1352 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1353 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1353 | question, i18n("Ok")) ; | 1354 | question, i18n("Ok")) ; |
1354 | 1355 | ||
1355 | } | 1356 | } |
1356 | delete calendar; | 1357 | delete calendar; |
1357 | updateView(); | 1358 | updateView(); |
1358 | emit tempDisableBR(false); | 1359 | emit tempDisableBR(false); |
1359 | return ;//syncOK; | 1360 | return ;//syncOK; |
1360 | 1361 | ||
1361 | } | 1362 | } |
1362 | 1363 | ||
1363 | bool CalendarView::importBday() | 1364 | bool CalendarView::importBday() |
1364 | { | 1365 | { |
1365 | #ifndef KORG_NOKABC | 1366 | #ifndef KORG_NOKABC |
1366 | 1367 | ||
1367 | #ifdef DESKTOP_VERSION | 1368 | #ifdef DESKTOP_VERSION |
1368 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1369 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1369 | KABC::AddressBook::Iterator it; | 1370 | KABC::AddressBook::Iterator it; |
1370 | int count = 0; | 1371 | int count = 0; |
1371 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1372 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1372 | ++count; | 1373 | ++count; |
1373 | } | 1374 | } |
1374 | QProgressBar bar(count,0 ); | 1375 | QProgressBar bar(count,0 ); |
1375 | int w = 300; | 1376 | int w = 300; |
1376 | if ( QApplication::desktop()->width() < 320 ) | 1377 | if ( QApplication::desktop()->width() < 320 ) |
1377 | w = 220; | 1378 | w = 220; |
1378 | int h = bar.sizeHint().height() ; | 1379 | int h = bar.sizeHint().height() ; |
1379 | int dw = QApplication::desktop()->width(); | 1380 | int dw = QApplication::desktop()->width(); |
1380 | int dh = QApplication::desktop()->height(); | 1381 | int dh = QApplication::desktop()->height(); |
1381 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1382 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1382 | bar.show(); | 1383 | bar.show(); |
1383 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1384 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1384 | qApp->processEvents(); | 1385 | qApp->processEvents(); |
1385 | count = 0; | 1386 | count = 0; |
1386 | int addCount = 0; | 1387 | int addCount = 0; |
1387 | KCal::Attendee* a = 0; | 1388 | KCal::Attendee* a = 0; |
1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1389 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1389 | if ( ! bar.isVisible() ) | 1390 | if ( ! bar.isVisible() ) |
1390 | return false; | 1391 | return false; |
1391 | bar.setProgress( count++ ); | 1392 | bar.setProgress( count++ ); |
1392 | qApp->processEvents(); | 1393 | qApp->processEvents(); |
1393 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1394 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1394 | if ( (*it).birthday().date().isValid() ){ | 1395 | if ( (*it).birthday().date().isValid() ){ |
1395 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1396 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1396 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1397 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1397 | ++addCount; | 1398 | ++addCount; |
1398 | } | 1399 | } |
1399 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1400 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1400 | if ( anni.isValid() ){ | 1401 | if ( anni.isValid() ){ |
1401 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1402 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1402 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1403 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1403 | ++addCount; | 1404 | ++addCount; |
1404 | } | 1405 | } |
1405 | } | 1406 | } |
1406 | updateView(); | 1407 | updateView(); |
1407 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1408 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1408 | #else //DESKTOP_VERSION | 1409 | #else //DESKTOP_VERSION |
1409 | 1410 | ||
1410 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1411 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1411 | // the result should now arrive through method insertBirthdays | 1412 | // the result should now arrive through method insertBirthdays |
1412 | 1413 | ||
1413 | #endif //DESKTOP_VERSION | 1414 | #endif //DESKTOP_VERSION |
1414 | 1415 | ||
1415 | #endif //KORG_NOKABC | 1416 | #endif //KORG_NOKABC |
1416 | 1417 | ||
1417 | 1418 | ||
1418 | return true; | 1419 | return true; |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1422 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1422 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1423 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1423 | const QStringList& anniversaryList, const QStringList& realNameList, | 1424 | const QStringList& anniversaryList, const QStringList& realNameList, |
1424 | const QStringList& emailList, const QStringList& assembledNameList, | 1425 | const QStringList& emailList, const QStringList& assembledNameList, |
1425 | const QStringList& uidList) | 1426 | const QStringList& uidList) |
1426 | { | 1427 | { |
1427 | //qDebug("KO::CalendarView::insertBirthdays"); | 1428 | //qDebug("KO::CalendarView::insertBirthdays"); |
1428 | if (uid == this->name()) | 1429 | if (uid == this->name()) |
1429 | { | 1430 | { |
1430 | int count = birthdayList.count(); | 1431 | int count = birthdayList.count(); |
1431 | int addCount = 0; | 1432 | int addCount = 0; |
1432 | KCal::Attendee* a = 0; | 1433 | KCal::Attendee* a = 0; |
1433 | 1434 | ||
1434 | //qDebug("CalView 1 %i", count); | 1435 | //qDebug("CalView 1 %i", count); |
1435 | 1436 | ||
1436 | QProgressBar bar(count,0 ); | 1437 | QProgressBar bar(count,0 ); |
1437 | int w = 300; | 1438 | int w = 300; |
1438 | if ( QApplication::desktop()->width() < 320 ) | 1439 | if ( QApplication::desktop()->width() < 320 ) |
1439 | w = 220; | 1440 | w = 220; |
1440 | int h = bar.sizeHint().height() ; | 1441 | int h = bar.sizeHint().height() ; |
1441 | int dw = QApplication::desktop()->width(); | 1442 | int dw = QApplication::desktop()->width(); |
1442 | int dh = QApplication::desktop()->height(); | 1443 | int dh = QApplication::desktop()->height(); |
1443 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1444 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1444 | bar.show(); | 1445 | bar.show(); |
1445 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1446 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1446 | qApp->processEvents(); | 1447 | qApp->processEvents(); |
1447 | 1448 | ||
1448 | QDate birthday; | 1449 | QDate birthday; |
1449 | QDate anniversary; | 1450 | QDate anniversary; |
1450 | QString realName; | 1451 | QString realName; |
1451 | QString email; | 1452 | QString email; |
1452 | QString assembledName; | 1453 | QString assembledName; |
1453 | QString uid; | 1454 | QString uid; |
1454 | bool ok = true; | 1455 | bool ok = true; |
1455 | for ( int i = 0; i < count; i++) | 1456 | for ( int i = 0; i < count; i++) |
1456 | { | 1457 | { |
1457 | if ( ! bar.isVisible() ) | 1458 | if ( ! bar.isVisible() ) |
1458 | return; | 1459 | return; |
1459 | bar.setProgress( i ); | 1460 | bar.setProgress( i ); |
1460 | qApp->processEvents(); | 1461 | qApp->processEvents(); |
1461 | 1462 | ||
1462 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1463 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1463 | if (!ok) { | 1464 | if (!ok) { |
1464 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1465 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1465 | } | 1466 | } |
1466 | 1467 | ||
1467 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1468 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1468 | if (!ok) { | 1469 | if (!ok) { |
1469 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1470 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1470 | } | 1471 | } |
1471 | realName = realNameList[i]; | 1472 | realName = realNameList[i]; |
1472 | email = emailList[i]; | 1473 | email = emailList[i]; |
1473 | assembledName = assembledNameList[i]; | 1474 | assembledName = assembledNameList[i]; |
1474 | uid = uidList[i]; | 1475 | uid = uidList[i]; |
1475 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1476 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1476 | 1477 | ||
1477 | if ( birthday.isValid() ){ | 1478 | if ( birthday.isValid() ){ |
1478 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1479 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1479 | KCal::Attendee::ReqParticipant,uid) ; | 1480 | KCal::Attendee::ReqParticipant,uid) ; |
1480 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1481 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1481 | ++addCount; | 1482 | ++addCount; |
1482 | } | 1483 | } |
1483 | 1484 | ||
1484 | if ( anniversary.isValid() ){ | 1485 | if ( anniversary.isValid() ){ |
1485 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1486 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1486 | KCal::Attendee::ReqParticipant,uid) ; | 1487 | KCal::Attendee::ReqParticipant,uid) ; |
1487 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1488 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1488 | ++addCount; | 1489 | ++addCount; |
1489 | } | 1490 | } |
1490 | } | 1491 | } |
1491 | 1492 | ||
1492 | updateView(); | 1493 | updateView(); |
1493 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1494 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1494 | 1495 | ||
1495 | } | 1496 | } |
1496 | 1497 | ||
1497 | } | 1498 | } |
1498 | 1499 | ||
1499 | 1500 | ||
1500 | 1501 | ||
1501 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1502 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1502 | { | 1503 | { |
1503 | //qDebug("addAnni "); | 1504 | //qDebug("addAnni "); |
1504 | Event * ev = new Event(); | 1505 | Event * ev = new Event(); |
1505 | ev->setOrganizer(KOPrefs::instance()->email()); | 1506 | ev->setOrganizer(KOPrefs::instance()->email()); |
1506 | if ( a ) { | 1507 | if ( a ) { |
1507 | ev->addAttendee( a ); | 1508 | ev->addAttendee( a ); |
1508 | } | 1509 | } |
1509 | QString kind; | 1510 | QString kind; |
1510 | if ( birthday ) { | 1511 | if ( birthday ) { |
1511 | kind = i18n( "Birthday" ); | 1512 | kind = i18n( "Birthday" ); |
1512 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1513 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1513 | } | 1514 | } |
1514 | else { | 1515 | else { |
1515 | kind = i18n( "Anniversary" ); | 1516 | kind = i18n( "Anniversary" ); |
1516 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1517 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1517 | } | 1518 | } |
1518 | ev->setCategories( kind ); | 1519 | ev->setCategories( kind ); |
1519 | ev->setDtStart( QDateTime(date) ); | 1520 | ev->setDtStart( QDateTime(date) ); |
1520 | ev->setDtEnd( QDateTime(date) ); | 1521 | ev->setDtEnd( QDateTime(date) ); |
1521 | ev->setFloats( true ); | 1522 | ev->setFloats( true ); |
1522 | Recurrence * rec = ev->recurrence(); | 1523 | Recurrence * rec = ev->recurrence(); |
1523 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1524 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1524 | rec->addYearlyNum( date.month() ); | 1525 | rec->addYearlyNum( date.month() ); |
1525 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1526 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1526 | delete ev; | 1527 | delete ev; |
1527 | return false; | 1528 | return false; |
1528 | } | 1529 | } |
1529 | return true; | 1530 | return true; |
1530 | 1531 | ||
1531 | } | 1532 | } |
1532 | bool CalendarView::importQtopia( const QString &categories, | 1533 | bool CalendarView::importQtopia( const QString &categories, |
1533 | const QString &datebook, | 1534 | const QString &datebook, |
1534 | const QString &todolist ) | 1535 | const QString &todolist ) |
1535 | { | 1536 | { |
1536 | 1537 | ||
1537 | QtopiaFormat qtopiaFormat; | 1538 | QtopiaFormat qtopiaFormat; |
1538 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1539 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1540 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1540 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1541 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1541 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1542 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1542 | 1543 | ||
1543 | updateView(); | 1544 | updateView(); |
1544 | return true; | 1545 | return true; |
1545 | 1546 | ||
1546 | #if 0 | 1547 | #if 0 |
1547 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1548 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1548 | mCurrentSyncDevice = "qtopia-XML"; | 1549 | mCurrentSyncDevice = "qtopia-XML"; |
1549 | if ( mSyncManager->mAskForPreferences ) | 1550 | if ( mSyncManager->mAskForPreferences ) |
1550 | edit_sync_options(); | 1551 | edit_sync_options(); |
1551 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1552 | CalendarLocal* calendar = new CalendarLocal(); | 1553 | CalendarLocal* calendar = new CalendarLocal(); |
1553 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1554 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1554 | bool syncOK = false; | 1555 | bool syncOK = false; |
1555 | QtopiaFormat qtopiaFormat; | 1556 | QtopiaFormat qtopiaFormat; |
1556 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1557 | bool loadOk = true; | 1558 | bool loadOk = true; |
1558 | if ( !categories.isEmpty() ) | 1559 | if ( !categories.isEmpty() ) |
1559 | loadOk = qtopiaFormat.load( calendar, categories ); | 1560 | loadOk = qtopiaFormat.load( calendar, categories ); |
1560 | if ( loadOk && !datebook.isEmpty() ) | 1561 | if ( loadOk && !datebook.isEmpty() ) |
1561 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1562 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1562 | if ( loadOk && !todolist.isEmpty() ) | 1563 | if ( loadOk && !todolist.isEmpty() ) |
1563 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1564 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1564 | 1565 | ||
1565 | if ( loadOk ) { | 1566 | if ( loadOk ) { |
1566 | getEventViewerDialog()->setSyncMode( true ); | 1567 | getEventViewerDialog()->setSyncMode( true ); |
1567 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1568 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1568 | getEventViewerDialog()->setSyncMode( false ); | 1569 | getEventViewerDialog()->setSyncMode( false ); |
1569 | qApp->processEvents(); | 1570 | qApp->processEvents(); |
1570 | if ( syncOK ) { | 1571 | if ( syncOK ) { |
1571 | if ( mSyncManager->mWriteBackFile ) | 1572 | if ( mSyncManager->mWriteBackFile ) |
1572 | { | 1573 | { |
1573 | // write back XML file | 1574 | // write back XML file |
1574 | 1575 | ||
1575 | } | 1576 | } |
1576 | setModified( true ); | 1577 | setModified( true ); |
1577 | } | 1578 | } |
1578 | } else { | 1579 | } else { |
1579 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1580 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1581 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1582 | } | 1583 | } |
1583 | delete calendar; | 1584 | delete calendar; |
1584 | updateView(); | 1585 | updateView(); |
1585 | return syncOK; | 1586 | return syncOK; |
1586 | 1587 | ||
1587 | 1588 | ||
1588 | #endif | 1589 | #endif |
1589 | 1590 | ||
1590 | } | 1591 | } |
1591 | 1592 | ||
1592 | void CalendarView::setSyncEventsReadOnly() | 1593 | void CalendarView::setSyncEventsReadOnly() |
1593 | { | 1594 | { |
1594 | Event * ev; | 1595 | Event * ev; |
1595 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1596 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1596 | ev = eL.first(); | 1597 | ev = eL.first(); |
1597 | while ( ev ) { | 1598 | while ( ev ) { |
1598 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1599 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1599 | ev->setReadOnly( true ); | 1600 | ev->setReadOnly( true ); |
1600 | ev = eL.next(); | 1601 | ev = eL.next(); |
1601 | } | 1602 | } |
1602 | } | 1603 | } |
1603 | bool CalendarView::openCalendar(QString filename, bool merge) | 1604 | bool CalendarView::openCalendar(QString filename, bool merge) |
1604 | { | 1605 | { |
1605 | 1606 | ||
1606 | if (filename.isEmpty()) { | 1607 | if (filename.isEmpty()) { |
1607 | return false; | 1608 | return false; |
1608 | } | 1609 | } |
1609 | 1610 | ||
1610 | if (!QFile::exists(filename)) { | 1611 | if (!QFile::exists(filename)) { |
1611 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1612 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1612 | return false; | 1613 | return false; |
1613 | } | 1614 | } |
1614 | 1615 | ||