2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file ClEventDeleterForm.cpp
19 * @brief This is the implementation file for the EventDeleterForm class.
23 #include "ClEventDeleterForm.h"
24 #include "ClMainFrame.h"
25 #include "ClResourceManager.h"
26 #include "ClEventListPresentationModel.h"
28 #include "ClEventItem.h"
29 #include "ClTwoButtonPopup.h"
31 using namespace Tizen;
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Runtime;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Social;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
41 using namespace Tizen::Locales;
43 static const int IDA_EVENT_DELETER_FORM_FOOTER_DELETE = 75001;
44 static const int IDA_EVENT_DELETER_FORM_DELETE_COMPLETE = 75009;
45 static const int IDA_SELECT_ALL_CHECKED = 75010;
46 static const int IDA_SELECT_ALL_UNCHECKED = 75011;
47 static const int IDA_BEFORE_TODAY_CHECKED = 75020;
48 static const int IDA_BEFORE_TODAY_UNCHECKED = 75021;
50 static const int ID_LIST_ITEM_BEFORE_AFTER = 100;
52 static const int H_ITEM = 112;
53 static const int H_GROUP_ITEM = 76;
54 static const int H_COUNT_LABEL = 48;
55 static const int LEFT_MARGIN = 16;
56 static const int TOTAL_MARGIN = 32;
57 static const int FONT_SIZE_EVENT_SUB_LIST = 32;
58 static const int TOP_BOTTOM_GROUP_ITEM_COUNT = 2;
59 static const int TOP_BOTTOM_ITEM_COUNT = 1;
60 static const int H_GROUP_ITEM_MINIMUM = 0;
61 static const int PREVIOUS_DATE = -1;
62 static const int NEXT_DATE = 1;
64 static const unsigned int COLOR_GROUP_ITEM_BACKGROUND = Color32<248, 246, 239>::Value;
65 static const unsigned int COLOR_GROUP_ITEM_TODAY_BACKGROUND = Color32<239, 236, 224>::Value;
66 static const unsigned int COLOR_GROUP_ITEM_TEXT = Color32<128, 128, 128>::Value;
67 static const unsigned int COLOR_GROUP_ITEM_TODAY_TEXT = Color32<59, 115, 182>::Value;
68 static const unsigned int COLOR_TOP_BOTTOM_ITEM_TEXT = Color32<42, 137, 194>::Value;
69 static const unsigned int COLOR_ITEM_TODAY_BACKGROUND = Color32<239, 236, 224>::Value;
70 static const unsigned int COLOR_ITEM_TEXT_PRESSED = Color32<255, 255, 255>::Value;
77 result Initialize(EventListPresentationModel* pPm, IList* pList, Control* pTarget);
79 virtual Object* Run(void);
81 EventListPresentationModel* __pPm;
87 AsyncDeleter::Initialize(EventListPresentationModel* pPm, IList* pList, Control* pTarget)
92 return Construct(DEFAULT_STACK_SIZE, THREAD_PRIORITY_LOW);
96 AsyncDeleter::Run(void)
98 __pPm->RemoveEvents(*__pList);
101 if (__pTarget != null)
103 __pTarget->SendUserEvent(IDA_EVENT_DELETER_FORM_DELETE_COMPLETE, null);
108 EventDeleterForm::EventDeleterForm(void)
111 , __pGroupedListViewDeleteList(null)
112 , __pSelectedEvent(null)
113 , __pCalendarbook(null)
114 , __pDateFormatter(null)
115 , __pTimeFormatter(null)
117 , __pSelectBeforeToday(null)
120 , __pTwoButtonPopup(null)
122 , __pProgressPopup(null)
123 , __topBottomItemEnabled(false)
125 , __itemHeight(112.f)
129 EventDeleterForm::~EventDeleterForm(void)
135 EventDeleterForm::Initialize(void)
137 return Construct(L"IDL_EVENT_DELETER_FORM");
141 EventDeleterForm::OnInitializing(void)
143 String fontSizeString;
144 Tizen::System::SettingInfo::GetValue(L"http://tizen.org/setting/font.size", fontSizeString);
145 AppLogDebug("fontSize: %ls", fontSizeString.GetPointer());
146 if (fontSizeString == L"small")
149 __itemHeight = 120.f;
151 else if (fontSizeString == L"medium")
154 __itemHeight = 140.f;
156 else if (fontSizeString == L"large")
159 __itemHeight = 157.f;
161 else if (fontSizeString == L"huge")
164 __itemHeight = 176.f;
166 else if (fontSizeString == L"giant")
169 __itemHeight = 205.f;
172 SetFormBackEventListener(this);
173 Tizen::System::SettingInfo::AddSettingEventListener(*this);
174 Footer* pFooter = GetFooter();
175 pFooter->AddActionEventListener(*this);
177 __pPanel = dynamic_cast<Panel*>(GetControl(L"IDC_PANEL"));
178 AppAssertf(__pPanel != null, "[E_FAILURE] Unable to get Panel.");
180 __pSelectAll = dynamic_cast<CheckButton*>(GetControl(L"IDC_SELECTALL_CHECKBUTTON", true));
181 AppAssertf(__pSelectAll != null, "[E_FAILURE] Unable to get CheckButton.");
182 __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
183 __pSelectAll->SetEnabled(false);
184 __pSelectAll->AddActionEventListener(*this);
186 __pSelectBeforeToday = dynamic_cast<CheckButton*>(GetControl(L"IDC_BEFORETODAY_CHECKBUTTON", true));
187 AppAssertf(__pSelectBeforeToday != null, "[E_FAILURE] Unable to get CheckButton.");
188 __pSelectBeforeToday->SetActionId(IDA_BEFORE_TODAY_CHECKED, IDA_BEFORE_TODAY_UNCHECKED);
189 __pSelectBeforeToday->AddActionEventListener(*this);
190 __pSelectBeforeToday->SetEnabled(false);
191 __pSelectBeforeToday->SetShowState(false);
192 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM));
194 __pGroupedListViewDeleteList = dynamic_cast<GroupedListView*>(GetControl(L"IDC_GROUPEDLISTVIEW"));
195 AppAssertf(__pGroupedListViewDeleteList != null, "[E_FAILURE] Unable to get GroupedListView.");
196 __pGroupedListViewDeleteList->SetItemProvider(*this);
197 __pGroupedListViewDeleteList->SetTextOfEmptyList(ResourceManager::GetString(IDS_CLD_BODY_NO_EVENTS));
198 __pGroupedListViewDeleteList->SetBitmapOfEmptyList(ResourceManager::GetBitmapN(IDB_LIST_VIEW_NO_CONTENTS_TEXT));
199 __pGroupedListViewDeleteList->AddGroupedListViewItemEventListener(*this);
201 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL"));
202 AppAssertf(__pLabel != null, "[E_FAILURE] Unable to get Label.");
204 __pPm = EventListPresentationModel::GetInstance();
206 __pDateFormatter = ResourceManager::CreateDateFormatterN(DATE_TIME_STYLE_SHORT);
208 __pTwoButtonPopup = new (std::nothrow) TwoButtonPopup();
209 __pTwoButtonPopup->Initialize();
211 __pSelectedEvent = new (std::nothrow) ArrayList();
212 __pSelectedEvent->Construct();
218 EventDeleterForm::OnTerminating(void)
226 delete __pCalendarbook;
227 delete __pDateFormatter;
228 delete __pTimeFormatter;
229 if (__pTwoButtonPopup)
231 __pTwoButtonPopup->Destroy();
233 if (__pProgressPopup)
235 __pProgressPopup->Destroy();
237 __pPm->RemoveCalendarEventChangedEventListener(*this);
239 if (__pSelectedEvent)
241 __pSelectedEvent->RemoveAll(true);
242 delete __pSelectedEvent;
245 Tizen::System::SettingInfo::RemoveSettingEventListener(*this);
250 EventDeleterForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
254 case IDA_EVENT_POPUP_DELETE:
262 if (!__pProgressPopup)
264 __pProgressPopup = new (std::nothrow) ProgressPopup();
265 __pProgressPopup->Construct(false, false);
267 __pProgressPopup->SetShowState(true);
268 __pProgressPopup->Show();
270 LinkedList* pDeleteEvents = new (std::nothrow) LinkedList(SingleObjectDeleter);
271 for (int i = __pGroupedListViewDeleteList->GetGroupCount() - 1; i >= 0; i--)
273 for (int j = __pGroupedListViewDeleteList->GetItemCountAt(i) - 1; j >= 0 ; j--)
275 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
277 int actualGroupIndex = i;
278 if (__topBottomItemEnabled == true)
280 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
282 pDeleteEvents->Add(new (std::nothrow) CalEventInstance(*__pPm->GetEventWithWholeIndex(actualGroupIndex, j)));
287 AsyncDeleter* pAsyncDeleter = new (std::nothrow) AsyncDeleter();
288 pAsyncDeleter->Initialize(__pPm, pDeleteEvents, this);
289 pAsyncDeleter->Start();
290 __pThread = pAsyncDeleter;
293 case IDA_EVENT_DELETER_FORM_DELETE_COMPLETE:
297 __pProgressPopup->SetShowState(false);
299 __pGroupedListViewDeleteList->UpdateList();
301 for (int i = __pGroupedListViewDeleteList->GetGroupCount() - 1; i >= 0; i--)
303 for (int j = __pGroupedListViewDeleteList->GetItemCountAt(i) - 1; j >= 0 ; j--)
305 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
309 __pSelectAll->SetSelected(IsSelectedAllEvent());
310 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
311 UpdateSelectedLabel();
319 pArgs->RemoveAll(true);
325 EventDeleterForm::OnFormBackRequested(Form& source)
327 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
331 EventDeleterForm::GetGroupCount(void)
333 int groupCount = __pPm->GetWholeDayCount();
335 if (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null)
341 if (groupCount != 0 && __topBottomItemEnabled == true)
343 groupCount += TOP_BOTTOM_GROUP_ITEM_COUNT;
345 if (groupCount == 0 && __pTwoButtonPopup != NULL)
347 __pTwoButtonPopup->SetShowState(false);
353 EventDeleterForm::GetItemCount(int groupIndex)
356 int actualGroupIndex = groupIndex;
358 if (__topBottomItemEnabled == true)
360 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
362 return TOP_BOTTOM_ITEM_COUNT;
366 actualGroupIndex = groupIndex - (TOP_BOTTOM_GROUP_ITEM_COUNT / 2);
370 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
376 EventDeleterForm::CreateGroupItem(int groupIndex, int itemWidth)
378 GroupItem* pItem = new (std::nothrow) GroupItem();
382 if (__topBottomItemEnabled == true && (groupIndex == 0 || groupIndex == GetGroupCount() - 1))
384 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_MINIMUM));
389 int actualGroupIndex = groupIndex;
392 if (__topBottomItemEnabled == true)
394 actualGroupIndex -= 1;
397 date = __pPm->GetDateTimeFromGroupIndex(actualGroupIndex);
398 dateString = __pPm->GetDateString(date);
399 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
401 if (itemCount == 0)//This is Today Index.(event is empty)
403 pItem->Construct(Dimension(itemWidth, 0));
408 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
411 pItem->SetElement(dateString);
413 if (EventListPresentationModel::IsToday(date) == true)
415 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TODAY_TEXT));
419 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TEXT));
426 EventDeleterForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
428 if (__topBottomItemEnabled == true)
430 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
432 CustomItem* pItem = new (std::nothrow) CustomItem();
438 __pDateFormatter->Format(__pPm->GetViewMinRange(), dateString);
439 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_BEFORE);
443 __pDateFormatter->Format(__pPm->GetViewMaxRange(), dateString);
444 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_AFTER);
447 string.Format(string.GetLength() + dateString.GetLength(), string.GetPointer(), dateString.GetPointer());
449 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
450 pItem->AddElement(Rectangle(LEFT_MARGIN, 0, itemWidth - TOTAL_MARGIN, H_ITEM)
451 , ID_LIST_ITEM_BEFORE_AFTER, string, FONT_SIZE_EVENT_SUB_LIST
452 , Color(COLOR_TOP_BOTTOM_ITEM_TEXT), Color(COLOR_ITEM_TEXT_PRESSED), Color(COLOR_ITEM_TEXT_PRESSED));
456 DateTime minDateTime = Calendarbook::GetMinDateTime();
457 minDateTime.AddYears(1);
458 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMinRange() > minDateTime);
462 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
463 maxDateTime.AddYears(-1);
464 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMaxRange() < maxDateTime);
470 groupIndex -= TOP_BOTTOM_ITEM_COUNT;
473 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, true);
475 const CalEventInstance* pEvent = __pPm->GetEventWithWholeIndex(groupIndex, itemIndex);
476 TryReturn((pEvent != null), null, "[E_SYSTEM] Unable to get event instance.");
478 EventItem* pItem = new (std::nothrow) EventItem();
479 pItem->Initialize(EVENT_ITEM_STYLE_SELECTION, itemWidth, __itemHeight);
480 if (EventListPresentationModel::IsToday(__pPm->GetDateTimeFromGroupIndex(groupIndex)) == true)
483 pItem->SetTitle(pEvent->GetSubject());
484 pItem->SetFontSize(__fontSize);
485 pItem->SetCalendarColor(__pPm->GetCalendarColor(pEvent->GetCalendarId()));
486 if (pEvent->IsAllDayEvent() == true)
488 pItem->SetAllDayEvent();
492 DateTime startTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetStartTime());
493 DateTime endTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetEndTime());
494 pItem->SetDateRange(startTime, endTime, __pPm->GetDateTimeFromGroupIndex(groupIndex), __pPm->GetTimeFormatter());
497 pItem->SetReminder(pEvent->HasReminder());
498 pItem->SetRepeat(pEvent->IsRecurring());
499 pItem->SetPriority(pEvent->GetPriority());
500 pItem->UpdateElements();
506 EventDeleterForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
508 AppLogDebug("Enter");
514 EventDeleterForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
516 AppLogDebug("Enter");
522 EventDeleterForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex,
523 int elementId, ListItemStatus status)
525 int actualGroupIndex = groupIndex;
526 if (__topBottomItemEnabled == true)
528 DateTime today = EventListPresentationModel::GetToday();
529 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
530 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
534 DateTime startDate = __pPm->GetDateTimeFromGroupIndex(0);
535 DateTime minRange = __pPm->GetViewMinRange();
536 minRange.AddMonths(PREVIOUS_DATE);
537 DateTime minDateTime = Calendarbook::GetMinDateTime();
538 minDateTime.AddYears(1);
539 if (minRange < minDateTime)
541 minRange = minDateTime;
544 __pPm->SetViewRange(minRange, __pPm->GetViewMaxRange());
546 __pGroupedListViewDeleteList->RefreshList(0, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
547 int addedGroupCount = __pPm->GetGroupIndex(startDate);
548 for (int i = 0; i < addedGroupCount; ++i)
550 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
552 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
553 int itemCount = __pPm->GetWholeEventCount(i);
554 for (int j = 0; j < itemCount; ++j)
556 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
558 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
563 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
565 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
568 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
569 UpdateSelectedLabel();
572 else if (groupIndex == __pGroupedListViewDeleteList->GetGroupCount() - 1)
574 int prevGroupCount = __pPm->GetWholeDayCount();
575 DateTime maxRange = __pPm->GetViewMaxRange();
576 maxRange.AddMonths(NEXT_DATE);
577 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
578 maxDateTime.AddYears(-1);
579 if (maxRange > maxDateTime)
581 maxRange = maxDateTime;
584 __pPm->SetViewRange(__pPm->GetViewMinRange(), maxRange);
586 int groupCount = __pPm->GetWholeDayCount();
587 for (int i = prevGroupCount; i < groupCount; ++i)
589 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
591 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
592 int itemCount = __pPm->GetWholeEventCount(i);
593 for (int j = 0; j < itemCount; ++j)
595 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
597 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
602 __pGroupedListViewDeleteList->RefreshList(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
603 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
605 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
608 __pGroupedListViewDeleteList->ScrollToItem(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0);
609 __pGroupedListViewDeleteList->Invalidate(false);
611 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
612 UpdateSelectedLabel();
617 SetAllSelectedEvents(listView, groupIndex, itemIndex, status);
619 if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == true)
621 __pSelectAll->SetSelected(IsSelectedAllEvent());
622 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
624 else if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == false)
626 __pSelectAll->SetSelected(false);
628 int actualIndex = (__topBottomItemEnabled == true) ? groupIndex - TOP_BOTTOM_ITEM_COUNT : groupIndex;
629 if (__pPm->GetCurrentDate() > __pPm->GetDateTimeFromGroupIndex(actualIndex))
631 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
635 UpdateSelectedLabel();
639 EventDeleterForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex,
640 SweepDirection direction)
645 EventDeleterForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView,
646 int groupIndex, int itemIndex,
647 int elementId, ListContextItemStatus status)
652 EventDeleterForm::OnGroupedListViewItemLongPressed(GroupedListView& listView, int groupIndex, int itemIndex,
653 int elementId, bool& invokeListViewItemCallback)
658 EventDeleterForm::OnGroupedListViewGroupItemSelected(GroupedListView& listView, int groupIndex)
660 if (listView.IsGroupExpanded(groupIndex) == true)
662 listView.CollapseGroup(groupIndex);
666 listView.ExpandGroup(groupIndex);
668 listView.Invalidate(true);
672 EventDeleterForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
674 DateTime minRange = __pPm->GetCurrentDate();
675 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), minRange.GetDay());
678 if (previousSceneId == IDSCN_YEAR)
680 minRange.SetValue(minRange.GetYear(), 1, 1);
682 maxRange.AddYears(NEXT_DATE);
683 maxRange.AddSeconds(PREVIOUS_DATE);
684 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_MBODY_ALL_THIS_YEAR));
686 else if (previousSceneId == IDSCN_MONTH)
688 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), 1);
690 maxRange.AddMonths(NEXT_DATE);
691 maxRange.AddSeconds(PREVIOUS_DATE);
692 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_MONTH));
694 else if (previousSceneId == IDSCN_DAY)
697 maxRange.AddDays(NEXT_DATE);
698 maxRange.AddSeconds(PREVIOUS_DATE);
699 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_DAY));
701 else if (previousSceneId == IDSCN_LIST)
703 minRange = __pPm->GetViewMinRange();
704 maxRange = __pPm->GetViewMaxRange();
706 __topBottomItemEnabled = true;
708 __pSelectBeforeToday->SetShowState(true);
709 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM * 2));
712 __pPm->SetViewType(VIEW_TYPE_DELETE);
713 __pPm->SetViewRange(minRange, maxRange);
714 __pPm->AddCalendarEventChangedEventListener(*this);
715 UpdateSelectedLabel();
717 if (__pSelectedEvent != null)
719 __pSelectedEvent->RemoveAll(true);
721 GetFooter()->SetItemEnabled(0, false);
726 EventDeleterForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
732 EventDeleterForm::OnSettingChanged(Tizen::Base::String& key)
734 if (key.Equals(KEY_SYSTEM_DATE,false))
736 __pGroupedListViewDeleteList->UpdateList();
741 EventDeleterForm::OnActionPerformed(const Control& source, int actionId)
743 TwoButtonPopupStyle style = TWO_BUTTON_POPUP_STYLE_SINGLE_EVENT;
745 DateTime today = EventListPresentationModel::GetToday();
746 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
748 int startGroupIndex = 0;
749 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
750 if (__topBottomItemEnabled == true)
752 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
753 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
758 case IDA_EVENT_DELETER_FORM_FOOTER_DELETE:
759 for (int i = startGroupIndex; i <= endGroupIndex; i++)
761 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
762 for (int j = 0; j < itemCount; j++)
764 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
766 const CalEventInstance* pEventInstance = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
767 if (pEventInstance != null && pEventInstance->IsRecurring() == true)
769 style = TWO_BUTTON_POPUP_STYLE_REPEATED_EVENT;
776 __pTwoButtonPopup->RequestPopup(style, this);
778 case IDA_SELECT_ALL_CHECKED:
779 for (int i = startGroupIndex; i <= endGroupIndex; i++)
781 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
782 for (int j = 0; j < itemCount; j++)
784 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
785 if (pEventInst != null)
787 RecordId id = pEventInst->GetOriginalEventId();
788 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
789 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
794 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
795 UpdateSelectedLabel();
797 case IDA_SELECT_ALL_UNCHECKED:
798 for (int i = startGroupIndex; i <= endGroupIndex; i++)
800 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
801 for (int j = 0; j < itemCount; j++)
803 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
804 if (pEventInst != null)
806 RecordId id = pEventInst->GetOriginalEventId();
807 __pSelectedEvent->Remove(Integer(id));
808 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
812 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
813 UpdateSelectedLabel();
815 case IDA_BEFORE_TODAY_CHECKED:
816 if (__topBottomItemEnabled == true)
818 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
820 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
821 for (int j = 0; j < itemCount; j++)
823 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
824 if (pEventInst != null)
826 RecordId id = pEventInst->GetOriginalEventId();
827 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
828 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
832 __pSelectAll->SetSelected(IsSelectedAllEvent());
833 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
834 UpdateSelectedLabel();
837 case IDA_BEFORE_TODAY_UNCHECKED:
838 if (__topBottomItemEnabled == true)
840 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
842 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
843 for (int j = 0; j < itemCount; j++)
845 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
846 if (pEventInst != null)
848 RecordId id = pEventInst->GetOriginalEventId();
849 __pSelectedEvent->Remove(Integer(id));
850 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
854 __pSelectAll->SetSelected(IsSelectedAllEvent());
855 UpdateSelectedLabel();
862 EventDeleterForm::SetAllSelectedEvents(GroupedListView& listView, int groupIndex, int itemIndex,
863 ListItemStatus status)
865 int actualGroupIndex = groupIndex;
866 if (__topBottomItemEnabled == true)
868 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
870 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(actualGroupIndex, itemIndex);
871 if (pEventInst != null)
873 RecordId id = pEventInst->GetOriginalEventId();
874 if (status == LIST_ITEM_STATUS_CHECKED)
876 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
878 else if (status == LIST_ITEM_STATUS_UNCHECKED)
880 __pSelectedEvent->Remove(Integer(id));
887 EventDeleterForm::AutoCheckSameEvents(RecordId id_original, ListItemStatus status)
889 int startGroupIndex = 0;
890 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
892 if (__topBottomItemEnabled == true)
894 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
895 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
899 for (int i = startGroupIndex; i <= endGroupIndex; i++)
901 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
902 for (int j = 0; j < itemCount; j++)
904 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
905 if (pEventInst != null)
907 RecordId id = pEventInst->GetOriginalEventId();
908 if (id == id_original)
910 __pGroupedListViewDeleteList->SetItemChecked(i, j, (status == LIST_ITEM_STATUS_CHECKED)?true:false);
917 EventDeleterForm::OnCalendarEventChanged(void)
919 __pGroupedListViewDeleteList->UpdateList();
921 int startGroupIndex = 0;
922 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
923 if (__topBottomItemEnabled == true)
925 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
926 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
929 for (int i = startGroupIndex; i <= endGroupIndex; i++)
931 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
932 for (int j = 0; j < itemCount; j++)
934 __pGroupedListViewDeleteList->SetItemChecked(i, j,false);
938 for (int i = startGroupIndex; i <= endGroupIndex; i++)
940 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
941 for (int j = 0; j < itemCount; j++)
943 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
944 if (pEventInst != null)
946 RecordId id = pEventInst->GetOriginalEventId();
947 if (__pSelectedEvent->Contains(Integer(id)))
949 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
955 if (IsSelectedAllEvent())
957 __pSelectAll->SetSelected(true);
961 __pSelectAll->SetSelected(false);
963 if (IsSelectedAllEventBeforeToday())
965 __pSelectBeforeToday->SetSelected(true);
969 __pSelectBeforeToday->SetSelected(false);
972 UpdateSelectedLabel();
974 if (!IsSelectedAnyEvent() && __pTwoButtonPopup != null && __pTwoButtonPopup->GetShowState() == true)
976 __pTwoButtonPopup->SetShowState(false);
982 EventDeleterForm::GetSelectedEventCount(void)
984 int startGroupIndex = 0;
985 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
986 if (__topBottomItemEnabled == true)
988 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
989 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
992 if (endGroupIndex < 0)
998 for (int i = startGroupIndex; i <= endGroupIndex; i++)
1000 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1001 for (int j = 0; j < itemCount; j++)
1003 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
1013 EventDeleterForm::IsSelectedAllEvent(void)
1015 int startGroupIndex = 0;
1016 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1017 if (__topBottomItemEnabled == true)
1019 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1020 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1023 if (endGroupIndex < 0)
1028 for (int i = startGroupIndex; i <= endGroupIndex; i++)
1030 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1031 for (int j = 0; j < itemCount; j++)
1033 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
1043 EventDeleterForm::IsSelectedAnyEvent(void)
1045 int startGroupIndex = 0;
1046 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1047 if (__topBottomItemEnabled == true)
1049 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1050 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1053 if (endGroupIndex < 0)
1058 for (int i = startGroupIndex; i <= endGroupIndex; i++)
1060 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1061 for (int j = 0; j < itemCount; j++)
1063 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
1072 EventDeleterForm::IsSelectedAllEventBeforeToday(void)
1074 DateTime today = EventListPresentationModel::GetToday();
1075 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay());
1077 if (__pPm->GetDateTimeFromGroupIndex(0) >= today)
1082 int startGroupIndex = 0;
1083 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1084 if (__topBottomItemEnabled == true)
1086 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1087 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1090 if (endGroupIndex < 0)
1095 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
1097 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1098 for (int j = 0; j < itemCount; j++)
1100 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
1110 EventDeleterForm::UpdateSelectedLabel(void)
1112 int itemCount = GetSelectedEventCount();
1113 int groupCount = GetGroupCount();
1114 if (groupCount == 0 || (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null))
1116 AppLogDebug("Select button enable.");
1117 __pSelectAll->SetEnabled(false);
1118 __pSelectBeforeToday->SetEnabled(false);
1122 AppLogDebug("Select button disable.");
1123 __pSelectAll->SetEnabled(true);
1124 __pSelectBeforeToday->SetEnabled(true);
1129 GetFooter()->SetItemEnabled(0, true);
1131 String labelString = ResourceManager::GetString(itemCount > 1 ? IDS_BR_POP_PD_ITEMS_SELECTED : IDS_BR_BODY_PD_ITEM_SELECTED);
1132 labelString.Format(labelString.GetLength() + Integer::ToString(itemCount).GetLength(), labelString.GetPointer(), itemCount);
1133 __pLabel->SetText(labelString);
1134 __pLabel->SetSize(GetClientAreaBounds().width, H_COUNT_LABEL);
1138 GetFooter()->SetItemEnabled(0, false);
1140 __pLabel->SetSize(GetClientAreaBounds().width, 0);