author | zautrix <zautrix> | 2005-06-08 12:35:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-08 12:35:38 (UTC) |
commit | d9e240cf1a88f4213c9169e9168d01b669613312 (patch) (unidiff) | |
tree | ed22cb872cc0f38625afe0f01036a48eb9b3edfa /libkcal/incidence.cpp | |
parent | 2448916479b456ca7c880427a80e8e32e95b2fba (diff) | |
download | kdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.zip kdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.tar.gz kdepimpi-d9e240cf1a88f4213c9169e9168d01b669613312.tar.bz2 |
better export
-rw-r--r-- | libkcal/incidence.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index f446197..4382416 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -357,192 +357,203 @@ void Incidence::addCategories(const QStringList &categories, bool addToRelations | |||
357 | updated(); | 357 | updated(); |
358 | if ( addToRelations ) { | 358 | if ( addToRelations ) { |
359 | Incidence * inc; | 359 | Incidence * inc; |
360 | QPtrList<Incidence> Relations = relations(); | 360 | QPtrList<Incidence> Relations = relations(); |
361 | for (inc=Relations.first();inc;inc=Relations.next()) { | 361 | for (inc=Relations.first();inc;inc=Relations.next()) { |
362 | inc->addCategories( categories, true ); | 362 | inc->addCategories( categories, true ); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 367 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
368 | { | 368 | { |
369 | if (mReadOnly) return; | 369 | if (mReadOnly) return; |
370 | mCategories = categories; | 370 | mCategories = categories; |
371 | checkCategories(); | 371 | checkCategories(); |
372 | updated(); | 372 | updated(); |
373 | if ( setForRelations ) { | 373 | if ( setForRelations ) { |
374 | Incidence * inc; | 374 | Incidence * inc; |
375 | QPtrList<Incidence> Relations = relations(); | 375 | QPtrList<Incidence> Relations = relations(); |
376 | for (inc=Relations.first();inc;inc=Relations.next()) { | 376 | for (inc=Relations.first();inc;inc=Relations.next()) { |
377 | inc->setCategories( categories, true ); | 377 | inc->setCategories( categories, true ); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | // TODO: remove setCategories(QString) function | 382 | // TODO: remove setCategories(QString) function |
383 | void Incidence::setCategories(const QString &catStr) | 383 | void Incidence::setCategories(const QString &catStr) |
384 | { | 384 | { |
385 | if (mReadOnly) return; | 385 | if (mReadOnly) return; |
386 | mCategories.clear(); | 386 | mCategories.clear(); |
387 | 387 | ||
388 | if (catStr.isEmpty()) return; | 388 | if (catStr.isEmpty()) return; |
389 | 389 | ||
390 | mCategories = QStringList::split(",",catStr); | 390 | mCategories = QStringList::split(",",catStr); |
391 | 391 | ||
392 | QStringList::Iterator it; | 392 | QStringList::Iterator it; |
393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
394 | *it = (*it).stripWhiteSpace(); | 394 | *it = (*it).stripWhiteSpace(); |
395 | } | 395 | } |
396 | checkCategories(); | 396 | checkCategories(); |
397 | updated(); | 397 | updated(); |
398 | } | 398 | } |
399 | 399 | ||
400 | QStringList Incidence::categories() const | 400 | QStringList Incidence::categories() const |
401 | { | 401 | { |
402 | return mCategories; | 402 | return mCategories; |
403 | } | 403 | } |
404 | 404 | ||
405 | QString Incidence::categoriesStr() | 405 | QString Incidence::categoriesStr() |
406 | { | 406 | { |
407 | return mCategories.join(","); | 407 | return mCategories.join(","); |
408 | } | 408 | } |
409 | QString Incidence::categoriesStrWithSpace() | 409 | QString Incidence::categoriesStrWithSpace() |
410 | { | 410 | { |
411 | return mCategories.join(", "); | 411 | return mCategories.join(", "); |
412 | } | 412 | } |
413 | 413 | ||
414 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 414 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
415 | { | 415 | { |
416 | if (mReadOnly) return; | 416 | if (mReadOnly) return; |
417 | mRelatedToUid = relatedToUid; | 417 | mRelatedToUid = relatedToUid; |
418 | } | 418 | } |
419 | 419 | ||
420 | QString Incidence::relatedToUid() const | 420 | QString Incidence::relatedToUid() const |
421 | { | 421 | { |
422 | return mRelatedToUid; | 422 | return mRelatedToUid; |
423 | } | 423 | } |
424 | 424 | ||
425 | void Incidence::setRelatedTo(Incidence *relatedTo) | 425 | void Incidence::setRelatedTo(Incidence *relatedTo) |
426 | { | 426 | { |
427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
428 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 428 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
429 | if (mReadOnly || mRelatedTo == relatedTo) return; | 429 | if (mReadOnly || mRelatedTo == relatedTo) return; |
430 | if(mRelatedTo) { | 430 | if(mRelatedTo) { |
431 | // updated(); | 431 | // updated(); |
432 | mRelatedTo->removeRelation(this); | 432 | mRelatedTo->removeRelation(this); |
433 | } | 433 | } |
434 | mRelatedTo = relatedTo; | 434 | mRelatedTo = relatedTo; |
435 | if (mRelatedTo) { | 435 | if (mRelatedTo) { |
436 | mRelatedTo->addRelation(this); | 436 | mRelatedTo->addRelation(this); |
437 | mRelatedToUid = mRelatedTo->uid(); | 437 | mRelatedToUid = mRelatedTo->uid(); |
438 | } else { | 438 | } else { |
439 | mRelatedToUid = ""; | 439 | mRelatedToUid = ""; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | Incidence *Incidence::relatedTo() const | 443 | Incidence *Incidence::relatedTo() const |
444 | { | 444 | { |
445 | return mRelatedTo; | 445 | return mRelatedTo; |
446 | } | 446 | } |
447 | 447 | ||
448 | QPtrList<Incidence> Incidence::relations() const | 448 | QPtrList<Incidence> Incidence::relations() const |
449 | { | 449 | { |
450 | return mRelations; | 450 | return mRelations; |
451 | } | 451 | } |
452 | 452 | ||
453 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | ||
454 | { | ||
455 | Incidence* inc; | ||
456 | QPtrList<Incidence> Relations = relations(); | ||
457 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
458 | inc->addRelationsToList( rel ); | ||
459 | } | ||
460 | if ( rel->findRef( this ) == -1 ) | ||
461 | rel->append( this ); | ||
462 | } | ||
463 | |||
453 | void Incidence::addRelation(Incidence *event) | 464 | void Incidence::addRelation(Incidence *event) |
454 | { | 465 | { |
455 | if( mRelations.findRef( event ) == -1 ) { | 466 | if( mRelations.findRef( event ) == -1 ) { |
456 | mRelations.append(event); | 467 | mRelations.append(event); |
457 | //updated(); | 468 | //updated(); |
458 | } | 469 | } |
459 | } | 470 | } |
460 | 471 | ||
461 | void Incidence::removeRelation(Incidence *event) | 472 | void Incidence::removeRelation(Incidence *event) |
462 | { | 473 | { |
463 | 474 | ||
464 | mRelations.removeRef(event); | 475 | mRelations.removeRef(event); |
465 | 476 | ||
466 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 477 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
467 | } | 478 | } |
468 | 479 | ||
469 | bool Incidence::recursOn(const QDate &qd) const | 480 | bool Incidence::recursOn(const QDate &qd) const |
470 | { | 481 | { |
471 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 482 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
472 | else return false; | 483 | else return false; |
473 | } | 484 | } |
474 | 485 | ||
475 | void Incidence::setExDates(const DateList &exDates) | 486 | void Incidence::setExDates(const DateList &exDates) |
476 | { | 487 | { |
477 | if (mReadOnly) return; | 488 | if (mReadOnly) return; |
478 | mExDates = exDates; | 489 | mExDates = exDates; |
479 | 490 | ||
480 | recurrence()->setRecurExDatesCount(mExDates.count()); | 491 | recurrence()->setRecurExDatesCount(mExDates.count()); |
481 | 492 | ||
482 | updated(); | 493 | updated(); |
483 | } | 494 | } |
484 | 495 | ||
485 | void Incidence::addExDate(const QDate &date) | 496 | void Incidence::addExDate(const QDate &date) |
486 | { | 497 | { |
487 | if (mReadOnly) return; | 498 | if (mReadOnly) return; |
488 | mExDates.append(date); | 499 | mExDates.append(date); |
489 | 500 | ||
490 | recurrence()->setRecurExDatesCount(mExDates.count()); | 501 | recurrence()->setRecurExDatesCount(mExDates.count()); |
491 | 502 | ||
492 | updated(); | 503 | updated(); |
493 | } | 504 | } |
494 | 505 | ||
495 | DateList Incidence::exDates() const | 506 | DateList Incidence::exDates() const |
496 | { | 507 | { |
497 | return mExDates; | 508 | return mExDates; |
498 | } | 509 | } |
499 | 510 | ||
500 | bool Incidence::isException(const QDate &date) const | 511 | bool Incidence::isException(const QDate &date) const |
501 | { | 512 | { |
502 | DateList::ConstIterator it; | 513 | DateList::ConstIterator it; |
503 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 514 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
504 | if ( (*it) == date ) { | 515 | if ( (*it) == date ) { |
505 | return true; | 516 | return true; |
506 | } | 517 | } |
507 | } | 518 | } |
508 | 519 | ||
509 | return false; | 520 | return false; |
510 | } | 521 | } |
511 | 522 | ||
512 | void Incidence::addAttachment(Attachment *attachment) | 523 | void Incidence::addAttachment(Attachment *attachment) |
513 | { | 524 | { |
514 | if (mReadOnly || !attachment) return; | 525 | if (mReadOnly || !attachment) return; |
515 | mAttachments.append(attachment); | 526 | mAttachments.append(attachment); |
516 | updated(); | 527 | updated(); |
517 | } | 528 | } |
518 | 529 | ||
519 | void Incidence::deleteAttachment(Attachment *attachment) | 530 | void Incidence::deleteAttachment(Attachment *attachment) |
520 | { | 531 | { |
521 | mAttachments.removeRef(attachment); | 532 | mAttachments.removeRef(attachment); |
522 | } | 533 | } |
523 | 534 | ||
524 | void Incidence::deleteAttachments(const QString& mime) | 535 | void Incidence::deleteAttachments(const QString& mime) |
525 | { | 536 | { |
526 | Attachment *at = mAttachments.first(); | 537 | Attachment *at = mAttachments.first(); |
527 | while (at) { | 538 | while (at) { |
528 | if (at->mimeType() == mime) | 539 | if (at->mimeType() == mime) |
529 | mAttachments.remove(); | 540 | mAttachments.remove(); |
530 | else | 541 | else |
531 | at = mAttachments.next(); | 542 | at = mAttachments.next(); |
532 | } | 543 | } |
533 | } | 544 | } |
534 | 545 | ||
535 | QPtrList<Attachment> Incidence::attachments() const | 546 | QPtrList<Attachment> Incidence::attachments() const |
536 | { | 547 | { |
537 | return mAttachments; | 548 | return mAttachments; |
538 | } | 549 | } |
539 | 550 | ||
540 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 551 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
541 | { | 552 | { |
542 | QPtrList<Attachment> attachments; | 553 | QPtrList<Attachment> attachments; |
543 | QPtrListIterator<Attachment> it( mAttachments ); | 554 | QPtrListIterator<Attachment> it( mAttachments ); |
544 | Attachment *at; | 555 | Attachment *at; |
545 | while ( (at = it.current()) ) { | 556 | while ( (at = it.current()) ) { |
546 | if (at->mimeType() == mime) | 557 | if (at->mimeType() == mime) |
547 | attachments.append(at); | 558 | attachments.append(at); |
548 | ++it; | 559 | ++it; |