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_BACKGROUND = Color32<248, 246, 239>::Value;
70 static const unsigned int COLOR_ITEM_TODAY_BACKGROUND = Color32<239, 236, 224>::Value;
71 static const unsigned int COLOR_ITEM_TEXT_PRESSED = Color32<255, 255, 255>::Value;
78 result Initialize(EventListPresentationModel* pPm, IList* pList, Control* pTarget);
80 virtual Object* Run(void);
82 EventListPresentationModel* __pPm;
88 AsyncDeleter::Initialize(EventListPresentationModel* pPm, IList* pList, Control* pTarget)
93 return Construct(DEFAULT_STACK_SIZE, THREAD_PRIORITY_LOW);
97 AsyncDeleter::Run(void)
99 __pPm->RemoveEvents(*__pList, true);
102 if (__pTarget != null)
104 __pTarget->SendUserEvent(IDA_EVENT_DELETER_FORM_DELETE_COMPLETE, null);
109 EventDeleterForm::EventDeleterForm(void)
112 , __pGroupedListViewDeleteList(null)
113 , __pCalendarbook(null)
114 , __pDateFormatter(null)
115 , __pTimeFormatter(null)
117 , __pSelectBeforeToday(null)
120 , __pTwoButtonPopup(null)
122 , __pProgressPopup(null)
123 , __topBottomItemEnabled(false)
127 EventDeleterForm::~EventDeleterForm(void)
133 EventDeleterForm::Initialize(void)
135 return Construct(L"IDL_EVENT_DELETER_FORM");
139 EventDeleterForm::OnInitializing(void)
141 SetFormBackEventListener(this);
142 Footer* pFooter = GetFooter();
143 pFooter->AddActionEventListener(*this);
145 __pPanel = dynamic_cast<Panel*>(GetControl(L"IDC_PANEL"));
146 AppAssertf(__pPanel != null, "[E_FAILURE] Unable to get Panel.");
148 __pSelectAll = dynamic_cast<CheckButton*>(GetControl(L"IDC_SELECTALL_CHECKBUTTON", true));
149 AppAssertf(__pSelectAll != null, "[E_FAILURE] Unable to get CheckButton.");
150 __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
151 __pSelectAll->SetEnabled(false);
152 __pSelectAll->AddActionEventListener(*this);
154 __pSelectBeforeToday = dynamic_cast<CheckButton*>(GetControl(L"IDC_BEFORETODAY_CHECKBUTTON", true));
155 AppAssertf(__pSelectBeforeToday != null, "[E_FAILURE] Unable to get CheckButton.");
156 __pSelectBeforeToday->SetActionId(IDA_BEFORE_TODAY_CHECKED, IDA_BEFORE_TODAY_UNCHECKED);
157 __pSelectBeforeToday->AddActionEventListener(*this);
158 __pSelectBeforeToday->SetEnabled(false);
159 __pSelectBeforeToday->SetShowState(false);
160 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM));
162 __pGroupedListViewDeleteList = dynamic_cast<GroupedListView*>(GetControl(L"IDC_GROUPEDLISTVIEW"));
163 AppAssertf(__pGroupedListViewDeleteList != null, "[E_FAILURE] Unable to get GroupedListView.");
164 __pGroupedListViewDeleteList->SetItemProvider(*this);
165 __pGroupedListViewDeleteList->SetTextOfEmptyList(ResourceManager::GetString(IDS_CLD_BODY_NO_EVENTS));
166 __pGroupedListViewDeleteList->SetBitmapOfEmptyList(ResourceManager::GetBitmapN(IDB_LIST_VIEW_NO_CONTENTS_TEXT));
167 __pGroupedListViewDeleteList->AddGroupedListViewItemEventListener(*this);
169 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL"));
170 AppAssertf(__pLabel != null, "[E_FAILURE] Unable to get Label.");
172 __pPm = EventListPresentationModel::GetInstance();
174 __pDateFormatter = ResourceManager::CreateDateFormatterN(DATE_TIME_STYLE_SHORT);
176 __pTwoButtonPopup = new (std::nothrow) TwoButtonPopup();
177 __pTwoButtonPopup->Initialize();
183 EventDeleterForm::OnTerminating(void)
185 if (__pThread != null)
191 delete __pCalendarbook;
192 delete __pDateFormatter;
193 delete __pTimeFormatter;
194 if (__pTwoButtonPopup != null)
196 __pTwoButtonPopup->Destroy();
198 if (__pProgressPopup != null)
200 __pProgressPopup->Destroy();
202 __pPm->RemoveCalendarEventChangedEventListener(*this);
208 EventDeleterForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
212 case IDA_EVENT_POPUP_DELETE:
214 if (__pThread != null)
220 if (__pProgressPopup == null)
222 __pProgressPopup = new (std::nothrow) ProgressPopup();
223 __pProgressPopup->Construct(false, false);
225 __pProgressPopup->SetShowState(true);
226 __pProgressPopup->Show();
228 LinkedList* pDeleteEvents = new (std::nothrow) LinkedList(SingleObjectDeleter);
229 for (int i = __pGroupedListViewDeleteList->GetGroupCount() - 1; i >= 0; i--)
231 for (int j = __pGroupedListViewDeleteList->GetItemCountAt(i) - 1; j >= 0 ; j--)
233 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
235 int actualGroupIndex = i;
236 if (__topBottomItemEnabled == true)
238 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
240 pDeleteEvents->Add(new (std::nothrow) CalEventInstance(*__pPm->GetEventWithWholeIndex(actualGroupIndex, j)));
241 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
246 AsyncDeleter* pAsyncDeleter = new (std::nothrow) AsyncDeleter();
247 pAsyncDeleter->Initialize(__pPm, pDeleteEvents, this);
248 pAsyncDeleter->Start();
249 __pThread = pAsyncDeleter;
252 case IDA_EVENT_DELETER_FORM_DELETE_COMPLETE:
256 __pProgressPopup->SetShowState(false);
258 __pGroupedListViewDeleteList->UpdateList();
260 __pSelectAll->SetSelected(IsSelectedAllEvent());
261 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
262 UpdateSelectedLabel();
270 pArgs->RemoveAll(true);
276 EventDeleterForm::OnFormBackRequested(Form& source)
278 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
282 EventDeleterForm::GetGroupCount(void)
284 int groupCount = __pPm->GetWholeDayCount();
286 if (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null)
291 if (groupCount != 0 && __topBottomItemEnabled == true)
293 groupCount += TOP_BOTTOM_GROUP_ITEM_COUNT;
300 EventDeleterForm::GetItemCount(int groupIndex)
303 int actualGroupIndex = groupIndex;
305 if (__topBottomItemEnabled == true)
307 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
309 return TOP_BOTTOM_ITEM_COUNT;
313 actualGroupIndex = groupIndex - (TOP_BOTTOM_GROUP_ITEM_COUNT / 2);
317 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
323 EventDeleterForm::CreateGroupItem(int groupIndex, int itemWidth)
325 GroupItem* pItem = new (std::nothrow) GroupItem();
329 if (__topBottomItemEnabled == true && (groupIndex == 0 || groupIndex == GetGroupCount() - 1))
331 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_MINIMUM));
336 int actualGroupIndex = groupIndex;
339 if (__topBottomItemEnabled == true)
341 actualGroupIndex -= 1;
344 date = __pPm->GetDateTimeFromGroupIndex(actualGroupIndex);
345 dateString = __pPm->GetDateString(date);
346 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
348 if (itemCount == 0)//This is Today Index.(event is empty)
350 pItem->Construct(Dimension(itemWidth, 0));
355 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
358 pItem->SetElement(dateString);
360 if (EventListPresentationModel::IsToday(date) == true)
362 pItem->SetBackgroundColor(Color(COLOR_GROUP_ITEM_TODAY_BACKGROUND));
363 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TODAY_TEXT));
367 pItem->SetBackgroundColor(Color(COLOR_GROUP_ITEM_BACKGROUND));
368 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TEXT));
375 EventDeleterForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
377 if (__topBottomItemEnabled == true)
379 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
381 CustomItem* pItem = new (std::nothrow) CustomItem();
387 __pDateFormatter->Format(__pPm->GetViewMinRange(), dateString);
388 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_BEFORE);
392 __pDateFormatter->Format(__pPm->GetViewMaxRange(), dateString);
393 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_AFTER);
396 string.Append(dateString);
398 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
399 // TBD : Background color of item must be transparent.(will be in SDK 2.1)
400 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(COLOR_ITEM_BACKGROUND));
401 pItem->AddElement(Rectangle(LEFT_MARGIN, 0, itemWidth - TOTAL_MARGIN, H_ITEM)
402 , ID_LIST_ITEM_BEFORE_AFTER, string, FONT_SIZE_EVENT_SUB_LIST
403 , Color(COLOR_TOP_BOTTOM_ITEM_TEXT), Color(COLOR_ITEM_TEXT_PRESSED), Color(COLOR_ITEM_TEXT_PRESSED));
407 DateTime minDateTime = Calendarbook::GetMinDateTime();
408 minDateTime.AddYears(1);
409 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMinRange() > minDateTime);
413 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
414 maxDateTime.AddYears(-1);
415 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMaxRange() < maxDateTime);
421 groupIndex -= TOP_BOTTOM_ITEM_COUNT;
424 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, true);
426 const CalEventInstance* pEvent = __pPm->GetEventWithWholeIndex(groupIndex, itemIndex);
427 TryReturn((pEvent != null), null, "[E_SYSTEM] Unable to get event instance.");
429 EventItem* pItem = new (std::nothrow) EventItem();
430 pItem->Initialize(EVENT_ITEM_STYLE_SELECTION, itemWidth);
431 if (EventListPresentationModel::IsToday(__pPm->GetDateTimeFromGroupIndex(groupIndex)) == true)
433 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(COLOR_ITEM_TODAY_BACKGROUND));
435 pItem->SetTitle(pEvent->GetSubject());
436 pItem->SetCalendarColor(__pPm->GetCalendarColor(pEvent->GetCalendarId()));
437 if (pEvent->IsAllDayEvent() == true)
439 pItem->SetAllDayEvent();
443 DateTime startTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetStartTime());
444 DateTime endTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetEndTime());
445 pItem->SetDateRange(startTime, endTime, __pPm->GetDateTimeFromGroupIndex(groupIndex), __pPm->GetTimeFormatter());
448 pItem->SetReminder(pEvent->HasReminder());
449 pItem->SetRepeat(pEvent->IsRecurring());
450 pItem->SetPriority(pEvent->GetPriority());
451 // pItem->SetFacebookEvent(false);
452 pItem->UpdateElements();
458 EventDeleterForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
465 EventDeleterForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
472 EventDeleterForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex,
473 int elementId, ListItemStatus status)
475 if (__topBottomItemEnabled == true)
477 DateTime today = EventListPresentationModel::GetToday();
478 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
482 DateTime startDate = __pPm->GetDateTimeFromGroupIndex(0);
483 DateTime minRange = __pPm->GetViewMinRange();
484 minRange.AddMonths(PREVIOUS_DATE);
485 DateTime minDateTime = Calendarbook::GetMinDateTime();
486 minDateTime.AddYears(1);
487 if (minRange < minDateTime)
489 minRange = minDateTime;
492 __pPm->SetViewRange(minRange, __pPm->GetViewMaxRange());
493 __pPm->SetViewType(VIEW_TYPE_LIST);
495 __pGroupedListViewDeleteList->RefreshList(0, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
496 int addedGroupCount = __pPm->GetGroupIndex(startDate);
497 for (int i = 0; i < addedGroupCount; ++i)
499 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
501 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
502 int itemCount = __pPm->GetWholeEventCount(i);
503 for (int j = 0; j < itemCount; ++j)
505 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
507 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
512 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
514 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
517 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
518 UpdateSelectedLabel();
521 else if (groupIndex == __pGroupedListViewDeleteList->GetGroupCount() - 1)
523 int prevGroupCount = __pPm->GetWholeDayCount();
524 DateTime maxRange = __pPm->GetViewMaxRange();
525 maxRange.AddMonths(NEXT_DATE);
526 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
527 maxDateTime.AddYears(-1);
528 if (maxRange > maxDateTime)
530 maxRange = maxDateTime;
533 __pPm->SetViewRange(__pPm->GetViewMinRange(), maxRange);
534 __pPm->SetViewType(VIEW_TYPE_LIST);
536 int groupCount = __pPm->GetWholeDayCount();
537 for (int i = prevGroupCount; i < groupCount; ++i)
539 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
541 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
542 int itemCount = __pPm->GetWholeEventCount(i);
543 for (int j = 0; j < itemCount; ++j)
545 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
547 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
552 __pGroupedListViewDeleteList->RefreshList(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
553 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
555 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
558 __pGroupedListViewDeleteList->ScrollToItem(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0);
559 __pGroupedListViewDeleteList->Invalidate(false);
561 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
562 UpdateSelectedLabel();
567 if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == true)
569 __pSelectAll->SetSelected(IsSelectedAllEvent());
570 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
572 else if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == false)
574 __pSelectAll->SetSelected(false);
576 int actualIndex = (__topBottomItemEnabled == true) ? groupIndex - TOP_BOTTOM_ITEM_COUNT : groupIndex;
577 if (__pPm->GetCurrentDate() > __pPm->GetDateTimeFromGroupIndex(actualIndex))
579 __pSelectBeforeToday->SetSelected(false);
583 UpdateSelectedLabel();
587 EventDeleterForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex,
588 SweepDirection direction)
593 EventDeleterForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView,
594 int groupIndex, int itemIndex,
595 int elementId, ListContextItemStatus status)
600 EventDeleterForm::OnGroupedListViewItemLongPressed(GroupedListView& listView, int groupIndex, int itemIndex,
601 int elementId, bool& invokeListViewItemCallback)
606 EventDeleterForm::OnGroupedListViewGroupItemSelected(GroupedListView& listView, int groupIndex)
608 if (listView.IsGroupExpanded(groupIndex) == true)
610 listView.CollapseGroup(groupIndex);
614 listView.ExpandGroup(groupIndex);
616 listView.Invalidate(true);
620 EventDeleterForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
622 DateTime minRange = __pPm->GetCurrentDate();
623 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), minRange.GetDay());
626 if (previousSceneId == IDSCN_YEAR)
628 minRange.SetValue(minRange.GetYear(), 1, 1);
630 maxRange.AddYears(NEXT_DATE);
631 maxRange.AddSeconds(PREVIOUS_DATE);
632 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_MBODY_ALL_THIS_YEAR));
634 else if (previousSceneId == IDSCN_MONTH)
636 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), 1);
638 maxRange.AddMonths(NEXT_DATE);
639 maxRange.AddSeconds(PREVIOUS_DATE);
640 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_MONTH));
642 else if (previousSceneId == IDSCN_DAY)
645 maxRange.AddDays(NEXT_DATE);
646 maxRange.AddSeconds(PREVIOUS_DATE);
647 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_DAY));
649 else if (previousSceneId == IDSCN_LIST)
651 minRange = __pPm->GetViewMinRange();
652 maxRange = __pPm->GetViewMaxRange();
654 __topBottomItemEnabled = true;
656 __pSelectBeforeToday->SetShowState(true);
657 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM * 2));
660 __pPm->SetViewType(VIEW_TYPE_LIST);
661 __pPm->SetViewRange(minRange, maxRange);
662 __pPm->AddCalendarEventChangedEventListener(*this);
663 UpdateSelectedLabel();
665 GetFooter()->SetItemEnabled(0, false);
670 EventDeleterForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
676 EventDeleterForm::OnActionPerformed(const Control& source, int actionId)
678 TwoButtonPopupStyle style = TWO_BUTTON_POPUP_STYLE_SINGLE_EVENT;
680 DateTime today = EventListPresentationModel::GetToday();
681 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
683 int startGroupIndex = 0;
684 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
685 if (__topBottomItemEnabled == true)
687 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
688 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
693 case IDA_EVENT_DELETER_FORM_FOOTER_DELETE:
694 for (int i = startGroupIndex; i <= endGroupIndex; i++)
696 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
697 for (int j = 0; j < itemCount; j++)
699 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
701 const CalEventInstance* pEventInstance = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
702 if (pEventInstance != null && pEventInstance->IsRecurring() == true)
704 style = TWO_BUTTON_POPUP_STYLE_REPEATED_EVENT;
711 __pTwoButtonPopup->RequestPopup(style, this);
713 case IDA_SELECT_ALL_CHECKED:
714 for (int i = startGroupIndex; i <= endGroupIndex; i++)
716 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
717 for (int j = 0; j < itemCount; j++)
719 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
722 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
723 UpdateSelectedLabel();
725 case IDA_SELECT_ALL_UNCHECKED:
726 for (int i = startGroupIndex; i <= endGroupIndex; i++)
728 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
729 for (int j = 0; j < itemCount; j++)
731 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
734 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
735 UpdateSelectedLabel();
737 case IDA_BEFORE_TODAY_CHECKED:
738 if (__topBottomItemEnabled == true)
740 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
742 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
743 for (int j = 0; j < itemCount; j++)
745 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
748 __pSelectAll->SetSelected(IsSelectedAllEvent());
749 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
750 UpdateSelectedLabel();
753 case IDA_BEFORE_TODAY_UNCHECKED:
754 if (__topBottomItemEnabled == true)
756 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
758 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
759 for (int j = 0; j < itemCount; j++)
761 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
764 __pSelectAll->SetSelected(IsSelectedAllEvent());
765 UpdateSelectedLabel();
772 EventDeleterForm::OnCalendarEventChanged(void)
774 __pGroupedListViewDeleteList->UpdateList();
776 __pSelectAll->SetSelected(IsSelectedAllEvent());
777 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
778 UpdateSelectedLabel();
782 EventDeleterForm::GetSelectedEventCount(void)
784 int startGroupIndex = 0;
785 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
786 if (__topBottomItemEnabled == true)
788 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
789 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
792 if (endGroupIndex < 0)
798 for (int i = startGroupIndex; i <= endGroupIndex; i++)
800 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
801 for (int j = 0; j < itemCount; j++)
803 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
813 EventDeleterForm::IsSelectedAllEvent(void)
815 int startGroupIndex = 0;
816 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
817 if (__topBottomItemEnabled == true)
819 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
820 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
823 if (endGroupIndex < 0)
828 for (int i = startGroupIndex; i <= endGroupIndex; i++)
830 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
831 for (int j = 0; j < itemCount; j++)
833 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
842 EventDeleterForm::IsSelectedAllEventBeforeToday(void)
844 DateTime today = EventListPresentationModel::GetToday();
845 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
847 if (__pPm->GetDateTimeFromGroupIndex(0) >= today)
852 int startGroupIndex = 0;
853 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
854 if (__topBottomItemEnabled == true)
856 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
857 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
860 if (endGroupIndex < 0)
865 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
867 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
868 for (int j = 0; j < itemCount; j++)
870 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
880 EventDeleterForm::UpdateSelectedLabel(void)
882 int itemCount = GetSelectedEventCount();
883 int groupCount = GetGroupCount();
884 if (groupCount == 0 || (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null))
886 AppLogDebug("Select button enable.");
887 __pSelectAll->SetEnabled(false);
888 __pSelectBeforeToday->SetEnabled(false);
892 AppLogDebug("Select button disable.");
893 __pSelectAll->SetEnabled(true);
894 __pSelectBeforeToday->SetEnabled(true);
899 GetFooter()->SetItemEnabled(0, true);
901 String labelString = ResourceManager::GetString(itemCount > 1 ? IDS_COM_BODY_PD_SELECTED : IDS_COM_BODY_PD_1_SELECTED);
902 labelString.Format(labelString.GetLength() + Integer::ToString(itemCount).GetLength(), labelString.GetPointer(), itemCount);
903 __pLabel->SetText(labelString);
904 __pLabel->SetSize(GetClientAreaBounds().width, H_COUNT_LABEL);
908 GetFooter()->SetItemEnabled(0, false);
910 __pLabel->SetSize(GetClientAreaBounds().width, 0);