author | zautrix <zautrix> | 2004-09-14 01:59:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-14 01:59:37 (UTC) |
commit | 739fec31c8cea89dd40ff1ce7dd7b84b05e4e973 (patch) (unidiff) | |
tree | e632528a6825911b1b7ae9db9af4e4c8984e6dbf | |
parent | 30762fe125216362e1a6c1d5ec5d22d9525aa336 (diff) | |
download | kdepimpi-739fec31c8cea89dd40ff1ce7dd7b84b05e4e973.zip kdepimpi-739fec31c8cea89dd40ff1ce7dd7b84b05e4e973.tar.gz kdepimpi-739fec31c8cea89dd40ff1ce7dd7b84b05e4e973.tar.bz2 |
Sync fixes
-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | libkcal/event.cpp | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 94cc97d..ce41fbd 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -984,151 +984,160 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
985 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
986 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
987 | } | 987 | } |
988 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
990 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
991 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
992 | Incidence* inL; | 992 | Incidence* inL; |
993 | QProgressBar bar( er.count(),0 ); | 993 | QProgressBar bar( er.count(),0 ); |
994 | bar.setCaption (i18n("Syncing - close to abort!") ); | 994 | bar.setCaption (i18n("Syncing - close to abort!") ); |
995 | 995 | ||
996 | int w = 300; | 996 | int w = 300; |
997 | if ( QApplication::desktop()->width() < 320 ) | 997 | if ( QApplication::desktop()->width() < 320 ) |
998 | w = 220; | 998 | w = 220; |
999 | int h = bar.sizeHint().height() ; | 999 | int h = bar.sizeHint().height() ; |
1000 | int dw = QApplication::desktop()->width(); | 1000 | int dw = QApplication::desktop()->width(); |
1001 | int dh = QApplication::desktop()->height(); | 1001 | int dh = QApplication::desktop()->height(); |
1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1003 | bar.show(); | 1003 | bar.show(); |
1004 | int modulo = (er.count()/10)+1; | 1004 | int modulo = (er.count()/10)+1; |
1005 | int incCounter = 0; | 1005 | int incCounter = 0; |
1006 | while ( inR ) { | 1006 | while ( inR ) { |
1007 | if ( ! bar.isVisible() ) | 1007 | if ( ! bar.isVisible() ) |
1008 | return false; | 1008 | return false; |
1009 | if ( incCounter % modulo == 0 ) | 1009 | if ( incCounter % modulo == 0 ) |
1010 | bar.setProgress( incCounter ); | 1010 | bar.setProgress( incCounter ); |
1011 | ++incCounter; | 1011 | ++incCounter; |
1012 | uid = inR->uid(); | 1012 | uid = inR->uid(); |
1013 | bool skipIncidence = false; | 1013 | bool skipIncidence = false; |
1014 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1014 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1015 | skipIncidence = true; | 1015 | skipIncidence = true; |
1016 | 1016 | QString idS; | |
1017 | qApp->processEvents(); | 1017 | qApp->processEvents(); |
1018 | if ( !skipIncidence ) { | 1018 | if ( !skipIncidence ) { |
1019 | inL = local->incidence( uid ); | 1019 | inL = local->incidence( uid ); |
1020 | if ( inL ) { // maybe conflict - same uid in both calendars | 1020 | if ( inL ) { // maybe conflict - same uid in both calendars |
1021 | int maxrev = inL->revision(); | 1021 | int maxrev = inL->revision(); |
1022 | if ( maxrev < inR->revision() ) | 1022 | if ( maxrev < inR->revision() ) |
1023 | maxrev = inR->revision(); | 1023 | maxrev = inR->revision(); |
1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1026 | if ( take == 3 ) | 1026 | if ( take == 3 ) |
1027 | return false; | 1027 | return false; |
1028 | if ( take == 1 ) {// take local | 1028 | if ( take == 1 ) {// take local |
1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1029 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1030 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | ||
1031 | else | ||
1032 | idS = inR->IDStr(); | ||
1030 | remote->deleteIncidence( inR ); | 1033 | remote->deleteIncidence( inR ); |
1031 | if ( inL->revision() < maxrev ) | 1034 | if ( inL->revision() < maxrev ) |
1032 | inL->setRevision( maxrev ); | 1035 | inL->setRevision( maxrev ); |
1033 | inR = inL->clone(); | 1036 | inR = inL->clone(); |
1034 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1037 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1038 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | ||
1039 | inR->setIDStr( idS ); | ||
1035 | remote->addIncidence( inR ); | 1040 | remote->addIncidence( inR ); |
1036 | ++changedRemote; | 1041 | ++changedRemote; |
1037 | } else { | 1042 | } else { |
1038 | if ( inR->revision() < maxrev ) | 1043 | if ( inR->revision() < maxrev ) |
1039 | inR->setRevision( maxrev ); | 1044 | inR->setRevision( maxrev ); |
1045 | idS = inL->IDStr(); | ||
1040 | local->deleteIncidence( inL ); | 1046 | local->deleteIncidence( inL ); |
1041 | local->addIncidence( inR->clone() ); | 1047 | inL = inR->clone(); |
1048 | inL->setIDStr( idS ); | ||
1049 | local->addIncidence( inL ); | ||
1042 | ++changedLocal; | 1050 | ++changedLocal; |
1043 | } | 1051 | } |
1044 | } | 1052 | } |
1045 | } else { // no conflict | 1053 | } else { // no conflict |
1046 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1054 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1047 | QString des = eventLSync->description(); | 1055 | QString des = eventLSync->description(); |
1048 | QString pref = "e"; | 1056 | QString pref = "e"; |
1049 | if ( inR->type() == "Todo" ) | 1057 | if ( inR->type() == "Todo" ) |
1050 | pref = "t"; | 1058 | pref = "t"; |
1051 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1059 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1052 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1060 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1053 | //remote->deleteIncidence( inR ); | 1061 | //remote->deleteIncidence( inR ); |
1054 | ++deletedEventR; | 1062 | ++deletedEventR; |
1055 | } else { | 1063 | } else { |
1056 | inR->setLastModified( modifiedCalendar ); | 1064 | inR->setLastModified( modifiedCalendar ); |
1057 | inL = inR->clone(); | 1065 | inL = inR->clone(); |
1058 | local->addIncidence( inL ); | 1066 | local->addIncidence( inL ); |
1059 | ++addedEvent; | 1067 | ++addedEvent; |
1060 | } | 1068 | } |
1061 | } else { | 1069 | } else { |
1062 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1070 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1063 | inR->setLastModified( modifiedCalendar ); | 1071 | inR->setLastModified( modifiedCalendar ); |
1064 | local->addIncidence( inR->clone() ); | 1072 | local->addIncidence( inR->clone() ); |
1065 | ++addedEvent; | 1073 | ++addedEvent; |
1066 | } else { | 1074 | } else { |
1067 | checkExternSyncEvent(eventRSyncSharp, inR); | 1075 | checkExternSyncEvent(eventRSyncSharp, inR); |
1068 | remote->deleteIncidence( inR ); | 1076 | remote->deleteIncidence( inR ); |
1069 | ++deletedEventR; | 1077 | ++deletedEventR; |
1070 | } | 1078 | } |
1071 | } | 1079 | } |
1072 | } | 1080 | } |
1073 | } | 1081 | } |
1074 | inR = er.next(); | 1082 | inR = er.next(); |
1075 | } | 1083 | } |
1076 | QPtrList<Incidence> el = local->rawIncidences(); | 1084 | QPtrList<Incidence> el = local->rawIncidences(); |
1077 | inL = el.first(); | 1085 | inL = el.first(); |
1078 | modulo = (el.count()/10)+1; | 1086 | modulo = (el.count()/10)+1; |
1079 | bar.setCaption (i18n("Add / remove events") ); | 1087 | bar.setCaption (i18n("Add / remove events") ); |
1080 | bar.setTotalSteps ( el.count() ) ; | 1088 | bar.setTotalSteps ( el.count() ) ; |
1081 | bar.show(); | 1089 | bar.show(); |
1082 | incCounter = 0; | 1090 | incCounter = 0; |
1083 | 1091 | ||
1084 | while ( inL ) { | 1092 | while ( inL ) { |
1085 | 1093 | ||
1086 | qApp->processEvents(); | 1094 | qApp->processEvents(); |
1087 | if ( ! bar.isVisible() ) | 1095 | if ( ! bar.isVisible() ) |
1088 | return false; | 1096 | return false; |
1089 | if ( incCounter % modulo == 0 ) | 1097 | if ( incCounter % modulo == 0 ) |
1090 | bar.setProgress( incCounter ); | 1098 | bar.setProgress( incCounter ); |
1091 | ++incCounter; | 1099 | ++incCounter; |
1092 | uid = inL->uid(); | 1100 | uid = inL->uid(); |
1093 | bool skipIncidence = false; | 1101 | bool skipIncidence = false; |
1094 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1102 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1095 | skipIncidence = true; | 1103 | skipIncidence = true; |
1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1104 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1097 | skipIncidence = true; | 1105 | skipIncidence = true; |
1098 | if ( !skipIncidence ) { | 1106 | if ( !skipIncidence ) { |
1099 | inR = remote->incidence( uid ); | 1107 | inR = remote->incidence( uid ); |
1100 | if ( ! inR ) { | 1108 | if ( ! inR ) { |
1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1109 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1110 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1111 | checkExternSyncEvent(eventLSyncSharp, inL); | ||
1103 | local->deleteIncidence( inL ); | 1112 | local->deleteIncidence( inL ); |
1104 | ++deletedEventL; | 1113 | ++deletedEventL; |
1105 | } else { | 1114 | } else { |
1106 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1115 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1107 | inL->removeID(mCurrentSyncDevice ); | 1116 | inL->removeID(mCurrentSyncDevice ); |
1108 | ++addedEventR; | 1117 | ++addedEventR; |
1109 | qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1118 | qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1110 | inL->setLastModified( modifiedCalendar ); | 1119 | inL->setLastModified( modifiedCalendar ); |
1111 | inR = inL->clone(); | 1120 | inR = inL->clone(); |
1112 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1113 | remote->addIncidence( inR ); | 1122 | remote->addIncidence( inR ); |
1114 | } | 1123 | } |
1115 | } | 1124 | } |
1116 | } else { | 1125 | } else { |
1117 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1118 | checkExternSyncEvent(eventLSyncSharp, inL); | 1127 | checkExternSyncEvent(eventLSyncSharp, inL); |
1119 | local->deleteIncidence( inL ); | 1128 | local->deleteIncidence( inL ); |
1120 | ++deletedEventL; | 1129 | ++deletedEventL; |
1121 | } else { | 1130 | } else { |
1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1131 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1123 | ++addedEventR; | 1132 | ++addedEventR; |
1124 | inL->setLastModified( modifiedCalendar ); | 1133 | inL->setLastModified( modifiedCalendar ); |
1125 | remote->addIncidence( inL->clone() ); | 1134 | remote->addIncidence( inL->clone() ); |
1126 | } | 1135 | } |
1127 | } | 1136 | } |
1128 | } | 1137 | } |
1129 | } | 1138 | } |
1130 | } | 1139 | } |
1131 | inL = el.next(); | 1140 | inL = el.next(); |
1132 | } | 1141 | } |
1133 | int delFut = 0; | 1142 | int delFut = 0; |
1134 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1143 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dd67252..dfa265b 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -15,65 +15,64 @@ | |||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Event::Event() : | 29 | Event::Event() : |
30 | mHasEndDate( false ), mTransparency( Opaque ) | 30 | mHasEndDate( false ), mTransparency( Opaque ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | Event::Event(const Event &e) : Incidence(e) | 34 | Event::Event(const Event &e) : Incidence(e) |
35 | { | 35 | { |
36 | mDtEnd = e.mDtEnd; | 36 | mDtEnd = e.mDtEnd; |
37 | mHasEndDate = e.mHasEndDate; | 37 | mHasEndDate = e.mHasEndDate; |
38 | mTransparency = e.mTransparency; | 38 | mTransparency = e.mTransparency; |
39 | } | 39 | } |
40 | 40 | ||
41 | Event::~Event() | 41 | Event::~Event() |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | kdDebug(5800) << "Event::clone()" << endl; | ||
48 | return new Event(*this); | 47 | return new Event(*this); |
49 | } | 48 | } |
50 | 49 | ||
51 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
52 | { | 51 | { |
53 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
54 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
55 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
56 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | 59 | ||
61 | void Event::setDtEnd(const QDateTime &dtEnd) | 60 | void Event::setDtEnd(const QDateTime &dtEnd) |
62 | { | 61 | { |
63 | if (mReadOnly) return; | 62 | if (mReadOnly) return; |
64 | 63 | ||
65 | mDtEnd = getEvenTime( dtEnd ); | 64 | mDtEnd = getEvenTime( dtEnd ); |
66 | 65 | ||
67 | setHasEndDate(true); | 66 | setHasEndDate(true); |
68 | setHasDuration(false); | 67 | setHasDuration(false); |
69 | 68 | ||
70 | updated(); | 69 | updated(); |
71 | } | 70 | } |
72 | 71 | ||
73 | QDateTime Event::dtEnd() const | 72 | QDateTime Event::dtEnd() const |
74 | { | 73 | { |
75 | if (hasEndDate()) return mDtEnd; | 74 | if (hasEndDate()) return mDtEnd; |
76 | if (hasDuration()) return dtStart().addSecs(duration()); | 75 | if (hasDuration()) return dtStart().addSecs(duration()); |
77 | 76 | ||
78 | kdDebug(5800) << "Warning! Event '" << summary() | 77 | kdDebug(5800) << "Warning! Event '" << summary() |
79 | << "' does have neither end date nor duration." << endl; | 78 | << "' does have neither end date nor duration." << endl; |