diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.11.42") +set(PIM_VERSION "5.11.43") project(KCalCore VERSION ${PIM_VERSION}) diff --git a/src/incidencebase.h b/src/incidencebase.h --- a/src/incidencebase.h +++ b/src/incidencebase.h @@ -518,14 +518,13 @@ void clearAttendees(); /** - Delete single attendee from the incidence. + Set the attendees of this incidence. + This replaces all previously set attendees, unlike addAttendee. - The given attendee will be delete()d at the end of this call. - - @param attendee The attendee to be removeComment - @param doUpdate If true the Observers are notified, if false they are not. + @param attendees A list of attendees. + @param doUpdate If true the Observers are notified, if false they are not. */ - void deleteAttendee(const Attendee::Ptr &attendee, bool doUpdate = true); + void setAttendees(const Attendee::List &attendees, bool doUpdate = true); /** Returns a list of incidence attendees. diff --git a/src/incidencebase.cpp b/src/incidencebase.cpp --- a/src/incidencebase.cpp +++ b/src/incidencebase.cpp @@ -449,27 +449,6 @@ } } -void IncidenceBase::deleteAttendee(const Attendee::Ptr &a, bool doupdate) -{ - if (!a || mReadOnly) { - return; - } - - int index = d->mAttendees.indexOf(a); - if (index >= 0) { - if (doupdate) { - update(); - } - - d->mAttendees.remove(index); - - if (doupdate) { - d->mDirtyFields.insert(FieldAttendees); - updated(); - } - } -} - Attendee::List IncidenceBase::attendees() const { return d->mAttendees; @@ -480,6 +459,29 @@ return d->mAttendees.count(); } +void IncidenceBase::setAttendees(const Attendee::List &attendees, bool doUpdate) +{ + if (mReadOnly) { + return; + } + + if (doUpdate) { + update(); + } + + // don't simply assign, we need the logic in addAttendee here too + clearAttendees(); + d->mAttendees.reserve(attendees.size()); + for (const auto &a : attendees) { + addAttendee(a, false); + } + + if (doUpdate) { + d->mDirtyFields.insert(FieldAttendees); + updated(); + } +} + void IncidenceBase::clearAttendees() { if (mReadOnly) {