Fixed Nabi Issues: 53721,53372,53761,53768
[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                 __pListView->SetItemEnabled(groupIndex, -1, false);
447         }
448         else
449         {
450                 r = pItem->Construct(Dimension(itemWidth, 48));
451         }
452
453         text = pGroupItemClass->__titleText;
454         text.Append(L" (");
455
456         int dayOfWeek = 0 ;
457         if (pGroupItemClass->__titleText == CommonUtil::GetString(L"IDS_COM_BODY_TODAY") || pGroupItemClass->__titleText == CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY"))
458         {
459                 Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
460                 if (pGregorianCalendar != NULL)
461                 {
462                         pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->__startTime.GetYear());
463                         pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->__startTime.GetMonth());
464                         pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->__startTime.GetDay());
465                         dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
466
467                         if (pGregorianCalendar != NULL)
468                         {
469                                 delete pGregorianCalendar;
470                         }
471                 }
472         }
473         switch(dayOfWeek)
474         {
475         case 1:
476                 r = text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SUN"));
477                 AppLog("dayOfWeek Append Result %s",GetErrorMessage(r));
478                 text.Append(L", ");
479                 break;
480         case 2:
481                 r = text.Append(CommonUtil::GetString(L"IDS_COM_BODY_MON"));
482                 AppLog("dayOfWeek Append Result %s",GetErrorMessage(r));
483                 text.Append(L", ");
484                 break;
485         case 3:
486                 r = text.Append(CommonUtil::GetString(L"IDS_COM_BODY_TUE"));
487                 AppLog("dayOfWeek Append Result %s",GetErrorMessage(r));
488                 text.Append(L", ");
489                 break;
490         case 4:
491                 r = text.Append(CommonUtil::GetString(L"IDS_COM_BODY_WED"));
492                 AppLog("dayOfWeek Append Result %s",GetErrorMessage(r));
493                 text.Append(L", ");
494                 break;
495         case 5:
496                 AppLog("dayOfWeek Append Result yoyo");
497                 r = text.Append(CommonUtil::GetString(L"IDS_COM_BODY_THU"));
498                 AppLog("dayOfWeek Append Result %s",GetErrorMessage(r));
499                 text.Append(L", ");
500                 break;
501         case 6:
502                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_FRI"));
503                 text.Append(L", ");
504                 break;
505         case 7:
506                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SAT"));
507                 text.Append(L", ");
508                 break;
509         default:
510                 break;
511         }
512
513
514         String month = L"";
515
516         if (pGroupItemClass->__titleText != L"Older")
517         {
518                 text.Append(pGroupItemClass->__startTime.GetDay());
519                 text.Append(L" ");
520                 strMonth = pGroupItemClass->__startTime.GetMonth();
521                 month = GetMonth(strMonth);
522                 text.Append(month);
523         }
524         else
525         {
526                 text.Append(L"~ ");
527         }
528
529         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")
530         {
531                 text.Append(L" - ");
532                 text.Append(pGroupItemClass->__endTime.GetDay());
533                 text.Append(L" ");
534                 strMonth = pGroupItemClass->__endTime.GetMonth();
535                 month = GetMonth(strMonth);
536                 text.Append(month);
537         }
538
539         text.Append(L")");
540         AppLogDebug("startTime day = %d month = %d year = %d",pGroupItemClass->__startTime.GetDay(),pGroupItemClass->__startTime.GetMonth(),pGroupItemClass->__startTime.GetYear());
541
542         pItem->SetElement(text, null);
543         pItem->SetTextSize(32);
544
545         return pItem;
546 }
547
548 ListItemBase*
549 EditHistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
550 {
551         AppLogDebug("EditHistoryListForm::CreateItem");
552         result r = E_FAILURE;
553         const int bookmarkBtnWidth = 64;
554         String bitmapId;
555         if (__pGroupData == null)
556         {
557                 return null;
558         }
559
560         CustomItem* pItem = new(std::nothrow) CustomItem();
561         if ( pItem == NULL)
562         {
563                 return null ;
564         }
565         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
566
567         if (pGroupItemClass == null)
568         {
569                 delete pItem;
570                 return null;
571         }
572
573         History* pHistory = dynamic_cast< History* >(pGroupItemClass->__pData->GetAt(itemIndex));
574         if ( pHistory == NULL )
575         {
576                 delete pItem;
577                 return null;
578         }
579         Bitmap* pBitmap = null;
580
581         r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128 + (__fontSize - 44)), LIST_ANNEX_STYLE_MARK);
582
583
584
585         pBitmap = pHistory->GetFavIconBitmap();
586         if (pBitmap == null)
587         {
588                 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
589         }
590
591         if (pBitmap != null)
592         {
593                 pItem->AddElement(Rectangle(16, 26  + (__fontSize - 44)/2, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
594                 delete pBitmap;
595         }
596         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);
597         if (IsFailed(r))
598         {
599                 delete pItem;
600                 AppLogException("CreateItem failed with %s", GetErrorMessage(r));
601                 return null;
602         }
603
604         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_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
605
606         return pItem;
607 }
608
609 bool
610 EditHistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
611 {
612
613         AppLogDebug("EditHistoryListForm::DeleteGroupItem");
614
615         if (__pGroupData == null)
616         {
617                 return false;
618         }
619
620         delete pItem;
621         pItem = null;
622
623         return true;
624
625 }
626
627 bool
628 EditHistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
629 {
630
631         if (__pGroupData == null)
632         {
633                 return false;
634         }
635
636         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
637         if (pGroupItemClass == null)
638         {
639                 return false;
640         }
641
642         delete pItem;
643         pItem = null;
644         return true;
645 }
646
647 int
648 EditHistoryListForm::GetGroupCount(void)
649 {
650         result r = E_FAILURE;
651         AppLogDebug("EditHistoryListForm::GetGroupCount");
652
653         __isNoHistoryPresent = true;
654
655         CreateGroupItems();
656
657         int count = 0;
658         //HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
659
660         DateTime startTime;
661         startTime.SetValue(0, 1, 1, 0, 0, 0);
662         DateTime endTime;
663         SystemTime::GetCurrentTime(endTime);
664         endTime.SetValue(endTime.GetYear(), endTime.GetMonth(), endTime.GetDay(), 23,59,59);
665
666         r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime ,endTime, count);
667
668         if(count == 0)
669         {
670                 __isNoHistoryPresent = false;
671                 AppLogDebug("the value of isNoHistoryPresent %d",__isNoHistoryPresent);
672                 __pTimer->Start(1000);
673                 __pSelectAllCheck->SetShowState(false);
674                 __pSelectedLabel->SetShowState(false);
675         }
676         else
677         {
678                 __isNoHistoryPresent = true;
679                 __pSelectAllCheck->SetShowState(true);
680                 __pSelectedLabel->SetShowState(true);
681         }
682         __pSelectAllCheck->Invalidate(true);
683         __pSelectedLabel->Invalidate(false);
684         GetFooter()->Invalidate(true);
685
686         if (__pGroupData != null)
687         {
688                 AppLogDebug("GetGroupCount returning %d",__pGroupData->GetCount());
689                 count = __pGroupData->GetCount();
690         }
691         else
692         {
693                 AppLogDebug("GetGroupCount returning 0");
694                 count = 0;
695         }
696
697         return count;
698 }
699
700 int
701 EditHistoryListForm::GetItemCount(int groupIndex)
702 {
703         AppLogDebug("EditHistoryListForm::GetItemCount");
704         result r = E_FAILURE;
705         int count = 0;
706
707         if (__pGroupData == null)
708         {
709                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
710                 return 0;
711         }
712
713         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
714
715         if (pGroupItemClass == null)
716         {
717                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
718                 return 0;
719         }
720
721
722         r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(pGroupItemClass->__startTime,pGroupItemClass->__endTime,count);
723
724         if ( r != E_SUCCESS)
725         {
726                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
727                 return 0;
728         }
729
730         if (pGroupItemClass->__pData != null)
731         {
732                 pGroupItemClass->__pData->RemoveAll(false);
733                 delete pGroupItemClass->__pData;
734         }
735         pGroupItemClass->__pData = new(std::nothrow) Collection::ArrayList();
736         pGroupItemClass->__pData->Construct();
737         AppLog("Starttime %ls endtime %ls",pGroupItemClass->__startTime.ToString().GetPointer(),pGroupItemClass->__endTime.ToString().GetPointer());
738         HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(pGroupItemClass->__startTime,pGroupItemClass->__endTime, 0, count, *pGroupItemClass->__pData);
739         AppLogDebug("Count = %d ", count);
740
741         if (__pGroupData == null)
742         {
743                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
744                 return 0;
745         }
746
747
748
749         if (pGroupItemClass == null || pGroupItemClass->__pData == null)
750         {
751                 AppLogDebug("EditHistoryListForm::GetItemCount returning 0");
752                 return 0;
753         }
754         else
755         {
756                 AppLogDebug("EditHistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->__pData->GetCount(),groupIndex,pGroupItemClass->__titleText.GetPointer());
757                 return pGroupItemClass->__pData->GetCount();
758         }
759 }
760
761 void
762 EditHistoryListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
763                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
764 {
765         AppLogDebug("EditHistoryListForm::OnSceneActivatedN");
766         int groupCount = 0;
767         int count = 0;
768         String selectedText = L"";
769
770         if(__pGroupData != null)
771         {
772                 groupCount =   __pGroupData->GetCount();
773
774                 for(int groupIndex = 0 ; groupIndex < groupCount ; groupIndex ++ )
775                 {
776                         count = __pListView->GetItemCountAt(groupIndex);
777
778                         for(int index = 0 ; index < count ; index++)
779                         {
780                                 if(__pListView->IsItemChecked( groupIndex,index ) == true)
781                                 {
782                                         __pListView->SetItemChecked(groupIndex,index,false);
783                                 }
784                         }
785                 }
786         }
787         if (__pListView != null)
788         {
789                 __pListView->UpdateList();
790         }
791         __pSelectAllCheck->SetSelected(false);
792         __selectedCount = 0;
793         selectedText.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedCount);
794         __pSelectedLabel->SetText(selectedText);
795         __pSelectedLabel->Invalidate(true);
796         GetFooter()->SetItemEnabled(1, false);
797         Invalidate(true);
798 }
799
800 void
801 EditHistoryListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
802                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
803 {
804         AppLogDebug("EditHistoryListForm::OnSceneDeactivated");
805 }
806
807 void
808 EditHistoryListForm::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
809 {
810
811 }
812
813 void
814 EditHistoryListForm::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus status)
815 {
816         AppLogDebug("EditHistoryListForm::OnGroupedListViewItemStateChanged entered");
817         String  selectedText;
818         bool flag = false;
819
820         if (status == LIST_ITEM_STATUS_UNCHECKED)
821         {
822                 __selectedCount--;
823         }
824         else
825         {
826                 __selectedCount++;
827         }
828
829         if (__selectedCount == 0)
830         {
831                 GetFooter()->SetItemEnabled(1,false);
832         }
833         else
834         {
835                 GetFooter()->SetItemEnabled(1,true);
836         }
837         GetFooter()->Invalidate(true);
838
839
840         if (__selectedCount >1)
841         {
842                 selectedText.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __selectedCount);
843         }
844         else
845         {
846                 selectedText.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedCount);
847         }
848
849         __pSelectedLabel->SetText(selectedText);
850         __pSelectedLabel->Invalidate(true);
851
852         if (status == LIST_ITEM_STATUS_UNCHECKED)
853         {
854                 __pSelectAllCheck->SetSelected(false);
855         }
856         else if (status == LIST_ITEM_STATUS_CHECKED && __pSelectAllCheck->IsSelected() == false && __pGroupData != null)
857         {
858                 int itemCount = __pGroupData->GetCount();
859                 for (int groupIndex = 0 ; groupIndex < itemCount ; groupIndex ++)
860                 {
861                         GroupItemClass* pGClass = (dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex)));
862                         if(pGClass == null)
863                         {
864                                 continue;
865                         }
866                         for (int itemIndex = 0 ; itemIndex < pGClass->__pData->GetCount() ; itemIndex ++)
867                         {
868                                 bool ret = __pListView->IsItemChecked(groupIndex,itemIndex);
869
870                                 if (ret == false)
871                                 {
872                                         __pSelectAllCheck->SetSelected(false);
873                                         return;
874                                 }
875                         }
876                 }
877                 __pSelectAllCheck->SetSelected(true);
878         }
879
880 }
881
882 void
883 EditHistoryListForm::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
884 {
885
886 }
887
888 String
889 EditHistoryListForm::GetMonth(int month)
890 {
891         String monthValue;
892         switch (month)
893         {
894         case 1:
895                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));;
896                 break;
897         case 2:
898                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));;
899                 break;
900         case 3:
901                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));;
902                 break;
903         case 4:
904                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APRIL"));;
905                 break;
906         case 5:
907                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));;
908                 break;
909         case 6:
910                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUNE"));;
911                 break;
912         case 7:
913                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));;
914                 break;
915         case 8:
916                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_AUG"));;
917                 break;
918         case 9:
919                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));;
920                 break;
921         case 10:
922                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));;
923                 break;
924         case 11:
925                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));;
926                 break;
927         case 12:
928                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));;
929                 break;
930         default:
931                 break;
932         }
933
934         return monthValue;
935 }
936
937 void
938 EditHistoryListForm::CreateGroupItems(void)
939 {
940         AppLogDebug("EditHistoryListForm::createGroupItems entered");
941         if (__pGroupData != null)
942         {
943                 __pGroupData->RemoveAll(true);
944                 delete __pGroupData;
945                 __pGroupData = null;
946         }
947
948         if (__pGroupData == null)
949         {
950                 __pGroupData = new(std::nothrow) Collection::ArrayList();
951                 __pGroupData->Construct();
952         }
953
954         DateTime currentTime;
955
956         HistoryPresentationModel::GetCurrentDateTime(currentTime);
957         GroupItemClass* pGroupItemClass = new(std::nothrow) GroupItemClass();
958         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");
959         pGroupItemClass->__endTime = currentTime;
960         pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
961         __pGroupData->Add(*pGroupItemClass);
962         int dayOfWeek = 0;
963         Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
964
965         if (pGregorianCalendar != NULL)
966         {
967                 pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());
968                 pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());
969                 pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());
970                 dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
971                 delete pGregorianCalendar;
972         }
973
974
975         switch(dayOfWeek)
976         {
977         case SUNDAY:
978                 pGroupItemClass = new(std::nothrow) GroupItemClass();
979                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
980                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
981                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
982                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 6 - 1);
983                 __pGroupData->Add(*pGroupItemClass);
984                 break;
985
986         case MONDAY:
987                 pGroupItemClass = new(std::nothrow) GroupItemClass();
988                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
989                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
990                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
991                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 7 - 1);
992                 __pGroupData->Add(*pGroupItemClass);
993                 break;
994
995         case TUESDAY:
996                 pGroupItemClass = new(std::nothrow) GroupItemClass();
997                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
998                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
999                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1000                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1001                 __pGroupData->Add(*pGroupItemClass);
1002                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1003                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1004                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1005                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1006                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1007                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 8 - 1);
1008                 __pGroupData->Add(*pGroupItemClass);
1009                 break;
1010
1011         case WEDNESDAY:
1012                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1013                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1014                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1015                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1016                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1017                 __pGroupData->Add(*pGroupItemClass);
1018
1019                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1020                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1021                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1022                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1023                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1024                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
1025                 __pGroupData->Add(*pGroupItemClass);
1026
1027                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1028                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1029                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1030                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1031                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1032                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 9 - 1);
1033                 __pGroupData->Add(*pGroupItemClass);
1034                 break;
1035
1036         case THURSDAY:
1037                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1038                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1039                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1040                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1041                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1042                 __pGroupData->Add(*pGroupItemClass);
1043
1044                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1045                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1046                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1047                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1048                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1049                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
1050                 __pGroupData->Add(*pGroupItemClass);
1051
1052                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1053                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1054                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1055                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1056                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1057                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
1058                 __pGroupData->Add(*pGroupItemClass);
1059
1060                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1061                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1062                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1063                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
1064                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1065                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 10 - 1);
1066                 __pGroupData->Add(*pGroupItemClass);
1067                 break;
1068
1069         case FRIDAY:
1070                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1071                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1072                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1073                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1074                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1075                 __pGroupData->Add(*pGroupItemClass);
1076
1077                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1078                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1079                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1080                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1081                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1082                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
1083                 __pGroupData->Add(*pGroupItemClass);
1084
1085                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1086                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1087                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1088                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1089                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1090                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
1091                 __pGroupData->Add(*pGroupItemClass);
1092
1093                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1094                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1095                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1096                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
1097                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1098                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 4 - 1);
1099                 __pGroupData->Add(*pGroupItemClass);
1100
1101                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1102                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1103                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1104                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 4 - 1);
1105                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1106                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 11 - 1);
1107                 __pGroupData->Add(*pGroupItemClass);
1108                 break;
1109
1110         case SATURDAY:
1111                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1112                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1113                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1114                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1115                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 1 - 1);
1116                 __pGroupData->Add(*pGroupItemClass);
1117
1118                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1119                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");
1120                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1121                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 1 - 1);
1122                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1123                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 2 - 1);
1124                 __pGroupData->Add(*pGroupItemClass);
1125
1126                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1127                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1128                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1129                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 2 - 1);
1130                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1131                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 3 - 1);
1132                 __pGroupData->Add(*pGroupItemClass);
1133
1134                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1135                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1136                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1137                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 3 - 1);
1138                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1139                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 4 - 1);
1140                 __pGroupData->Add(*pGroupItemClass);
1141
1142                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1143                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1144                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1145                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 4 - 1);
1146                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1147                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 5 - 1);
1148                 __pGroupData->Add(*pGroupItemClass);
1149
1150                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1151                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1152                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1153                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 5 - 1);
1154                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1155                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 12 - 1);
1156                 __pGroupData->Add(*pGroupItemClass);
1157                 break;
1158
1159         default:
1160                 break;
1161         }
1162         int day = currentTime.GetDay();
1163         switch(day/7)
1164         {
1165         case 2:
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                 break;
1174
1175         case 3:
1176                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1177                 pGroupItemClass->__titleText = L"Two weeks ago";
1178                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1179                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1180                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1181                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1182                 __pGroupData->Add(*pGroupItemClass);
1183
1184                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1185                 pGroupItemClass->__titleText = L"Three weeks ago";
1186                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1187                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1188                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1189                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1190                 __pGroupData->Add(*pGroupItemClass);
1191                 break;
1192
1193         case 4:
1194                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1195                 pGroupItemClass->__titleText = L"Two weeks ago";
1196                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1197                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1198                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1199                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1200                 __pGroupData->Add(*pGroupItemClass);
1201
1202                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1203                 pGroupItemClass->__titleText = L"Three weeks ago";
1204                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1205                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1206                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1207                 pGroupItemClass->__startTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1208                 __pGroupData->Add(*pGroupItemClass);
1209
1210                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1211                 pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1212                 pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1213                 pGroupItemClass->__endTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1214                 pGroupItemClass->__startTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1215                 __pGroupData->Add(*pGroupItemClass);
1216                 break;
1217         default:
1218                 break;
1219         }
1220
1221         pGroupItemClass = new(std::nothrow) GroupItemClass();
1222         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_MONTH");
1223         pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1224         pGroupItemClass->__endTime.AddDays(-1);
1225         pGroupItemClass->__startTime.SetValue(currentTime.GetYear(), 1, 1);
1226         pGroupItemClass->__startTime.AddMonths(currentTime.GetMonth() - 1 - 1);
1227         __pGroupData->Add(*pGroupItemClass);
1228
1229         pGroupItemClass = new(std::nothrow) GroupItemClass();
1230         pGroupItemClass->__titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");
1231         pGroupItemClass->__endTime.SetValue(currentTime.GetYear(),1, 1);
1232         pGroupItemClass->__endTime.AddMonths(currentTime.GetMonth() - 2);
1233         pGroupItemClass->__endTime.AddDays(-1);
1234         pGroupItemClass->__startTime.SetValue(0, 0, 0);
1235         __pGroupData->Add(*pGroupItemClass);
1236 }
1237
1238 void EditHistoryListForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1239 {
1240         if (__pListView != null)
1241         {
1242                 __pListView->UpdateList();
1243         }
1244 }
1245
1246 void
1247 EditHistoryListForm::OnTimerExpired(Timer&  timer)
1248 {
1249         SceneManager* pSceneManager = SceneManager::GetInstance();
1250
1251         if ( pSceneManager != NULL)
1252         {
1253                 pSceneManager->GoBackward(BackwardSceneTransition());
1254         }
1255 }
1256
1257 void
1258 EditHistoryListForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
1259 {
1260         AppLog("receiving userevent for appcontrol %d",requestId);
1261         if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
1262         {
1263                 AppLog("receiving userevent for appcontrol %d ",requestId);
1264                 if(__pConfirmationPopup)
1265                 {
1266                         __pConfirmationPopup->SetShowState(false);
1267                         delete __pConfirmationPopup;
1268                         __pConfirmationPopup = null;
1269                 }
1270         }
1271 }