From: SungWan Kim Date: Mon, 8 Apr 2013 09:55:54 +0000 (+0900) Subject: Resolve recurrence defect of edited event instance. X-Git-Tag: 2.1_release~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5d871477c662c6112544145c9df72b23d25b82f;p=apps%2Fosp%2FCalendar.git Resolve recurrence defect of edited event instance. Change-Id: Ia4d94f59462e4b639a31b8219c19f205eda233c9 Signed-off-by: SungWan Kim --- diff --git a/src/ClEventPresentationModel.cpp b/src/ClEventPresentationModel.cpp index 33d4e9b..7e0c13e 100644 --- a/src/ClEventPresentationModel.cpp +++ b/src/ClEventPresentationModel.cpp @@ -500,6 +500,17 @@ EventPresentationModel::SetEvent(const CalEvent& event) delete __pEvent; __pEvent = new (std::nothrow) CalEvent(event); + if (__pEvent->GetBaseEventId() != __pEvent->GetRecordId() && __pEvent->GetBaseEventId() != INVALID_RECORD_ID) + { + CalEvent* pBaseEvent = __pCalendarbook->GetEventN(__pEvent->GetBaseEventId()); + if (pBaseEvent != null) + { + delete __pRecurrence; + __pRecurrence = new (std::nothrow) Recurrence(*pBaseEvent->GetRecurrence()); + delete pBaseEvent; + } + } + delete __pCalendar; if (__pEvent->GetCalendarId() != INVALID_RECORD_ID) { @@ -570,6 +581,17 @@ EventPresentationModel::SetEventId(const RecordId eventId) delete __pEvent; __pEvent = pEvent; + if (__pEvent->GetBaseEventId() != __pEvent->GetRecordId() && __pEvent->GetBaseEventId() != INVALID_RECORD_ID) + { + CalEvent* pBaseEvent = __pCalendarbook->GetEventN(__pEvent->GetBaseEventId()); + if (pBaseEvent != null) + { + delete __pRecurrence; + __pRecurrence = new (std::nothrow) Recurrence(*pBaseEvent->GetRecurrence()); + delete pBaseEvent; + } + } + delete __pCalendar; if (__pEvent->GetCalendarId() != INVALID_RECORD_ID) { @@ -607,12 +629,24 @@ EventPresentationModel::SetEventInstance(const CalEventInstance& event) { delete __pRecurrence; __pRecurrence = (pEvent->GetRecurrence() != null) ? new (std::nothrow) Recurrence(*pEvent->GetRecurrence()) : null; + pEvent->SetRecurrence(null); pEvent->SetStartAndEndTime(__pEventInstance->GetStartTime(), __pEventInstance->GetEndTime()); } delete __pEvent; __pEvent = pEvent; + if (__pEvent->GetBaseEventId() != __pEvent->GetRecordId() && __pEvent->GetBaseEventId() != INVALID_RECORD_ID) + { + CalEvent* pBaseEvent = __pCalendarbook->GetEventN(__pEvent->GetBaseEventId()); + if (pBaseEvent != null) + { + delete __pRecurrence; + __pRecurrence = new (std::nothrow) Recurrence(*pBaseEvent->GetRecurrence()); + delete pBaseEvent; + } + } + delete __pCalendar; if (__pEventInstance->GetCalendarId() != INVALID_RECORD_ID) { @@ -848,23 +882,39 @@ EventPresentationModel::Update(void) } else if (__allEventEditing == true) { - RecordId calendarId = (__pEventInstance != null) ? __pEventInstance->GetCalendarId() : __pEvent->GetCalendarId(); - if (__pCalendar != null && calendarId != INVALID_RECORD_ID && __pCalendar->GetRecordId() != calendarId) + if (__pEvent->GetBaseEventId() != eventId && __pEvent->GetBaseEventId() != INVALID_RECORD_ID) { - if (__pEvent->GetCalendarId() != INVALID_RECORD_ID) + __pEventInstance = GetEventInstance(); + if (__pEventInstance != null) { - __pCalendarbook->RemoveEvent(*__pEvent); + r = __pCalendarbook->UpdateEventInstance(*__pEventInstance, *__pEvent); } else { - __pCalendarbook->RemoveEvent(eventId); + r = E_FAILURE; + AppLogDebug("[E_FAILURE] Unable to get event instance."); } - - r = __pCalendarbook->AddEvent(*__pEvent, __pCalendar->GetRecordId()); } else { - r = __pCalendarbook->UpdateEvent(*__pEvent); + RecordId calendarId = (__pEventInstance != null) ? __pEventInstance->GetCalendarId() : __pEvent->GetCalendarId(); + if (__pCalendar != null && calendarId != INVALID_RECORD_ID && __pCalendar->GetRecordId() != calendarId) + { + if (__pEvent->GetCalendarId() != INVALID_RECORD_ID) + { + __pCalendarbook->RemoveEvent(*__pEvent); + } + else + { + __pCalendarbook->RemoveEvent(eventId); + } + + r = __pCalendarbook->AddEvent(*__pEvent, __pCalendar->GetRecordId()); + } + else + { + r = __pCalendarbook->UpdateEvent(*__pEvent); + } } } else if (__pEventInstance != null)