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 Footer* pFooter = GetFooter();
174 pFooter->AddActionEventListener(*this);
176 __pPanel = dynamic_cast<Panel*>(GetControl(L"IDC_PANEL"));
177 AppAssertf(__pPanel != null, "[E_FAILURE] Unable to get Panel.");
179 __pSelectAll = dynamic_cast<CheckButton*>(GetControl(L"IDC_SELECTALL_CHECKBUTTON", true));
180 AppAssertf(__pSelectAll != null, "[E_FAILURE] Unable to get CheckButton.");
181 __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
182 __pSelectAll->SetEnabled(false);
183 __pSelectAll->AddActionEventListener(*this);
185 __pSelectBeforeToday = dynamic_cast<CheckButton*>(GetControl(L"IDC_BEFORETODAY_CHECKBUTTON", true));
186 AppAssertf(__pSelectBeforeToday != null, "[E_FAILURE] Unable to get CheckButton.");
187 __pSelectBeforeToday->SetActionId(IDA_BEFORE_TODAY_CHECKED, IDA_BEFORE_TODAY_UNCHECKED);
188 __pSelectBeforeToday->AddActionEventListener(*this);
189 __pSelectBeforeToday->SetEnabled(false);
190 __pSelectBeforeToday->SetShowState(false);
191 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM));
193 __pGroupedListViewDeleteList = dynamic_cast<GroupedListView*>(GetControl(L"IDC_GROUPEDLISTVIEW"));
194 AppAssertf(__pGroupedListViewDeleteList != null, "[E_FAILURE] Unable to get GroupedListView.");
195 __pGroupedListViewDeleteList->SetItemProvider(*this);
196 __pGroupedListViewDeleteList->SetTextOfEmptyList(ResourceManager::GetString(IDS_CLD_BODY_NO_EVENTS));
197 __pGroupedListViewDeleteList->SetBitmapOfEmptyList(ResourceManager::GetBitmapN(IDB_LIST_VIEW_NO_CONTENTS_TEXT));
198 __pGroupedListViewDeleteList->AddGroupedListViewItemEventListener(*this);
200 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL"));
201 AppAssertf(__pLabel != null, "[E_FAILURE] Unable to get Label.");
203 __pPm = EventListPresentationModel::GetInstance();
205 __pDateFormatter = ResourceManager::CreateDateFormatterN(DATE_TIME_STYLE_SHORT);
207 __pTwoButtonPopup = new (std::nothrow) TwoButtonPopup();
208 __pTwoButtonPopup->Initialize();
210 __pSelectedEvent = new (std::nothrow) ArrayList();
211 __pSelectedEvent->Construct();
217 EventDeleterForm::OnTerminating(void)
225 delete __pCalendarbook;
226 delete __pDateFormatter;
227 delete __pTimeFormatter;
228 if (__pTwoButtonPopup)
230 __pTwoButtonPopup->Destroy();
232 if (__pProgressPopup)
234 __pProgressPopup->Destroy();
236 __pPm->RemoveCalendarEventChangedEventListener(*this);
238 if (__pSelectedEvent)
240 __pSelectedEvent->RemoveAll(true);
241 delete __pSelectedEvent;
249 EventDeleterForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
253 case IDA_EVENT_POPUP_DELETE:
261 if (!__pProgressPopup)
263 __pProgressPopup = new (std::nothrow) ProgressPopup();
264 __pProgressPopup->Construct(false, false);
266 __pProgressPopup->SetShowState(true);
267 __pProgressPopup->Show();
269 LinkedList* pDeleteEvents = new (std::nothrow) LinkedList(SingleObjectDeleter);
270 for (int i = __pGroupedListViewDeleteList->GetGroupCount() - 1; i >= 0; i--)
272 for (int j = __pGroupedListViewDeleteList->GetItemCountAt(i) - 1; j >= 0 ; j--)
274 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
276 int actualGroupIndex = i;
277 if (__topBottomItemEnabled == true)
279 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
281 pDeleteEvents->Add(new (std::nothrow) CalEventInstance(*__pPm->GetEventWithWholeIndex(actualGroupIndex, j)));
286 AsyncDeleter* pAsyncDeleter = new (std::nothrow) AsyncDeleter();
287 pAsyncDeleter->Initialize(__pPm, pDeleteEvents, this);
288 pAsyncDeleter->Start();
289 __pThread = pAsyncDeleter;
292 case IDA_EVENT_DELETER_FORM_DELETE_COMPLETE:
296 __pProgressPopup->SetShowState(false);
298 __pGroupedListViewDeleteList->UpdateList();
300 for (int i = __pGroupedListViewDeleteList->GetGroupCount() - 1; i >= 0; i--)
302 for (int j = __pGroupedListViewDeleteList->GetItemCountAt(i) - 1; j >= 0 ; j--)
304 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
308 __pSelectAll->SetSelected(IsSelectedAllEvent());
309 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
310 UpdateSelectedLabel();
318 pArgs->RemoveAll(true);
324 EventDeleterForm::OnFormBackRequested(Form& source)
326 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
330 EventDeleterForm::GetGroupCount(void)
332 int groupCount = __pPm->GetWholeDayCount();
334 if (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null)
340 if (groupCount != 0 && __topBottomItemEnabled == true)
342 groupCount += TOP_BOTTOM_GROUP_ITEM_COUNT;
344 if (groupCount == 0 && __pTwoButtonPopup != NULL)
346 __pTwoButtonPopup->SetShowState(false);
352 EventDeleterForm::GetItemCount(int groupIndex)
355 int actualGroupIndex = groupIndex;
357 if (__topBottomItemEnabled == true)
359 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
361 return TOP_BOTTOM_ITEM_COUNT;
365 actualGroupIndex = groupIndex - (TOP_BOTTOM_GROUP_ITEM_COUNT / 2);
369 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
375 EventDeleterForm::CreateGroupItem(int groupIndex, int itemWidth)
377 GroupItem* pItem = new (std::nothrow) GroupItem();
381 if (__topBottomItemEnabled == true && (groupIndex == 0 || groupIndex == GetGroupCount() - 1))
383 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_MINIMUM));
388 int actualGroupIndex = groupIndex;
391 if (__topBottomItemEnabled == true)
393 actualGroupIndex -= 1;
396 date = __pPm->GetDateTimeFromGroupIndex(actualGroupIndex);
397 dateString = __pPm->GetDateString(date);
398 itemCount = __pPm->GetWholeEventCount(actualGroupIndex);
400 if (itemCount == 0)//This is Today Index.(event is empty)
402 pItem->Construct(Dimension(itemWidth, 0));
407 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
410 pItem->SetElement(dateString);
412 if (EventListPresentationModel::IsToday(date) == true)
414 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TODAY_TEXT));
418 pItem->SetTextColor(Color(COLOR_GROUP_ITEM_TEXT));
425 EventDeleterForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
427 if (__topBottomItemEnabled == true)
429 if (groupIndex == 0 || groupIndex == GetGroupCount() - 1)
431 CustomItem* pItem = new (std::nothrow) CustomItem();
437 __pDateFormatter->Format(__pPm->GetViewMinRange(), dateString);
438 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_BEFORE);
442 __pDateFormatter->Format(__pPm->GetViewMaxRange(), dateString);
443 string = ResourceManager::GetString(IDS_LIST_VIEW_TAP_VIEW_AFTER);
446 string.Format(string.GetLength() + dateString.GetLength(), string.GetPointer(), dateString.GetPointer());
448 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
449 pItem->AddElement(Rectangle(LEFT_MARGIN, 0, itemWidth - TOTAL_MARGIN, H_ITEM)
450 , ID_LIST_ITEM_BEFORE_AFTER, string, FONT_SIZE_EVENT_SUB_LIST
451 , Color(COLOR_TOP_BOTTOM_ITEM_TEXT), Color(COLOR_ITEM_TEXT_PRESSED), Color(COLOR_ITEM_TEXT_PRESSED));
455 DateTime minDateTime = Calendarbook::GetMinDateTime();
456 minDateTime.AddYears(1);
457 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMinRange() > minDateTime);
461 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
462 maxDateTime.AddYears(-1);
463 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, __pPm->GetViewMaxRange() < maxDateTime);
469 groupIndex -= TOP_BOTTOM_ITEM_COUNT;
472 __pGroupedListViewDeleteList->SetItemEnabled(groupIndex, itemIndex, true);
474 const CalEventInstance* pEvent = __pPm->GetEventWithWholeIndex(groupIndex, itemIndex);
475 TryReturn((pEvent != null), null, "[E_SYSTEM] Unable to get event instance.");
477 EventItem* pItem = new (std::nothrow) EventItem();
478 pItem->Initialize(EVENT_ITEM_STYLE_SELECTION, itemWidth, __itemHeight);
479 if (EventListPresentationModel::IsToday(__pPm->GetDateTimeFromGroupIndex(groupIndex)) == true)
482 pItem->SetTitle(pEvent->GetSubject());
483 pItem->SetFontSize(__fontSize);
484 pItem->SetCalendarColor(__pPm->GetCalendarColor(pEvent->GetCalendarId()));
485 if (pEvent->IsAllDayEvent() == true)
487 pItem->SetAllDayEvent();
491 DateTime startTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetStartTime());
492 DateTime endTime = ResourceManager::ConvertUtcTimeToWallTime(pEvent->GetEndTime());
493 pItem->SetDateRange(startTime, endTime, __pPm->GetDateTimeFromGroupIndex(groupIndex), __pPm->GetTimeFormatter());
496 pItem->SetReminder(pEvent->HasReminder());
497 pItem->SetRepeat(pEvent->IsRecurring());
498 pItem->SetPriority(pEvent->GetPriority());
499 pItem->UpdateElements();
505 EventDeleterForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
507 AppLogDebug("Enter");
513 EventDeleterForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
515 AppLogDebug("Enter");
521 EventDeleterForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex,
522 int elementId, ListItemStatus status)
524 int actualGroupIndex = groupIndex;
525 if (__topBottomItemEnabled == true)
527 DateTime today = EventListPresentationModel::GetToday();
528 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
529 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
533 DateTime startDate = __pPm->GetDateTimeFromGroupIndex(0);
534 DateTime minRange = __pPm->GetViewMinRange();
535 minRange.AddMonths(PREVIOUS_DATE);
536 DateTime minDateTime = Calendarbook::GetMinDateTime();
537 minDateTime.AddYears(1);
538 if (minRange < minDateTime)
540 minRange = minDateTime;
543 __pPm->SetViewRange(minRange, __pPm->GetViewMaxRange());
545 __pGroupedListViewDeleteList->RefreshList(0, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
546 int addedGroupCount = __pPm->GetGroupIndex(startDate);
547 for (int i = 0; i < addedGroupCount; ++i)
549 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
551 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
552 int itemCount = __pPm->GetWholeEventCount(i);
553 for (int j = 0; j < itemCount; ++j)
555 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
557 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
562 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
564 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
567 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
568 UpdateSelectedLabel();
571 else if (groupIndex == __pGroupedListViewDeleteList->GetGroupCount() - 1)
573 int prevGroupCount = __pPm->GetWholeDayCount();
574 DateTime maxRange = __pPm->GetViewMaxRange();
575 maxRange.AddMonths(NEXT_DATE);
576 DateTime maxDateTime = Calendarbook::GetMaxDateTime();
577 maxDateTime.AddYears(-1);
578 if (maxRange > maxDateTime)
580 maxRange = maxDateTime;
583 __pPm->SetViewRange(__pPm->GetViewMinRange(), maxRange);
585 int groupCount = __pPm->GetWholeDayCount();
586 for (int i = prevGroupCount; i < groupCount; ++i)
588 __pGroupedListViewDeleteList->RefreshList(i + TOP_BOTTOM_ITEM_COUNT, -1, LIST_REFRESH_TYPE_ITEM_ADD);
590 DateTime date = __pPm->GetDateTimeFromGroupIndex(i);
591 int itemCount = __pPm->GetWholeEventCount(i);
592 for (int j = 0; j < itemCount; ++j)
594 if (__pSelectAll->IsSelected() == true || (__pSelectBeforeToday->IsSelected() == true && date < today))
596 __pGroupedListViewDeleteList->SetItemChecked(i + TOP_BOTTOM_ITEM_COUNT, j, true);
601 __pGroupedListViewDeleteList->RefreshList(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0, LIST_REFRESH_TYPE_ITEM_MODIFY);
602 if (__pGroupedListViewDeleteList->IsGroupExpanded(__pGroupedListViewDeleteList->GetGroupCount() - 1) == false)
604 __pGroupedListViewDeleteList->ExpandGroup(__pGroupedListViewDeleteList->GetGroupCount() - 1);
607 __pGroupedListViewDeleteList->ScrollToItem(__pGroupedListViewDeleteList->GetGroupCount() - 1, 0);
608 __pGroupedListViewDeleteList->Invalidate(false);
610 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
611 UpdateSelectedLabel();
616 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(actualGroupIndex, itemIndex);
618 if (pEventInst != null)
620 id = pEventInst->GetOriginalEventId();
621 AutoCheckSameEvents(id, status);
624 SetAllSelectedEvents(listView, groupIndex, itemIndex, status);
626 if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == true)
628 __pSelectAll->SetSelected(IsSelectedAllEvent());
629 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
631 else if (__pGroupedListViewDeleteList->IsItemChecked(groupIndex, itemIndex) == false)
633 __pSelectAll->SetSelected(false);
635 int actualIndex = (__topBottomItemEnabled == true) ? groupIndex - TOP_BOTTOM_ITEM_COUNT : groupIndex;
636 if (__pPm->GetCurrentDate() > __pPm->GetDateTimeFromGroupIndex(actualIndex))
638 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
642 UpdateSelectedLabel();
646 EventDeleterForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex,
647 SweepDirection direction)
652 EventDeleterForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView,
653 int groupIndex, int itemIndex,
654 int elementId, ListContextItemStatus status)
659 EventDeleterForm::OnGroupedListViewItemLongPressed(GroupedListView& listView, int groupIndex, int itemIndex,
660 int elementId, bool& invokeListViewItemCallback)
665 EventDeleterForm::OnGroupedListViewGroupItemSelected(GroupedListView& listView, int groupIndex)
667 if (listView.IsGroupExpanded(groupIndex) == true)
669 listView.CollapseGroup(groupIndex);
673 listView.ExpandGroup(groupIndex);
675 listView.Invalidate(true);
679 EventDeleterForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
681 DateTime minRange = __pPm->GetCurrentDate();
682 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), minRange.GetDay());
685 if (previousSceneId == IDSCN_YEAR)
687 minRange.SetValue(minRange.GetYear(), 1, 1);
689 maxRange.AddYears(NEXT_DATE);
690 maxRange.AddSeconds(PREVIOUS_DATE);
691 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_MBODY_ALL_THIS_YEAR));
693 else if (previousSceneId == IDSCN_MONTH)
695 minRange.SetValue(minRange.GetYear(), minRange.GetMonth(), 1);
697 maxRange.AddMonths(NEXT_DATE);
698 maxRange.AddSeconds(PREVIOUS_DATE);
699 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_MONTH));
701 else if (previousSceneId == IDSCN_DAY)
704 maxRange.AddDays(NEXT_DATE);
705 maxRange.AddSeconds(PREVIOUS_DATE);
706 __pSelectAll->SetText(ResourceManager::GetString(IDS_CLD_BODY_ALL_THIS_DAY));
708 else if (previousSceneId == IDSCN_LIST)
710 minRange = __pPm->GetViewMinRange();
711 maxRange = __pPm->GetViewMaxRange();
713 __topBottomItemEnabled = true;
715 __pSelectBeforeToday->SetShowState(true);
716 __pPanel->SetSize(Dimension(GetClientAreaBounds().width, H_ITEM * 2));
719 __pPm->SetViewType(VIEW_TYPE_DELETE);
720 __pPm->SetViewRange(minRange, maxRange);
721 __pPm->AddCalendarEventChangedEventListener(*this);
722 UpdateSelectedLabel();
724 if (__pSelectedEvent != null)
726 __pSelectedEvent->RemoveAll(true);
728 GetFooter()->SetItemEnabled(0, false);
733 EventDeleterForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
739 EventDeleterForm::OnActionPerformed(const Control& source, int actionId)
741 TwoButtonPopupStyle style = TWO_BUTTON_POPUP_STYLE_SINGLE_EVENT;
743 DateTime today = EventListPresentationModel::GetToday();
744 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay(), 0, 0, 0);
746 int startGroupIndex = 0;
747 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
748 if (__topBottomItemEnabled == true)
750 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
751 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
756 case IDA_EVENT_DELETER_FORM_FOOTER_DELETE:
757 for (int i = startGroupIndex; i <= endGroupIndex; i++)
759 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
760 for (int j = 0; j < itemCount; j++)
762 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
764 const CalEventInstance* pEventInstance = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
765 if (pEventInstance != null && pEventInstance->IsRecurring() == true)
767 style = TWO_BUTTON_POPUP_STYLE_REPEATED_EVENT;
774 __pTwoButtonPopup->RequestPopup(style, this);
776 case IDA_SELECT_ALL_CHECKED:
777 for (int i = startGroupIndex; i <= endGroupIndex; i++)
779 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
780 for (int j = 0; j < itemCount; j++)
782 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
783 if (pEventInst != null)
785 RecordId id = pEventInst->GetOriginalEventId();
786 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
787 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
792 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
793 UpdateSelectedLabel();
795 case IDA_SELECT_ALL_UNCHECKED:
796 for (int i = startGroupIndex; i <= endGroupIndex; i++)
798 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
799 for (int j = 0; j < itemCount; j++)
801 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
802 if (pEventInst != null)
804 RecordId id = pEventInst->GetOriginalEventId();
805 __pSelectedEvent->Remove(Integer(id));
806 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
810 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
811 UpdateSelectedLabel();
813 case IDA_BEFORE_TODAY_CHECKED:
814 if (__topBottomItemEnabled == true)
816 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
818 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
819 for (int j = 0; j < itemCount; j++)
821 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
822 if (pEventInst != null)
824 RecordId id = pEventInst->GetOriginalEventId();
825 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
826 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
830 __pSelectAll->SetSelected(IsSelectedAllEvent());
831 __pSelectBeforeToday->SetSelected(IsSelectedAllEventBeforeToday());
832 UpdateSelectedLabel();
835 case IDA_BEFORE_TODAY_UNCHECKED:
836 if (__topBottomItemEnabled == true)
838 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
840 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
841 for (int j = 0; j < itemCount; j++)
843 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
844 if (pEventInst != null)
846 RecordId id = pEventInst->GetOriginalEventId();
847 __pSelectedEvent->Remove(Integer(id));
848 __pGroupedListViewDeleteList->SetItemChecked(i, j, false);
852 __pSelectAll->SetSelected(IsSelectedAllEvent());
853 UpdateSelectedLabel();
860 EventDeleterForm::SetAllSelectedEvents(GroupedListView& listView, int groupIndex, int itemIndex,
861 ListItemStatus status)
863 int actualGroupIndex = groupIndex;
864 if (__topBottomItemEnabled == true)
866 actualGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
868 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(actualGroupIndex, itemIndex);
869 if (pEventInst != null)
871 RecordId id = pEventInst->GetOriginalEventId();
872 if (status == LIST_ITEM_STATUS_CHECKED)
874 __pSelectedEvent->Add(new (std::nothrow) Integer(id));
876 else if (status == LIST_ITEM_STATUS_UNCHECKED)
878 __pSelectedEvent->Remove(Integer(id));
885 EventDeleterForm::AutoCheckSameEvents(RecordId id_original, ListItemStatus status)
887 int startGroupIndex = 0;
888 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
890 if (__topBottomItemEnabled == true)
892 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
893 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
897 for (int i = startGroupIndex; i <= endGroupIndex; i++)
899 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
900 for (int j = 0; j < itemCount; j++)
902 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
903 if (pEventInst != null)
905 RecordId id = pEventInst->GetOriginalEventId();
906 if (id == id_original)
908 __pGroupedListViewDeleteList->SetItemChecked(i, j, (status == LIST_ITEM_STATUS_CHECKED)?true:false);
915 EventDeleterForm::OnCalendarEventChanged(void)
917 __pGroupedListViewDeleteList->UpdateList();
919 int startGroupIndex = 0;
920 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
921 if (__topBottomItemEnabled == true)
923 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
924 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
927 for (int i = startGroupIndex; i <= endGroupIndex; i++)
929 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
930 for (int j = 0; j < itemCount; j++)
932 __pGroupedListViewDeleteList->SetItemChecked(i, j,false);
936 for (int i = startGroupIndex; i <= endGroupIndex; i++)
938 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
939 for (int j = 0; j < itemCount; j++)
941 const CalEventInstance* pEventInst = __pPm->GetEventWithWholeIndex(i - startGroupIndex, j);
942 if (pEventInst != null)
944 RecordId id = pEventInst->GetOriginalEventId();
945 if (__pSelectedEvent->Contains(Integer(id)))
947 __pGroupedListViewDeleteList->SetItemChecked(i, j, true);
953 if (IsSelectedAllEvent())
955 __pSelectAll->SetSelected(true);
959 __pSelectAll->SetSelected(false);
961 __pSelectBeforeToday->SetSelected(false);
962 UpdateSelectedLabel();
964 if (!IsSelectedAnyEvent() && __pTwoButtonPopup != null && __pTwoButtonPopup->GetShowState() == true)
966 __pTwoButtonPopup->SetShowState(false);
972 EventDeleterForm::GetSelectedEventCount(void)
974 int startGroupIndex = 0;
975 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
976 if (__topBottomItemEnabled == true)
978 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
979 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
982 if (endGroupIndex < 0)
988 for (int i = startGroupIndex; i <= endGroupIndex; i++)
990 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
991 for (int j = 0; j < itemCount; j++)
993 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
1003 EventDeleterForm::IsSelectedAllEvent(void)
1005 int startGroupIndex = 0;
1006 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1007 if (__topBottomItemEnabled == true)
1009 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1010 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1013 if (endGroupIndex < 0)
1018 for (int i = startGroupIndex; i <= endGroupIndex; i++)
1020 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1021 for (int j = 0; j < itemCount; j++)
1023 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
1033 EventDeleterForm::IsSelectedAnyEvent(void)
1035 int startGroupIndex = 0;
1036 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1037 if (__topBottomItemEnabled == true)
1039 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1040 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1043 if (endGroupIndex < 0)
1048 for (int i = startGroupIndex; i <= endGroupIndex; i++)
1050 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1051 for (int j = 0; j < itemCount; j++)
1053 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == true)
1062 EventDeleterForm::IsSelectedAllEventBeforeToday(void)
1064 DateTime today = EventListPresentationModel::GetToday();
1065 today.SetValue(today.GetYear(), today.GetMonth(), today.GetDay());
1067 if (__pPm->GetDateTimeFromGroupIndex(0) >= today)
1072 int startGroupIndex = 0;
1073 int endGroupIndex = __pGroupedListViewDeleteList->GetGroupCount() - 1;
1074 if (__topBottomItemEnabled == true)
1076 startGroupIndex = TOP_BOTTOM_ITEM_COUNT;
1077 endGroupIndex -= TOP_BOTTOM_ITEM_COUNT;
1080 if (endGroupIndex < 0)
1085 for (int i = startGroupIndex; i <= endGroupIndex && __pPm->GetDateTimeFromGroupIndex(i - startGroupIndex) < today; i++)
1087 int itemCount = __pGroupedListViewDeleteList->GetItemCountAt(i);
1088 for (int j = 0; j < itemCount; j++)
1090 if (__pGroupedListViewDeleteList->IsItemChecked(i, j) == false)
1100 EventDeleterForm::UpdateSelectedLabel(void)
1102 int itemCount = GetSelectedEventCount();
1103 int groupCount = GetGroupCount();
1104 if (groupCount == 0 || (groupCount == 1 && __pPm->GetEventWithWholeIndex(0, 0) == null))
1106 AppLogDebug("Select button enable.");
1107 __pSelectAll->SetEnabled(false);
1108 __pSelectBeforeToday->SetEnabled(false);
1112 AppLogDebug("Select button disable.");
1113 __pSelectAll->SetEnabled(true);
1114 __pSelectBeforeToday->SetEnabled(true);
1119 GetFooter()->SetItemEnabled(0, true);
1121 String labelString = ResourceManager::GetString(itemCount > 1 ? IDS_BR_POP_PD_ITEMS_SELECTED : IDS_BR_BODY_PD_ITEM_SELECTED);
1122 labelString.Format(labelString.GetLength() + Integer::ToString(itemCount).GetLength(), labelString.GetPointer(), itemCount);
1123 __pLabel->SetText(labelString);
1124 __pLabel->SetSize(GetClientAreaBounds().width, H_COUNT_LABEL);
1128 GetFooter()->SetItemEnabled(0, false);
1130 __pLabel->SetSize(GetClientAreaBounds().width, 0);