summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
authorzautrix <zautrix>2005-07-09 23:58:28 (UTC)
committer zautrix <zautrix>2005-07-09 23:58:28 (UTC)
commit2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b (patch) (unidiff)
treee57782981707d6932940d0489fc942bfeab40dd6 /libkcal/incidence.cpp
parent47370b5d0dea0f29bb929ba13cf45186095c762d (diff)
downloadkdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.zip
kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.gz
kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.bz2
fixxx
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 11f7ecc..e4bcc5e 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -236,97 +236,117 @@ Incidence* Incidence::recreateCloneException( QDate d )
236 if ( doesRecur() ) { 236 if ( doesRecur() ) {
237 addExDate( d ); 237 addExDate( d );
238 newInc->recurrence()->unsetRecurs(); 238 newInc->recurrence()->unsetRecurs();
239 if ( typeID() == eventID ) { 239 if ( typeID() == eventID ) {
240 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 240 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
241 QTime tim = dtStart().time(); 241 QTime tim = dtStart().time();
242 newInc->setDtStart( QDateTime(d, tim) ); 242 newInc->setDtStart( QDateTime(d, tim) );
243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
244 } else { 244 } else {
245 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 245 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
246 QTime tim = ((Todo*)this)->dtDue().time(); 246 QTime tim = ((Todo*)this)->dtDue().time();
247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
249 ((Todo*)this)->setRecurDates(); 249 ((Todo*)this)->setRecurDates();
250 } 250 }
251 newInc->setExDates( DateList () ); 251 newInc->setExDates( DateList () );
252 } 252 }
253 return newInc; 253 return newInc;
254} 254}
255 255
256void Incidence::recreate() 256void Incidence::recreate()
257{ 257{
258 setCreated(QDateTime::currentDateTime()); 258 setCreated(QDateTime::currentDateTime());
259 259
260 setUid(CalFormat::createUniqueId()); 260 setUid(CalFormat::createUniqueId());
261 261
262 setRevision(0); 262 setRevision(0);
263 setIDStr( ":" ); 263 setIDStr( ":" );
264 setLastModified(QDateTime::currentDateTime()); 264 setLastModified(QDateTime::currentDateTime());
265} 265}
266void Incidence::cloneRelations( Incidence * newInc ) 266void Incidence::cloneRelations( Incidence * newInc )
267{ 267{
268 // newInc is already a clone of this incidence 268 // newInc is already a clone of this incidence
269 Incidence * inc; 269 Incidence * inc;
270 Incidence * cloneInc; 270 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations(); 271 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) { 272 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone(); 273 cloneInc = inc->clone();
274 cloneInc->recreate(); 274 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc ); 275 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc ); 276 inc->cloneRelations( cloneInc );
277 } 277 }
278} 278}
279void Incidence::setReadOnly( bool readOnly ) 279void Incidence::setReadOnly( bool readOnly )
280{ 280{
281 IncidenceBase::setReadOnly( readOnly ); 281 IncidenceBase::setReadOnly( readOnly );
282 recurrence()->setRecurReadOnly( readOnly); 282 recurrence()->setRecurReadOnly( readOnly);
283} 283}
284 284void Incidence::setLastModifiedSubInvalid()
285{
286 mLastModifiedSub = QDateTime();
287 if ( mRelatedTo )
288 mRelatedTo->setLastModifiedSubInvalid();
289}
290QDateTime Incidence::lastModifiedSub()
291{
292 if ( !mRelations.count() )
293 return lastModified();
294 if ( mLastModifiedSub.isValid() )
295 return mLastModifiedSub;
296 mLastModifiedSub = lastModified();
297 Incidence * inc;
298 QPtrList<Incidence> Relations = relations();
299 for (inc=Relations.first();inc;inc=Relations.next()) {
300 if ( inc->lastModifiedSub() > mLastModifiedSub )
301 mLastModifiedSub = inc->lastModifiedSub();
302 }
303 return mLastModifiedSub;
304}
285void Incidence::setCreated(QDateTime created) 305void Incidence::setCreated(QDateTime created)
286{ 306{
287 if (mReadOnly) return; 307 if (mReadOnly) return;
288 mCreated = getEvenTime(created); 308 mCreated = getEvenTime(created);
289} 309}
290 310
291QDateTime Incidence::created() const 311QDateTime Incidence::created() const
292{ 312{
293 return mCreated; 313 return mCreated;
294} 314}
295 315
296void Incidence::setRevision(int rev) 316void Incidence::setRevision(int rev)
297{ 317{
298 if (mReadOnly) return; 318 if (mReadOnly) return;
299 mRevision = rev; 319 mRevision = rev;
300 320
301 updated(); 321 updated();
302} 322}
303 323
304int Incidence::revision() const 324int Incidence::revision() const
305{ 325{
306 return mRevision; 326 return mRevision;
307} 327}
308 328
309void Incidence::setDtStart(const QDateTime &dtStart) 329void Incidence::setDtStart(const QDateTime &dtStart)
310{ 330{
311 331
312 QDateTime dt = getEvenTime(dtStart); 332 QDateTime dt = getEvenTime(dtStart);
313 recurrence()->setRecurStart( dt); 333 recurrence()->setRecurStart( dt);
314 IncidenceBase::setDtStart( dt ); 334 IncidenceBase::setDtStart( dt );
315} 335}
316 336
317void Incidence::setDescription(const QString &description) 337void Incidence::setDescription(const QString &description)
318{ 338{
319 if (mReadOnly) return; 339 if (mReadOnly) return;
320 mDescription = description; 340 mDescription = description;
321 updated(); 341 updated();
322} 342}
323 343
324QString Incidence::description() const 344QString Incidence::description() const
325{ 345{
326 return mDescription; 346 return mDescription;
327} 347}
328 348
329 349
330void Incidence::setSummary(const QString &summary) 350void Incidence::setSummary(const QString &summary)
331{ 351{
332 if (mReadOnly) return; 352 if (mReadOnly) return;
@@ -423,107 +443,107 @@ void Incidence::setRelatedToUid(const QString &relatedToUid)
423} 443}
424 444
425QString Incidence::relatedToUid() const 445QString Incidence::relatedToUid() const
426{ 446{
427 return mRelatedToUid; 447 return mRelatedToUid;
428} 448}
429 449
430void Incidence::setRelatedTo(Incidence *relatedTo) 450void Incidence::setRelatedTo(Incidence *relatedTo)
431{ 451{
432 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 452 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
433 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 453 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
434 if (mReadOnly || mRelatedTo == relatedTo) return; 454 if (mReadOnly || mRelatedTo == relatedTo) return;
435 if(mRelatedTo) { 455 if(mRelatedTo) {
436 // updated(); 456 // updated();
437 mRelatedTo->removeRelation(this); 457 mRelatedTo->removeRelation(this);
438 } 458 }
439 mRelatedTo = relatedTo; 459 mRelatedTo = relatedTo;
440 if (mRelatedTo) { 460 if (mRelatedTo) {
441 mRelatedTo->addRelation(this); 461 mRelatedTo->addRelation(this);
442 mRelatedToUid = mRelatedTo->uid(); 462 mRelatedToUid = mRelatedTo->uid();
443 } else { 463 } else {
444 mRelatedToUid = ""; 464 mRelatedToUid = "";
445 } 465 }
446} 466}
447 467
448Incidence *Incidence::relatedTo() const 468Incidence *Incidence::relatedTo() const
449{ 469{
450 return mRelatedTo; 470 return mRelatedTo;
451} 471}
452 472
453QPtrList<Incidence> Incidence::relations() const 473QPtrList<Incidence> Incidence::relations() const
454{ 474{
455 return mRelations; 475 return mRelations;
456} 476}
457 477
458void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 478void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
459{ 479{
460 Incidence* inc; 480 Incidence* inc;
461 QPtrList<Incidence> Relations = relations(); 481 QPtrList<Incidence> Relations = relations();
462 for (inc=Relations.first();inc;inc=Relations.next()) { 482 for (inc=Relations.first();inc;inc=Relations.next()) {
463 inc->addRelationsToList( rel ); 483 inc->addRelationsToList( rel );
464 } 484 }
465 if ( rel->findRef( this ) == -1 ) 485 if ( rel->findRef( this ) == -1 )
466 rel->append( this ); 486 rel->append( this );
467} 487}
468 488
469void Incidence::addRelation(Incidence *event) 489void Incidence::addRelation(Incidence *event)
470{ 490{
491 setLastModifiedSubInvalid();
471 if( mRelations.findRef( event ) == -1 ) { 492 if( mRelations.findRef( event ) == -1 ) {
472 mRelations.append(event); 493 mRelations.append(event);
473 //updated(); 494 //updated();
474 } 495 }
475} 496}
476 497
477void Incidence::removeRelation(Incidence *event) 498void Incidence::removeRelation(Incidence *event)
478{ 499{
479 500 setLastModifiedSubInvalid();
480 mRelations.removeRef(event); 501 mRelations.removeRef(event);
481
482// if (event->getRelatedTo() == this) event->setRelatedTo(0); 502// if (event->getRelatedTo() == this) event->setRelatedTo(0);
483} 503}
484 504
485bool Incidence::recursOn(const QDate &qd) const 505bool Incidence::recursOn(const QDate &qd) const
486{ 506{
487 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 507 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
488 else return false; 508 else return false;
489} 509}
490 510
491void Incidence::setExDates(const DateList &exDates) 511void Incidence::setExDates(const DateList &exDates)
492{ 512{
493 if (mReadOnly) return; 513 if (mReadOnly) return;
494 mExDates = exDates; 514 mExDates = exDates;
495 515
496 recurrence()->setRecurExDatesCount(mExDates.count()); 516 recurrence()->setRecurExDatesCount(mExDates.count());
497 517
498 updated(); 518 updated();
499} 519}
500 520
501void Incidence::addExDate(const QDate &date) 521void Incidence::addExDate(const QDate &date)
502{ 522{
503 if (mReadOnly) return; 523 if (mReadOnly) return;
504 mExDates.append(date); 524 mExDates.append(date);
505 525
506 recurrence()->setRecurExDatesCount(mExDates.count()); 526 recurrence()->setRecurExDatesCount(mExDates.count());
507 527
508 updated(); 528 updated();
509} 529}
510 530
511DateList Incidence::exDates() const 531DateList Incidence::exDates() const
512{ 532{
513 return mExDates; 533 return mExDates;
514} 534}
515 535
516bool Incidence::isException(const QDate &date) const 536bool Incidence::isException(const QDate &date) const
517{ 537{
518 DateList::ConstIterator it; 538 DateList::ConstIterator it;
519 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 539 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
520 if ( (*it) == date ) { 540 if ( (*it) == date ) {
521 return true; 541 return true;
522 } 542 }
523 } 543 }
524 544
525 return false; 545 return false;
526} 546}
527 547
528void Incidence::addAttachment(Attachment *attachment) 548void Incidence::addAttachment(Attachment *attachment)
529{ 549{