2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
17 #include "browser-add-to-bookmark-view.h"
18 #include "browser-view.h"
19 #include "browser-history-layout.h"
21 Date::Date() : day(0), month(0), year(0) {}
23 Date::Date(Date &date)
26 this->month = date.month;
27 this->year = date.year;
30 void Date::operator=(Date &date)
33 this->month = date.month;
34 this->year = date.year;
37 bool Date::operator==(Date &date)
39 return (this->day == date.day && this->month == date.month && this->year == date.year);
42 bool Date::operator!=(Date &date)
44 return (this->day != date.day || this->month != date.month || this->year != date.year);
47 Browser_History_Layout::Browser_History_Layout(void)
48 : m_history_genlist(NULL)
49 ,m_edit_mode_select_all_layout(NULL)
50 ,m_edit_mode_select_all_check_button(NULL)
52 ,m_no_history_label(NULL)
53 ,m_processing_popup_timer(NULL)
56 ,m_total_item_count(0)
57 ,m_processing_popup(NULL)
58 ,m_processing_popup_layout(NULL)
59 ,m_processing_progress_bar(NULL)
60 ,m_select_all_check_value(EINA_FALSE)
61 ,m_searchbar_layout(NULL)
62 ,m_searched_history_genlist(NULL)
63 ,m_no_content_search_result(NULL)
65 ,m_delete_confirm_popup(NULL)
67 BROWSER_LOGD("[%s]", __func__);
70 Browser_History_Layout::~Browser_History_Layout(void)
72 BROWSER_LOGD("[%s]", __func__);
75 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
76 if (m_history_list[i])
77 delete m_history_list[i];
79 m_history_list.clear();
81 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
82 if (m_history_date_label_list[i])
83 free(m_history_date_label_list[i]);
85 m_history_date_label_list.clear();
87 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
88 if (m_searched_history_date_label_list[i])
89 free(m_searched_history_date_label_list[i]);
91 m_searched_history_date_label_list.clear();
93 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
94 if (m_searched_history_item_list[i])
95 delete m_searched_history_item_list[i];
97 m_searched_history_item_list.clear();
99 if (m_delete_confirm_popup)
100 evas_object_del(m_delete_confirm_popup);
103 Eina_Bool Browser_History_Layout::init(void)
105 BROWSER_LOGD("[%s]", __func__);
106 return _create_main_layout();
109 Eina_Bool Browser_History_Layout::_show_searched_history(const char *search_text)
111 BROWSER_LOGD("search_text = [%s]", search_text);
113 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
114 if (m_searched_history_item_list[i])
115 delete m_searched_history_item_list[i];
117 m_searched_history_item_list.clear();
119 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
120 if (m_searched_history_date_label_list[i])
121 free(m_searched_history_date_label_list[i]);
123 m_searched_history_date_label_list.clear();
125 if (!search_text || !strlen(search_text)) {
126 if (m_searched_history_genlist || m_no_content_search_result) {
127 elm_box_unpack_all(m_content_box);
128 elm_box_pack_start(m_content_box, m_history_genlist);
129 evas_object_show(m_history_genlist);
131 if (m_searched_history_genlist) {
132 evas_object_del(m_searched_history_genlist);
133 m_searched_history_genlist = NULL;
136 if (m_no_content_search_result) {
137 evas_object_del(m_no_content_search_result);
138 m_no_content_search_result = NULL;
141 if (m_history_list.size() == 0) {
142 if (m_no_history_label) {
143 elm_box_unpack_all(m_content_box);
144 elm_box_pack_start(m_content_box, m_no_history_label);
152 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
154 Browser_History_DB::history_item *item = NULL;
155 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
156 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
157 if (item->url.find(search_text) != string::npos || item->title.find(search_text) != string::npos) {
158 Browser_History_DB::history_item *searched_item = NULL;
159 searched_item = new(nothrow) Browser_History_DB::history_item;
160 searched_item->id = item->id;
161 searched_item->url = item->url;
162 searched_item->title = item->title;
163 searched_item->date = item->date;
164 searched_item->is_delete = item->is_delete;
165 searched_item->user_data = item->user_data;
166 m_searched_history_item_list.push_back(searched_item);
169 it = elm_genlist_item_next_get(it);
172 if (m_searched_history_item_list.size()) {
173 if (m_no_content_search_result) {
174 evas_object_del(m_no_content_search_result);
175 m_no_content_search_result = NULL;
178 if (!m_searched_history_genlist) {
179 m_searched_history_genlist = _create_history_genlist();
180 if (!m_searched_history_genlist) {
181 BROWSER_LOGE("_create_history_genlist failed");
186 elm_genlist_clear(m_searched_history_genlist);
190 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++) {
191 sscanf(m_searched_history_item_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
192 m_searched_history_item_list[i]->user_data = (void *)this;
193 if (last_date != date) {
195 char *labe_item = strdup(m_searched_history_item_list[i]->date.c_str());
197 BROWSER_LOGE("strdup failed");
200 m_searched_history_date_label_list.push_back(labe_item);
201 it = elm_genlist_item_append(m_searched_history_genlist, &m_history_group_title_class,
202 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
204 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
206 elm_genlist_item_append(m_searched_history_genlist, &m_history_genlist_item_class,
207 m_searched_history_item_list[i], it, ELM_GENLIST_ITEM_NONE,
208 __history_item_clicked_cb, this);
211 elm_box_unpack_all(m_content_box);
212 evas_object_hide(m_history_genlist);
213 elm_box_pack_start(m_content_box, m_searched_history_genlist);
214 evas_object_show(m_searched_history_genlist);
216 BROWSER_LOGD("show no content");
217 if (m_no_content_search_result)
218 evas_object_del(m_no_content_search_result);
219 m_no_content_search_result = elm_layout_add(m_content_box);
220 if (!m_no_content_search_result) {
221 BROWSER_LOGE("elm_layout_add failed");
224 elm_layout_theme_set(m_no_content_search_result, "layout", "nocontents", "search");
225 elm_object_part_text_set(m_no_content_search_result, "elm.text", BR_STRING_NO_SEARCH_RESULT);
226 evas_object_size_hint_weight_set(m_no_content_search_result, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
227 evas_object_size_hint_align_set(m_no_content_search_result, EVAS_HINT_FILL, EVAS_HINT_FILL);
229 if (m_searched_history_genlist) {
230 evas_object_del(m_searched_history_genlist);
231 m_searched_history_genlist = NULL;
234 elm_box_unpack_all(m_content_box);
235 evas_object_hide(m_history_genlist);
236 elm_box_pack_start(m_content_box, m_no_content_search_result);
237 evas_object_show(m_no_content_search_result);
243 void Browser_History_Layout::__search_delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
245 const char *search_text = elm_entry_entry_get(obj);
246 BROWSER_LOGD("search_text=[%s]", search_text);
248 if (!data || !search_text)
251 char *utf8_text = elm_entry_markup_to_utf8(search_text);
255 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
256 if (!history_layout->_show_searched_history(utf8_text))
257 BROWSER_LOGE("_show_searched_history failed");
262 void Browser_History_Layout::_enable_searchbar_layout(Eina_Bool enable)
265 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "searchbar_base");
268 m_searchbar = br_elm_searchbar_add(m_searchbar_layout);
270 BROWSER_LOGD("br_elm_searchbar_add failed");
273 elm_object_part_content_set(m_searchbar_layout, "searchbar", m_searchbar);
274 evas_object_show(m_searchbar);
276 elm_object_signal_emit(m_searchbar_layout, "elm,state,show,searchbar", "elm");
278 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
279 elm_entry_input_panel_layout_set(searchbar_entry, ELM_INPUT_PANEL_LAYOUT_URL);
281 evas_object_smart_callback_add(searchbar_entry, "changed", __search_delay_changed_cb, this);
283 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
284 if (m_searched_history_item_list[i])
285 delete m_searched_history_item_list[i];
287 m_searched_history_item_list.clear();
289 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
290 if (m_searched_history_date_label_list[i])
291 free(m_searched_history_date_label_list[i]);
293 m_searched_history_date_label_list.clear();
295 if (m_searched_history_genlist || m_no_content_search_result) {
296 elm_box_unpack_all(m_content_box);
297 elm_box_pack_start(m_content_box, m_history_genlist);
298 evas_object_show(m_history_genlist);
300 if (m_searched_history_genlist) {
301 evas_object_del(m_searched_history_genlist);
302 m_searched_history_genlist = NULL;
305 if (m_no_content_search_result) {
306 evas_object_del(m_no_content_search_result);
307 m_no_content_search_result = NULL;
312 elm_object_part_content_unset(m_searchbar_layout, "searchbar");
313 evas_object_hide(m_searchbar);
316 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
317 evas_object_smart_callback_del(searchbar_entry, "changed", __search_delay_changed_cb);
319 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "noindicator");
323 void Browser_History_Layout::_set_edit_mode(Eina_Bool edit_mode)
325 BROWSER_LOGD("[%s]", __func__);
326 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
330 _enable_searchbar_layout(!edit_mode);
333 elm_object_style_set(m_bg, "edit_mode");
335 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
336 if (!m_edit_mode_select_all_layout) {
337 BROWSER_LOGE("elm_layout_add failed");
340 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
341 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
342 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
343 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
344 __edit_mode_select_all_clicked_cb, this);
346 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
347 if (!m_edit_mode_select_all_check_button) {
348 BROWSER_LOGE("elm_layout_add failed");
351 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
352 __edit_mode_select_all_check_changed_cb, this);
353 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
355 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
356 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
358 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
359 evas_object_show(m_edit_mode_select_all_layout);
361 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
362 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
364 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
366 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
367 BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
369 if (m_edit_mode_select_all_layout) {
370 elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
371 evas_object_del(m_edit_mode_select_all_layout);
372 m_edit_mode_select_all_layout = NULL;
374 if (m_edit_mode_select_all_check_button) {
375 evas_object_del(m_edit_mode_select_all_check_button);
376 m_edit_mode_select_all_check_button = NULL;
378 if (m_no_history_label) {
379 evas_object_del(m_no_history_label);
380 m_no_history_label = NULL;
383 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
384 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
385 BROWSER_LOGE("_set_controlbar_type failed");
387 Elm_Object_Item *it = NULL;
388 Browser_History_DB::history_item *item = NULL;
389 it = elm_genlist_first_item_get(m_history_genlist);
391 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
392 item->is_delete = EINA_FALSE;
393 it = elm_genlist_item_next_get(it);
396 elm_object_style_set(m_bg, "default");
397 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
398 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
400 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
402 if (m_history_list.size() == 0) {
403 elm_box_unpack_all(m_content_box);
404 elm_genlist_clear(m_history_genlist);
405 evas_object_hide(m_history_genlist);
407 if (m_edit_mode_select_all_layout) {
408 evas_object_del(m_edit_mode_select_all_layout);
409 m_edit_mode_select_all_layout = NULL;
411 if (m_edit_mode_select_all_check_button) {
412 evas_object_del(m_edit_mode_select_all_check_button);
413 m_edit_mode_select_all_check_button = NULL;
416 m_no_history_label = elm_label_add(m_searchbar_layout);
417 if (!m_no_history_label) {
418 BROWSER_LOGE("elm_label_add failed");
422 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
423 elm_object_text_set(m_no_history_label, text.c_str());
424 evas_object_show(m_no_history_label);
425 elm_box_pack_start(m_content_box, m_no_history_label);
427 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
432 void Browser_History_Layout::_show_selection_info(void)
434 BROWSER_LOGD("[%s]", __func__);
435 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
436 int selected_count = 0;
439 Browser_History_DB::history_item *item = NULL;
440 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
441 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
446 it = elm_genlist_item_next_get(it);
449 if (selected_count == 0) {
450 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
454 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
456 if (selected_count == 1) {
457 show_notify_popup(BR_STRING_ONE_ITEM_SELECTED, 0, EINA_TRUE);
458 } else if (selected_count > 1) {
459 char *small_popup_text = NULL;
460 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 4;
462 small_popup_text = (char *)malloc(string_len * sizeof(char));
463 memset(small_popup_text, 0x00, string_len);
465 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
466 show_notify_popup(small_popup_text, 0, EINA_TRUE);
468 if (small_popup_text)
469 free(small_popup_text);
470 small_popup_text = 0x00;
474 void Browser_History_Layout::_show_delete_processing_popup(void)
476 BROWSER_LOGD("[%s]", __func__);
477 if (m_processing_popup)
478 evas_object_del(m_processing_popup);
480 m_processing_popup = elm_popup_add(m_searchbar_layout);
481 if (!m_processing_popup) {
482 BROWSER_LOGE("elm_popup_add failed");
486 if (m_processing_popup_layout)
487 evas_object_del(m_processing_popup_layout);
488 m_processing_popup_layout = elm_layout_add(m_processing_popup);
489 if (!m_processing_popup_layout) {
490 BROWSER_LOGE("elm_layout_add failed");
493 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
494 "browser/popup_center_progressview")) {
495 BROWSER_LOGE("elm_layout_file_set failed");
498 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
500 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
501 elm_object_style_set(m_processing_progress_bar, "list_progress");
502 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
503 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
504 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
505 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
507 if (m_processing_popup_timer)
508 ecore_timer_del(m_processing_popup_timer);
510 m_processed_count = 0;
511 m_processed_it = elm_genlist_last_item_get(m_history_genlist);
513 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
514 m_total_item_count = 0;
516 Browser_History_DB::history_item *item = NULL;
517 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
518 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
520 m_total_item_count++;
522 it = elm_genlist_item_next_get(it);
525 m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
526 evas_object_show(m_processing_progress_bar);
528 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
529 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
530 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
531 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
533 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
535 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
536 if (!cancel_button) {
537 BROWSER_LOGE("elm_button_add failed");
540 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
541 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
542 evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
544 evas_object_show(m_processing_popup);
547 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
549 BROWSER_LOGD("[%s]", __func__);
553 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
555 evas_object_del(history_layout->m_processing_popup);
557 history_layout->m_processing_progress_bar = NULL;
558 history_layout->m_processed_it = NULL;
560 if (history_layout->m_processing_popup_timer) {
561 ecore_timer_del(history_layout->m_processing_popup_timer);
562 history_layout->m_processing_popup_timer = NULL;
565 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
567 if (history_layout->m_history_list.size() == 0) {
568 elm_box_unpack_all(history_layout->m_content_box);
569 elm_genlist_clear(history_layout->m_history_genlist);
570 evas_object_hide(history_layout->m_history_genlist);
572 if (history_layout->m_edit_mode_select_all_layout) {
573 evas_object_del(history_layout->m_edit_mode_select_all_layout);
574 history_layout->m_edit_mode_select_all_layout = NULL;
576 if (history_layout->m_edit_mode_select_all_check_button) {
577 evas_object_del(history_layout->m_edit_mode_select_all_check_button);
578 history_layout->m_edit_mode_select_all_check_button = NULL;
581 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
582 if (!history_layout->m_no_history_label) {
583 BROWSER_LOGE("elm_label_add failed");
587 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
588 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
589 evas_object_show(history_layout->m_no_history_label);
590 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
592 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
593 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
594 BROWSER_LOGE("_set_controlbar_type failed");
596 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
600 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
602 BROWSER_LOGD("[%s]", __func__);
604 return ECORE_CALLBACK_CANCEL;
606 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
607 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
609 Eina_Bool check_value = history_layout->m_select_all_check_value;
611 double value = elm_progressbar_value_get(progress_bar);
613 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
615 history_layout->m_processing_popup_timer = NULL;
616 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
618 return ECORE_CALLBACK_CANCEL;
621 while (history_layout->m_processed_it) {
622 Browser_History_DB::history_item *item = NULL;
623 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
626 && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
627 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
628 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
629 if (history_layout->m_history_list[index]->id == item->id) {
630 delete history_layout->m_history_list[index];
631 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
635 history_layout->m_processed_count++;
636 Elm_Object_Item *it = history_layout->m_processed_it;
637 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
638 elm_object_item_del(it);
639 elm_genlist_realized_items_update(history_layout->m_history_genlist);
641 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
643 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
645 if (history_layout->m_processed_count % 20 == 0)
649 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
650 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
652 char progress_text[20] = {0, };
653 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
654 history_layout->m_processed_count, history_layout->m_total_item_count);
656 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
657 "elm.text.right", progress_text);
659 return ECORE_CALLBACK_RENEW;
662 void Browser_History_Layout::_show_select_processing_popup(void)
664 BROWSER_LOGD("[%s]", __func__);
665 if (m_processing_popup)
666 evas_object_del(m_processing_popup);
668 m_processing_popup = elm_popup_add(m_searchbar_layout);
669 if (!m_processing_popup) {
670 BROWSER_LOGE("elm_popup_add failed");
674 if (m_processing_popup_layout)
675 evas_object_del(m_processing_popup_layout);
676 m_processing_popup_layout = elm_layout_add(m_processing_popup);
677 if (!m_processing_popup_layout) {
678 BROWSER_LOGE("elm_layout_add failed");
681 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
682 "browser/popup_center_progressview")) {
683 BROWSER_LOGE("elm_layout_file_set failed");
686 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
688 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
689 elm_object_style_set(m_processing_progress_bar, "list_progress");
690 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
691 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
692 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
693 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
695 if (m_processing_popup_timer)
696 ecore_timer_del(m_processing_popup_timer);
698 m_processed_count = 0;
699 m_processed_it = elm_genlist_first_item_get(m_history_genlist);
701 m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
702 evas_object_show(m_processing_progress_bar);
704 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
705 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
706 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
707 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
709 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
711 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
712 if (!cancel_button) {
713 BROWSER_LOGE("elm_button_add failed");
716 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
717 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
718 evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
720 evas_object_show(m_processing_popup);
722 Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
723 m_select_all_check_value = check_value;
726 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
729 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
731 BROWSER_LOGD("[%s]", __func__);
735 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
737 evas_object_del(history_layout->m_processing_popup);
739 history_layout->m_processing_progress_bar = NULL;
740 history_layout->m_processed_it = NULL;
742 if (history_layout->m_processing_popup_timer) {
743 ecore_timer_del(history_layout->m_processing_popup_timer);
744 history_layout->m_processing_popup_timer = NULL;
747 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
750 Browser_History_DB::history_item *item = NULL;
751 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
753 if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
756 it = elm_genlist_item_next_get(it);
759 history_layout->_delete_date_only_label_genlist_item();
762 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
764 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
767 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
770 return ECORE_CALLBACK_CANCEL;
772 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
773 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
775 Eina_Bool check_value = history_layout->m_select_all_check_value;
777 double value = elm_progressbar_value_get(progress_bar);
779 __select_processing_popup_response_cb(history_layout, NULL, NULL);
781 history_layout->m_processing_popup_timer = NULL;
782 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
783 history_layout->_show_selection_info();
785 return ECORE_CALLBACK_CANCEL;
788 while (history_layout->m_processed_it) {
789 Browser_History_DB::history_item *item = NULL;
790 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
791 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
792 item->is_delete = !check_value;
793 elm_genlist_item_update(history_layout->m_processed_it);
794 history_layout->m_processed_count++;
796 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
798 if (history_layout->m_processed_count % 30 == 0)
802 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
803 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
805 char progress_text[20] = {0, };
806 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
807 history_layout->m_processed_count, history_layout->m_history_list.size());
809 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
810 "elm.text.right", progress_text);
812 return ECORE_CALLBACK_RENEW;
815 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
816 Evas_Object *obj, void *event_info)
818 BROWSER_LOGD("[%s]", __func__);
822 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
823 Eina_Bool value = elm_check_state_get(obj);
825 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
826 elm_check_state_set(obj, !value);
827 history_layout->_show_select_processing_popup();
829 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
831 Browser_History_DB::history_item *item = NULL;
832 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
834 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
835 item->is_delete = value;
836 elm_genlist_item_update(it);
839 it = elm_genlist_item_next_get(it);
842 history_layout->_show_selection_info();
846 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
847 Evas_Object *obj, void *event_info)
852 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
854 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
855 history_layout->_show_select_processing_popup();
857 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
858 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
860 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
862 Browser_History_DB::history_item *item = NULL;
863 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
865 /* Ignore the date label. */
866 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
867 item->is_delete = !value;
868 elm_genlist_item_update(it);
871 it = elm_genlist_item_next_get(it);
874 history_layout->_show_selection_info();
878 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
880 BROWSER_LOGD("[%s]", __func__);
884 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
886 Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
887 Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
890 if (!elm_genlist_decorate_mode_get(obj)) {
891 /* calculate the index of the selected item */
892 while (index_item != seleted_item) {
893 /* Do not count date label item */
894 if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
897 index_item = elm_genlist_item_next_get(index_item);
900 const char *selected_url = NULL;
901 if (history_layout->m_searched_history_genlist == obj)
902 selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
904 selected_url = history_layout->m_history_list[index]->url.c_str();
906 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
908 Browser_History_DB::history_item *item = NULL;
909 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
910 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
911 item->is_delete = !(item->is_delete);
912 elm_genlist_item_update(seleted_item);
914 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
916 int selected_count = 0;
918 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
920 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
921 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
926 it = elm_genlist_item_next_get(it);
929 if (selected_count == total_count)
930 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
932 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
934 history_layout->_show_selection_info();
938 void Browser_History_Layout::_delete_selected_history(void)
940 BROWSER_LOGD("[%s]", __func__);
942 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
943 int delete_item_count = 0;
944 Browser_History_DB::history_item *item = NULL;
946 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
947 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
950 it = elm_genlist_item_next_get(it);
953 if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
954 _show_delete_processing_popup();
956 Eina_List *delete_item_list = NULL;
957 it = elm_genlist_first_item_get(m_history_genlist);
958 int remain_count = 0;
959 Browser_History_DB::history_item *item = NULL;
962 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
963 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
965 delete_item_list = eina_list_append(delete_item_list, it);
969 it = elm_genlist_item_next_get(it);
972 int count = eina_list_count(delete_item_list);
973 for (int i = 0; i < count; i++) {
974 it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
975 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
976 /* Delete history item */
977 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
979 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
981 delete_item_list = eina_list_next(delete_item_list);
983 for(int index = 0 ; index < m_history_list.size() ; index++) {
984 if (m_history_list[index]->id == item->id) {
985 delete m_history_list[index];
986 m_history_list.erase(m_history_list.begin() + index);
990 elm_object_item_del(it);
992 eina_list_free(delete_item_list);
994 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
996 _delete_date_only_label_genlist_item();
998 if (remain_count == 0) {
999 elm_box_unpack_all(m_content_box);
1000 elm_genlist_clear(m_history_genlist);
1001 evas_object_hide(m_history_genlist);
1003 if (m_edit_mode_select_all_layout) {
1004 evas_object_del(m_edit_mode_select_all_layout);
1005 m_edit_mode_select_all_layout = NULL;
1007 if (m_edit_mode_select_all_check_button) {
1008 evas_object_del(m_edit_mode_select_all_check_button);
1009 m_edit_mode_select_all_check_button = NULL;
1012 m_no_history_label = elm_label_add(m_searchbar_layout);
1013 if (!m_no_history_label) {
1014 BROWSER_LOGE("elm_label_add failed");
1018 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1019 elm_object_text_set(m_no_history_label, text.c_str());
1020 evas_object_show(m_no_history_label);
1021 elm_box_pack_start(m_content_box, m_no_history_label);
1023 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1024 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1025 BROWSER_LOGE("_set_controlbar_type failed");
1027 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1030 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1034 void Browser_History_Layout::_reload_history_genlist(void)
1036 Elm_Object_Item *it = NULL;
1037 while (it = elm_genlist_first_item_get(m_history_genlist))
1038 elm_object_item_del(it);
1040 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1041 if (m_history_list[i])
1042 delete m_history_list[i];
1044 elm_box_unpack_all(m_content_box);
1045 m_history_list.clear();
1047 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1048 if (m_history_date_label_list[i])
1049 free(m_history_date_label_list[i]);
1051 m_history_date_label_list.clear();
1053 Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1055 BROWSER_LOGE("get_history_list failed");
1057 unsigned int history_count = m_history_list.size();
1058 BROWSER_LOGD("history_count=%d", history_count);
1061 for(int i = 0 ; i < history_count; i++) {
1062 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1063 m_history_list[i]->user_data = (void *)this;
1064 if (m_last_date != date) {
1066 char *labe_item = strdup(m_history_list[i]->date.c_str());
1068 BROWSER_LOGE("strdup failed");
1071 m_history_date_label_list.push_back(labe_item);
1072 it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1073 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1075 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1077 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1078 ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1081 if (m_no_history_label) {
1082 evas_object_del(m_no_history_label);
1083 m_no_history_label = NULL;
1086 if (m_edit_mode_select_all_check_button) {
1087 evas_object_del(m_edit_mode_select_all_check_button);
1088 m_edit_mode_select_all_check_button = NULL;
1091 if (m_edit_mode_select_all_layout) {
1092 evas_object_del(m_edit_mode_select_all_layout);
1093 m_edit_mode_select_all_layout = NULL;
1096 if (m_history_list.size() == 0) {
1097 evas_object_hide(m_history_genlist);
1099 m_no_history_label = elm_label_add(m_searchbar_layout);
1100 if (!m_no_history_label) {
1101 BROWSER_LOGE("elm_label_add failed");
1105 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1106 elm_object_text_set(m_no_history_label, text.c_str());
1107 evas_object_show(m_no_history_label);
1108 elm_box_pack_start(m_content_box, m_no_history_label);
1110 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1111 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1112 BROWSER_LOGE("_set_controlbar_type failed");
1113 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1115 elm_box_pack_start(m_content_box, m_history_genlist);
1116 evas_object_show(m_history_genlist);
1118 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1119 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1123 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1125 BROWSER_LOGD("[%s]", __func__);
1126 elm_object_style_set(m_bg, "default");
1128 m_searchbar_layout = elm_layout_add(m_navi_bar);
1129 if (!m_searchbar_layout) {
1130 BROWSER_LOGE("elm_layout_add failed");
1134 _enable_searchbar_layout(EINA_TRUE);
1136 evas_object_show(m_searchbar_layout);
1138 m_content_box = elm_box_add(m_searchbar_layout);
1139 if (!m_content_box) {
1140 BROWSER_LOGE("elm_box_add failed");
1144 m_history_genlist = _create_history_genlist();
1145 if (!m_history_genlist) {
1146 BROWSER_LOGE("_create_history_genlist failed");
1150 m_history_genlist_item_class.item_style = "2text.1icon.4";
1151 m_history_genlist_item_class.decorate_all_item_style = "edit_default";
1152 m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1153 m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1154 m_history_genlist_item_class.func.state_get = NULL;
1155 m_history_genlist_item_class.func.del = NULL;
1157 m_history_group_title_class.item_style = "grouptitle";
1158 m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1159 m_history_group_title_class.func.content_get = NULL;
1160 m_history_group_title_class.func.state_get = NULL;
1161 m_history_group_title_class.func.del = NULL;
1163 _reload_history_genlist();
1165 evas_object_show(m_content_box);
1166 elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1171 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1173 BROWSER_LOGD("[%s]", __func__);
1175 m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1176 if (!m_delete_confirm_popup) {
1177 BROWSER_LOGE("elm_popup_add failed");
1181 evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1182 elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1184 Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1185 elm_object_text_set(ok_button, BR_STRING_YES);
1186 elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1188 Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1189 elm_object_text_set(cancel_button, BR_STRING_NO);
1190 elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1191 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1192 m_delete_confirm_popup);
1194 evas_object_show(m_delete_confirm_popup);
1198 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1203 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1207 char *mark_up = NULL;
1209 if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1210 || !strncmp(part, "elm.base.text", strlen("elm.base.text")))
1212 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1214 } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))) {
1215 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1222 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1227 char *date_label = (char *)data;
1229 if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1231 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1233 sscanf(date_label, "%d-%d-%d",
1234 &date.year, &date.month, &date.day);
1235 // BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1237 struct tm *time_info;
1239 time_info = localtime(&raw_time);
1241 // BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1242 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1243 day_gap = time_info->tm_mday - date.day;
1245 time_info->tm_year = date.year - 1900;
1246 time_info->tm_mon = date.month - 1;
1248 time_info->tm_mday = date.day;
1252 strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1253 else if (day_gap == 1)
1254 strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1256 strftime (buffer, 40, "%a, %b %d %Y", time_info);
1257 return strdup(buffer);
1262 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1265 BROWSER_LOGD("event_info = %d", (int)event_info);
1270 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1272 if (history_layout->m_delete_confirm_popup) {
1273 evas_object_del(history_layout->m_delete_confirm_popup);
1274 history_layout->m_delete_confirm_popup = NULL;
1277 history_layout->_delete_selected_history();
1279 history_layout->_set_edit_mode(EINA_FALSE);
1281 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1284 BROWSER_LOGD("event_info = %d", (int)event_info);
1289 Evas_Object *popup = (Evas_Object *)data;
1290 evas_object_del(popup);
1293 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1295 BROWSER_LOGD("[%s]", __func__);
1297 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1298 /* Remove date only label item */
1300 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1301 Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1302 if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1304 it = elm_genlist_item_next_get(it);
1305 elm_object_item_del(tmp_it);
1309 it = elm_genlist_item_next_get(it);
1313 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1318 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1319 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1320 if (!history_layout)
1323 if (!strncmp(part, "elm.icon", strlen("elm.icon"))) {
1324 Evas_Object *favicon = NULL;
1325 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1329 Evas_Object *default_favicon = elm_icon_add(obj);
1330 if (!default_favicon) {
1331 BROWSER_LOGE("elm_icon_add is failed");
1334 elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1335 evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1336 return default_favicon;
1338 } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1339 if (elm_genlist_decorate_mode_get(obj)) {
1340 Evas_Object *check_button = elm_check_add(obj);
1341 if (!check_button) {
1342 BROWSER_LOGE("elm_check_add is failed");
1345 elm_check_state_pointer_set(check_button, &(item->is_delete));
1346 elm_check_state_set(check_button, item->is_delete);
1347 evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1348 return check_button;
1355 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1357 BROWSER_LOGD("[%s]", __func__);
1360 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1361 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1362 int selected_count = 0;
1363 int total_count = 0;
1364 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1366 Browser_History_DB::history_item *item = NULL;
1367 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1369 /* Ignore the date label. */
1370 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1372 if (item->is_delete)
1375 it = elm_genlist_item_next_get(it);
1378 if (total_count == selected_count)
1379 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1381 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1383 history_layout->_show_selection_info();
1386 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1388 BROWSER_LOGD("[%s]", __func__);
1389 Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1391 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1392 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);