summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-08 10:00:24 (UTC)
committer zautrix <zautrix>2005-07-08 10:00:24 (UTC)
commite1ed9342934d027f8b72a97eb710a52abe53b719 (patch) (unidiff)
tree2d1eef77b64cb5cc9e040fea3a35d240fee5bfd2
parent9635c9a7b8f5c19a1784079d4b67cb3ca600fc33 (diff)
downloadkdepimpi-e1ed9342934d027f8b72a97eb710a52abe53b719.zip
kdepimpi-e1ed9342934d027f8b72a97eb710a52abe53b719.tar.gz
kdepimpi-e1ed9342934d027f8b72a97eb710a52abe53b719.tar.bz2
rec dect fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/event.cpp75
1 files changed, 66 insertions, 9 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 46e8174..5285559 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -197,6 +197,13 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime*
197 } 197 }
198 return false; 198 return false;
199 } 199 }
200 if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) {
201 if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) {
202 // no need to test. times mismatch
203 //fprintf(stderr,"timi ");
204 return false;
205 }
206 }
200 Event *nonRecur = 0; 207 Event *nonRecur = 0;
201 Event *recurEvent = 0; 208 Event *recurEvent = 0;
202 if ( ! doesRecur() ) { 209 if ( ! doesRecur() ) {
@@ -217,11 +224,23 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime*
217 return false; 224 return false;
218 if ( startDT && enr < *startDT ) 225 if ( startDT && enr < *startDT )
219 return false; 226 return false;
227
220 int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); 228 int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd );
221 if ( recurEvent->doesFloat() ) 229 if ( recurEvent->doesFloat() )
222 recDuration += 86400; 230 recDuration += 86400;
223 bool ok = true; 231 bool ok = false;
224 QDateTime recStart = recurEvent->mDtStart.addSecs( -300);; 232 QDateTime recStart;
233 if ( startDT ) {
234 recStart = recurEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok );
235 }
236 if ( recStart.isValid() ) {
237 //qDebug("%s start at %s ", startDT-> toString().latin1(), recStart.toString().latin1());
238 recStart = recStart.addSecs( -300);
239 }
240 else
241 recStart = recurEvent->mDtStart.addSecs( -300);
242 ok = true;
243
225 while ( ok ) { 244 while ( ok ) {
226 recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); 245 recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok );
227 if ( ok ) { 246 if ( ok ) {
@@ -243,31 +262,68 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime*
243 } 262 }
244 return false; 263 return false;
245 } 264 }
246 265 if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) {
247 QDateTime incidenceStart = mDtStart; 266 if ( recurrence()->doesRecur() == Recurrence::rWeekly && testEvent->recurrence()->doesRecur() == Recurrence::rWeekly ) {
267 bool found = false;
268 uint i;
269 for ( i=0; i< recurrence()->days().size();++i ) {
270 found = found || (recurrence()->days().testBit( i ) && testEvent->recurrence()->days().testBit( i ) );
271 }
272 if ( ! found ) {
273 //qDebug("recurring days mismatch %s -- %s", summary().latin1(),testEvent->summary().latin1());
274 return false;
275 }
276
277 }
278 }
279 bool ok = true;
280 QDateTime incidenceStart;// = mDtStart;
281 QDateTime testincidenceStart;// = testEvent->mDtStart;
282 if ( startDT ) {
283 incidenceStart = recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok );
284 testincidenceStart = testEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok );
285 }
286 if ( !testincidenceStart.isValid() )
287 testincidenceStart = testEvent->mDtStart;
288 if ( !incidenceStart.isValid() )
289 incidenceStart = mDtStart;
248 int duration = mDtStart.secsTo( mDtEnd ); 290 int duration = mDtStart.secsTo( mDtEnd );
249 if ( doesFloat() ) 291 if ( doesFloat() )
250 duration += 86400; 292 duration += 86400;
251 QDateTime testincidenceStart = testEvent->mDtStart;
252 int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); 293 int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd );
253 if ( testEvent->doesFloat() ) 294 if ( testEvent->doesFloat() )
254 testduration += 86400; 295 testduration += 86400;
255 bool computeThis = false; 296 bool computeThis = false;
256 if ( incidenceStart < testincidenceStart ) 297 if ( incidenceStart < testincidenceStart )
257 computeThis = true; 298 computeThis = true;
258 bool ok = true;
259 if ( computeThis ) 299 if ( computeThis )
260 incidenceStart = incidenceStart.addSecs( -300 ); 300 incidenceStart = incidenceStart.addSecs( -300 );
261 else 301 else
262 testincidenceStart = testincidenceStart.addSecs( -300 ); 302 testincidenceStart = testincidenceStart.addSecs( -300 );
263 int count = 0; 303 int count = 0;
304 ok = true;
305 int countbreak = 2000;
306 QDateTime stopSearch;
307 bool testStop = false;
308 if ( startDT ) {
309 stopSearch = startDT->addDays( 365*3 );
310 testStop = true;
311 }
264 while ( ok ) { 312 while ( ok ) {
265 ++count; 313 ++count;
266 if ( count > 1000 ) break; 314 if ( count > countbreak ) break;
267 if ( computeThis ) 315 if ( computeThis ) {
316 if ( testStop )
317 if ( testincidenceStart > stopSearch )
318 break;
268 incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); 319 incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok );
269 else 320 }
321 else {
322 if ( testStop )
323 if ( incidenceStart > stopSearch )
324 break;
270 testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); 325 testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok );
326 }
271 if ( ok ) { 327 if ( ok ) {
272 if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { 328 if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) {
273 if ( incidenceStart < testincidenceStart ) 329 if ( incidenceStart < testincidenceStart )
@@ -284,6 +340,7 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime*
284 } 340 }
285 341
286 } 342 }
343 //qDebug("%d rec counter stopped at %d - %s %s", ok ,count, summary().latin1(),testEvent->summary().latin1() );
287 return false; 344 return false;
288} 345}
289QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 346QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const