author | zautrix <zautrix> | 2004-08-02 00:09:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-02 00:09:04 (UTC) |
commit | 3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (patch) (unidiff) | |
tree | fdff56329649c084b6f5af8d8e96c0157686575e /korganizer/calendarview.cpp | |
parent | 3b4aa1cd78395c0f94b99decd901842944765746 (diff) | |
download | kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.zip kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.gz kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.bz2 |
More sync hacking
-rw-r--r-- | korganizer/calendarview.cpp | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfc6b10..9160e1d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -850,11 +850,14 @@ Event* CalendarView::getLastSyncEvent() | |||
850 | { | 850 | { |
851 | Event* lse; | 851 | Event* lse; |
852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
853 | lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); | 853 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
854 | if (!lse) { | 854 | if (!lse) { |
855 | lse = new Event(); | 855 | lse = new Event(); |
856 | lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); | 856 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
857 | lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); | 857 | QString sum = ""; |
858 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | ||
859 | sum = "E: "; | ||
860 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | ||
858 | lse->setDtStart( mLastCalendarSync ); | 861 | lse->setDtStart( mLastCalendarSync ); |
859 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 862 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
860 | lse->setCategories( i18n("SyncEvent") ); | 863 | lse->setCategories( i18n("SyncEvent") ); |
@@ -865,22 +868,45 @@ Event* CalendarView::getLastSyncEvent() | |||
865 | return lse; | 868 | return lse; |
866 | 869 | ||
867 | } | 870 | } |
868 | void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) | 871 | void CalendarView::setupExternSyncProfiles() |
869 | { | 872 | { |
870 | if ( ! lastSync ) | 873 | Event* lse; |
871 | return; | 874 | mExternLastSyncEvent.clear(); |
872 | if ( toDelete->zaurusId() < 0 ) | 875 | int i; |
876 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | ||
877 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | ||
878 | if ( lse ) | ||
879 | mExternLastSyncEvent.append( lse ); | ||
880 | else | ||
881 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | ||
882 | } | ||
883 | |||
884 | } | ||
885 | // we check, if the to delete event has a id for a profile | ||
886 | // if yes, we set this id in the profile to delete | ||
887 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | ||
888 | { | ||
889 | if ( ! lastSync.count() == 0 ) | ||
873 | return; | 890 | return; |
874 | if ( toDelete->type() == "Journal" ) | 891 | if ( toDelete->type() == "Journal" ) |
875 | return; | 892 | return; |
876 | QString des = lastSync->description(); | 893 | |
877 | QString pref = "e"; | 894 | Event* eve = lastSync.first(); |
878 | if ( toDelete->type() == "Todo" ) | 895 | |
879 | pref = "t"; | 896 | while ( eve ) { |
880 | des += pref+ QString::number ( toDelete->zaurusId() ) + ","; | 897 | int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
881 | lastSync->setReadOnly( false ); | 898 | if ( id >= 0 ) { |
882 | lastSync->setDescription( des ); | 899 | QString des = eve->description(); |
883 | lastSync->setReadOnly( true ); | 900 | QString pref = "e"; |
901 | if ( toDelete->type() == "Todo" ) | ||
902 | pref = "t"; | ||
903 | des += pref+ QString::number ( id ) + ","; | ||
904 | eve->setReadOnly( false ); | ||
905 | eve->setDescription( des ); | ||
906 | eve->setReadOnly( true ); | ||
907 | } | ||
908 | eve = lastSync.next(); | ||
909 | } | ||
884 | 910 | ||
885 | } | 911 | } |
886 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 912 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
@@ -899,12 +925,12 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
899 | Event* eventL; | 925 | Event* eventL; |
900 | Event* eventRSync; | 926 | Event* eventRSync; |
901 | Event* eventLSync; | 927 | Event* eventLSync; |
902 | Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); | 928 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
903 | Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); | 929 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
904 | bool fullDateRange = false; | 930 | bool fullDateRange = false; |
905 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
906 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
907 | eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); | 933 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
908 | if ( eventR ) { | 934 | if ( eventR ) { |
909 | eventRSync = (Event*) eventR->clone(); | 935 | eventRSync = (Event*) eventR->clone(); |
910 | remote->deleteEvent(eventR ); | 936 | remote->deleteEvent(eventR ); |
@@ -913,7 +939,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
913 | fullDateRange = true; | 939 | fullDateRange = true; |
914 | eventRSync = new Event(); | 940 | eventRSync = new Event(); |
915 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 941 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
916 | eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); | 942 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
917 | eventRSync->setDtStart( mLastCalendarSync ); | 943 | eventRSync->setDtStart( mLastCalendarSync ); |
918 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 944 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
919 | eventRSync->setCategories( i18n("SyncEvent") ); | 945 | eventRSync->setCategories( i18n("SyncEvent") ); |
@@ -965,7 +991,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
965 | ++incCounter; | 991 | ++incCounter; |
966 | uid = inR->uid(); | 992 | uid = inR->uid(); |
967 | bool skipIncidence = false; | 993 | bool skipIncidence = false; |
968 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 994 | if ( uid.left(15) == QString("last-syncEvent-") ) |
969 | skipIncidence = true; | 995 | skipIncidence = true; |
970 | 996 | ||
971 | qApp->processEvents(); | 997 | qApp->processEvents(); |
@@ -1015,7 +1041,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1015 | local->addIncidence( inR->clone() ); | 1041 | local->addIncidence( inR->clone() ); |
1016 | ++addedEvent; | 1042 | ++addedEvent; |
1017 | } else { | 1043 | } else { |
1018 | checkSharpEvent(eventRSyncSharp, inR); | 1044 | checkExternSyncEvent(eventRSyncSharp, inR); |
1019 | remote->deleteIncidence( inR ); | 1045 | remote->deleteIncidence( inR ); |
1020 | ++deletedEventR; | 1046 | ++deletedEventR; |
1021 | } | 1047 | } |
@@ -1042,7 +1068,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1042 | ++incCounter; | 1068 | ++incCounter; |
1043 | uid = inL->uid(); | 1069 | uid = inL->uid(); |
1044 | bool skipIncidence = false; | 1070 | bool skipIncidence = false; |
1045 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 1071 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1046 | skipIncidence = true; | 1072 | skipIncidence = true; |
1047 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1073 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1048 | skipIncidence = true; | 1074 | skipIncidence = true; |
@@ -1063,7 +1089,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1063 | } | 1089 | } |
1064 | } else { | 1090 | } else { |
1065 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1091 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1066 | checkSharpEvent(eventLSyncSharp, inL); | 1092 | checkExternSyncEvent(eventLSyncSharp, inL); |
1067 | local->deleteIncidence( inL ); | 1093 | local->deleteIncidence( inL ); |
1068 | ++deletedEventL; | 1094 | ++deletedEventL; |
1069 | } else { | 1095 | } else { |
@@ -1342,7 +1368,7 @@ void CalendarView::setSyncEventsReadOnly() | |||
1342 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1368 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1343 | ev = eL.first(); | 1369 | ev = eL.first(); |
1344 | while ( ev ) { | 1370 | while ( ev ) { |
1345 | if ( ev->uid().left(21) == QString("last-syncEvent-device") ) | 1371 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1346 | ev->setReadOnly( true ); | 1372 | ev->setReadOnly( true ); |
1347 | ev = eL.next(); | 1373 | ev = eL.next(); |
1348 | } | 1374 | } |
@@ -1806,7 +1832,7 @@ void CalendarView::changeTodoDisplay(Todo *which, int action) | |||
1806 | void CalendarView::checkZaurusId( int id, bool todo ) | 1832 | void CalendarView::checkZaurusId( int id, bool todo ) |
1807 | { | 1833 | { |
1808 | if ( id >= 0 ) { | 1834 | if ( id >= 0 ) { |
1809 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); | 1835 | Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM"); |
1810 | if ( lse ) { | 1836 | if ( lse ) { |
1811 | QString des = lse->description(); | 1837 | QString des = lse->description(); |
1812 | QString pref = "e"; | 1838 | QString pref = "e"; |