HW Key Changes. Removal of unsupported and deprecated API's. NABI issue fix
[apps/osp/Internet.git] / src / IntHistoryListForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 //!Internet HistoryListForm class
18 /*@file: HistoryListForm.cpp
19  *@brief:       This class defines HistoryListForm used define history
20  *
21  */
22
23 #include <FApp.h>
24 #include <FUi.h>
25 #include "IntBookmarkData.h"
26 #include "IntBookmarkPresentationModel.h"
27 #include "IntCommonLib.h"
28 #include "IntFaviconManager.h"
29 #include "IntHistoryListForm.h"
30 #include "IntHistoryPresentationModel.h"
31 #include "IntMultipleWindowPresentationModel.h"
32 #include "IntSceneRegister.h"
33 #include "IntTypes.h"
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Locales;
41 using namespace Tizen::Media;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
45 using namespace Tizen::System;
46
47 static const wchar_t* IDB_TAB_ICON_BOOKMARKS = L"I01_tab_icon_bookmarks.png";
48 static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";
49 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
50 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
51
52
53 const int HistoryListForm::IDA_TABBAR_ITEM_1 = 101;
54 const int HistoryListForm::IDA_TABBAR_ITEM_2 = 102;
55 const int HistoryListForm::IDA_EDIT_HISTORY_LIST_FORM = 103;
56 const int HistoryListForm::IDA_FORMAT_ICON = 104;
57 const int HistoryListForm::IDA_FORMAT_TITLE = 105;
58 const int HistoryListForm::IDA_FORMAT_URL = 106;
59 const int HistoryListForm::IDA_FORMAT_BOOKMARK = 107;
60
61
62 HistoryListForm::HistoryListForm(void)
63 {
64         __pBookmarkList = null;
65         __pGroupedListView =null;
66         __pSearchListView = null;
67         __pSearchBar = null;
68         __pGroupData = null;
69         __pSearchedData = null ;
70         __searchHistory = false;
71         __isNoHistoryPresent = true;
72         __searchText = L"";
73         __previousSceneId = L"";
74 }
75
76 HistoryListForm::~HistoryListForm(void)
77 {
78         if (__pGroupData != null)
79         {
80                 __pGroupData->RemoveAll(false);
81                 delete __pGroupData;
82         }
83         if(__pBookmarkList != null)
84         {
85                 __pBookmarkList->RemoveAll(false);
86                 delete __pBookmarkList;
87         }
88         if (__pSearchListView)
89         {
90                 delete __pSearchListView;
91                 __pSearchListView = null;
92         }
93 }
94
95 bool
96 HistoryListForm::Initialize(void)
97 {
98         Construct(L"IDL_HISTORY_LIST");
99
100         return true;
101 }
102
103 result
104 HistoryListForm::OnInitializing(void)
105 {
106         AppLog("HistoryListForm::OnInitializing");
107         result r = E_SUCCESS;
108         SceneManager* pSceneManager = null;
109         HeaderItem bookmark;
110         HeaderItem history;
111         Header *pHeader = GetHeader();
112         Bitmap *pIconBitmap = null;
113         AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
114         const Color brown = Color(32, 32, 32, 0xFF);
115 //      bool isHwBackButtonExist = false;
116 //      Tizen::System::SystemInfo::GetValue(L"http:://tizen.org/feature/input.back.key",isHwBackButtonExist);
117 //
118 //      SetFormStyle(FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
119         // Setup back event listener
120         SetFormBackEventListener(this);
121
122         GetHeader()->AddActionEventListener(*this);
123         GetFooter()->AddActionEventListener(*this);
124
125 //      if(isHwBackButtonExist)
126 //      {
127 //              GetFooter()->SetBackButtonEnabled(false);
128 //      }
129         AddOrientationEventListener(*this);
130         SettingInfo::AddSettingEventListener(*this);
131
132         pSceneManager = SceneManager::GetInstance();
133         if (pSceneManager != null)
134         {
135                 pSceneManager->AddSceneEventListener(IDSCN_HISTORY_LIST, *this);
136         }
137
138         __fontSize = CommonUtil::GetFontSize();
139         if (pAppResource == null)
140         {
141                 return E_FAILURE;
142         }
143
144         __pGroupedListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));
145         if (__pGroupedListView == null)
146         {
147                 return E_FAILURE;
148         }
149
150         r = __pGroupedListView->SetItemProvider(*this);
151         if (IsFailed(r))
152         {
153                 return r;
154         }
155
156
157         __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
158         if (__pSearchBar == null)
159         {
160                 return E_FAILURE;
161         }
162         __pSearchBar->AddFocusEventListener(*this);
163         __pSearchListView = new(std::nothrow) GroupedListView();
164         if (__pSearchListView == null)
165         {
166                 return E_FAILURE;
167         }
168
169         __pGroupedListView->AddGroupedListViewItemEventListener(*this);
170         r = __pGroupedListView->SetBounds(Rectangle(0,__pGroupedListView->GetY(),GetClientAreaBounds().width,GetClientAreaBounds().height  - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
171         if (IsFailed(r))
172         {
173                 return r;
174         }
175         r = __pSearchListView->Construct(Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height -__pSearchBar->GetHeight() - __pSearchBar->GetY()), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
176         if (IsFailed(r))
177         {
178                 return r;
179         }
180         r = __pSearchListView->SetItemProvider(*this);
181         if (IsFailed(r))
182         {
183                 return r;
184         }
185         r = __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
186
187         if (IsFailed(r))
188         {
189                 return r;
190         }
191
192         __pSearchListView->SetBackgroundColor(GetBackgroundColor());
193         __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
194         __pSearchListView->AddGroupedListViewItemEventListener(*this);
195         r = __pSearchListView->SetShowState(false);
196         if (IsFailed(r))
197         {
198                 return r;
199         }
200
201
202         __pSearchBar->AddSearchBarEventListener(*this);
203         __pSearchBar->AddKeypadEventListener(*this);
204         r = __pSearchBar->SetContent(__pSearchListView);
205
206         if (pHeader != null)
207         {
208                 pHeader->SetStyle(HEADER_STYLE_TAB);
209                 bookmark.Construct(IDA_TABBAR_ITEM_1);
210                 String strbookmark;
211                 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
212                 bookmark.SetText(strbookmark);
213                 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARKS);
214                 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
215                 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
216                 pHeader->AddItem(bookmark);
217
218                 if (pIconBitmap)
219                 {
220                         delete pIconBitmap;
221                 }
222
223
224                 history.Construct(IDA_TABBAR_ITEM_2);
225                 String strhistory;
226                 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
227                 history.SetText(strhistory);
228                 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
229                 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
230                 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
231                 pHeader->AddItem(history);
232                 pHeader->SetItemSelected(1);
233                 pHeader->SetTabEditModeEnabled(false);
234
235                 if (pIconBitmap != NULL)
236                 {
237                         delete pIconBitmap;
238                 }
239         }
240
241         __pBookmarkList = new(std::nothrow) Collection::ArrayList();
242         __pBookmarkList->Construct();
243         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
244         return r;
245 }
246
247 result
248 HistoryListForm::OnTerminating(void)
249 {
250         result r = E_SUCCESS;
251
252         SettingInfo::RemoveSettingEventListener(*this);
253         return r;
254 }
255
256 void
257 HistoryListForm::OnActionPerformed(const Control& source, int actionId)
258 {
259         AppLog("HistoryListForm::OnActionPerformed");
260         result r = E_FAILURE;
261         SceneManager* pSceneManager = SceneManager::GetInstance();
262         if (pSceneManager == null)
263         {
264                 return;
265         }
266         switch (actionId)
267         {
268         case IDA_EDIT_HISTORY_LIST_FORM:
269         {
270                 AppLog("ID_EDIT_HISTORY_LIST_FORM entered");
271                 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
272                 if (IsFailed(r))
273                 {
274                         return;
275                 }
276         }
277         break;
278         case IDA_TABBAR_ITEM_1:
279         {
280         //      result r = GetHeader()->SetItemSelected(1);
281         //      AppLog("SetItemSelected result %s",GetErrorMessage(r));
282         //      GetHeader()->Invalidate(true);
283
284                 if (pSceneManager != null)
285                 {
286                         if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
287                         {
288                                 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
289                                 {
290                                         AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
291                                         return;
292                                 }
293                         }
294                         else
295                         {
296
297                                 if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
298                                 {
299                                         AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
300                                         return;
301                                 }
302
303                         }
304                 }
305 //              r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
306                 if (IsFailed(r))
307                 {
308                         return;
309                 }
310         }
311         break;
312         default:
313                 break;
314         }
315 }
316
317 void
318 HistoryListForm::OnFocusGained(const Tizen::Ui::Control& source)
319 {
320         __pSearchListView->SetEnabled(false);
321 }
322
323 void
324 HistoryListForm::OnFocusLost(const Tizen::Ui::Control& source)
325 {
326         __pSearchListView->SetEnabled(true);
327         __searchHistory = false;
328 }
329 void
330 HistoryListForm::OnFormBackRequested(Form& source)
331 {
332         SceneManager* pSceneManager = SceneManager::GetInstance();
333         if (pSceneManager == null)
334         {
335                 return;
336         }
337         result r = E_FAILURE;
338         if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
339         {
340                         r = pSceneManager->GoBackward(BackwardSceneTransition());
341         }
342         else
343         {
344                 r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
345         }
346         if(IsFailed(r))
347         {
348                 AppLogDebug("HistoryListForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));
349         }
350 }
351
352 GroupItem*
353 HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
354 {
355         result r = E_FAILURE;
356         int strMonth = 0;
357         String text(L"");
358         DateTime endTime;
359         DateTime startTime;
360         int count = 0;
361         GroupItem* pItem = null;
362         GroupItemClass* pGroupItemClass = null;
363
364         String weeksAgo2 = L"";
365         weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
366
367         String weeksAgo3 = L"";
368         weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
369
370         String weeksAgo4 = L"";
371         weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),4);
372
373         pItem = new(std::nothrow) GroupItem();
374         if (pItem == null)
375         {
376                 return null;
377         }
378         pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
379
380         if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null || pGroupItemClass->GetHistoryData()->GetCount() == 0)
381         {
382                 AppLog("CreateGroupItem :: if history is null");
383                 r = pItem->Construct(Dimension(itemWidth, 0));
384                 return pItem;
385         }
386         else
387         {
388                 r = pItem->Construct(Dimension(itemWidth, 48));
389         }
390         text = pGroupItemClass->GetTitleText();
391
392         if (__searchHistory == false)
393         {
394                 String month = L"";
395                 text.Append(L" (");
396                 if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_TODAY") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY"))
397                 {
398                         int dayOfWeek = 0;
399                         Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
400                         if ( pGregorianCalendar != NULL)
401                         {
402                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->GetStartTime().GetYear());
403                                 if (IsFailed(r))
404                                 {
405                                         if( pItem != null)
406                                         {
407                                                 delete pItem;
408                                         }
409                                         delete pGregorianCalendar;
410                                         return null;
411                                 }
412                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->GetStartTime().GetMonth());
413                                 if (IsFailed(r))
414                                 {
415                                         if( pItem != null)
416                                         {
417                                                 delete pItem;
418                                         }
419                                         delete pGregorianCalendar;
420                                         return null;
421                                 }
422                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->GetStartTime().GetDay());
423                                 if (IsFailed(r))
424                                 {
425                                         if( pItem != null)
426                                         {
427                                                 delete pItem;
428                                         }
429                                         delete pGregorianCalendar;
430                                         return null;
431                                 }
432                                 dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
433                                 if (pGregorianCalendar != NULL)
434                                 {
435                                         delete pGregorianCalendar;
436                                 }
437
438                         }
439                         switch(dayOfWeek)
440                         {
441                         case SUNDAY:
442                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SUN"));
443                                 break;
444                         case MONDAY:
445                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_MON"));
446                                 break;
447                         case TUESDAY:
448                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_TUE"));
449                                 break;
450                         case WEDNESDAY:
451                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_WED"));
452                                 break;
453                         case THURSDAY:
454                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_THU"));
455                                 break;
456                         case FRIDAY:
457                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_FRI"));
458                                 break;
459                         case SATURDAY:
460                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SAT"));
461                                 break;
462                         default:
463                                 break;
464                         }
465                         text.Append(L", ");
466                 }
467
468                 if (pGroupItemClass->GetTitleText() != CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
469                 {
470                         text.Append(pGroupItemClass->GetStartTime().GetDay());
471                         text.Append(L". ");
472                         strMonth = pGroupItemClass->GetStartTime().GetMonth();
473                         month = GetMonth(strMonth);
474                         text.Append(month);
475                 }
476                 else
477                 {
478                         text.Append(L"~ ");
479                 }
480
481
482
483                 if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
484                                 || pGroupItemClass->GetTitleText() == weeksAgo3 || pGroupItemClass->GetTitleText() == weeksAgo4 || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
485                 {
486                         text.Append(L" - ");
487                         text.Append(pGroupItemClass->GetEndTime().GetDay());
488                         text.Append(L". ");
489                         strMonth = pGroupItemClass->GetEndTime().GetMonth();
490                         month = GetMonth(strMonth);
491                         text.Append(month);
492                 }
493                 text.Append(L")");
494         }
495
496         r = pItem->SetElement(text, null);
497         if (IsFailed(r))
498         {
499                 delete pItem;
500                 AppLogDebug("Failed with %s", GetErrorMessage(r));
501                 return null;
502         }
503         r = pItem->SetTextSize(32);
504         if (IsFailed(r))
505         {
506                 delete pItem;
507                 return null;
508         }
509
510         return pItem;
511 }
512
513 ListItemBase*
514 HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
515 {
516         AppLog("HistoryListForm::CreateItem");
517         result r = E_FAILURE;
518         History* pHistory = null;
519         Bitmap* pBitmap = null;
520         Bitmap* pBookmarkBitmap = null;
521         GroupItemClass* pGroupItemClass = null;
522         CustomItem* pItem = new(std::nothrow) CustomItem();
523         int bookmarkBtnWidth = 0;
524         String bitmapId;
525
526         Image* pImage = null;
527         pImage = new Image();
528         pImage->Construct();
529
530         if(__pGroupData == null)
531         {
532                 delete pItem;
533                 return null;
534         }
535
536         if (pItem == null)
537         {
538                 return null;
539         }
540         pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
541         if (pGroupItemClass == null)
542         {
543                 delete pItem;
544                 return null;
545         }
546         if (pGroupItemClass->GetHistoryData() == null)
547         {
548                 delete pItem;
549                 return null;
550         }
551         pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
552         if (pHistory == null)
553         {
554                 delete pItem;
555                 return null;
556         }
557         r = pItem->Construct(Dimension(itemWidth, 128 - 44 + __fontSize), LIST_ANNEX_STYLE_NORMAL);
558         if (IsFailed(r))
559         {
560                 delete pItem;
561                 return null;
562         }
563
564         ByteBuffer* pFavIconBuffer = null;
565         pFavIconBuffer = pHistory->GetFavIconBuffer();
566
567         AppLog("BookmarkListForm::CreateItem check 0");
568
569         if (pFavIconBuffer != null)
570         {
571                 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
572         }
573         else
574         {
575                 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
576         }
577
578         pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
579
580         AppLog("BookmarkListForm::CreateItem check 1");
581
582         //bitmapId = pHistory->GetFaviconId() ;
583         //pBitmap = pHistory->GetFavIconBitmap();
584
585         if (pBitmap == null)
586         {
587                 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
588         }
589         if (pBitmap != null)
590         {
591                 r = pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2,72, 72), IDA_FORMAT_ICON, *pBitmap, null);
592                 delete pBitmap;
593                 if (IsFailed(r))
594                 {
595                         delete pItem;
596                         AppLogException("CreateItem failed with %s", GetErrorMessage(r));
597                         return null;
598                 }
599         }
600         bool urlFoundInBookmark = false;
601
602         if(__pBookmarkList != null)
603         {
604                 for (int i = 0; i < __pBookmarkList->GetCount();i++)
605                 {
606                         BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
607                         if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
608                         {
609                                 urlFoundInBookmark = true;
610                                 break;
611                         }
612                 }
613         }
614         if (urlFoundInBookmark == true)
615         {
616                 pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
617         }
618         else
619         {
620                 pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
621         }
622         bookmarkBtnWidth = 64;
623
624
625         r = pItem->AddElement(Rectangle(104, 10, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 60 - 44 + __fontSize), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), __fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
626         TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
627
628 //      if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
629 //              r = pItem->AddElement(Rectangle(104, 70, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
630 //      else
631                 r = pItem->AddElement(Rectangle(104, 70 - 44 +__fontSize, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
632         TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
633         if ( pBookmarkBitmap != null)
634         {
635                 r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2 +(__fontSize - 44)/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
636                 TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
637                 delete pBookmarkBitmap;
638         }
639         delete pImage;
640         return pItem;
641
642         CATCH:
643         delete pItem;
644         return null;
645 }
646
647 bool
648 HistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
649 {
650
651         //      delete pItem;
652         //      pItem = null;
653         return false;
654 }
655
656 bool
657 HistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
658 {
659         AppLog("HistoryListForm::DeleteItem");
660         result r = E_FAILURE;
661         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
662         if (pGroupItemClass == null)
663         {
664                 return false;
665         }
666
667         //      if (pGroupItemClass->__pData != null)
668         //      {
669         //              r = pGroupItemClass->__pData->RemoveAt(itemIndex);
670         //              if (IsFailed(r))
671         //              {
672         //                      return false;
673         //              }
674         //      }
675
676         delete pItem;
677         pItem = null;
678         return true;
679 }
680
681 int
682 HistoryListForm::GetGroupCount(void)
683 {
684         __isNoHistoryPresent = true;
685         CreateGroupItems();
686         if (__pGroupData != null)
687         {
688                 if (__searchHistory == false)
689                 {
690                         int count = 0;
691                         DateTime startTime;
692                         DateTime endTime;
693                         HistoryPresentationModel::GetCurrentDateTime(endTime);
694
695                         startTime.SetValue(0,0,0);
696
697                         HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
698                         if (count == 0)
699                         {
700                                 return 0;
701                         }
702                         return __pGroupData->GetCount();
703                 }
704                 else
705                 {
706                         int count = 0;
707                 //      String searchText = __pSearchBar->GetText();
708                         result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);
709                         if(count)
710                                 return 1;
711                         else
712                                 return 0;
713                 }
714         }
715         else
716         {
717                 return 0;
718         }
719 }
720
721 int
722 HistoryListForm::GetItemCount(int groupIndex)
723 {
724         result r = E_FAILURE;
725         int count = 0;
726         DateTime endTime;
727         DateTime startTime;
728         String text;
729
730         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
731         if (pGroupItemClass == null)
732         {
733                 return null;
734         }
735         if (__searchHistory == false)
736         {
737                 startTime = pGroupItemClass->GetStartTime();
738                 endTime = pGroupItemClass->GetEndTime();
739                 r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
740         }
741         else
742         {
743                 //text =  __pSearchBar->GetText();
744                 r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count,__searchText);
745                 if(count == 0)
746                 {
747                         return count;
748                 }
749         }
750         if (IsFailed(r))
751         {
752                 return 0;
753         }
754
755         ArrayList* pData = new(std::nothrow) ArrayList();
756         if (pData == null)
757         {
758                 return 0;
759         }
760         r = pData->Construct();
761
762         if (IsFailed(r))
763         {
764                 delete pData;
765                 return 0;
766         }
767
768         if (__searchHistory == false)
769         {
770                 startTime = pGroupItemClass->GetStartTime();
771                 endTime = pGroupItemClass->GetEndTime();
772                 AppLog("Starttime %ls endtime %ls",startTime.ToString().GetPointer(),endTime.ToString().GetPointer());
773                 r = HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(startTime,endTime, 0, count, *pData);
774         }
775         else
776         {
777                 //text = __pSearchBar->GetText() ;
778                 r = HistoryPresentationModel::GetInstance()->GetSearchHistory(0, count, *pData,__searchText );
779         }
780         if (IsFailed(r))
781         {
782                 delete pData;
783                 return 0;
784         }
785         pGroupItemClass->SetHistoryData(pData);
786
787
788         if (__isNoHistoryPresent == true && count == 0)
789         {
790                 __isNoHistoryPresent = true;
791                 GetFooter()->SetItemEnabled(0, false);
792         }
793         else
794         {
795                 __isNoHistoryPresent = false;
796                 GetFooter()->SetItemEnabled(0, true);
797         }
798         //       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
799         if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null)
800         {
801                 delete pData;
802                 return 0;
803         }
804         else
805         {
806                 AppLogDebug("HistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->GetHistoryData()->GetCount(),groupIndex,pGroupItemClass->GetTitleText().GetPointer());
807                 return pGroupItemClass->GetHistoryData()->GetCount();
808         }
809 }
810
811 void
812 HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
813 {
814
815         GetHeader()->SetItemSelected(1);
816 //      __previousSceneId = previousSceneId;
817         ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
818         if(pList != null)
819         {
820                 pList->GetAt(pList->GetCount()-1,__previousSceneId);
821         }
822
823         if(__pBookmarkList != null)
824         {
825                 __pBookmarkList->RemoveAll(false);
826         }
827
828         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
829
830         AppLog("HistoryListForm::OnSceneActivatedN called");
831         //GetHeader()->Invalidate(true);
832         if (__pGroupData == null)
833         {
834                 __pGroupData = new(std::nothrow) ArrayList();
835                 __pGroupData->Construct();
836         }
837         if (__pGroupedListView != null)
838         {
839                 __pGroupedListView->UpdateList();
840         }
841         if (__isNoHistoryPresent == true)
842         {
843                 GetFooter()->SetItemEnabled(0, false);
844         }
845         else
846         {
847                 GetFooter()->SetItemEnabled(0, true);
848         }
849
850         int count = 0;
851         DateTime startTime;
852         DateTime endTime;
853         HistoryPresentationModel::GetCurrentDateTime(endTime);;
854
855         startTime.SetValue(0,0,0);
856         HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
857         if (count == 0)
858         {
859                 __pSearchBar->SetShowState(false);
860                 __pSearchBar->Invalidate(true);
861         }
862         else
863         {
864                 __pSearchBar->SetShowState(true);
865                 __pSearchBar->Invalidate(true);
866         }
867
868         //      if (__isNoHistoryPresent == true)
869         //      {
870         //              //      __pGroupedListView->SetBitmapOfEmptyList(AppResource::GetInstance()->GetBitmapN(L"I01_Nocontents_Bookmarks.png"));
871         //              __pGroupedListView->UpdateList();
872         //      }
873
874         result r = GetHeader()->SetItemSelected(2);
875         if (IsFailed(r))
876         {
877                 AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));
878                 return;
879         }
880
881
882
883         Invalidate(true);
884
885 }
886
887 void
888 HistoryListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
889 {
890         AppLog("HistoryListForm::OnSceneDeactivated");
891         __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
892 }
893
894 void
895 HistoryListForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
896 {
897
898 }
899
900 void
901 HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
902 {
903         GroupItemClass* pGroupItemClass = null;
904         History* pHistory = null;
905         AppLog("int groupIndex %d, int itemIndex %d, int elementId %d, ListItemStatus status %d",groupIndex,itemIndex,elementId,status);
906         if (elementId == IDA_FORMAT_BOOKMARK)
907         {
908                 String toggledUrl = L"";
909                 AppLog("BookMarkStatusChanged ID_FORMAT_BOOKMARK");
910                 pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
911                 if (pGroupItemClass == null)
912                 {
913                         return;
914                 }
915                 pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
916                 if (pHistory == null)
917                 {
918                         return;
919                 }
920                 toggledUrl = pHistory->GetHistoryUrl();
921
922                 AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());
923
924                 bool bookmarkFound = false;
925                 BookmarkData* pBookMark = null;
926                 if(__pBookmarkList != null)
927                 {
928                         for (int i = 0; i < __pBookmarkList->GetCount(); i++)
929                         {
930                                 pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
931                                 if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
932                                 {
933                                         bookmarkFound = true;
934                                         break;
935                                 }
936                         }
937                 }
938                 if(bookmarkFound == false)
939                 {
940                         // Add the history in bookmark database
941                         result r = E_FAILURE;
942                         BookmarkData bookmark;
943
944                         String bookmarkTitle = pHistory->GetHistoryTitle();
945
946                         bookmark.SetBookmarkTitle(bookmarkTitle);
947                         bookmark.SetUrl(pHistory->GetHistoryUrl());
948                         bookmark.SetFaviconId(pHistory->GetFaviconId());
949                         bookmark.SetFavIconBuffer(*pHistory->GetFavIconBuffer());
950                         //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
951                         r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(bookmark);
952                 }
953                 else
954                 {
955                         // remove the history from bookmark database
956                         BookmarkPresentationModel::GetInstance()->DeleteBookmark(toggledUrl);
957                 }
958
959                 if(__pBookmarkList != null)
960                 {
961                         __pBookmarkList->RemoveAll(false);
962                         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
963                 }
964                 listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
965                 listView.UpdateList();
966         }
967         else
968         {
969                 pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
970                 if (pGroupItemClass == null)
971                 {
972                         return;
973                 }
974
975                 History* pHistory1 = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
976                 if (pHistory1 == null)
977                 {
978                         return;
979                 }
980                 SceneManager* pSceneManager = SceneManager::GetInstance();
981                 ArrayList *pArgList = null;
982                 result r = E_SUCCESS;
983                 pArgList = new(std::nothrow) ArrayList();
984                 if (pArgList != null)
985                 {
986                         r = pArgList->Construct();
987                         if (IsFailed(r))
988                         {
989                                 delete pArgList;
990                                 return;
991                         }
992
993                         r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
994                         r = pArgList->Add(*new(std::nothrow) String(pHistory1->GetHistoryUrl()));
995                         if (IsFailed(r))
996                         {
997                                 delete pArgList;
998                                 return;
999                         }
1000
1001
1002                 }
1003
1004                 String scneId = L"";
1005                 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(scneId);
1006
1007                 if (pSceneManager != null)
1008                 {
1009                         AppLog("pSceneManager exists");
1010                         r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(scneId), pArgList);
1011                         if(pArgList)
1012                         {
1013                                 pArgList->RemoveAll(false);
1014                                 delete pArgList;
1015                         }
1016                         if (IsFailed(r))
1017                         {
1018                                 return;
1019                         }
1020                 }
1021         }
1022
1023 }
1024
1025 void
1026 HistoryListForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
1027 {
1028
1029 }
1030
1031 void
1032 HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
1033 {
1034         result r = E_FAILURE;
1035         if (mode == SEARCH_BAR_MODE_NORMAL)
1036         {
1037                 if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
1038                 {
1039                         __pSearchListView->SetEnabled(true);
1040                 }
1041
1042                 r = __pSearchListView->SetShowState(false);
1043                 if (IsFailed(r))
1044                 {
1045                         return;
1046                 }
1047                 r = __pGroupedListView->SetShowState(true);
1048                 if (IsFailed(r))
1049                 {
1050                         return;
1051                 }
1052
1053                 __pSearchListView->SetEnabled(true);
1054                 if(__pSearchBar != null)
1055                         __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1056                 Invalidate(true);
1057                 __searchHistory = false;
1058                 r = __pGroupedListView->UpdateList();
1059                 if (__isNoHistoryPresent == true)
1060                 {
1061                         GetFooter()->SetItemEnabled(0, false);
1062                 }
1063                 else
1064                 {
1065                         GetFooter()->SetItemEnabled(0, true);
1066                 }
1067                 if(__pSearchBar != null)
1068                 {
1069                         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1070                 }
1071                 if (IsFailed(r))
1072                 {
1073                         return;
1074                 }
1075         }
1076         else
1077         {
1078
1079                 //              __pSearchListView->SetEnabled(false);
1080                 r = __pSearchListView->SetShowState(true);
1081                 if (IsFailed(r))
1082                 {
1083                         return;
1084                 }
1085                 __pSearchListView->SetEnabled(false);
1086                 r = __pSearchListView->UpdateList();
1087                 if (IsFailed(r))
1088                 {
1089                         return;
1090                 }
1091                 r = __pGroupedListView->SetShowState(false);
1092                 if (IsFailed(r))
1093                 {
1094                         return;
1095                 }
1096                 if(__pSearchBar != null)
1097                 {
1098                         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1099                 }
1100         }
1101 }
1102
1103 String
1104 HistoryListForm::GetMonth(int month)
1105 {
1106         String monthValue = L"";
1107         switch (month)
1108         {
1109         case JANUARY:
1110                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));
1111                 break;
1112         case FEBRUARY:
1113                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));
1114                 break;
1115         case MARCH:
1116                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));
1117                 break;
1118         case APRIL:
1119                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));
1120                 break;
1121         case MAY:
1122                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));
1123                 break;
1124         case JUNE:
1125                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUNE"));
1126                 break;
1127         case JULY:
1128                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));
1129                 break;
1130         case AUGUST:
1131                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_AUG"));
1132                 break;
1133         case SEPTEMBER:
1134                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));
1135                 break;
1136         case OCTOBER:
1137                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));
1138                 break;
1139         case NOVEMBER:
1140                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));
1141                 break;
1142         case DECEMBER:
1143                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));
1144                 break;
1145         default:
1146                 break;
1147         }
1148
1149
1150         return monthValue;
1151 }
1152
1153 void
1154 HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAction)
1155 {
1156         result r = E_FAILURE;
1157         if (__pSearchBar != null)
1158         {
1159                 __pSearchBar->HideKeypad();
1160         }
1161
1162         if (__pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1163         {
1164                 __pSearchListView->SetEnabled(true);
1165                 __searchHistory = true;
1166                 __searchText =__pSearchBar->GetText();
1167                 AppLog("SearchTextHistory %S errormsg %s",__searchText.GetPointer(),GetErrorMessage(GetLastResult()));
1168
1169                 r = __pGroupedListView->SetShowState(false);
1170                 if (IsFailed(r))
1171                 {
1172                         return;
1173                 }
1174                 r = __pSearchListView->SetShowState(true);
1175                 if (IsFailed(r))
1176                 {
1177                         return;
1178                 }
1179                 r= __pSearchListView->UpdateList();
1180                 if (__isNoHistoryPresent == true)
1181                 {
1182                         GetFooter()->SetItemEnabled(0, false);
1183                 }
1184                 else
1185                 {
1186                         GetFooter()->SetItemEnabled(0, true);
1187                 }
1188                 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1189
1190                 if (IsFailed(r))
1191                 {
1192                         return;
1193                 }
1194         }
1195         else
1196         {
1197                 __searchHistory = false;
1198         }
1199         Invalidate(true);
1200 }
1201
1202 void
1203 HistoryListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1204 {
1205         FloatRectangle clientRect;
1206         clientRect = GetClientAreaBoundsF();
1207         AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
1208         __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1209         __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1210         __pGroupedListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1211 //      __pGroupedListView->SetEnabled(false);
1212         Invalidate(true);
1213 }
1214
1215 void
1216 HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1217 {
1218         result r = E_FAILURE;
1219         if (__pGroupedListView != null)
1220         {
1221                 if(__pSearchBar != null &&__pSearchBar->GetShowState())
1222                         r = __pGroupedListView->SetBounds(Rectangle(0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
1223                 else if(__pSearchBar != null)
1224                         r = __pGroupedListView->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
1225                 if (IsFailed(r))
1226                 {
1227                         return;
1228                 }
1229                 __pGroupedListView->UpdateList();
1230
1231                 if (__pSearchListView != null)
1232                 {
1233                         r = __pSearchListView->SetBounds(Rectangle(0,  0, GetClientAreaBounds().width, __pGroupedListView->GetHeight()));
1234                         if (IsFailed(r))
1235                         {
1236                                 return;
1237                         }
1238
1239                         __pSearchListView->UpdateList();
1240
1241                         if(__pSearchBar != null)
1242                                 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1243                 }
1244
1245         }
1246
1247         if (__isNoHistoryPresent == true)
1248         {
1249                 GetFooter()->SetItemEnabled(0, false);
1250         }
1251         else
1252         {
1253                 GetFooter()->SetItemEnabled(0, true);
1254         }
1255 }
1256
1257 void
1258 HistoryListForm::OnKeypadWillOpen(Control& source)
1259 {
1260         GetFooter()->SetShowState(false);
1261         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1262         __pSearchListView->SetEnabled(false);
1263         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1264         Invalidate(true);
1265
1266 }
1267
1268 void
1269 HistoryListForm::OnKeypadOpened(Control& source)
1270 {
1271         // this is added because some time footer is shown when key pad is opened, do not remove
1272         GetFooter()->SetShowState(false);
1273         GetFooter()->Invalidate(true);
1274         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1275 }
1276
1277 void
1278 HistoryListForm::OnKeypadClosed(Control& source)
1279 {
1280         if(Clipboard::GetInstance()->IsPopupVisible() == true)
1281         {
1282                 return;
1283         }
1284         GetFooter()->SetShowState(true);
1285         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1286         __pSearchListView->Invalidate(false);
1287         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1288         __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1289         Invalidate(true);
1290 }
1291
1292 void
1293 HistoryListForm::CreateGroupItems()
1294 {
1295         result r = E_FAILURE;
1296         DateTime currentTime;
1297         DateTime dateTime;
1298         GroupItemClass* pGroupItemClass = null;
1299         String titleText;
1300
1301         String weeksAgo2 = L"";
1302         weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
1303
1304         String weeksAgo3 = L"";
1305         weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
1306
1307         if (__pGroupData != null)
1308         {
1309                 __pGroupData->RemoveAll(false);
1310                 delete __pGroupData;
1311                 __pGroupData = null;
1312         }
1313         __pGroupData = new(std::nothrow) ArrayList();
1314         if (__pGroupData == null)
1315         {
1316                 return;
1317         }
1318         r = __pGroupData->Construct();
1319         if (IsFailed(r))
1320         {
1321                 delete __pGroupData;
1322                 __pGroupData = null;
1323                 return;
1324         }
1325         if (__searchHistory == true)
1326         {
1327                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1328                 if (pGroupItemClass == null)
1329                 {
1330                         return;
1331                 }
1332                 titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");
1333                 pGroupItemClass->SetTitleText(titleText);
1334                 r = __pGroupData->Add(*pGroupItemClass);
1335                 if (IsFailed(r))
1336                 {
1337                         return;
1338                 }
1339         }
1340         else
1341         {
1342                 Calendar* pGregorianCalendar = null;
1343                 int dayOfWeek = 0;
1344                 int day = 0;
1345                 HistoryPresentationModel::GetCurrentDateTime(currentTime);
1346                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1347                 if (pGroupItemClass == null)
1348                 {
1349                         return;
1350                 }
1351                 titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");
1352                 pGroupItemClass->SetTitleText(titleText);
1353                 pGroupItemClass->SetEndTime(currentTime);
1354                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1355                 pGroupItemClass->SetStartTime(dateTime);
1356                 __pGroupData->Add(*pGroupItemClass);
1357
1358
1359                 pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
1360                 if ( pGregorianCalendar != NULL )
1361                 {
1362                         pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());
1363                         pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());
1364                         pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());
1365                         dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
1366                         delete pGregorianCalendar;
1367                 }
1368                 switch(dayOfWeek)
1369                 {
1370                 case SUNDAY:
1371                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1372                         if (pGroupItemClass == null)
1373                         {
1374                                 return;
1375                         }
1376                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1377                         pGroupItemClass->SetTitleText(titleText);
1378                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1379                         pGroupItemClass->SetEndTime(dateTime);
1380                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1381                         dateTime.AddDays(currentTime.GetDay() - 6 - 1);
1382                         pGroupItemClass->SetStartTime(dateTime);
1383                         __pGroupData->Add(*pGroupItemClass);
1384                         break;
1385                 case MONDAY:
1386                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1387                         if (pGroupItemClass == null)
1388                         {
1389                                 return;
1390                         }
1391                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1392                         pGroupItemClass->SetTitleText(titleText);
1393                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1394                         pGroupItemClass->SetEndTime(dateTime);
1395                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1396                         dateTime.AddDays(currentTime.GetDay() - 7 - 1);
1397                         pGroupItemClass->SetStartTime(dateTime);
1398                         __pGroupData->Add(*pGroupItemClass);
1399                         break;
1400                 case TUESDAY:
1401                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1402                         if (pGroupItemClass == null)
1403                         {
1404                                 return;
1405                         }
1406                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1407                         pGroupItemClass->SetTitleText(titleText);
1408                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1409                         pGroupItemClass->SetEndTime(dateTime);
1410                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1411                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1412                         pGroupItemClass->SetStartTime(dateTime);
1413                         __pGroupData->Add(*pGroupItemClass);
1414
1415                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1416                         if (pGroupItemClass == null)
1417                         {
1418                                 return;
1419                         }
1420                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1421                         pGroupItemClass->SetTitleText(titleText);
1422                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1423                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1424                         pGroupItemClass->SetEndTime(dateTime);
1425                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1426                         dateTime.AddDays(currentTime.GetDay() - 8 - 1);
1427                         pGroupItemClass->SetStartTime(dateTime);
1428                         __pGroupData->Add(*pGroupItemClass);
1429                         break;
1430                 case WEDNESDAY:
1431                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1432                         if (pGroupItemClass == null)
1433                         {
1434                                 return;
1435                         }
1436                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1437                         pGroupItemClass->SetTitleText(titleText);
1438                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1439                         pGroupItemClass->SetEndTime(dateTime);
1440                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1441                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1442                         pGroupItemClass->SetStartTime(dateTime);
1443                         __pGroupData->Add(*pGroupItemClass);
1444
1445                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1446                         if (pGroupItemClass == null)
1447                         {
1448                                 return;
1449                         }
1450                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1451                         pGroupItemClass->SetTitleText(titleText);
1452                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1453                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1454                         pGroupItemClass->SetEndTime(dateTime);
1455                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1456                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1457                         pGroupItemClass->SetStartTime(dateTime);
1458                         __pGroupData->Add(*pGroupItemClass);
1459
1460                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1461                         if (pGroupItemClass == null)
1462                         {
1463                                 return;
1464                         }
1465                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1466                         pGroupItemClass->SetTitleText(titleText);
1467                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1468                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1469                         pGroupItemClass->SetEndTime(dateTime);
1470                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1471                         dateTime.AddDays(currentTime.GetDay() - 9 - 1);
1472                         pGroupItemClass->SetStartTime(dateTime);
1473                         __pGroupData->Add(*pGroupItemClass);
1474                         break;
1475                 case THURSDAY:
1476                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1477                         if (pGroupItemClass == null)
1478                         {
1479                                 return;
1480                         }
1481                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1482                         pGroupItemClass->SetTitleText(titleText);
1483                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1484                         pGroupItemClass->SetEndTime(dateTime);
1485                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1486                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1487                         pGroupItemClass->SetStartTime(dateTime);
1488                         __pGroupData->Add(*pGroupItemClass);
1489
1490                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1491                         if (pGroupItemClass == null)
1492                         {
1493                                 return;
1494                         }
1495                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1496                         pGroupItemClass->SetTitleText(titleText);
1497                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1498                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1499                         pGroupItemClass->SetEndTime(dateTime);
1500                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1501                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1502                         pGroupItemClass->SetStartTime(dateTime);
1503                         __pGroupData->Add(*pGroupItemClass);
1504
1505                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1506                         if (pGroupItemClass == null)
1507                         {
1508                                 return;
1509                         }
1510                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1511                         pGroupItemClass->SetTitleText(titleText);
1512                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1513                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1514                         pGroupItemClass->SetEndTime(dateTime);
1515                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1516                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1517                         pGroupItemClass->SetStartTime(dateTime);
1518                         __pGroupData->Add(*pGroupItemClass);
1519
1520                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1521                         if (pGroupItemClass == null)
1522                         {
1523                                 return;
1524                         }
1525                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1526                         pGroupItemClass->SetTitleText(titleText);
1527                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1528                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1529                         pGroupItemClass->SetEndTime(dateTime);
1530                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1531                         dateTime.AddDays(currentTime.GetDay() - 10 - 1);
1532                         pGroupItemClass->SetStartTime(dateTime);
1533                         __pGroupData->Add(*pGroupItemClass);
1534                         break;
1535                 case FRIDAY:
1536                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1537                         if (pGroupItemClass == null)
1538                         {
1539                                 return;
1540                         }
1541                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1542                         pGroupItemClass->SetTitleText(titleText);
1543                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1544                         pGroupItemClass->SetEndTime(dateTime);
1545                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1546                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1547                         pGroupItemClass->SetStartTime(dateTime);
1548                         __pGroupData->Add(*pGroupItemClass);
1549
1550                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1551                         if (pGroupItemClass == null)
1552                         {
1553                                 return;
1554                         }
1555                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1556                         pGroupItemClass->SetTitleText(titleText);
1557                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1558                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1559                         pGroupItemClass->SetEndTime(dateTime);
1560                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1561                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1562                         pGroupItemClass->SetStartTime(dateTime);
1563                         __pGroupData->Add(*pGroupItemClass);
1564
1565                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1566                         if (pGroupItemClass == null)
1567                         {
1568                                 return;
1569                         }
1570                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1571                         pGroupItemClass->SetTitleText(titleText);
1572                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1573                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1574                         pGroupItemClass->SetEndTime(dateTime);
1575                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1576                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1577                         pGroupItemClass->SetStartTime(dateTime);
1578                         __pGroupData->Add(*pGroupItemClass);
1579
1580                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1581                         if (pGroupItemClass == null)
1582                         {
1583                                 return;
1584                         }
1585                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1586                         pGroupItemClass->SetTitleText(titleText);
1587                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1588                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1589                         pGroupItemClass->SetEndTime(dateTime);
1590                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1591                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1592                         pGroupItemClass->SetStartTime(dateTime);
1593                         __pGroupData->Add(*pGroupItemClass);
1594
1595                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1596                         if (pGroupItemClass == null)
1597                         {
1598                                 return;
1599                         }
1600                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1601                         pGroupItemClass->SetTitleText(titleText);
1602                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1603                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1604                         pGroupItemClass->SetEndTime(dateTime);
1605                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1606                         dateTime.AddDays(currentTime.GetDay() - 11 - 1);
1607                         pGroupItemClass->SetStartTime(dateTime);
1608                         __pGroupData->Add(*pGroupItemClass);
1609                         break;
1610                 case SATURDAY:
1611                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1612                         if (pGroupItemClass == null)
1613                         {
1614                                 return;
1615                         }
1616                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1617                         pGroupItemClass->SetTitleText(titleText);
1618                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1619                         pGroupItemClass->SetEndTime(dateTime);
1620                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1621                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1622                         pGroupItemClass->SetStartTime(dateTime);
1623                         __pGroupData->Add(*pGroupItemClass);
1624
1625                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1626                         if (pGroupItemClass == null)
1627                         {
1628                                 return;
1629                         }
1630                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");
1631                         pGroupItemClass->SetTitleText(titleText);
1632                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1633                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1634                         pGroupItemClass->SetEndTime(dateTime);
1635                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1636                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1637                         pGroupItemClass->SetStartTime(dateTime);
1638                         __pGroupData->Add(*pGroupItemClass);
1639
1640                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1641                         if (pGroupItemClass == null)
1642                         {
1643                                 return;
1644                         }
1645                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1646                         pGroupItemClass->SetTitleText(titleText);
1647                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1648                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1649                         pGroupItemClass->SetEndTime(dateTime);
1650                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1651                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1652                         pGroupItemClass->SetStartTime(dateTime);
1653                         __pGroupData->Add(*pGroupItemClass);
1654
1655                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1656                         if (pGroupItemClass == null)
1657                         {
1658                                 return;
1659                         }
1660                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1661                         pGroupItemClass->SetTitleText(titleText);
1662                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1663                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1664                         pGroupItemClass->SetEndTime(dateTime);
1665                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1666                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1667                         pGroupItemClass->SetStartTime(dateTime);
1668                         __pGroupData->Add(*pGroupItemClass);
1669
1670                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1671                         if (pGroupItemClass == null)
1672                         {
1673                                 return;
1674                         }
1675                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1676                         pGroupItemClass->SetTitleText(titleText);
1677                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1678                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1679                         pGroupItemClass->SetEndTime(dateTime);
1680                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1681                         dateTime.AddDays(currentTime.GetDay() - 5 - 1);
1682                         pGroupItemClass->SetStartTime(dateTime);
1683                         __pGroupData->Add(*pGroupItemClass);
1684
1685                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1686                         if (pGroupItemClass == null)
1687                         {
1688                                 return;
1689                         }
1690                         titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
1691                         pGroupItemClass->SetTitleText(titleText);
1692                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1693                         dateTime.AddDays(currentTime.GetDay() - 5 - 1);
1694                         pGroupItemClass->SetEndTime(dateTime);
1695                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1696                         dateTime.AddDays(currentTime.GetDay() - 12 - 1);
1697                         pGroupItemClass->SetStartTime(dateTime);
1698                         __pGroupData->Add(*pGroupItemClass);
1699                         break;
1700
1701                 default:
1702                         break;
1703                 }
1704                 day = currentTime.GetDay();
1705                 switch(day/7)
1706                 {
1707                 case 2:
1708                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1709                         if (pGroupItemClass == null)
1710                         {
1711                                 return;
1712                         }
1713
1714                         pGroupItemClass->SetTitleText(weeksAgo2);
1715                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1716                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1717                         pGroupItemClass->SetEndTime(dateTime);
1718                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1719                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1720                         pGroupItemClass->SetStartTime(dateTime);
1721                         __pGroupData->Add(*pGroupItemClass);
1722
1723                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1724                         {
1725                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1726                                 if (pGroupItemClass == null)
1727                                 {
1728                                         return;
1729                                 }
1730                                 String weeksAgo3 = L"";
1731                                 weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
1732                                 pGroupItemClass->SetTitleText(weeksAgo3);
1733                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1734                                 dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1735                                 pGroupItemClass->SetEndTime(dateTime);
1736                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1737                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1738                                 pGroupItemClass->SetStartTime(dateTime);
1739                                 __pGroupData->Add(*pGroupItemClass);
1740                         }
1741                         break;
1742                 case 3:
1743                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1744                         if (pGroupItemClass == null)
1745                         {
1746                                 return;
1747                         }
1748                         pGroupItemClass->SetTitleText(weeksAgo2);
1749                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1750                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1751                         pGroupItemClass->SetEndTime(dateTime);
1752                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1753                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1754                         pGroupItemClass->SetStartTime(dateTime);
1755                         __pGroupData->Add(*pGroupItemClass);
1756
1757                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1758                         if (pGroupItemClass == null)
1759                         {
1760                                 return;
1761                         }
1762
1763                         pGroupItemClass->SetTitleText(weeksAgo3);
1764                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1765                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1766                         pGroupItemClass->SetEndTime(dateTime);
1767                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1768                         dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1769                         pGroupItemClass->SetStartTime(dateTime);
1770                         __pGroupData->Add(*pGroupItemClass);
1771
1772                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1773                         {
1774                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1775                                 if (pGroupItemClass == null)
1776                                 {
1777                                         return;
1778                                 }
1779                                 titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1780                                 pGroupItemClass->SetTitleText(titleText);
1781                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1782                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1783                                 pGroupItemClass->SetEndTime(dateTime);
1784                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1785                                 //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
1786                                 pGroupItemClass->SetStartTime(dateTime);
1787                                 __pGroupData->Add(*pGroupItemClass);
1788                         }
1789                         break;
1790                 case 4:
1791                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1792                         if (pGroupItemClass == null)
1793                         {
1794                                 return;
1795                         }
1796                         pGroupItemClass->SetTitleText(weeksAgo2);
1797                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1798                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1799                         pGroupItemClass->SetEndTime(dateTime);
1800                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1801                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1802                         pGroupItemClass->SetStartTime(dateTime);
1803                         __pGroupData->Add(*pGroupItemClass);
1804
1805                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1806                         if (pGroupItemClass == null)
1807                         {
1808                                 return;
1809                         }
1810                         pGroupItemClass->SetTitleText(weeksAgo3);
1811                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1812                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1813                         pGroupItemClass->SetEndTime(dateTime);
1814                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1815                         dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1816                         pGroupItemClass->SetStartTime(dateTime);
1817                         __pGroupData->Add(*pGroupItemClass);
1818
1819                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1820                         {
1821                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1822                                 if (pGroupItemClass == null)
1823                                 {
1824                                         return;
1825                                 }
1826                                 titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1827                                 pGroupItemClass->SetTitleText(titleText);
1828                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1829                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1830                                 pGroupItemClass->SetEndTime(dateTime);
1831                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1832                                 //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
1833                                 pGroupItemClass->SetStartTime(dateTime);
1834                                 __pGroupData->Add(*pGroupItemClass);
1835                         }
1836                         break;
1837                 default:
1838                         break;
1839                 }
1840                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1841                 if (pGroupItemClass == null)
1842                 {
1843                         return;
1844                 }
1845                 titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_MONTH");
1846                 pGroupItemClass->SetTitleText(titleText);
1847                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1848                 dateTime.AddDays(-1);
1849                 pGroupItemClass->SetEndTime(dateTime);
1850                 dateTime.SetValue(currentTime.GetYear(), 1, 1);
1851                 dateTime.AddMonths(currentTime.GetMonth() - 1 - 1);
1852                 pGroupItemClass->SetStartTime(dateTime);
1853                 __pGroupData->Add(*pGroupItemClass);
1854
1855                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1856                 if (pGroupItemClass == null)
1857                 {
1858                         return;
1859                 }
1860                 titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");
1861                 pGroupItemClass->SetTitleText(titleText);
1862                 dateTime.SetValue(currentTime.GetYear(),1, 1);
1863                 dateTime.AddMonths(currentTime.GetMonth() - 2);
1864                 dateTime.AddDays(-1);
1865                 pGroupItemClass->SetEndTime(dateTime);
1866                 DateTime dateTime2;
1867                 dateTime2.SetValue(0, 0, 0);
1868                 pGroupItemClass->SetStartTime(dateTime2);
1869                 __pGroupData->Add(*pGroupItemClass);
1870         }
1871 }
1872
1873 GroupItemClass::GroupItemClass()
1874 {
1875         __pData = null;
1876 }
1877
1878 GroupItemClass&
1879 GroupItemClass::operator =(const GroupItemClass& rhs)
1880 {
1881         if (this != &rhs)
1882         {
1883                 __pData = rhs.__pData;
1884         }
1885         return *this;
1886 }
1887
1888 GroupItemClass::GroupItemClass(const GroupItemClass& groupItem)
1889 {
1890         __pData = groupItem.__pData;
1891 }
1892
1893 GroupItemClass::~GroupItemClass()
1894 {
1895         if (__pData)
1896         {
1897                 __pData->RemoveAll(true);
1898                 delete __pData;
1899         }
1900 }
1901
1902 void
1903 GroupItemClass::SetStartTime(DateTime& startTime)
1904 {
1905         __startTime = startTime;
1906 }
1907
1908 void
1909 GroupItemClass::SetEndTime(DateTime& endTime)
1910 {
1911         __endTime = endTime;
1912 }
1913
1914 void
1915 GroupItemClass::SetTitleText(String& titleText)
1916 {
1917         __titleText = titleText;
1918 }
1919
1920 void
1921 GroupItemClass::SetHistoryData(ArrayList* pData)
1922 {
1923         __pData = pData;
1924 }
1925
1926 DateTime
1927 GroupItemClass::GetStartTime(void)
1928 {
1929         return __startTime;
1930 }
1931
1932 DateTime
1933 GroupItemClass::GetEndTime(void)
1934 {
1935         return __endTime;
1936 }
1937
1938 String
1939 GroupItemClass::GetTitleText(void)
1940 {
1941         return __titleText;
1942 }
1943
1944 ArrayList*
1945 GroupItemClass::GetHistoryData(void)
1946 {
1947         return __pData;
1948 }
1949
1950 void
1951 HistoryListForm::OnSettingChanged(Tizen::Base::String& key)
1952 {
1953         if (__pGroupedListView)
1954         {
1955                 __pGroupedListView->UpdateList();
1956         }
1957 }