cad46a5de85c6278b4d86dca975945b3f8a5ea27
[apps/osp/Internet.git] / src / IntEditHistoryListForm.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 //!Internet
19 /*@file:    IntEditHistoryListForm
20  *@brief:       This class defines EditHistoryListForm used to edit the history scene
21  *
22  */
23
24 #include <FAppUiApp.h>
25 #include <FUi.h>
26 #include "IntCommonLib.h"
27 #include "IntEditHistoryListForm.h"
28 #include "IntFaviconManager.h"
29 #include "IntHistoryPresentationModel.h"
30 #include "IntNotificationPanel.h"
31 #include "IntSceneRegister.h"
32 #include "IntTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Locales;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43
44 const int EditHistoryListForm::IDA_TABBAR_ITEM_1 = 101;
45 const int EditHistoryListForm::IDA_TABBAR_ITEM_2 = 102;
46 const int EditHistoryListForm::IDA_BUTTON_NEXT_FORM = 103;
47 const int EditHistoryListForm::IDA_FORMAT_ICON = 104;
48 const int EditHistoryListForm::IDA_FORMAT_TITLE = 105;
49 const int EditHistoryListForm::IDA_FORMAT_URL = 106;
50 const int EditHistoryListForm::IDA_SELECT_ALL_CHECKED = 107;
51 const int EditHistoryListForm::IDA_SELECT_ALL_UNCHECKED = 108;
52 const int EditHistoryListForm::IDA_DELETE_HISTORY = 109;
53 const int EditHistoryListForm::IDA_CANCEL = 110;
54
55
56 EditHistoryListForm::EditHistoryListForm(void)
57 :__pListView(null)
58 ,__pGroupData(null)
59 ,__pTimer(null)
60 ,__pSelectAllCheck(null)
61 ,__pSelectedLabel(null)
62 ,__selectedCount(0)
63 ,__isNoHistoryPresent(true)
64 {
65 }
66
67 EditHistoryListForm::~EditHistoryListForm(void)
68 {
69         AppLog("EditHistoryListForm::~EditHistoryListForm called");
70
71         if (__pGroupData != null)
72         {
73                 AppLog("removing __pGroupData");
74                 __pGroupData->RemoveAll(false);
75                 delete __pGroupData;
76         }
77 }
78
79 bool
80 EditHistoryListForm::Initialize(void)
81 {
82         Construct(L"IDL_EDIT_HISTORY_LIST");
83
84         return true;
85 }
86
87 result
88 EditHistoryListForm::OnInitializing(void)
89 {
90         result r = E_SUCCESS;
91
92         SetFormBackEventListener(this);
93
94         AppLogDebug("EditHistoryListForm::OnInitializing");
95         SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
96
97         Header* pHeader = GetHeader();
98
99         if (pHeader == NULL)
100         {
101                 return E_FAILURE;
102         }
103
104         pHeader->SetTitleText(CommonUtil::GetString("IDS_BR_SK_DELETE_ABB"));
105
106         GetFooter()->AddActionEventListener(*this);
107         AddOrientationEventListener(*this);
108
109         SceneManager::GetInstance()->AddSceneEventListener(IDSCN_EDIT_HISTORY_LIST, *this);
110         __pSelectedLabel = static_cast< Label* >(GetControl(L"IDC_LABEL1"));
111
112         if (__pSelectedLabel == null)
113         {
114                 return E_FAILURE;
115         }
116         String  selectedText = CommonUtil::GetString(L"IDS_COM_OPT_SELECTED");
117         selectedText.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
118         selectedText.Append(L"(0)");
119         __pSelectedLabel->SetText(selectedText);
120
121         __pSelectAllCheck = static_cast< CheckButton* >(GetControl(L"IDC_SELECT_ALL",true));
122
123         if (__pSelectAllCheck != null)
124         {
125                 __pSelectAllCheck->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
126                 __pSelectAllCheck->AddActionEventListener(*this);
127         }
128         else
129         {
130                 return E_FAILURE;
131         }
132
133         __pListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));
134         if( __pListView != NULL)
135         {
136                 __pListView->SetItemProvider(*this);
137                 __pListView->AddGroupedListViewItemEventListener(*this);
138         }
139         else
140         {
141                 return E_FAILURE;
142         }
143
144         __pTimer = new (std::nothrow) Timer();
145         r = __pTimer->Construct(*this);
146
147         return r;
148 }
149
150 result
151 EditHistoryListForm::OnTerminating(void)
152 {
153         result r = E_SUCCESS;
154
155         return r;
156 }
157
158 void
159 EditHistoryListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
160 {
161         String  selectedText = CommonUtil::GetString(L"IDS_COM_OPT_SELECTED");
162         SceneManager* pSceneManager = SceneManager::GetInstance();
163
164         if (pSceneManager == null)
165         {
166                 return;
167         }
168
169         switch (actionId)
170         {
171         case IDA_TABBAR_ITEM_1:
172         {
173                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
174                 if (IsFailed(r))
175                 {
176                         AppLogDebug("EditHistoryListForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
177                         return;
178                 }
179         }
180
181         break;
182         case IDA_SELECT_ALL_CHECKED:
183         {
184                 int selectedCount = 0;
185                 for (int groupIndex = 0 ; __pGroupData != null && groupIndex < __pGroupData->GetCount() ; groupIndex ++)
186                 {
187                         GroupItemClass* pGClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
188                         if(pGClass == null)
189                         {
190                                 continue;
191                         }
192                         for (int itemIndex = 0 ; itemIndex < pGClass->__pData->GetCount() ; itemIndex ++)
193                         {
194                                 selectedCount++;
195                                 __pListView->SetItemChecked(groupIndex,itemIndex,true);
196                         }
197                 }
198                 selectedText.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
199                 selectedText.Append(L"(");
200                 selectedText.Append(selectedCount);
201                 selectedText.Append(L")");
202                 __selectedCount = selectedCount;
203
204                 __pSelectedLabel->SetText(selectedText);
205                 __pSelectedLabel->Invalidate(true);
206
207                 if(__selectedCount > 0)
208                 {
209                         GetFooter()->SetItemEnabled(0, true);
210                         GetFooter()->Invalidate(true);
211                 }
212
213                 __pListView->Invalidate(true);
214
215         }
216         break;
217         case IDA_SELECT_ALL_UNCHECKED:
218         {
219                 for (int groupIndex = 0 ; __pGroupData != null && groupIndex < __pGroupData->GetCount() ; groupIndex ++)
220                 {
221                         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
222                         if(pGroupItemClass == null)
223                         {
224                                 continue;
225                         }
226                         for (int itemIndex = 0 ; itemIndex < pGroupItemClass->__pData->GetCount() ; itemIndex ++)
227                         {
228                                 __pListView->SetItemChecked(groupIndex,itemIndex,false);
229                         }
230                 }
231                 selectedText.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
232                 selectedText.Append(L"(0)");
233                 __pSelectedLabel->SetText(selectedText);
234                 __selectedCount = 0;
235                 __pSelectedLabel->Invalidate(true);
236
237                 GetFooter()->SetItemEnabled(0, false);
238                 GetFooter()->Invalidate(true);
239
240                 __pListView->Invalidate(true);
241         }
242         break;
243         case IDA_DELETE_HISTORY:
244         {
245
246                 ArrayList* pArrayList = new(std::nothrow) ArrayList();
247                 int itemCount = 0;
248                 int count = 0;
249                 int groupCount = 0;
250                 int counter = 0;
251                 pArrayList->Construct();
252                 for (int groupIndex = 0 ; __pGroupData != null && groupIndex < __pGroupData->GetCount() ; groupIndex ++)
253                 {
254                         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
255
256                         if (pGroupItemClass == null || pGroupItemClass->__pData == null)
257                         {
258                                 AppLogDebug(" pGroupItemClass || __pData is null");
259                                 continue;
260                         }
261                         itemCount = pGroupItemClass->__pData->GetCount();
262                         for (int itemIndex = 0 ; itemIndex < itemCount ; itemIndex++)
263                         {
264                                 bool ret = __pListView->IsItemChecked(groupIndex,itemIndex);
265                                 if (ret == false)
266                                 {
267                                         continue;
268                                 }
269                                 AppLog("deleting history for groupId %d, item %d",groupIndex,itemIndex);
270                                 int hisId = -1;
271                                 History* pHistory = dynamic_cast< History* >(pGroupItemClass->__pData->GetAt(itemIndex));
272                                 if(pHistory == null)
273                                 {
274                                         continue;
275                                 }
276                                 pArrayList->Add(*new(std::nothrow) String(pHistory->GetHistoryId()));
277
278                         }
279                 }
280
281                 HistoryPresentationModel::GetInstance()->DeleteMultipleHistory(pArrayList);
282
283                 if (pArrayList != null)
284                 {
285                         pArrayList->RemoveAll(true);
286                         delete pArrayList;
287                 }
288
289                 if(__pGroupData != null)
290                 {
291                         groupCount =   __pGroupData->GetCount();
292
293                         for(int groupIndex = 0 ; groupIndex < groupCount ; groupIndex ++ )
294                         {
295                                 counter = __pListView->GetItemCountAt(groupIndex);
296
297                                 for(int index = 0 ; index < counter ; index++)
298                                 {
299                                         if(__pListView->IsItemChecked( groupIndex,index ) == true)
300                                         {
301                                                 __pListView->SetItemChecked(groupIndex,index,false);
302                                         }
303                                 }
304                         }
305                 }
306
307
308
309                 __pSelectAllCheck->SetSelected(false);
310
311                 GetFooter()->SetItemEnabled(0,false);
312                 GetFooter()->Invalidate(true);
313                 selectedText.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
314                 selectedText.Append(L"(0)");
315                 __pSelectedLabel->SetText(selectedText);
316                 __selectedCount = 0;
317                 __pSelectedLabel->Invalidate(true);
318                 if (__pListView != null)
319                 {
320                         __pListView->UpdateList();
321                 }
322
323                 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
324                 String notification = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
325                 pNotification->SetText(notification);
326                 pNotification->ShowNotification();
327         }
328         break;
329         case IDA_CANCEL:
330         {
331                 if( __pTimer != NULL)
332                 {
333                         __pTimer->Cancel();
334                 }
335                 result r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
336                 if (IsFailed(r))
337                 {
338                         AppLogDebug("EditHistoryListForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
339                         return;
340                 }
341
342         }
343         break;
344
345         default:
346                 break;
347         }
348 }
349
350 void
351 EditHistoryListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
352 {
353         SceneManager* pSceneManager = SceneManager::GetInstance();
354
355         if (pSceneManager == null)
356         {
357                 return;
358         }
359
360         result r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
361         if (IsFailed(r))
362         {
363                 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
364                 return;
365         }
366 }
367
368 GroupItem*
369 EditHistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
370 {
371         AppLogDebug("EditHistoryListForm::CreateGroupItem");
372         result r = E_FAILURE;
373
374         int strMonth = 0;
375         String text;
376         GroupItem* pItem = null;
377         int count = 0;
378
379         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
380         if(pGroupItemClass == null)
381                 return null;
382         pItem = new(std::nothrow) GroupItem();
383
384         if (pItem == null)
385         {
386                 return null;
387         }
388
389         if ( pGroupItemClass->__pData == null || pGroupItemClass->__pData->GetCount() == 0)
390         {
391                 r = pItem->Construct(Dimension(itemWidth, 0));
392         }
393         else
394         {
395                 r = pItem->Construct(Dimension(itemWidth, 48));
396         }
397
398         text = pGroupItemClass->__titleText;
399         text.Append(L" (");
400
401         int dayOfWeek = 0 ;
402         if (pGroupItemClass->__titleText == L"Today" || pGroupItemClass->__titleText == L"Yesterday")
403         {
404                 Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
405                 if (pGregorianCalendar != NULL)
406                 {
407                         pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->__startTime.GetYear());
408                         pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->__startTime.GetMonth());
409                         pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->__startTime.GetDay());
410                         dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
411
412                         if (pGregorianCalendar != NULL)
413                         {
414                                 delete pGregorianCalendar;
415                         }
416                 }
417         }
418         switch(dayOfWeek)
419         {
420         case 1:
421                 text.Append(L"Sun");
422                 break;
423         case 2:
424                 text.Append(L"Mon");
425                 break;
426         case 3:
427                 text.Append(L"Tue");
428                 break;
429         case 4:
430                 text.Append(L"Wed");
431                 break;
432         case 5:
433                 text.Append(L"Thu");
434                 break;
435         case 6:
436                 text.Append(L"Fri");
437                 break;
438         case 7:
439                 text.Append(L"Sat");
440                 break;
441         default:
442                 break;
443         }
444         text.Append(L", ");
445
446         String month = L"";
447
448         if (pGroupItemClass->__titleText != L"Older")
449         {
450                 text.Append(pGroupItemClass->__startTime.GetDay());
451                 text.Append(L". ");
452                 strMonth = pGroupItemClass->__startTime.GetMonth();
453                 month = GetMonth(strMonth);
454                 text.Append(month);
455         }
456         else
457         {
458                 text.Append(L"~ ");
459         }
460
461         if (pGroupItemClass->__titleText == L"Last week" || pGroupItemClass->__titleText == L"Two weeks ago" || pGroupItemClass->__titleText == L"Three weeks ago" || pGroupItemClass->__titleText == L"Four weeks ago" || pGroupItemClass->__titleText == L"Last month" || pGroupItemClass->__titleText == L"Older")
462         {
463                 text.Append(L" - ");
464                 text.Append(pGroupItemClass->__endTime.GetDay());
465                 text.Append(L". ");
466                 strMonth = pGroupItemClass->__endTime.GetMonth();
467                 month = GetMonth(strMonth);
468                 text.Append(month);
469         }
470
471         text.Append(L")");
472         AppLogDebug("startTime day = %d month = %d year = %d",pGroupItemClass->__startTime.GetDay(),pGroupItemClass->__startTime.GetMonth(),pGroupItemClass->__startTime.GetYear());
473
474         pItem->SetElement(text, null);
475         pItem->SetTextSize(32);
476
477         return pItem;
478 }
479
480 ListItemBase*
481 EditHistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
482 {
483         AppLogDebug("EditHistoryListForm::CreateItem");
484         result r = E_FAILURE;
485         const int bookmarkBtnWidth = 64;
486         String bitmapId;
487         if (__pGroupData == null)
488         {
489                 return null;
490         }
491
492         CustomItem* pItem = new(std::nothrow) CustomItem();
493         if ( pItem == NULL)
494         {
495                 return null ;
496         }
497         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
498
499         if (pGroupItemClass == null)
500         {
501                 delete pItem;
502                 return null;
503         }
504
505         History* pHistory = dynamic_cast< History* >(pGroupItemClass->__pData->GetAt(itemIndex));
506         if ( pHistory == NULL )
507         {
508                 delete pItem;
509                 return null;
510         }
511         Bitmap* pBitmap = null;
512
513         r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128), LIST_ANNEX_STYLE_MARK);
514
515
516
517         pBitmap = pHistory->GetFavIconBitmap();
518         if (pBitmap == null)
519         {
520                 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
521         }
522
523         if (pBitmap != null)
524         {
525                 pItem->AddElement(Rectangle(16, 26, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
526                 delete pBitmap;
527         }
528         r = pItem->AddElement(Rectangle(92, 4, GetClientAreaBounds().width - 96 - 32 -64 -32, 60), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), 44,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
529         if (IsFailed(r))
530         {
531                 delete pItem;
532                 AppLogException("CreateItem failed with %s", GetErrorMessage(r));
533                 return null;
534         }
535
536         pItem->AddElement(Rectangle(92, 68, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 52), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
537
538         return pItem;
539 }
540
541 bool
542 EditHistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
543 {
544
545         AppLogDebug("EditHistoryListForm::DeleteGroupItem");
546
547         if (__pGroupData == null)
548         {
549                 return false;
550         }
551
552         delete pItem;
553         pItem = null;
554
555         return true;
556
557 }
558
559 bool
560 EditHistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
561 {
562
563         if (__pGroupData == null)
564         {
565                 return false;
566         }
567
568         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
569         if (pGroupItemClass == null)
570         {
571                 return false;
572         }
573
574         delete pItem;
575         pItem = null;
576         return true;
577 }
578
579 int
580 EditHistoryListForm::GetGroupCount(void)
581 {
582         AppLogDebug("EditHistoryListForm::GetGroupCount");
583
584         __isNoHistoryPresent = true;
585
586         CreateGroupItems();
587
588         int count = 0;
589         HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
590         if(count == 0)
591         {
592                 __isNoHistoryPresent = false;
593                 AppLogDebug("the value of isNoHistoryPresent %d",__isNoHistoryPresent);
594                 __pTimer->Start(1000);
595                 __pSelectAllCheck->SetShowState(false);
596                 __pSelectedLabel->SetShowState(false);
597         }
598         else
599         {
600                 __isNoHistoryPresent = true;
601                 __pSelectAllCheck->SetShowState(true);
602                 __pSelectedLabel->SetShowState(true);
603         }
604         __pSelectAllCheck->Invalidate(true);
605         __pSelectedLabel->Invalidate(false);
606         GetFooter()->Invalidate(true);
607
608         if (__pGroupData != null)
609         {
610                 AppLogDebug("GetGroupCount returning %d",__pGroupData->GetCount());
611                 count = __pGroupData->GetCount();
612         }
613         else
614         {
615                 AppLogDebug("GetGroupCount returning 0");
616                 count = 0;
617         }
618
619         return count;
620 }
621
622 int
623 EditHistoryListForm::GetItemCount(int groupIndex)
624 {
625         AppLogDebug("EditHistoryListForm::GetItemCount");
626         result r = E_FAILURE;
627         int count = 0;
628
629         if (__pGroupData == null)
630         {
631                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
632                 return 0;
633         }
634
635         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
636
637         if (pGroupItemClass == null)
638         {
639                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
640                 return 0;
641         }
642
643
644         r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(pGroupItemClass->__startTime,pGroupItemClass->__endTime,count);
645
646         if ( r != E_SUCCESS)
647         {
648                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
649                 return 0;
650         }
651
652         if (pGroupItemClass->__pData != null)
653         {
654                 pGroupItemClass->__pData->RemoveAll(false);
655                 delete pGroupItemClass->__pData;
656         }
657         pGroupItemClass->__pData = new(std::nothrow) Collection::ArrayList();
658         pGroupItemClass->__pData->Construct();
659         AppLog("Starttime %ls endtime %ls",pGroupItemClass->__startTime.ToString().GetPointer(),pGroupItemClass->__endTime.ToString().GetPointer());
660         HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(pGroupItemClass->__startTime,pGroupItemClass->__endTime, 0, count, *pGroupItemClass->__pData);
661         AppLogDebug("Count = %d ", count);
662
663         if (__pGroupData == null)
664         {
665                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
666                 return 0;
667         }
668
669
670
671         if (pGroupItemClass == null || pGroupItemClass->__pData == null)
672         {
673                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
674                 return 0;
675         }
676         else
677         {
678                 AppLogDebug("EditHistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->__pData->GetCount(),groupIndex,pGroupItemClass->__titleText.GetPointer());
679                 return pGroupItemClass->__pData->GetCount();
680         }
681 }
682
683 void
684 EditHistoryListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
685                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
686 {
687         AppLogDebug("EditHistoryListForm::OnSceneActivatedN");
688         int groupCount = 0;
689         int count = 0;
690
691         if(__pGroupData != null)
692         {
693                 groupCount =   __pGroupData->GetCount();
694
695                 for(int groupIndex = 0 ; groupIndex < groupCount ; groupIndex ++ )
696                 {
697                         count = __pListView->GetItemCountAt(groupIndex);
698
699                         for(int index = 0 ; index < count ; index++)
700                         {
701                                 if(__pListView->IsItemChecked( groupIndex,index ) == true)
702                                 {
703                                         __pListView->SetItemChecked(groupIndex,index,false);
704                                 }
705                         }
706                 }
707         }
708         if (__pListView != null)
709         {
710                 __pListView->UpdateList();
711         }
712         __pSelectAllCheck->SetSelected(false);
713
714         GetFooter()->SetItemEnabled(0, false);
715         Invalidate(true);
716 }
717
718 void
719 EditHistoryListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
720                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
721 {
722         AppLogDebug("EditHistoryListForm::OnSceneDeactivated");
723 }
724
725 void
726 EditHistoryListForm::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
727 {
728
729 }
730
731 void
732 EditHistoryListForm::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus status)
733 {
734         AppLogDebug("EditHistoryListForm::OnGroupedListViewItemStateChanged entered");
735         String  selectedText = CommonUtil::GetString(L"IDS_COM_OPT_SELECTED");
736         bool flag = false;
737
738         if (status == LIST_ITEM_STATUS_UNCHECKED)
739         {
740                 __selectedCount--;
741         }
742         else
743         {
744                 __selectedCount++;
745         }
746
747         if (__selectedCount == 0)
748         {
749                 GetFooter()->SetItemEnabled(0,false);
750         }
751         else
752         {
753                 GetFooter()->SetItemEnabled(0,true);
754         }
755         GetFooter()->Invalidate(true);
756
757         selectedText.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
758         selectedText.Append(L"(");
759         selectedText.Append(__selectedCount);
760         selectedText.Append(L")");
761
762         __pSelectedLabel->SetText(selectedText);
763         __pSelectedLabel->Invalidate(true);
764
765         if (status == LIST_ITEM_STATUS_UNCHECKED)
766         {
767                 __pSelectAllCheck->SetSelected(false);
768         }
769         else if (status == LIST_ITEM_STATUS_CHECKED && __pSelectAllCheck->IsSelected() == false && __pGroupData != null)
770         {
771                 int itemCount = __pGroupData->GetCount();
772                 for (int groupIndex = 0 ; groupIndex < itemCount ; groupIndex ++)
773                 {
774                         GroupItemClass* pGClass = (dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex)));
775                         if(pGClass == null)
776                         {
777                                 continue;
778                         }
779                         for (int itemIndex = 0 ; itemIndex < pGClass->__pData->GetCount() ; itemIndex ++)
780                         {
781                                 bool ret = __pListView->IsItemChecked(groupIndex,itemIndex);
782
783                                 if (ret == false)
784                                 {
785                                         __pSelectAllCheck->SetSelected(false);
786                                         return;
787                                 }
788                         }
789                 }
790                 __pSelectAllCheck->SetSelected(true);
791         }
792
793 }
794
795 void
796 EditHistoryListForm::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
797 {
798
799 }
800
801 String
802 EditHistoryListForm::GetMonth(int month)
803 {
804         String monthValue;
805         switch (month)
806         {
807         case 1:
808                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));;
809                 break;
810         case 2:
811                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));;
812                 break;
813         case 3:
814                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));;
815                 break;
816         case 4:
817                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));;
818                 break;
819         case 5:
820                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));;
821                 break;
822         case 6:
823                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUN"));;
824                 break;
825         case 7:
826                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));;
827                 break;
828         case 8:
829                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_AUG"));;
830                 break;
831         case 9:
832                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));;
833                 break;
834         case 10:
835                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));;
836                 break;
837         case 11:
838                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));;
839                 break;
840         case 12:
841                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));;
842                 break;
843         default:
844                 break;
845         }
846
847         return monthValue;
848 }
849
850 void
851 EditHistoryListForm::CreateGroupItems(void)
852 {
853         AppLogDebug("EditHistoryListForm::createGroupItems entered");
854         if (__pGroupData != null)
855         {
856                 __pGroupData->RemoveAll(true);
857                 delete __pGroupData;
858                 __pGroupData = null;
859         }
860
861         if (__pGroupData == null)
862         {
863                 __pGroupData = new(std::nothrow) Collection::ArrayList();
864                 __pGroupData->Construct();
865         }
866
867         DateTime currentTime;
868
869         HistoryPresentationModel::GetCurrentDateTime(currentTime);
870         GroupItemClass* pGroupItemClass = new(std::nothrow) GroupItemClass();
871         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");
872         pGroupItemClass->__endTime = currentTime;
873         pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
874         __pGroupData->Add(*pGroupItemClass);
875         int dayOfWeek = 0;
876         Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
877
878         if (pGregorianCalendar != NULL)
879         {
880                 pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());
881                 pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());
882                 pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());
883                 dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
884                 delete pGregorianCalendar;
885         }
886
887
888         switch(dayOfWeek)
889         {
890         case SUNDAY:
891                 pGroupItemClass = new(std::nothrow) GroupItemClass();
892                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
893                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
894                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
895                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 6 - 1);
896                 __pGroupData->Add(*pGroupItemClass);
897                 break;
898
899         case MONDAY:
900                 pGroupItemClass = new(std::nothrow) GroupItemClass();
901                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
902                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
903                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
904                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 7 - 1);
905                 __pGroupData->Add(*pGroupItemClass);
906                 break;
907
908         case TUESDAY:
909                 pGroupItemClass = new(std::nothrow) GroupItemClass();
910                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
911                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
912                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
913                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
914                 __pGroupData->Add(*pGroupItemClass);
915                 pGroupItemClass = new(std::nothrow) GroupItemClass();
916                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
917                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
918                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
919                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
920                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 8 - 1);
921                 __pGroupData->Add(*pGroupItemClass);
922                 break;
923
924         case WEDNESDAY:
925                 pGroupItemClass = new(std::nothrow) GroupItemClass();
926                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
927                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
928                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
929                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
930                 __pGroupData->Add(*pGroupItemClass);
931
932                 pGroupItemClass = new(std::nothrow) GroupItemClass();
933                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
934                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
935                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
936                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
937                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
938                 __pGroupData->Add(*pGroupItemClass);
939
940                 pGroupItemClass = new(std::nothrow) GroupItemClass();
941                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
942                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
943                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
944                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
945                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 9 - 1);
946                 __pGroupData->Add(*pGroupItemClass);
947                 break;
948
949         case THURSDAY:
950                 pGroupItemClass = new(std::nothrow) GroupItemClass();
951                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
952                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
953                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
954                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
955                 __pGroupData->Add(*pGroupItemClass);
956
957                 pGroupItemClass = new(std::nothrow) GroupItemClass();
958                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
959                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
960                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
961                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
962                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
963                 __pGroupData->Add(*pGroupItemClass);
964
965                 pGroupItemClass = new(std::nothrow) GroupItemClass();
966                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
967                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
968                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
969                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
970                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
971                 __pGroupData->Add(*pGroupItemClass);
972
973                 pGroupItemClass = new(std::nothrow) GroupItemClass();
974                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
975                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
976                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
977                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
978                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 10 - 1);
979                 __pGroupData->Add(*pGroupItemClass);
980                 break;
981
982         case FRIDAY:
983                 pGroupItemClass = new(std::nothrow) GroupItemClass();
984                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
985                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
986                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
987                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
988                 __pGroupData->Add(*pGroupItemClass);
989
990                 pGroupItemClass = new(std::nothrow) GroupItemClass();
991                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
992                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
993                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
994                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
995                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
996                 __pGroupData->Add(*pGroupItemClass);
997
998                 pGroupItemClass = new(std::nothrow) GroupItemClass();
999                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1000                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1001                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1002                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1003                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
1004                 __pGroupData->Add(*pGroupItemClass);
1005
1006                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1007                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1008                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1009                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
1010                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1011                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 4 - 1);
1012                 __pGroupData->Add(*pGroupItemClass);
1013
1014                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1015                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1016                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1017                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 4 - 1);
1018                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1019                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 11 - 1);
1020                 __pGroupData->Add(*pGroupItemClass);
1021                 break;
1022
1023         case SATURDAY:
1024                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1025                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1026                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1027                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1028                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1029                 __pGroupData->Add(*pGroupItemClass);
1030
1031                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1032                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");
1033                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1034                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1035                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1036                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
1037                 __pGroupData->Add(*pGroupItemClass);
1038
1039                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1040                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1041                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1042                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1043                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1044                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
1045                 __pGroupData->Add(*pGroupItemClass);
1046
1047                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1048                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1049                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1050                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
1051                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1052                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 4 - 1);
1053                 __pGroupData->Add(*pGroupItemClass);
1054
1055                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1056                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1057                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1058                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 4 - 1);
1059                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1060                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 5 - 1);
1061                 __pGroupData->Add(*pGroupItemClass);
1062
1063                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1064                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1065                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1066                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 5 - 1);
1067                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1068                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 12 - 1);
1069                 __pGroupData->Add(*pGroupItemClass);
1070                 break;
1071
1072         default:
1073                 break;
1074         }
1075         int day = currentTime.GetDay();
1076         switch(day/7)
1077         {
1078         case 2:
1079                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1080                 pGroupItemClass->__titleText = L"Two weeks ago";
1081                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1082                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1083                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1084                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1085                 __pGroupData->Add(*pGroupItemClass);
1086                 break;
1087
1088         case 3:
1089                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1090                 pGroupItemClass->__titleText = L"Two weeks ago";
1091                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1092                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1093                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1094                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1095                 __pGroupData->Add(*pGroupItemClass);
1096
1097                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1098                 pGroupItemClass->__titleText = L"Three weeks ago";
1099                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1100                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1101                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1102                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1103                 __pGroupData->Add(*pGroupItemClass);
1104                 break;
1105
1106         case 4:
1107                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1108                 pGroupItemClass->__titleText = L"Two weeks ago";
1109                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1110                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1111                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1112                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1113                 __pGroupData->Add(*pGroupItemClass);
1114
1115                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1116                 pGroupItemClass->__titleText = L"Three weeks ago";
1117                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1118                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1119                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1120                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1121                 __pGroupData->Add(*pGroupItemClass);
1122
1123                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1124                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1125                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1126                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1127                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1128                 __pGroupData->Add(*pGroupItemClass);
1129                 break;
1130         default:
1131                 break;
1132         }
1133
1134         pGroupItemClass = new(std::nothrow) GroupItemClass();
1135         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH");
1136         pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1137         pGroupItemClass->__endTime.AddDays(-1);
1138         pGroupItemClass->__startTime.SetValue(currentTime.GetYear(), 1, 1);
1139         pGroupItemClass->__startTime.AddMonths(currentTime.GetMonth() - 1 - 1);
1140         __pGroupData->Add(*pGroupItemClass);
1141
1142         pGroupItemClass = new(std::nothrow) GroupItemClass();
1143         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");
1144         pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),1, 1);
1145         pGroupItemClass->__endTime.AddMonths(currentTime.GetMonth() - 2);
1146         pGroupItemClass->__endTime.AddDays(-1);
1147         pGroupItemClass->__startTime.SetValue(0, 0, 0);
1148         __pGroupData->Add(*pGroupItemClass);
1149 }
1150
1151 void EditHistoryListForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1152 {
1153         if (__pListView != null)
1154         {
1155                 __pListView->UpdateList();
1156         }
1157 }
1158
1159 void
1160 EditHistoryListForm::OnTimerExpired(Timer&  timer)
1161 {
1162         SceneManager* pSceneManager = SceneManager::GetInstance();
1163
1164         if ( pSceneManager != NULL)
1165         {
1166                 pSceneManager->GoBackward(BackwardSceneTransition());
1167         }
1168 }