author | zautrix <zautrix> | 2005-01-16 12:04:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 12:04:50 (UTC) |
commit | f3f63a1a1363cba9f58790812e43d6eda14f733c (patch) (unidiff) | |
tree | 009a8e73b8e79bbd9d153a9cf17f258c60488fb2 | |
parent | d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b (diff) | |
download | kdepimpi-f3f63a1a1363cba9f58790812e43d6eda14f733c.zip kdepimpi-f3f63a1a1363cba9f58790812e43d6eda14f733c.tar.gz kdepimpi-f3f63a1a1363cba9f58790812e43d6eda14f733c.tar.bz2 |
filter fix
-rw-r--r-- | korganizer/calendarview.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 02c5e45..685bb60 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1022,193 +1022,192 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1022 | return false; | 1022 | return false; |
1023 | if ( incCounter % modulo == 0 ) | 1023 | if ( incCounter % modulo == 0 ) |
1024 | bar.setProgress( incCounter ); | 1024 | bar.setProgress( incCounter ); |
1025 | ++incCounter; | 1025 | ++incCounter; |
1026 | uid = inR->uid(); | 1026 | uid = inR->uid(); |
1027 | bool skipIncidence = false; | 1027 | bool skipIncidence = false; |
1028 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1028 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1029 | skipIncidence = true; | 1029 | skipIncidence = true; |
1030 | QString idS; | 1030 | QString idS; |
1031 | qApp->processEvents(); | 1031 | qApp->processEvents(); |
1032 | if ( !skipIncidence ) { | 1032 | if ( !skipIncidence ) { |
1033 | inL = local->incidence( uid ); | 1033 | inL = local->incidence( uid ); |
1034 | if ( inL ) { // maybe conflict - same uid in both calendars | 1034 | if ( inL ) { // maybe conflict - same uid in both calendars |
1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1037 | if ( take == 3 ) | 1037 | if ( take == 3 ) |
1038 | return false; | 1038 | return false; |
1039 | if ( take == 1 ) {// take local ********************** | 1039 | if ( take == 1 ) {// take local ********************** |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1042 | else | 1042 | else |
1043 | idS = inR->IDStr(); | 1043 | idS = inR->IDStr(); |
1044 | remote->deleteIncidence( inR ); | 1044 | remote->deleteIncidence( inR ); |
1045 | inR = inL->clone(); | 1045 | inR = inL->clone(); |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1048 | inR->setIDStr( idS ); | 1048 | inR->setIDStr( idS ); |
1049 | remote->addIncidence( inR ); | 1049 | remote->addIncidence( inR ); |
1050 | if ( mSyncManager->syncWithDesktop() ) | 1050 | if ( mSyncManager->syncWithDesktop() ) |
1051 | inR->setPilotId( 2 ); | 1051 | inR->setPilotId( 2 ); |
1052 | ++changedRemote; | 1052 | ++changedRemote; |
1053 | } else {// take remote ********************** | 1053 | } else {// take remote ********************** |
1054 | idS = inL->IDStr(); | 1054 | idS = inL->IDStr(); |
1055 | int pid = inL->pilotId(); | 1055 | int pid = inL->pilotId(); |
1056 | local->deleteIncidence( inL ); | 1056 | local->deleteIncidence( inL ); |
1057 | inL = inR->clone(); | 1057 | inL = inR->clone(); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inL->setPilotId( pid ); | 1059 | inL->setPilotId( pid ); |
1060 | inL->setIDStr( idS ); | 1060 | inL->setIDStr( idS ); |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1064 | } | 1064 | } |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++changedLocal; | 1066 | ++changedLocal; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | } else { // no conflict ********** add or delete remote | 1069 | } else { // no conflict ********** add or delete remote |
1070 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1070 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1071 | QString des = eventLSync->description(); | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | QString pref = "e"; | 1072 | QString des = eventLSync->description(); |
1073 | if ( inR->type() == "Todo" ) | 1073 | QString pref = "e"; |
1074 | pref = "t"; | 1074 | if ( inR->type() == "Todo" ) |
1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1075 | pref = "t"; |
1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1076 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1077 | //remote->deleteIncidence( inR ); | 1077 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1078 | ++deletedEventR; | 1078 | //remote->deleteIncidence( inR ); |
1079 | } else { | 1079 | ++deletedEventR; |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | } else { |
1081 | inR->setLastModified( modifiedCalendar ); | 1081 | inR->setLastModified( modifiedCalendar ); |
1082 | inL = inR->clone(); | 1082 | inL = inR->clone(); |
1083 | inL->setIDStr( ":" ); | 1083 | inL->setIDStr( ":" ); |
1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1086 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1087 | ++addedEvent; |
1088 | |||
1088 | } | 1089 | } |
1089 | } | 1090 | } else { |
1090 | } else { | 1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | ||
1092 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | ||
1093 | inR->setLastModified( modifiedCalendar ); | 1092 | inR->setLastModified( modifiedCalendar ); |
1094 | inL = inR->clone(); | 1093 | inL = inR->clone(); |
1095 | inL->setIDStr( ":" ); | 1094 | inL->setIDStr( ":" ); |
1096 | local->addIncidence( inL ); | 1095 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1096 | ++addedEvent; |
1097 | |||
1098 | } else { | ||
1099 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1100 | remote->deleteIncidence( inR ); | ||
1101 | ++deletedEventR; | ||
1098 | } | 1102 | } |
1099 | } else { | ||
1100 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1101 | remote->deleteIncidence( inR ); | ||
1102 | ++deletedEventR; | ||
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | inR = er.next(); | 1107 | inR = er.next(); |
1108 | } | 1108 | } |
1109 | QPtrList<Incidence> el = local->rawIncidences(); | 1109 | QPtrList<Incidence> el = local->rawIncidences(); |
1110 | inL = el.first(); | 1110 | inL = el.first(); |
1111 | modulo = (el.count()/10)+1; | 1111 | modulo = (el.count()/10)+1; |
1112 | bar.setCaption (i18n("Add / remove events") ); | 1112 | bar.setCaption (i18n("Add / remove events") ); |
1113 | bar.setTotalSteps ( el.count() ) ; | 1113 | bar.setTotalSteps ( el.count() ) ; |
1114 | bar.show(); | 1114 | bar.show(); |
1115 | incCounter = 0; | 1115 | incCounter = 0; |
1116 | 1116 | ||
1117 | while ( inL ) { | 1117 | while ( inL ) { |
1118 | 1118 | ||
1119 | qApp->processEvents(); | 1119 | qApp->processEvents(); |
1120 | if ( ! bar.isVisible() ) | 1120 | if ( ! bar.isVisible() ) |
1121 | return false; | 1121 | return false; |
1122 | if ( incCounter % modulo == 0 ) | 1122 | if ( incCounter % modulo == 0 ) |
1123 | bar.setProgress( incCounter ); | 1123 | bar.setProgress( incCounter ); |
1124 | ++incCounter; | 1124 | ++incCounter; |
1125 | uid = inL->uid(); | 1125 | uid = inL->uid(); |
1126 | bool skipIncidence = false; | 1126 | bool skipIncidence = false; |
1127 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1127 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1128 | skipIncidence = true; | 1128 | skipIncidence = true; |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1130 | skipIncidence = true; | 1130 | skipIncidence = true; |
1131 | if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){ | ||
1132 | skipIncidence = true; | ||
1133 | } | ||
1131 | if ( !skipIncidence ) { | 1134 | if ( !skipIncidence ) { |
1132 | inR = remote->incidence( uid ); | 1135 | inR = remote->incidence( uid ); |
1133 | if ( ! inR ) { // no conflict ********** add or delete local | 1136 | if ( ! inR ) { // no conflict ********** add or delete local |
1134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1137 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1135 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1138 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1136 | checkExternSyncEvent(eventLSyncSharp, inL); | 1139 | checkExternSyncEvent(eventLSyncSharp, inL); |
1137 | local->deleteIncidence( inL ); | 1140 | local->deleteIncidence( inL ); |
1138 | ++deletedEventL; | 1141 | ++deletedEventL; |
1139 | } else { | 1142 | } else { |
1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1143 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1141 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | inL->removeID(mCurrentSyncDevice ); |
1142 | inL->removeID(mCurrentSyncDevice ); | 1145 | ++addedEventR; |
1143 | ++addedEventR; | 1146 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1144 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1147 | inL->setLastModified( modifiedCalendar ); |
1145 | inL->setLastModified( modifiedCalendar ); | 1148 | inR = inL->clone(); |
1146 | inR = inL->clone(); | 1149 | inR->setIDStr( ":" ); |
1147 | inR->setIDStr( ":" ); | 1150 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1148 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1151 | remote->addIncidence( inR ); |
1149 | remote->addIncidence( inR ); | ||
1150 | } | ||
1151 | } | 1152 | } |
1152 | } | 1153 | } |
1153 | } else { | 1154 | } else { |
1154 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1155 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1155 | checkExternSyncEvent(eventLSyncSharp, inL); | 1156 | checkExternSyncEvent(eventLSyncSharp, inL); |
1156 | local->deleteIncidence( inL ); | 1157 | local->deleteIncidence( inL ); |
1157 | ++deletedEventL; | 1158 | ++deletedEventL; |
1158 | } else { | 1159 | } else { |
1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1160 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1160 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1161 | ++addedEventR; |
1161 | ++addedEventR; | 1162 | inL->setLastModified( modifiedCalendar ); |
1162 | inL->setLastModified( modifiedCalendar ); | 1163 | inR = inL->clone(); |
1163 | inR = inL->clone(); | 1164 | inR->setIDStr( ":" ); |
1164 | inR->setIDStr( ":" ); | 1165 | remote->addIncidence( inR ); |
1165 | remote->addIncidence( inR ); | ||
1166 | } | ||
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | } | 1168 | } |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | inL = el.next(); | 1171 | inL = el.next(); |
1173 | } | 1172 | } |
1174 | int delFut = 0; | 1173 | int delFut = 0; |
1175 | int remRem = 0; | 1174 | int remRem = 0; |
1176 | if ( mSyncManager->mWriteBackInFuture ) { | 1175 | if ( mSyncManager->mWriteBackInFuture ) { |
1177 | er = remote->rawIncidences(); | 1176 | er = remote->rawIncidences(); |
1178 | remRem = er.count(); | 1177 | remRem = er.count(); |
1179 | inR = er.first(); | 1178 | inR = er.first(); |
1180 | QDateTime dt; | 1179 | QDateTime dt; |
1181 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1180 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1182 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1181 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1183 | while ( inR ) { | 1182 | while ( inR ) { |
1184 | if ( inR->type() == "Todo" ) { | 1183 | if ( inR->type() == "Todo" ) { |
1185 | Todo * t = (Todo*)inR; | 1184 | Todo * t = (Todo*)inR; |
1186 | if ( t->hasDueDate() ) | 1185 | if ( t->hasDueDate() ) |
1187 | dt = t->dtDue(); | 1186 | dt = t->dtDue(); |
1188 | else | 1187 | else |
1189 | dt = cur.addSecs( 62 ); | 1188 | dt = cur.addSecs( 62 ); |
1190 | } | 1189 | } |
1191 | else if (inR->type() == "Event" ) { | 1190 | else if (inR->type() == "Event" ) { |
1192 | bool ok; | 1191 | bool ok; |
1193 | dt = inR->getNextOccurence( cur, &ok ); | 1192 | dt = inR->getNextOccurence( cur, &ok ); |
1194 | if ( !ok ) | 1193 | if ( !ok ) |
1195 | dt = cur.addSecs( -62 ); | 1194 | dt = cur.addSecs( -62 ); |
1196 | } | 1195 | } |
1197 | else | 1196 | else |
1198 | dt = inR->dtStart(); | 1197 | dt = inR->dtStart(); |
1199 | if ( dt < cur || dt > end ) { | 1198 | if ( dt < cur || dt > end ) { |
1200 | remote->deleteIncidence( inR ); | 1199 | remote->deleteIncidence( inR ); |
1201 | ++delFut; | 1200 | ++delFut; |
1202 | } | 1201 | } |
1203 | inR = er.next(); | 1202 | inR = er.next(); |
1204 | } | 1203 | } |
1205 | } | 1204 | } |
1206 | bar.hide(); | 1205 | bar.hide(); |
1207 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1206 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1208 | eventLSync->setReadOnly( false ); | 1207 | eventLSync->setReadOnly( false ); |
1209 | eventLSync->setDtStart( mLastCalendarSync ); | 1208 | eventLSync->setDtStart( mLastCalendarSync ); |
1210 | eventRSync->setDtStart( mLastCalendarSync ); | 1209 | eventRSync->setDtStart( mLastCalendarSync ); |
1211 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1210 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1212 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1211 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1213 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1212 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1214 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1213 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |