b91e12a614aac1219161c607747e1c684b425481
[apps/web/download-manager.git] / src / download-manager-view.cpp
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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 /**
18  * @file        download-manager-view.cpp
19  * @author      Jungki Kwak (jungki.kwak@samsung.com)
20  * @brief       UI manager class for download list view and delete view
21  */
22 #include <sstream>
23 #include <queue>
24 #include "download-manager-view.h"
25 #include "download-manager-history-db.h"
26 #include "download-manager-downloadItem.h"
27
28 static void destroy_window_cb(void *data, Evas_Object *obj, void *event);
29
30 enum {
31         DOWNLOAD_NOTIFY_SELECTED,
32         DOWNLOAD_NOTIFY_DELETED
33 };
34
35 DownloadView::DownloadView(void)
36         : eoWindow(NULL)
37         , eoBackground(NULL)
38         , eoLayout(NULL)
39         , eoNaviBar(NULL)
40         , eoNaviBarItem(NULL)
41         , eoBackBtn(NULL)
42         , eoControlBar(NULL)
43         , eoCbItemDelete(NULL)
44         , eoCbItemCancel(NULL)
45         , eoCbItemEmpty(NULL)
46         , eoBoxLayout(NULL)
47         , eoBox(NULL)
48         , eoDldList(NULL)
49         , eoPopup(NULL)
50         , eoSelectAllLayout(NULL)
51         , eoAllCheckedBox(NULL)
52         , eoNotifyInfo(NULL)
53         , eoNotifyInfoLayout(NULL)
54         , m_allChecked(EINA_FALSE)
55 #ifndef _TIZEN_PUBLIC
56         , m_sweepedItem(NULL)
57 #endif
58         , m_viewItemCount(0)
59 {
60 // FIXME Later : init private members
61         DownloadEngine &engine = DownloadEngine::getInstance();
62         engine.initEngine();
63         DateUtil &inst = DateUtil::getInstance();
64         inst.updateLocale();
65         dldGenlistGroupStyle.item_style = "grouptitle";
66         dldGenlistGroupStyle.func.text_get = getGenlistGroupLabelCB;
67         dldGenlistGroupStyle.func.content_get = NULL;
68         dldGenlistGroupStyle.func.state_get = NULL;
69         dldGenlistGroupStyle.func.del = NULL;
70
71         m_today.setType(DATETIME::DATE_TYPE_TODAY);
72         m_yesterday.setType(DATETIME::DATE_TYPE_YESTERDAY);
73         m_previousDay.setType(DATETIME::DATE_TYPE_PREVIOUS);
74 }
75
76 DownloadView::~DownloadView()
77 {
78         DP_LOG_FUNC();
79 //      DownloadEngine &engine = DownloadEngine::getInstance();
80 //      engine.deinitEngine();
81 }
82
83 Evas_Object *DownloadView::create(void)
84 {
85         Evas_Object *window = NULL;
86         window = createWindow(PACKAGE);
87         if (!window)
88                 return NULL;
89
90         createBackground(window);
91         createLayout(window);
92         setIndicator(window);
93         createView();
94
95         return window;
96 }
97
98 void DownloadView::destroy()
99 {
100         DownloadEngine &engine = DownloadEngine::getInstance();
101         engine.deinitEngine();
102 }
103
104 void DownloadView::show()
105 {
106         DP_LOG_FUNC();
107 #ifdef _SILENT_LAUNCH
108         evas_object_show(eoWindow);
109 #endif
110         elm_win_raise(eoWindow);
111         handleUpdateDateGroupType(NULL);
112 }
113
114 void DownloadView::hide()
115 {
116         DP_LOG_FUNC();
117         removePopup();
118 #ifndef _TIZEN_PUBLIC
119         cancelSweepEvent();
120 #endif
121         destroyNotifyInfo();
122         if (isGenlistEditMode()) {
123                 hideGenlistEditMode();
124         }
125 #ifdef _SILENT_LAUNCH
126         evas_object_hide(eoWindow);
127 #endif
128         elm_win_lower(eoWindow);
129 }
130
131 void DownloadView::activateWindow()
132 {
133         if (!eoWindow)
134                 create();
135
136         show();
137 }
138
139 #ifndef _TIZEN_PUBLIC
140 void DownloadView::rotateWindow(int angle)
141 {
142         if (angle >= 0)
143                 elm_win_rotation_with_resize_set(eoWindow, angle);
144 }
145 #endif
146
147 void DownloadView::showViewItem(int id, const char *title)
148 {
149         DP_LOG_FUNC();
150 }
151
152 /* This is called by AUL view mode */
153 void DownloadView::playContent(int id, const char *title)
154 {
155         DP_LOG_FUNC();
156 }
157
158 void DownloadView::setIndicator(Evas_Object *window)
159 {
160         elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
161 }
162
163 Evas_Object *DownloadView::createWindow(const char *windowName)
164 {
165         eoWindow = elm_win_add(NULL, windowName, ELM_WIN_BASIC);
166         if (eoWindow) {
167                 elm_win_title_set(eoWindow, __("IDS_BR_HEADER_DOWNLOAD_MANAGER"));
168                 elm_win_borderless_set(eoWindow, EINA_TRUE);
169                 elm_win_conformant_set(eoWindow, 1);
170                 evas_object_smart_callback_add(eoWindow, "delete,request",
171                                 destroy_window_cb,      static_cast<void*>(this));
172         }
173         return eoWindow;
174 }
175
176 Evas_Object *DownloadView::createBackground(Evas_Object *window)
177 {
178         if (!window)
179                 return NULL;
180
181         eoBackground = elm_bg_add(window);
182         if (eoBackground) {
183                 evas_object_size_hint_weight_set(eoBackground, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
184                 elm_win_resize_object_add(window, eoBackground);
185                 evas_object_show(eoBackground);
186         } else {
187                 DP_LOGE("Fail to create bg object");
188         }
189         return eoBackground;
190 }
191
192 Evas_Object *DownloadView::createLayout(Evas_Object *parent)
193 {
194         if (!parent) {
195                 DP_LOGE("Invalid Paramter");
196                 return NULL;
197         }
198
199         eoLayout = elm_layout_add(parent);
200         if (eoLayout) {
201                 if (!elm_layout_theme_set(eoLayout, "layout", "application", "default" ))
202                         DP_LOGE("Fail to set elm_layout_theme_set");
203
204                 evas_object_size_hint_weight_set(eoLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
205                 elm_win_resize_object_add(parent, eoLayout);
206
207                 edje_object_signal_emit(elm_layout_edje_get(eoLayout), "elm,state,show,indicator", "elm");
208                 evas_object_show(eoLayout);
209         } else {
210                 DP_LOGE("Fail to create layout");
211         }
212         return eoLayout;
213 }
214
215 void DownloadView::createView()
216 {
217         DP_LOG_FUNC();
218         createNaviBar();
219         createList();
220         if (m_viewItemCount < 1)
221                 showEmptyView();
222 }
223
224 void DownloadView::createNaviBar()
225 {
226         DP_LOGD_FUNC();
227         eoNaviBar = elm_naviframe_add(eoLayout);
228         elm_object_part_content_set(eoLayout, "elm.swallow.content", eoNaviBar);
229         createBackBtn();
230         createBox();
231         eoNaviBarItem = elm_naviframe_item_push(eoNaviBar,
232                 __("IDS_BR_HEADER_DOWNLOAD_MANAGER"),eoBackBtn, NULL, eoBoxLayout, NULL);
233         createControlBar();
234         evas_object_show(eoNaviBar);
235 }
236
237 void DownloadView::createBackBtn()
238 {
239         DP_LOGD_FUNC();
240         eoBackBtn = elm_button_add(eoNaviBar);
241         elm_object_style_set(eoBackBtn, "naviframe/end_btn/default");
242         evas_object_smart_callback_add(eoBackBtn, "clicked", backBtnCB,NULL);
243         evas_object_show(eoBackBtn);
244 }
245
246 void DownloadView::createControlBar()
247 {
248         DP_LOGD_FUNC();
249
250         eoControlBar = elm_toolbar_add(eoNaviBar);
251         if (eoControlBar == NULL)
252                 return;
253         elm_toolbar_shrink_mode_set(eoControlBar, ELM_TOOLBAR_SHRINK_EXPAND);
254         eoCbItemDelete = elm_toolbar_item_append(eoControlBar, NULL,
255                 S_("IDS_COM_OPT_DELETE"), cbItemDeleteCB, eoNaviBar);
256         eoCbItemEmpty = elm_toolbar_item_append(eoControlBar, NULL, NULL, NULL, NULL);
257         elm_object_item_part_content_set(eoNaviBarItem, "controlbar",
258                 eoControlBar);
259         elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
260         elm_object_item_disabled_set(eoCbItemEmpty, EINA_TRUE);
261         evas_object_show(eoControlBar);
262 }
263
264 void DownloadView::createBox()
265 {
266         DP_LOGD_FUNC();
267         eoBoxLayout = elm_layout_add(eoNaviBar);
268         elm_layout_theme_set(eoBoxLayout, "layout", "application", "noindicator");
269         evas_object_size_hint_weight_set(eoBoxLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
270
271         eoBox = elm_box_add(eoBoxLayout);
272         elm_object_part_content_set(eoBoxLayout, "elm.swallow.content", eoBox );
273
274         evas_object_show(eoBox);
275         evas_object_show(eoBoxLayout);
276 }
277
278 void DownloadView::createList()
279 {
280         //DP_LOGD_FUNC();
281         eoDldList = elm_genlist_add(eoBoxLayout);
282         DP_LOGD("create::eoDldList[%p]",eoDldList);
283 /* When using ELM_LIST_LIMIT, the window size is broken at the landscape mode */
284         evas_object_size_hint_weight_set(eoDldList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
285         evas_object_size_hint_align_set(eoDldList, EVAS_HINT_FILL, EVAS_HINT_FILL);
286         elm_genlist_homogeneous_set(eoDldList, EINA_TRUE);
287         elm_genlist_block_count_set(eoDldList,8);
288
289 #ifndef _TIZEN_PUBLIC
290         evas_object_smart_callback_add(eoDldList, "drag,start,right", sweepRightCB, NULL);
291         evas_object_smart_callback_add(eoDldList, "drag,start,left", sweepLeftCB, NULL);
292 #endif
293         elm_box_pack_end(eoBox, eoDldList);
294         evas_object_show(eoDldList);
295 }
296
297 void destroy_window_cb(void *data, Evas_Object *obj, void *event)
298 {
299         DP_LOG_FUNC();
300         elm_exit();
301 }
302
303 void DownloadView::changedRegion()
304 {
305         DateUtil &inst = DateUtil::getInstance();
306         inst.updateLocale();
307         elm_genlist_realized_items_update(eoDldList);
308 }
309
310 void DownloadView::attachViewItem(ViewItem *viewItem)
311 {
312         DP_LOG_FUNC();
313         if (m_viewItemCount < 1) {
314                 hideEmptyView();
315                 createList();
316         }
317         if (viewItem) {
318                 addViewItemToGenlist(viewItem);
319                 m_viewItemCount++;
320         }
321 }
322
323 void DownloadView::detachViewItem(ViewItem *viewItem)
324 {
325         DP_LOG("delete viewItem[%p]",viewItem);
326         if (viewItem) {
327                 delete viewItem;
328                 m_viewItemCount--;
329         }
330         if (!isGenlistEditMode() &&
331                         (m_viewItemCount < 1))
332                 showEmptyView();
333 }
334
335 void DownloadView::update()
336 {
337         Elm_Object_Item *it = NULL;
338         DP_LOG_FUNC();
339         if (!eoDldList) {
340                 DP_LOGE("download list is NULL");
341                 return;
342         }
343         it = elm_genlist_first_item_get(eoDldList);
344         while (it) {
345                 DP_LOGD("glItem[%p]",it);
346                 elm_genlist_item_update(it);
347                 it = elm_genlist_item_next_get(it);
348         }
349 }
350
351 void DownloadView::update(ViewItem *viewItem)
352 {
353         if (!viewItem)
354                 return;
355
356         DP_LOG("DownloadView::update viewItem [%p]", viewItem);
357         elm_genlist_item_update(viewItem->genlistItem());
358 }
359
360 void DownloadView::update(Elm_Object_Item *glItem)
361 {
362         if (!glItem)
363                 return;
364
365         DP_LOG("DownloadView::update glItem [%p]", glItem);
366         elm_genlist_item_update(glItem);
367 }
368
369 #ifndef _TIZEN_PUBLIC
370 ViewItem *DownloadView::findViewItemForGenlistItem(Elm_Object_Item *glItem)
371 {
372         Elm_Object_Item *it = NULL;
373         ViewItem *viewItem = NULL;
374         if (!eoDldList) {
375                 DP_LOGE("download list is NULL");
376                 return NULL;
377         }
378         it = elm_genlist_first_item_get(eoDldList);
379         while (it) {
380                 /* don't search group item */
381                 if (elm_genlist_item_select_mode_get(it) !=
382                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && it == glItem) {
383                         viewItem = (ViewItem *)elm_object_item_data_get(it);
384                         break;
385                 }
386                 it = elm_genlist_item_next_get(it);
387         }
388
389         return viewItem;
390 }
391 #endif
392
393 void DownloadView::addViewItemToGenlist(ViewItem *viewItem)
394 {
395         DP_LOG_FUNC();
396         handleUpdateDateGroupType(viewItem);
397         createGenlistItem(viewItem);
398 }
399
400 void DownloadView::createGenlistItem(ViewItem *viewItem)
401 {
402         Elm_Object_Item *glItem = NULL;
403         Elm_Object_Item *glGroupItem = NULL;
404         /* EAPI Elm_Object_Item *elm_genlist_item_prepend(
405          *      Evas_Object *obj,
406          *      const Elm_Genlist_Item_Class *itc,
407          *      const void *data,
408          *      Elm_Object_Item *parent,
409          *      Elm_Genlist_Item_Type flags,
410          *      Evas_Smart_Cb func,
411          *      const void *func_data) EINA_ARG_NONNULL(1); */
412         glGroupItem = getGenlistGroupItem(viewItem->dateGroupType());
413         DP_LOGD("group item[%p]",glGroupItem);
414         if (!glGroupItem) {
415                 DateGroup *dateGrpObj = getDateGroupObj(viewItem->dateGroupType());
416                 if (!viewItem->isFinished()) {
417                         glGroupItem = elm_genlist_item_prepend(
418                                 eoDldList,
419                                 &dldGenlistGroupStyle,
420                                 static_cast<const void*>(dateGrpObj),
421                                 NULL,
422                                 ELM_GENLIST_ITEM_GROUP,
423                                 NULL,
424                                 NULL);
425                 } else {
426                         /* Download History Item */
427                         glGroupItem = elm_genlist_item_append(
428                                 eoDldList,
429                                 &dldGenlistGroupStyle,
430                                 static_cast<const void*>(dateGrpObj),
431                                 NULL,
432                                 ELM_GENLIST_ITEM_GROUP,
433                                 NULL,
434                                 NULL);
435                 }
436                 if (!glGroupItem)
437                         DP_LOGE("Fail to add a genlist group item");
438                 else
439                         elm_genlist_item_select_mode_set(glGroupItem,
440                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
441                 setGenlistGroupItem(viewItem->dateGroupType(), glGroupItem);
442         }
443         increaseGenlistGroupCount(viewItem->dateGroupType());
444         if (!viewItem->isFinished()) {
445                 glItem = elm_genlist_item_insert_after(
446                         eoDldList,
447                         viewItem->elmGenlistStyle(),
448                         static_cast<const void*>(viewItem),
449                         glGroupItem,
450                         glGroupItem,
451                         ELM_GENLIST_ITEM_NONE,
452                         genlistClickCB,
453                         static_cast<const void*>(viewItem));
454         } else {
455                 /* Download History Item */
456                 glItem = elm_genlist_item_append(
457                         eoDldList,
458                         viewItem->elmGenlistStyle(),
459                         static_cast<const void*>(viewItem),
460                         glGroupItem,
461                         ELM_GENLIST_ITEM_NONE,
462                         genlistClickCB,
463                         static_cast<const void*>(viewItem));
464         }
465         if (!glItem)
466                 DP_LOGE("Fail to add a genlist item");
467
468         DP_LOGD("genlist groupItem[%p] item[%p] viewItem[%p]", glGroupItem, glItem, viewItem);
469         viewItem->setGenlistItem(glItem);
470         /* Move scrollbar to top.
471          * When groupItem means today group in case of addtion of download link item
472         **/
473         if (!viewItem->isFinished())
474                 elm_genlist_item_show(glGroupItem, ELM_GENLIST_ITEM_SCROLLTO_TOP);
475 }
476
477 void DownloadView::showEmptyView()
478 {
479         DP_LOGD_FUNC();
480         if (!eoEmptyNoContent) {
481                 eoEmptyNoContent = elm_layout_add(eoLayout);
482                 elm_layout_theme_set(eoEmptyNoContent, "layout", "nocontents", "text");
483                 evas_object_size_hint_weight_set(eoEmptyNoContent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484                 evas_object_size_hint_align_set(eoEmptyNoContent, EVAS_HINT_FILL, EVAS_HINT_FILL);
485                 elm_object_part_text_set(eoEmptyNoContent, "elm.text",
486                         __("IDS_DL_BODY_NO_DOWNLOADS"));
487                 evas_object_size_hint_weight_set (eoEmptyNoContent,
488                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
489
490                 if (eoDldList) {
491                         elm_box_unpack(eoBox,eoDldList);
492                         /* Detection code */
493                         DP_LOGD("del::eoDldList[%p]",eoDldList);
494                         evas_object_del(eoDldList);
495                         eoDldList = NULL;
496                 }
497                 elm_box_pack_start(eoBox, eoEmptyNoContent);
498         }
499         evas_object_show(eoEmptyNoContent);
500         elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
501 }
502
503 void DownloadView::hideEmptyView()
504 {
505         DP_LOGD_FUNC();
506         if(eoEmptyNoContent) {
507                 elm_box_unpack(eoBox, eoEmptyNoContent);
508                 evas_object_del(eoEmptyNoContent);
509                 eoEmptyNoContent = NULL;
510         }
511         elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
512 }
513
514 bool DownloadView::isGenlistEditMode()
515 {
516         return (bool)elm_genlist_decorate_mode_get(eoDldList);
517 }
518
519 #ifndef _TIZEN_PUBLIC
520 void DownloadView::cancelSweepEvent()
521 {
522         DP_LOGD_FUNC();
523         if (m_sweepedItem) {
524                 m_sweepedItem->sweepLeft();
525                 m_sweepedItem = NULL;
526         }
527 }
528 #endif
529
530 void DownloadView::createSelectAllLayout()
531 {
532         eoSelectAllLayout = elm_layout_add(eoBox);
533         elm_layout_theme_set(eoSelectAllLayout, "genlist", "item",
534                 "select_all/default");
535         evas_object_size_hint_weight_set(eoSelectAllLayout, EVAS_HINT_EXPAND,
536                 EVAS_HINT_FILL);
537         evas_object_size_hint_align_set(eoSelectAllLayout, EVAS_HINT_FILL,
538                 EVAS_HINT_FILL);
539         evas_object_event_callback_add(eoSelectAllLayout, EVAS_CALLBACK_MOUSE_DOWN,
540                 selectAllClickedCB, NULL);
541         eoAllCheckedBox = elm_check_add(eoSelectAllLayout);
542         elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
543         evas_object_smart_callback_add(eoAllCheckedBox, "changed",
544                 selectAllChangedCB, NULL);
545         evas_object_propagate_events_set(eoAllCheckedBox, EINA_FALSE);
546         elm_object_part_content_set(eoSelectAllLayout, "elm.icon", eoAllCheckedBox);
547         elm_object_text_set(eoSelectAllLayout, S_("IDS_COM_BODY_SELECT_ALL"));
548         elm_box_pack_start(eoBox, eoSelectAllLayout);
549         evas_object_show(eoSelectAllLayout);
550         m_allChecked = EINA_FALSE;
551 }
552
553 void DownloadView::changeAllCheckedValue()
554 {
555         m_allChecked = !m_allChecked;
556         elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
557         handleChangedAllCheckedState();
558 }
559
560 void DownloadView::destroyCheckedItem()
561 {
562         Eina_List *list = NULL;
563         Elm_Object_Item *it = NULL;
564         ViewItem *item = NULL;
565         int checkedCount = 0;
566         queue <unsigned int> deleteQueue;
567
568         DP_LOGD_FUNC();
569
570         it = elm_genlist_first_item_get(eoDldList);
571
572         while (it) {
573                 item = (ViewItem *)elm_object_item_data_get(it);
574                 /* elm_genlist_item_select_mode_get is needed to check group item */
575                 if (elm_genlist_item_select_mode_get(it) !=
576                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY &&
577                                 item && item->checkedValue()) {
578                         list = eina_list_append(list, it);
579                 }
580                 it = elm_genlist_item_next_get(it);
581         }
582
583         if (!list) {
584                 DP_LOGD("There is no delete item");
585                 return;
586         }
587
588         checkedCount = eina_list_count(list);
589         if (checkedCount < 1)
590                 return;
591         DP_LOGD("checkedCount[%d]", checkedCount);
592
593         for (int i = 0; i < checkedCount; i++)
594         {
595                 it = (Elm_Object_Item *)eina_list_data_get(list);
596                 if (it)
597                         item = (ViewItem *)elm_object_item_data_get(it);
598                 else
599                         DP_LOGE("genlist item is null");
600                 list = eina_list_next(list);
601                 if (item) {
602                         deleteQueue.push(item->historyId());
603                         item->destroy();
604                 } else {
605                         DP_LOGE("viewItem is null");
606                 }
607         }
608         if (list)
609                 eina_list_free(list);
610
611         DownloadHistoryDB::deleteMultipleItem(deleteQueue);
612         showNotifyInfo(DOWNLOAD_NOTIFY_DELETED, checkedCount);
613         hideGenlistEditMode();
614 }
615
616 void DownloadView::showGenlistEditMode()
617 {
618         DP_LOG_FUNC();
619 #ifndef _TIZEN_PUBLIC
620         cancelSweepEvent();
621 #endif
622         /* Initialize notify info widget */
623         destroyNotifyInfo();
624         elm_object_item_text_set(eoNaviBarItem, S_("IDS_COM_OPT_DELETE"));
625         /* Change layoutbackground color to edit mode color */
626         elm_object_style_set(eoBackground, "edit_mode");
627         /* Disable the back button of control bar */
628         elm_object_item_part_content_unset(eoNaviBarItem, "prev_btn");
629         destroyEvasObj(eoBackBtn);
630
631         if (eoCbItemEmpty)
632                 elm_object_item_del(eoCbItemEmpty);
633         eoCbItemCancel = elm_toolbar_item_append(eoControlBar, NULL,
634                 S_("IDS_COM_SK_CANCEL"), cbItemCancelCB, eoNaviBar);
635
636         /* Append 'Select All' layout */
637         createSelectAllLayout();
638         /* Set reorder end edit mode */
639         elm_genlist_reorder_mode_set(eoDldList, EINA_TRUE);
640         elm_genlist_decorate_mode_set(eoDldList, EINA_TRUE);
641         /* This means even if the ouside of checked box is selected,
642            it is same to click a check box. */
643         elm_genlist_select_mode_set(eoDldList, ELM_OBJECT_SELECT_MODE_ALWAYS);
644
645         Elm_Object_Item *it = NULL;
646         ViewItem *viewItem = NULL;
647         it = elm_genlist_first_item_get(eoDldList);
648         while (it) {
649                 viewItem = (ViewItem *)elm_object_item_data_get(it);
650                 if (elm_genlist_item_select_mode_get(it) !=
651                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY &&
652                                 viewItem && !(viewItem->isFinished()))
653                         elm_object_item_disabled_set(it, EINA_TRUE);
654                 it = elm_genlist_item_next_get(it);
655         }
656         elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
657 }
658
659 void DownloadView::hideGenlistEditMode()
660 {
661         DP_LOG_FUNC();
662
663         elm_object_item_text_set(eoNaviBarItem, __("IDS_BR_HEADER_DOWNLOAD_MANAGER"));
664         elm_object_style_set(eoBackground, "default");
665
666         /* Recreate back button */
667         createBackBtn();
668         elm_object_item_part_content_set(eoNaviBarItem, "prev_btn", eoBackBtn);
669
670         if (eoCbItemCancel) {
671                 elm_object_item_del(eoCbItemCancel);
672                 eoCbItemCancel = NULL;
673         }
674         eoCbItemEmpty = elm_toolbar_item_append(eoControlBar, NULL, NULL, NULL, NULL);
675         elm_object_item_disabled_set(eoCbItemEmpty, EINA_TRUE);
676
677         elm_box_unpack(eoBox, eoSelectAllLayout);
678
679         destroyEvasObj(eoAllCheckedBox);
680         destroyEvasObj(eoSelectAllLayout);
681
682         elm_genlist_reorder_mode_set(eoDldList, EINA_FALSE);
683         elm_genlist_decorate_mode_set(eoDldList, EINA_FALSE);
684         elm_genlist_select_mode_set(eoDldList, ELM_OBJECT_SELECT_MODE_DEFAULT);
685
686         Elm_Object_Item *it = NULL;
687         ViewItem *viewItem = NULL;
688         it = elm_genlist_first_item_get(eoDldList);
689         while (it) {
690                 viewItem = (ViewItem *)elm_object_item_data_get(it);
691                 if (elm_genlist_item_select_mode_get(it) !=
692                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
693                         if (elm_object_item_disabled_get(it))
694                                 elm_object_item_disabled_set(it, EINA_FALSE);
695                         viewItem->setCheckedValue(EINA_FALSE);
696                         viewItem->setCheckedBtn(NULL);
697                 }
698                 it = elm_genlist_item_next_get(it);
699         }
700
701         m_allChecked = EINA_FALSE;
702
703         if (m_viewItemCount < 1) {
704                 elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
705                 showEmptyView();
706         } else
707                 elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
708 }
709
710 void DownloadView::handleChangedAllCheckedState()
711 {
712         int checkedCount = 0;
713         Elm_Object_Item *it = NULL;
714         ViewItem *viewItem = NULL;
715         it = elm_genlist_first_item_get(eoDldList);
716         while (it) {
717                 viewItem = (ViewItem *)elm_object_item_data_get(it);
718                 if (elm_genlist_item_select_mode_get(it) !=
719                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
720                         if (viewItem->isFinished()) {
721                                 viewItem->setCheckedValue(m_allChecked);
722                                 viewItem->updateCheckedBtn();
723                                 checkedCount++;
724                         }
725                 }
726                 it = elm_genlist_item_next_get(it);
727         }
728
729         if (m_allChecked && checkedCount > 0) {
730                 elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
731                 showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, checkedCount);
732         } else {
733                 elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
734                 showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, 0);
735         }
736 }
737
738 void DownloadView::handleCheckedState()
739 {
740         int checkedCount = 0;
741         int deleteAbleTotalCount = 0;
742
743         DP_LOGD_FUNC();
744
745         Elm_Object_Item *it = NULL;
746         ViewItem *viewItem = NULL;
747         it = elm_genlist_first_item_get(eoDldList);
748         while (it) {
749                 viewItem = (ViewItem *)elm_object_item_data_get(it);
750                 if (elm_genlist_item_select_mode_get(it) !=
751                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
752                         if (viewItem->checkedValue())
753                                 checkedCount++;
754                         if (viewItem->isFinished())
755                                 deleteAbleTotalCount++;
756                 }
757                 it = elm_genlist_item_next_get(it);
758         }
759
760         if (checkedCount == deleteAbleTotalCount)
761                 m_allChecked = EINA_TRUE;
762         else
763                 m_allChecked = EINA_FALSE;
764         elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
765
766         if (checkedCount == 0) {
767                 elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
768                 destroyNotifyInfo();
769         } else
770                 elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
771         showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, checkedCount);
772 }
773 void DownloadView::createNotifyInfo()
774 {
775         DP_LOGD_FUNC();
776         eoNotifyInfo = elm_notify_add(eoBoxLayout);
777         elm_notify_orient_set(eoNotifyInfo, ELM_NOTIFY_ORIENT_BOTTOM);
778         evas_object_size_hint_weight_set(eoNotifyInfo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
779         evas_object_size_hint_align_set(eoNotifyInfo, EVAS_HINT_FILL, EVAS_HINT_FILL);
780         evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_SHOW, showNotifyInfoCB, eoLayout);
781         evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_HIDE, hideNotifyInfoCB, eoLayout);
782         eoNotifyInfoLayout = elm_layout_add(eoNotifyInfo);
783         elm_object_content_set(eoNotifyInfo, eoNotifyInfoLayout);
784 }
785
786 void DownloadView::showNotifyInfo(int type, int selectedCount)
787 {
788 #ifndef _TIZEN_PUBLIC
789         int angle = 0;
790 #endif
791         string buf;
792         DP_LOGD_FUNC();
793
794 #ifndef _TIZEN_PUBLIC
795         angle = elm_win_rotation_get(eoWindow);
796 #endif
797
798         if (selectedCount == 0) {
799                 destroyNotifyInfo();
800                 return;
801         }
802
803         if (!eoNotifyInfo)
804                 createNotifyInfo();
805
806 #ifndef _TIZEN_PUBLIC
807         if (angle == 0 || angle == 180)
808                 elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
809                         "vertical/bottom_12");
810         else
811                 elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
812                         "horizontal/bottom_12");
813 #else
814         elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
815                 "vertical/bottom_12");
816 #endif
817         buf.append(" ");
818         if (type == DOWNLOAD_NOTIFY_SELECTED) {
819                 stringstream countStr;
820                 countStr << selectedCount;
821                 buf = S_("IDS_COM_BODY_SELECTED");
822                 buf.append(" (");
823                 buf.append(countStr.str());
824                 buf.append(")");
825         } else if (type == DOWNLOAD_NOTIFY_DELETED) {
826                 buf = S_("IDS_COM_POP_DELETED");
827                 elm_notify_timeout_set(eoNotifyInfo, 3);
828         }
829         edje_object_part_text_set(_EDJ(eoNotifyInfoLayout), "elm.text", buf.c_str());
830         evas_object_show(eoNotifyInfo);
831 }
832
833 void DownloadView::destroyNotifyInfo()
834 {
835         DP_LOGD_FUNC();
836         destroyEvasObj(eoNotifyInfoLayout);
837         destroyEvasObj(eoNotifyInfo);
838         eoNotifyInfoLayout = NULL;
839         eoNotifyInfo = NULL;
840 }
841
842 /* Static callback function */
843 void DownloadView::showNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj,
844         void *event)
845 {
846         Evas_Object *layout = (Evas_Object *)data;
847         if (!data) {
848                 DP_LOGE("data is NULL");
849                 return;
850         }
851         edje_object_signal_emit(_EDJ(layout), "elm,layout,content,bottom_padding",
852                 "layout");
853 }
854
855 void DownloadView::hideNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj,
856         void *event)
857 {
858         Evas_Object *layout = (Evas_Object *)data;
859         if (!data) {
860                 DP_LOGE("data is NULL");
861                 return;
862         }
863         edje_object_signal_emit(_EDJ(layout), "elm,layout,content,default", "layout");
864 }
865
866 void DownloadView::selectAllClickedCB(void *data, Evas *evas, Evas_Object *obj,
867         void *event_info)
868 {
869         DownloadView &view = DownloadView::getInstance();
870         DP_LOGD_FUNC();
871         view.changeAllCheckedValue();
872 }
873
874 void DownloadView::selectAllChangedCB(void *data, Evas_Object *obj,
875         void *event_info)
876 {
877         DownloadView &view = DownloadView::getInstance();
878         DP_LOGD_FUNC();
879         view.handleChangedAllCheckedState();
880 }
881
882 #ifndef _TIZEN_PUBLIC
883 void DownloadView::sweepRightCB(void *data, Evas_Object *obj, void *event_info)
884 {
885         DownloadView& view = DownloadView::getInstance();
886         DP_LOGD_FUNC();
887         if (!obj || !event_info) {
888                 DP_LOGE("obj or event_info is NULL");
889                 return;
890         }
891         if (!elm_genlist_decorate_mode_get(obj)) {
892                 Elm_Object_Item *glItem = (Elm_Object_Item *)event_info;
893                 ViewItem *viewItem = view.findViewItemForGenlistItem(glItem);
894                 if (viewItem) {
895                         if (viewItem->isFinished()) {
896                                 if (view.sweepedItem())
897                                         view.sweepedItem()->sweepLeft();
898                                 viewItem->sweepRight();
899                                 view.setSweepedItem(viewItem);
900                         }
901                 } else {
902                         DP_LOGE("Fail to find view item at sweep mode");
903                 }
904         } else
905                 DP_LOGD("Unable to sweep right");
906 }
907
908 void DownloadView::sweepLeftCB(void *data, Evas_Object *obj, void *event_info)
909 {
910         DownloadView& view = DownloadView::getInstance();
911         DP_LOGD_FUNC();
912         if (!obj || !event_info) {
913                 DP_LOGE("obj or event_info is NULL");
914                 return;
915         }
916
917         if (!elm_genlist_decorate_mode_get(obj)) {
918                 Elm_Object_Item *glItem = (Elm_Object_Item *)event_info;
919                 ViewItem *viewItem = view.findViewItemForGenlistItem(glItem);
920                 if (viewItem) {
921                         if (viewItem->isFinished()) {
922                                 viewItem->sweepLeft();
923                                 view.setSweepedItem(NULL);
924                         }
925                 } else {
926                         DP_LOGE("Fail to find view item at sweep mode");
927                 }
928         } else
929                 DP_LOGD("Unable to sweep left");
930 }
931 #endif
932
933 void DownloadView::backBtnCB(void *data, Evas_Object *obj, void *event_info)
934 {
935         DownloadView& view = DownloadView::getInstance();
936         view.hide();
937 }
938
939 void DownloadView::cbItemDeleteCB(void *data, Evas_Object *obj, void *event_info)
940 {
941
942         DownloadView& view = DownloadView::getInstance();
943         if (!view.isGenlistEditMode())
944                 view.showGenlistEditMode();
945         else
946                 view.destroyCheckedItem();
947 }
948
949 void DownloadView::cbItemCancelCB(void *data, Evas_Object *obj, void *event_info)
950 {
951         DownloadView& view = DownloadView::getInstance();
952         view.destroyNotifyInfo();
953         view.hideGenlistEditMode();
954 }
955
956 void DownloadView::genlistClickCB(void *data, Evas_Object *obj, void *event_info)
957 {
958         ViewItem *item = reinterpret_cast<ViewItem *>(data);
959         DP_LOGD_FUNC();
960         if (!data) {
961                 DP_LOGE("data is NULL");
962                 return;
963         }
964         item->clickedGenlistItem();
965 }
966
967 void DownloadView::cancelClickCB(void *data, Evas_Object *obj, void *event_info)
968 {
969         ViewItem *item = NULL;
970
971         DP_LOGD_FUNC();
972
973         if (!data) {
974                 DP_LOGE("data is NULL");
975                 return;
976         }
977         item = reinterpret_cast<ViewItem *>(data);
978         item->requestCancel();
979
980 }
981
982 void DownloadView::showErrPopup(string &desc)
983 {
984         removePopup();
985
986         eoPopup = elm_popup_add(eoWindow);
987         evas_object_size_hint_weight_set(eoPopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
988         elm_object_text_set(eoPopup, desc.c_str());
989         elm_popup_timeout_set(eoPopup, 2);
990         evas_object_smart_callback_add(eoPopup, "response", errPopupResponseCB, NULL);
991         evas_object_show(eoPopup);
992 }
993
994 void DownloadView::errPopupResponseCB(void *data, Evas_Object *obj, void *event_info)
995 {
996         DP_LOGD_FUNC();
997         DownloadView& view = DownloadView::getInstance();
998         view.removePopup();
999 }
1000
1001 void DownloadView::removePopup()
1002 {
1003         DP_LOGD_FUNC();
1004         destroyEvasObj(eoPopup);
1005 }
1006
1007 DateGroup *DownloadView::getDateGroupObj(int type)
1008 {
1009         DateGroup *obj = NULL;
1010         switch (type) {
1011         case DATETIME::DATE_TYPE_LATER:
1012         case DATETIME::DATE_TYPE_TODAY:
1013                 obj = &m_today;
1014                 break;
1015         case DATETIME::DATE_TYPE_YESTERDAY:
1016                 obj = &m_yesterday;
1017                 break;
1018         case DATETIME::DATE_TYPE_PREVIOUS:
1019                 obj = &m_previousDay;
1020                 break;
1021         default:
1022                 obj = NULL;
1023                 DP_LOGE("Cannot enter here");
1024                 break;
1025         }
1026         return obj;
1027 }
1028
1029 Elm_Object_Item *DownloadView::getGenlistGroupItem(int type)
1030 {
1031         DateGroup *obj = getDateGroupObj(type);
1032         if (!obj)
1033                 return NULL;
1034         return obj->glGroupItem();
1035 }
1036
1037 void DownloadView::setGenlistGroupItem(int type, Elm_Object_Item *item)
1038 {
1039         DateGroup *obj = getDateGroupObj(type);
1040         if (!obj)
1041                 return;
1042         obj->setGlGroupItem(item);
1043 }
1044
1045 void DownloadView::increaseGenlistGroupCount(int type)
1046 {
1047         DateGroup *obj = getDateGroupObj(type);
1048         if (!obj)
1049                 return;
1050         if (type == DATETIME::DATE_TYPE_TODAY || type == DATETIME::DATE_TYPE_LATER) {
1051                 if (m_today.getCount() < 1) {
1052                         DateUtil &inst = DateUtil::getInstance();
1053                         inst.setTodayStandardTime();
1054                 }
1055         }
1056         obj->increaseCount();
1057         DP_LOGD("increased count[%d]",obj->getCount());
1058 }
1059
1060 int DownloadView::getGenlistGroupCount(int type)
1061 {
1062         DateGroup *obj = getDateGroupObj(type);
1063         if (!obj)
1064                 return 0;
1065         DP_LOGD("Group count[%d]",obj->getCount());
1066         return obj->getCount();
1067 }
1068
1069 void DownloadView::handleGenlistGroupItem(int type)
1070 {
1071         DateGroup *obj = getDateGroupObj(type);
1072         if (!obj)
1073                 return;
1074         obj->decreaseCount();
1075         DP_LOGD("count[%d]type[%d]",obj->getCount(),type);
1076         if (obj->getCount() < 1) {
1077                 //DP_LOGD("Group Item[%p][%d]", obj->glGroupItem(),type);
1078                 elm_object_item_del(obj->glGroupItem());
1079                 obj->setGlGroupItem(NULL);
1080         }
1081 }
1082
1083 void DownloadView::handleUpdateDateGroupType(ViewItem *viewItem)
1084 {
1085         int diffDays = 0;
1086         DateUtil &inst = DateUtil::getInstance();
1087         DP_LOGD_FUNC();
1088         diffDays = inst.getDiffDaysFromToday();
1089         if (viewItem) {
1090         /* Update a view item which is added now
1091          * This should be only called when attaching item
1092         **/
1093                 viewItem->extractDateGroupType();
1094         } else if (diffDays != 0) {
1095         /* FIXME later
1096          * Now, it is recreated download items and group items.
1097          * Consider to move only group item later.
1098          * This should be only called from show() function
1099         **/
1100 /* FIXME later
1101  * Another problem is happend becuase eina list is used repacing with vector */
1102 #if 0
1103                 cleanGenlistData();
1104                 Elm_Object_Item *it = NULL;
1105                 ViewItem *viewItem = NULL;
1106                 it = elm_genlist_first_item_get(eoDldList);
1107                 while (it) {
1108                         viewItem = (ViewItem *)elm_object_item_data_get(it);
1109                         if (!viewItem || elm_genlist_item_select_mode_get(it) !=
1110                                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
1111                                 continue;
1112                         viewItem->extractDateGroupType();
1113                         createGenlistItem(viewItem);
1114                         it = elm_genlist_item_next_get(it);
1115                 }
1116 #endif
1117         }
1118         inst.setTodayStandardTime();
1119 }
1120
1121 void DownloadView::moveRetryItem(ViewItem *viewItem)
1122 {
1123         Elm_Object_Item *todayGroupItem = NULL;
1124         Elm_Object_Item *firstItem = NULL;
1125         DP_LOGD_FUNC();
1126         if (!viewItem) {
1127                 DP_LOGE("view item is NULL");
1128                 return;
1129         }
1130         firstItem = elm_genlist_first_item_get(eoDldList);
1131         if (firstItem) {
1132                 DP_LOGD("groupItem[%p] viewItem[%p]", firstItem, viewItem);
1133                 /* This is group item */
1134                 if (elm_genlist_item_select_mode_get(firstItem) ==
1135                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1136                         /* The top item is the item after group item */
1137                         firstItem = elm_genlist_item_next_get(firstItem);
1138                         DP_LOGD("firstItem[%p], present item[%p]", firstItem, viewItem->genlistItem());
1139                         if (firstItem == viewItem->genlistItem()) {
1140                                 DP_LOGD("This is already top item. Don't need to move");
1141                                 return;
1142                         }
1143                 }
1144         }
1145         elm_object_item_del(viewItem->genlistItem());
1146         viewItem->setGenlistItem(NULL);
1147         handleGenlistGroupItem(viewItem->dateGroupType());
1148         todayGroupItem = getGenlistGroupItem(DATETIME::DATE_TYPE_TODAY);
1149         if (!todayGroupItem) {
1150                 DateGroup *dateGrpObj = getDateGroupObj(DATETIME::DATE_TYPE_TODAY);
1151                 todayGroupItem = elm_genlist_item_prepend(
1152                                 eoDldList,
1153                                 &dldGenlistGroupStyle,
1154                                 static_cast<const void*>(dateGrpObj),
1155                                 NULL,
1156                                 ELM_GENLIST_ITEM_GROUP,
1157                                 NULL,
1158                                 NULL);
1159                 setGenlistGroupItem(DATETIME::DATE_TYPE_TODAY, todayGroupItem);
1160                 if (!todayGroupItem)
1161                         DP_LOGE("Fail to add a genlist group item");
1162                 else
1163                         elm_genlist_item_select_mode_set(todayGroupItem,
1164                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1165         }
1166         increaseGenlistGroupCount(DATETIME::DATE_TYPE_TODAY);
1167         Elm_Object_Item *glItem = elm_genlist_item_insert_after(
1168                         eoDldList,
1169                         viewItem->elmGenlistStyle(),
1170                         static_cast<const void*>(viewItem),
1171                         todayGroupItem,
1172                         todayGroupItem,
1173                         ELM_GENLIST_ITEM_NONE,
1174                         genlistClickCB,
1175                         static_cast<const void*>(viewItem));
1176         if (!glItem)
1177                 DP_LOGE("Fail to add a genlist item");
1178         DP_LOGD("genlist groupItem[%p] item[%p] viewItem[%p]", todayGroupItem,
1179                 glItem, viewItem);
1180         viewItem->setGenlistItem(glItem);
1181         elm_genlist_item_show(todayGroupItem, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1182         viewItem->extractDateGroupType();
1183 }
1184
1185 char *DownloadView::getGenlistGroupLabel(void *data, Evas_Object *obj, const char *part)
1186 {
1187         DateGroup *dateGrp = static_cast<DateGroup *>(data);
1188
1189         if(!data || !obj || !part)
1190                 return NULL;
1191
1192         DP_LOGD("ViewItem::getListGroupLabel:part[%s] groupDateType[%d] obj[%p]", part, dateGrp->getType(), obj);
1193         if (strncmp(part, "elm.text", strlen("elm.text")) == 0) {
1194                 DateUtil &inst = DateUtil::getInstance();
1195                 string msg;
1196                 string outBuf;
1197                 double udateTime = 0;
1198                 switch (dateGrp->getType()) {
1199                 case DATETIME::DATE_TYPE_PREVIOUS:
1200                         msg = S_("IDS_COM_BODY_PREVIOUS_DAYS");
1201                         break;
1202                 case DATETIME::DATE_TYPE_YESTERDAY:
1203                         udateTime = inst.yesterdayTime()*1000;
1204                         msg = S_("IDS_COM_BODY_YESTERDAY");
1205                         msg += " (";
1206                         inst.getDateStr(LOCALE_STYLE::FULL_DATE, udateTime, outBuf);
1207                         msg += outBuf;
1208                         msg += ")";
1209                         break;
1210                 case DATETIME::DATE_TYPE_LATER:
1211                 case DATETIME::DATE_TYPE_TODAY:
1212                         udateTime = inst.nowTime()*1000;
1213                         msg = S_("IDS_COM_BODY_TODAY");
1214                         msg += " (";
1215                         inst.getDateStr(LOCALE_STYLE::FULL_DATE, udateTime, outBuf);
1216                         msg += outBuf;
1217                         msg += ")";
1218                         break;
1219                 default :
1220                         DP_LOGE("Cannot enter here");
1221                         return NULL;
1222                 }
1223                 return strdup(msg.c_str());
1224         }
1225         return NULL;
1226 }
1227
1228 char *DownloadView::getGenlistGroupLabelCB(void *data, Evas_Object *obj, const char *part)
1229 {
1230 //      DP_LOGD_FUNC();
1231         if(!data || !obj || !part)
1232                 return NULL;
1233
1234         DownloadView &view = DownloadView::getInstance();
1235         return view.getGenlistGroupLabel(data, obj, part);
1236 }
1237
1238 void DownloadView::cleanGenlistData()
1239 {
1240         Elm_Object_Item *grpItem = NULL;
1241         DP_LOGD_FUNC();
1242         grpItem = m_today.glGroupItem();
1243         if (grpItem)
1244                 elm_object_item_del(grpItem);
1245         m_today.initData();
1246         grpItem = m_yesterday.glGroupItem();
1247         if (grpItem)
1248                 elm_object_item_del(grpItem);
1249         m_yesterday.initData();
1250         grpItem = m_previousDay.glGroupItem();
1251         if (grpItem)
1252                 elm_object_item_del(grpItem);
1253         m_previousDay.initData();
1254         elm_genlist_clear(eoDldList);
1255 }
1256