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