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