Changeset View
Changeset View
Standalone View
Standalone View
src/incidencebase.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 103 | { | |||
---|---|---|---|---|---|
107 | mUid = other.mUid; | 107 | mUid = other.mUid; | ||
108 | mDuration = other.mDuration; | 108 | mDuration = other.mDuration; | ||
109 | mAllDay = other.mAllDay; | 109 | mAllDay = other.mAllDay; | ||
110 | mHasDuration = other.mHasDuration; | 110 | mHasDuration = other.mHasDuration; | ||
111 | 111 | | |||
112 | mComments = other.mComments; | 112 | mComments = other.mComments; | ||
113 | mContacts = other.mContacts; | 113 | mContacts = other.mContacts; | ||
114 | 114 | | |||
115 | mAttendees.clear(); | 115 | mAttendees = other.mAttendees; | ||
116 | mAttendees.reserve(other.mAttendees.count()); | 116 | mAttendees.reserve(other.mAttendees.count()); | ||
117 | for (Attendee::List::ConstIterator it = other.mAttendees.constBegin(), | | |||
118 | end = other.mAttendees.constEnd(); | | |||
119 | it != end; ++it) { | | |||
120 | mAttendees.append(Attendee::Ptr(new Attendee(*(*it)))); | | |||
121 | } | | |||
122 | mUrl = other.mUrl; | 117 | mUrl = other.mUrl; | ||
123 | } | 118 | } | ||
124 | 119 | | |||
125 | //@endcond | 120 | //@endcond | ||
126 | 121 | | |||
127 | IncidenceBase::IncidenceBase() | 122 | IncidenceBase::IncidenceBase() | ||
128 | : d(new KCalCore::IncidenceBase::Private) | 123 | : d(new KCalCore::IncidenceBase::Private) | ||
129 | { | 124 | { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 179 | { | |||
189 | 184 | | |||
190 | Attendee::List al1 = attendees(); | 185 | Attendee::List al1 = attendees(); | ||
191 | Attendee::List al2 = i2.attendees(); | 186 | Attendee::List al2 = i2.attendees(); | ||
192 | Attendee::List::ConstIterator a1 = al1.constBegin(); | 187 | Attendee::List::ConstIterator a1 = al1.constBegin(); | ||
193 | Attendee::List::ConstIterator a2 = al2.constBegin(); | 188 | Attendee::List::ConstIterator a2 = al2.constBegin(); | ||
194 | //TODO Does the order of attendees in the list really matter? | 189 | //TODO Does the order of attendees in the list really matter? | ||
195 | //Please delete this comment if you know it's ok, kthx | 190 | //Please delete this comment if you know it's ok, kthx | ||
196 | for (; a1 != al1.constEnd() && a2 != al2.constEnd(); ++a1, ++a2) { | 191 | for (; a1 != al1.constEnd() && a2 != al2.constEnd(); ++a1, ++a2) { | ||
197 | if (!(**a1 == **a2)) { | 192 | if (!(*a1 == *a2)) { | ||
198 | // qCDebug(KCALCORE_LOG) << "Attendees are different"; | 193 | // qCDebug(KCALCORE_LOG) << "Attendees are different"; | ||
199 | return false; | 194 | return false; | ||
200 | } | 195 | } | ||
201 | } | 196 | } | ||
202 | 197 | | |||
203 | if (!CustomProperties::operator==(i2)) { | 198 | if (!CustomProperties::operator==(i2)) { | ||
204 | // qCDebug(KCALCORE_LOG) << "Properties are different"; | 199 | // qCDebug(KCALCORE_LOG) << "Properties are different"; | ||
205 | return false; | 200 | return false; | ||
▲ Show 20 Lines • Show All 215 Lines • ▼ Show 20 Line(s) | 414 | { | |||
421 | d->mContacts.clear(); | 416 | d->mContacts.clear(); | ||
422 | } | 417 | } | ||
423 | 418 | | |||
424 | QStringList IncidenceBase::contacts() const | 419 | QStringList IncidenceBase::contacts() const | ||
425 | { | 420 | { | ||
426 | return d->mContacts; | 421 | return d->mContacts; | ||
427 | } | 422 | } | ||
428 | 423 | | |||
429 | void IncidenceBase::addAttendee(const Attendee::Ptr &a, bool doupdate) | 424 | void IncidenceBase::addAttendee(const Attendee &a, bool doupdate) | ||
430 | { | 425 | { | ||
431 | if (!a || mReadOnly) { | 426 | if (a.isNull() || mReadOnly) { | ||
432 | return; | 427 | return; | ||
433 | } | 428 | } | ||
434 | 429 | Q_ASSERT(!a.uid().isEmpty()); | |||
435 | Q_ASSERT(!a->uid().isEmpty()); | | |||
436 | Q_ASSERT(!d->mAttendees.contains(a)); | | |||
437 | 430 | | |||
438 | if (doupdate) { | 431 | if (doupdate) { | ||
439 | update(); | 432 | update(); | ||
440 | } | 433 | } | ||
441 | 434 | | |||
442 | d->mAttendees.append(a); | 435 | d->mAttendees.append(a); | ||
443 | if (doupdate) { | 436 | if (doupdate) { | ||
444 | d->mDirtyFields.insert(FieldAttendees); | 437 | d->mDirtyFields.insert(FieldAttendees); | ||
Show All 38 Lines | |||||
483 | { | 476 | { | ||
484 | if (mReadOnly) { | 477 | if (mReadOnly) { | ||
485 | return; | 478 | return; | ||
486 | } | 479 | } | ||
487 | d->mDirtyFields.insert(FieldAttendees); | 480 | d->mDirtyFields.insert(FieldAttendees); | ||
488 | d->mAttendees.clear(); | 481 | d->mAttendees.clear(); | ||
489 | } | 482 | } | ||
490 | 483 | | |||
491 | Attendee::Ptr IncidenceBase::attendeeByMail(const QString &email) const | 484 | Attendee IncidenceBase::attendeeByMail(const QString &email) const | ||
492 | { | 485 | { | ||
493 | Attendee::List::ConstIterator it; | 486 | Attendee::List::ConstIterator it; | ||
494 | for (it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it) { | 487 | for (it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it) { | ||
495 | if ((*it)->email() == email) { | 488 | if ((*it).email() == email) { | ||
496 | return *it; | 489 | return *it; | ||
497 | } | 490 | } | ||
498 | } | 491 | } | ||
499 | 492 | | |||
500 | return Attendee::Ptr(); | 493 | return {}; | ||
501 | } | 494 | } | ||
502 | 495 | | |||
503 | Attendee::Ptr IncidenceBase::attendeeByMails(const QStringList &emails, const QString &email) const | 496 | Attendee IncidenceBase::attendeeByMails(const QStringList &emails, const QString &email) const | ||
504 | { | 497 | { | ||
505 | QStringList mails = emails; | 498 | QStringList mails = emails; | ||
506 | if (!email.isEmpty()) { | 499 | if (!email.isEmpty()) { | ||
507 | mails.append(email); | 500 | mails.append(email); | ||
508 | } | 501 | } | ||
509 | 502 | | |||
510 | Attendee::List::ConstIterator itA; | 503 | Attendee::List::ConstIterator itA; | ||
511 | for (itA = d->mAttendees.constBegin(); itA != d->mAttendees.constEnd(); ++itA) { | 504 | for (itA = d->mAttendees.constBegin(); itA != d->mAttendees.constEnd(); ++itA) { | ||
512 | for (QStringList::const_iterator it = mails.constBegin(); it != mails.constEnd(); ++it) { | 505 | for (QStringList::const_iterator it = mails.constBegin(); it != mails.constEnd(); ++it) { | ||
513 | if ((*itA)->email() == (*it)) { | 506 | if ((*itA).email() == (*it)) { | ||
514 | return *itA; | 507 | return *itA; | ||
515 | } | 508 | } | ||
516 | } | 509 | } | ||
517 | } | 510 | } | ||
518 | 511 | | |||
519 | return Attendee::Ptr(); | 512 | return {}; | ||
520 | } | 513 | } | ||
521 | 514 | | |||
522 | Attendee::Ptr IncidenceBase::attendeeByUid(const QString &uid) const | 515 | Attendee IncidenceBase::attendeeByUid(const QString &uid) const | ||
523 | { | 516 | { | ||
524 | Attendee::List::ConstIterator it; | 517 | Attendee::List::ConstIterator it; | ||
525 | for (it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it) { | 518 | for (it = d->mAttendees.constBegin(); it != d->mAttendees.constEnd(); ++it) { | ||
526 | if ((*it)->uid() == uid) { | 519 | if ((*it).uid() == uid) { | ||
527 | return *it; | 520 | return *it; | ||
528 | } | 521 | } | ||
529 | } | 522 | } | ||
530 | 523 | | |||
531 | return Attendee::Ptr(); | 524 | return {}; | ||
532 | } | 525 | } | ||
533 | 526 | | |||
534 | void IncidenceBase::setDuration(const Duration &duration) | 527 | void IncidenceBase::setDuration(const Duration &duration) | ||
535 | { | 528 | { | ||
536 | update(); | 529 | update(); | ||
537 | d->mDuration = duration; | 530 | d->mDuration = duration; | ||
538 | setHasDuration(true); | 531 | setHasDuration(true); | ||
539 | d->mDirtyFields.insert(FieldDuration); | 532 | d->mDirtyFields.insert(FieldDuration); | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 660 | { | |||
675 | 668 | | |||
676 | out << *(static_cast<CustomProperties *>(i.data())); | 669 | out << *(static_cast<CustomProperties *>(i.data())); | ||
677 | serializeQDateTimeAsKDateTime(out, i->d->mLastModified); | 670 | serializeQDateTimeAsKDateTime(out, i->d->mLastModified); | ||
678 | serializeQDateTimeAsKDateTime(out, i->d->mDtStart); | 671 | serializeQDateTimeAsKDateTime(out, i->d->mDtStart); | ||
679 | out << i->organizer() << i->d->mUid << i->d->mDuration | 672 | out << i->organizer() << i->d->mUid << i->d->mDuration | ||
680 | << i->d->mAllDay << i->d->mHasDuration << i->d->mComments << i->d->mContacts | 673 | << i->d->mAllDay << i->d->mHasDuration << i->d->mComments << i->d->mContacts | ||
681 | << i->d->mAttendees.count() << i->d->mUrl; | 674 | << i->d->mAttendees.count() << i->d->mUrl; | ||
682 | 675 | | |||
683 | for (const Attendee::Ptr &attendee : qAsConst(i->d->mAttendees)) { | 676 | for (const Attendee &attendee : qAsConst(i->d->mAttendees)) { | ||
684 | out << attendee; | 677 | out << attendee; | ||
685 | } | 678 | } | ||
686 | 679 | | |||
687 | // Serialize the sub-class data. In KDE5 we can add new virtuals. | 680 | // Serialize the sub-class data. In KDE5 we can add new virtuals. | ||
688 | i->virtual_hook(KCalCore::IncidenceBase::SerializerHook, &out); | 681 | i->virtual_hook(KCalCore::IncidenceBase::SerializerHook, &out); | ||
689 | 682 | | |||
690 | return out; | 683 | return out; | ||
691 | } | 684 | } | ||
Show All 28 Lines | 687 | { | |||
720 | deserializeKDateTimeAsQDateTime(in, i->d->mDtStart); | 713 | deserializeKDateTimeAsQDateTime(in, i->d->mDtStart); | ||
721 | in >> i->d->mOrganizer >> i->d->mUid >> i->d->mDuration | 714 | in >> i->d->mOrganizer >> i->d->mUid >> i->d->mDuration | ||
722 | >> i->d->mAllDay >> i->d->mHasDuration >> i->d->mComments >> i->d->mContacts >> attendeeCount | 715 | >> i->d->mAllDay >> i->d->mHasDuration >> i->d->mComments >> i->d->mContacts >> attendeeCount | ||
723 | >> i->d->mUrl; | 716 | >> i->d->mUrl; | ||
724 | 717 | | |||
725 | i->d->mAttendees.clear(); | 718 | i->d->mAttendees.clear(); | ||
726 | i->d->mAttendees.reserve(attendeeCount); | 719 | i->d->mAttendees.reserve(attendeeCount); | ||
727 | for (int it = 0; it < attendeeCount; it++) { | 720 | for (int it = 0; it < attendeeCount; it++) { | ||
728 | Attendee::Ptr attendee = Attendee::Ptr(new Attendee(QString(), QString())); | 721 | Attendee attendee; | ||
729 | in >> attendee; | 722 | in >> attendee; | ||
730 | i->d->mAttendees.append(attendee); | 723 | i->d->mAttendees.append(attendee); | ||
731 | } | 724 | } | ||
732 | 725 | | |||
733 | // Deserialize the sub-class data. In KDE5 we can add new virtuals. | 726 | // Deserialize the sub-class data. In KDE5 we can add new virtuals. | ||
734 | i->virtual_hook(KCalCore::IncidenceBase::DeserializerHook, &in); | 727 | i->virtual_hook(KCalCore::IncidenceBase::DeserializerHook, &in); | ||
735 | 728 | | |||
736 | return in; | 729 | return in; | ||
737 | } | 730 | } | ||
738 | 731 | | |||
739 | IncidenceBase::IncidenceObserver::~IncidenceObserver() | 732 | IncidenceBase::IncidenceObserver::~IncidenceObserver() | ||
740 | { | 733 | { | ||
741 | } | 734 | } |