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.
19 #include "browser-add-to-bookmark-view.h"
20 #include "browser-view.h"
21 #include "browser-history-layout.h"
23 Date::Date() : day(0), month(0), year(0) {}
25 Date::Date(Date &date)
28 this->month = date.month;
29 this->year = date.year;
32 void Date::operator=(Date &date)
35 this->month = date.month;
36 this->year = date.year;
39 bool Date::operator==(Date &date)
41 return (this->day == date.day && this->month == date.month && this->year == date.year);
44 bool Date::operator!=(Date &date)
46 return (this->day != date.day || this->month != date.month || this->year != date.year);
49 Browser_History_Layout::Browser_History_Layout(void)
50 : m_history_genlist(NULL)
51 ,m_edit_mode_select_all_layout(NULL)
52 ,m_edit_mode_select_all_check_button(NULL)
54 ,m_no_history_label(NULL)
55 ,m_current_sweep_item(NULL)
56 ,m_processing_popup_timer(NULL)
59 ,m_total_item_count(0)
60 ,m_processing_popup(NULL)
61 ,m_processing_popup_layout(NULL)
62 ,m_processing_progress_bar(NULL)
63 ,m_select_all_check_value(EINA_FALSE)
64 ,m_searchbar_layout(NULL)
65 ,m_searched_history_genlist(NULL)
66 ,m_no_content_search_result(NULL)
68 ,m_delete_confirm_popup(NULL)
69 ,m_is_bookmark_on_off_icon_clicked(EINA_FALSE)
71 BROWSER_LOGD("[%s]", __func__);
74 Browser_History_Layout::~Browser_History_Layout(void)
76 BROWSER_LOGD("[%s]", __func__);
79 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
80 if (m_history_list[i])
81 delete m_history_list[i];
83 m_history_list.clear();
85 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
86 if (m_history_date_label_list[i])
87 free(m_history_date_label_list[i]);
89 m_history_date_label_list.clear();
91 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
92 if (m_searched_history_date_label_list[i])
93 free(m_searched_history_date_label_list[i]);
95 m_searched_history_date_label_list.clear();
97 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
98 if (m_searched_history_item_list[i])
99 delete m_searched_history_item_list[i];
101 m_searched_history_item_list.clear();
103 if (m_delete_confirm_popup)
104 evas_object_del(m_delete_confirm_popup);
108 Eina_Bool Browser_History_Layout::init(void)
110 BROWSER_LOGD("[%s]", __func__);
111 return _create_main_layout();
114 Eina_Bool Browser_History_Layout::_show_searched_history(const char *search_text)
116 BROWSER_LOGD("search_text = [%s]", search_text);
118 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
119 if (m_searched_history_item_list[i])
120 delete m_searched_history_item_list[i];
122 m_searched_history_item_list.clear();
124 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
125 if (m_searched_history_date_label_list[i])
126 free(m_searched_history_date_label_list[i]);
128 m_searched_history_date_label_list.clear();
130 if (!search_text || !strlen(search_text)) {
131 if (m_searched_history_genlist || m_no_content_search_result) {
132 elm_box_unpack_all(m_content_box);
133 elm_box_pack_start(m_content_box, m_history_genlist);
134 evas_object_show(m_history_genlist);
136 if (m_searched_history_genlist) {
137 evas_object_del(m_searched_history_genlist);
138 m_searched_history_genlist = NULL;
141 if (m_no_content_search_result) {
142 evas_object_del(m_no_content_search_result);
143 m_no_content_search_result = NULL;
146 if (m_history_list.size() == 0) {
147 if (m_no_history_label) {
148 elm_box_unpack_all(m_content_box);
149 elm_box_pack_start(m_content_box, m_no_history_label);
157 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
159 Browser_History_DB::history_item *item = NULL;
160 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
161 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
162 if (item->url.find(search_text) != string::npos || item->title.find(search_text) != string::npos) {
163 Browser_History_DB::history_item *searched_item = NULL;
164 searched_item = new(nothrow) Browser_History_DB::history_item;
165 searched_item->id = item->id;
166 searched_item->url = item->url;
167 searched_item->title = item->title;
168 searched_item->date = item->date;
169 searched_item->is_delete = item->is_delete;
170 searched_item->user_data = item->user_data;
171 m_searched_history_item_list.push_back(searched_item);
174 it = elm_genlist_item_next_get(it);
177 if (m_searched_history_item_list.size()) {
178 if (m_no_content_search_result) {
179 evas_object_del(m_no_content_search_result);
180 m_no_content_search_result = NULL;
183 if (!m_searched_history_genlist) {
184 m_searched_history_genlist = _create_history_genlist();
185 if (!m_searched_history_genlist) {
186 BROWSER_LOGE("_create_history_genlist failed");
191 elm_genlist_clear(m_searched_history_genlist);
195 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++) {
196 sscanf(m_searched_history_item_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
197 m_searched_history_item_list[i]->user_data = (void *)this;
198 if (last_date != date) {
200 char *labe_item = strdup(m_searched_history_item_list[i]->date.c_str());
202 BROWSER_LOGE("strdup failed");
205 m_searched_history_date_label_list.push_back(labe_item);
206 it = elm_genlist_item_append(m_searched_history_genlist, &m_history_group_title_class,
207 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
209 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
211 elm_genlist_item_append(m_searched_history_genlist, &m_history_genlist_item_class,
212 m_searched_history_item_list[i], it, ELM_GENLIST_ITEM_NONE,
213 __history_item_clicked_cb, this);
216 elm_box_unpack_all(m_content_box);
217 evas_object_hide(m_history_genlist);
218 elm_box_pack_start(m_content_box, m_searched_history_genlist);
219 evas_object_show(m_searched_history_genlist);
221 BROWSER_LOGD("show no content");
222 if (m_no_content_search_result)
223 evas_object_del(m_no_content_search_result);
224 m_no_content_search_result = elm_layout_add(m_content_box);
225 if (!m_no_content_search_result) {
226 BROWSER_LOGE("elm_layout_add failed");
229 elm_layout_theme_set(m_no_content_search_result, "layout", "nocontents", "search");
230 elm_object_part_text_set(m_no_content_search_result, "elm.text", BR_STRING_NO_SEARCH_RESULT);
231 evas_object_size_hint_weight_set(m_no_content_search_result, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
232 evas_object_size_hint_align_set(m_no_content_search_result, EVAS_HINT_FILL, EVAS_HINT_FILL);
234 if (m_searched_history_genlist) {
235 evas_object_del(m_searched_history_genlist);
236 m_searched_history_genlist = NULL;
239 elm_box_unpack_all(m_content_box);
240 evas_object_hide(m_history_genlist);
241 elm_box_pack_start(m_content_box, m_no_content_search_result);
242 evas_object_show(m_no_content_search_result);
248 void Browser_History_Layout::__search_delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
250 const char *search_text = elm_entry_entry_get(obj);
251 BROWSER_LOGD("search_text=[%s]", search_text);
253 if (!data || !search_text)
256 char *utf8_text = elm_entry_markup_to_utf8(search_text);
260 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
261 if (!history_layout->_show_searched_history(utf8_text))
262 BROWSER_LOGE("_show_searched_history failed");
267 void Browser_History_Layout::_enable_searchbar_layout(Eina_Bool enable)
270 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "searchbar_base");
273 m_searchbar = br_elm_searchbar_add(m_searchbar_layout);
275 BROWSER_LOGD("br_elm_searchbar_add failed");
278 elm_object_part_content_set(m_searchbar_layout, "searchbar", m_searchbar);
279 evas_object_show(m_searchbar);
281 elm_object_signal_emit(m_searchbar_layout, "elm,state,show,searchbar", "elm");
283 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
284 elm_entry_input_panel_layout_set(searchbar_entry, ELM_INPUT_PANEL_LAYOUT_URL);
286 evas_object_smart_callback_add(searchbar_entry, "changed", __search_delay_changed_cb, this);
288 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
289 if (m_searched_history_item_list[i])
290 delete m_searched_history_item_list[i];
292 m_searched_history_item_list.clear();
294 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
295 if (m_searched_history_date_label_list[i])
296 free(m_searched_history_date_label_list[i]);
298 m_searched_history_date_label_list.clear();
300 if (m_searched_history_genlist || m_no_content_search_result) {
301 elm_box_unpack_all(m_content_box);
302 elm_box_pack_start(m_content_box, m_history_genlist);
303 evas_object_show(m_history_genlist);
305 if (m_searched_history_genlist) {
306 evas_object_del(m_searched_history_genlist);
307 m_searched_history_genlist = NULL;
310 if (m_no_content_search_result) {
311 evas_object_del(m_no_content_search_result);
312 m_no_content_search_result = NULL;
317 elm_object_part_content_unset(m_searchbar_layout, "searchbar");
318 evas_object_hide(m_searchbar);
321 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
322 evas_object_smart_callback_del(searchbar_entry, "changed", __search_delay_changed_cb);
324 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "noindicator");
328 void Browser_History_Layout::_set_edit_mode(Eina_Bool edit_mode)
330 BROWSER_LOGD("[%s]", __func__);
331 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
335 _enable_searchbar_layout(!edit_mode);
338 elm_object_style_set(m_bg, "edit_mode");
340 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
341 if (!m_edit_mode_select_all_layout) {
342 BROWSER_LOGE("elm_layout_add failed");
345 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
346 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
347 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
348 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
349 __edit_mode_select_all_clicked_cb, this);
351 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
352 if (!m_edit_mode_select_all_check_button) {
353 BROWSER_LOGE("elm_layout_add failed");
356 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
357 __edit_mode_select_all_check_changed_cb, this);
358 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
360 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
361 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
363 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
364 evas_object_show(m_edit_mode_select_all_layout);
366 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
367 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
369 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
371 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
372 BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
374 if (m_edit_mode_select_all_layout) {
375 elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
376 evas_object_del(m_edit_mode_select_all_layout);
377 m_edit_mode_select_all_layout = NULL;
379 if (m_edit_mode_select_all_check_button) {
380 evas_object_del(m_edit_mode_select_all_check_button);
381 m_edit_mode_select_all_check_button = NULL;
383 if (m_no_history_label) {
384 evas_object_del(m_no_history_label);
385 m_no_history_label = NULL;
388 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
389 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
390 BROWSER_LOGE("_set_controlbar_type failed");
392 Elm_Object_Item *it = NULL;
393 Browser_History_DB::history_item *item = NULL;
394 it = elm_genlist_first_item_get(m_history_genlist);
396 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
397 item->is_delete = EINA_FALSE;
398 it = elm_genlist_item_next_get(it);
401 elm_object_style_set(m_bg, "default");
402 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
403 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
405 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
407 if (m_history_list.size() == 0) {
408 elm_box_unpack_all(m_content_box);
409 elm_genlist_clear(m_history_genlist);
410 evas_object_hide(m_history_genlist);
412 if (m_edit_mode_select_all_layout) {
413 evas_object_del(m_edit_mode_select_all_layout);
414 m_edit_mode_select_all_layout = NULL;
416 if (m_edit_mode_select_all_check_button) {
417 evas_object_del(m_edit_mode_select_all_check_button);
418 m_edit_mode_select_all_check_button = NULL;
421 m_no_history_label = elm_label_add(m_searchbar_layout);
422 if (!m_no_history_label) {
423 BROWSER_LOGE("elm_label_add failed");
427 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
428 elm_object_text_set(m_no_history_label, text.c_str());
429 evas_object_show(m_no_history_label);
430 elm_box_pack_start(m_content_box, m_no_history_label);
432 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
437 void Browser_History_Layout::_show_selection_info(void)
439 BROWSER_LOGD("[%s]", __func__);
440 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
441 int selected_count = 0;
444 Browser_History_DB::history_item *item = NULL;
445 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
446 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
451 it = elm_genlist_item_next_get(it);
454 if (selected_count == 0) {
455 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
459 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
461 if (selected_count == 1) {
462 show_notify_popup(BR_STRING_ONE_ITEM_SELECTED, 0, EINA_TRUE);
463 } else if (selected_count > 1) {
464 char *small_popup_text = NULL;
465 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 1;
467 small_popup_text = (char *)malloc(string_len * sizeof(char));
468 memset(small_popup_text, 0x00, string_len);
470 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
471 show_notify_popup(small_popup_text, 0, EINA_TRUE);
473 if (small_popup_text)
474 free(small_popup_text);
475 small_popup_text = 0x00;
479 void Browser_History_Layout::_show_delete_processing_popup(void)
481 BROWSER_LOGD("[%s]", __func__);
482 if (m_processing_popup)
483 evas_object_del(m_processing_popup);
485 m_processing_popup = elm_popup_add(m_searchbar_layout);
486 if (!m_processing_popup) {
487 BROWSER_LOGE("elm_popup_add failed");
491 if (m_processing_popup_layout)
492 evas_object_del(m_processing_popup_layout);
493 m_processing_popup_layout = elm_layout_add(m_processing_popup);
494 if (!m_processing_popup_layout) {
495 BROWSER_LOGE("elm_layout_add failed");
498 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
499 "browser/popup_center_progressview")) {
500 BROWSER_LOGE("elm_layout_file_set failed");
503 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
505 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
506 elm_object_style_set(m_processing_progress_bar, "list_progress");
507 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
508 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
509 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
510 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
512 if (m_processing_popup_timer)
513 ecore_timer_del(m_processing_popup_timer);
515 m_processed_count = 0;
516 m_processed_it = elm_genlist_last_item_get(m_history_genlist);
518 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
519 m_total_item_count = 0;
521 Browser_History_DB::history_item *item = NULL;
522 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
523 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
525 m_total_item_count++;
527 it = elm_genlist_item_next_get(it);
530 m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
531 evas_object_show(m_processing_progress_bar);
533 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
534 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
535 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
536 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
538 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
540 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
541 if (!cancel_button) {
542 BROWSER_LOGE("elm_button_add failed");
545 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
546 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
547 evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
549 evas_object_show(m_processing_popup);
552 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
554 BROWSER_LOGD("[%s]", __func__);
558 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
560 evas_object_del(history_layout->m_processing_popup);
562 history_layout->m_processing_progress_bar = NULL;
563 history_layout->m_processed_it = NULL;
565 if (history_layout->m_processing_popup_timer) {
566 ecore_timer_del(history_layout->m_processing_popup_timer);
567 history_layout->m_processing_popup_timer = NULL;
570 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
572 if (history_layout->m_history_list.size() == 0) {
573 elm_box_unpack_all(history_layout->m_content_box);
574 elm_genlist_clear(history_layout->m_history_genlist);
575 evas_object_hide(history_layout->m_history_genlist);
577 if (history_layout->m_edit_mode_select_all_layout) {
578 evas_object_del(history_layout->m_edit_mode_select_all_layout);
579 history_layout->m_edit_mode_select_all_layout = NULL;
581 if (history_layout->m_edit_mode_select_all_check_button) {
582 evas_object_del(history_layout->m_edit_mode_select_all_check_button);
583 history_layout->m_edit_mode_select_all_check_button = NULL;
586 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
587 if (!history_layout->m_no_history_label) {
588 BROWSER_LOGE("elm_label_add failed");
592 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
593 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
594 evas_object_show(history_layout->m_no_history_label);
595 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
597 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
598 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
599 BROWSER_LOGE("_set_controlbar_type failed");
601 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
605 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
607 BROWSER_LOGD("[%s]", __func__);
609 return ECORE_CALLBACK_CANCEL;
611 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
612 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
614 Eina_Bool check_value = history_layout->m_select_all_check_value;
616 double value = elm_progressbar_value_get(progress_bar);
618 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
620 history_layout->m_processing_popup_timer = NULL;
621 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
623 return ECORE_CALLBACK_CANCEL;
626 while (history_layout->m_processed_it) {
627 Browser_History_DB::history_item *item = NULL;
628 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
631 && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
632 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
633 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
634 if (history_layout->m_history_list[index]->id == item->id) {
635 delete history_layout->m_history_list[index];
636 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
640 history_layout->m_processed_count++;
641 Elm_Object_Item *it = history_layout->m_processed_it;
642 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
643 elm_object_item_del(it);
644 elm_genlist_realized_items_update(history_layout->m_history_genlist);
646 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
648 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
650 if (history_layout->m_processed_count % 20 == 0)
654 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
655 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
657 char progress_text[20] = {0, };
658 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
659 history_layout->m_processed_count, history_layout->m_total_item_count);
661 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
662 "elm.text.right", progress_text);
664 return ECORE_CALLBACK_RENEW;
667 void Browser_History_Layout::_show_select_processing_popup(void)
669 BROWSER_LOGD("[%s]", __func__);
670 if (m_processing_popup)
671 evas_object_del(m_processing_popup);
673 m_processing_popup = elm_popup_add(m_searchbar_layout);
674 if (!m_processing_popup) {
675 BROWSER_LOGE("elm_popup_add failed");
679 if (m_processing_popup_layout)
680 evas_object_del(m_processing_popup_layout);
681 m_processing_popup_layout = elm_layout_add(m_processing_popup);
682 if (!m_processing_popup_layout) {
683 BROWSER_LOGE("elm_layout_add failed");
686 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
687 "browser/popup_center_progressview")) {
688 BROWSER_LOGE("elm_layout_file_set failed");
691 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
693 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
694 elm_object_style_set(m_processing_progress_bar, "list_progress");
695 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
696 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
697 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
698 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
700 if (m_processing_popup_timer)
701 ecore_timer_del(m_processing_popup_timer);
703 m_processed_count = 0;
704 m_processed_it = elm_genlist_first_item_get(m_history_genlist);
706 m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
707 evas_object_show(m_processing_progress_bar);
709 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
710 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
711 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
712 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
714 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
716 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
717 if (!cancel_button) {
718 BROWSER_LOGE("elm_button_add failed");
721 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
722 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
723 evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
725 evas_object_show(m_processing_popup);
727 Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
728 m_select_all_check_value = check_value;
731 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
734 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
736 BROWSER_LOGD("[%s]", __func__);
740 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
742 evas_object_del(history_layout->m_processing_popup);
744 history_layout->m_processing_progress_bar = NULL;
745 history_layout->m_processed_it = NULL;
747 if (history_layout->m_processing_popup_timer) {
748 ecore_timer_del(history_layout->m_processing_popup_timer);
749 history_layout->m_processing_popup_timer = NULL;
752 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
755 Browser_History_DB::history_item *item = NULL;
756 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
758 if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
761 it = elm_genlist_item_next_get(it);
764 history_layout->_delete_date_only_label_genlist_item();
767 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
769 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
772 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
775 return ECORE_CALLBACK_CANCEL;
777 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
778 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
780 Eina_Bool check_value = history_layout->m_select_all_check_value;
782 double value = elm_progressbar_value_get(progress_bar);
784 __select_processing_popup_response_cb(history_layout, NULL, NULL);
786 history_layout->m_processing_popup_timer = NULL;
787 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
788 history_layout->_show_selection_info();
790 return ECORE_CALLBACK_CANCEL;
793 while (history_layout->m_processed_it) {
794 Browser_History_DB::history_item *item = NULL;
795 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
796 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
797 item->is_delete = !check_value;
798 elm_genlist_item_update(history_layout->m_processed_it);
799 history_layout->m_processed_count++;
801 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
803 if (history_layout->m_processed_count % 30 == 0)
807 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
808 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
810 char progress_text[20] = {0, };
811 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
812 history_layout->m_processed_count, history_layout->m_history_list.size());
814 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
815 "elm.text.right", progress_text);
817 return ECORE_CALLBACK_RENEW;
820 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
821 Evas_Object *obj, void *event_info)
823 BROWSER_LOGD("[%s]", __func__);
827 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
828 Eina_Bool value = elm_check_state_get(obj);
830 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
831 elm_check_state_set(obj, !value);
832 history_layout->_show_select_processing_popup();
834 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
836 Browser_History_DB::history_item *item = NULL;
837 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
839 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
840 item->is_delete = value;
841 elm_genlist_item_update(it);
844 it = elm_genlist_item_next_get(it);
847 history_layout->_show_selection_info();
851 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
852 Evas_Object *obj, void *event_info)
857 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
859 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
860 history_layout->_show_select_processing_popup();
862 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
863 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
865 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
867 Browser_History_DB::history_item *item = NULL;
868 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
870 /* Ignore the date label. */
871 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
872 item->is_delete = !value;
873 elm_genlist_item_update(it);
876 it = elm_genlist_item_next_get(it);
879 history_layout->_show_selection_info();
883 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
885 BROWSER_LOGD("[%s]", __func__);
889 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
891 if (history_layout->m_is_bookmark_on_off_icon_clicked) {
892 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_FALSE;
893 Elm_Object_Item *selected_item = (Elm_Object_Item *)eventInfo;
894 elm_genlist_item_selected_set(selected_item, EINA_FALSE);
898 Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
899 Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
902 if (!elm_genlist_decorate_mode_get(obj)) {
903 /* calculate the index of the selected item */
904 while (index_item != seleted_item) {
905 /* Do not count date label item */
906 if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
909 index_item = elm_genlist_item_next_get(index_item);
912 const char *selected_url = NULL;
913 if (history_layout->m_searched_history_genlist == obj)
914 selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
916 selected_url = history_layout->m_history_list[index]->url.c_str();
918 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
920 Browser_History_DB::history_item *item = NULL;
921 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
922 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
923 item->is_delete = !(item->is_delete);
924 elm_genlist_item_update(seleted_item);
926 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
928 int selected_count = 0;
930 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
932 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
933 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
938 it = elm_genlist_item_next_get(it);
941 if (selected_count == total_count)
942 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
944 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
946 history_layout->_show_selection_info();
950 void Browser_History_Layout::_delete_selected_history(void)
952 BROWSER_LOGD("[%s]", __func__);
954 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
955 int delete_item_count = 0;
956 Browser_History_DB::history_item *item = NULL;
958 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
959 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
962 it = elm_genlist_item_next_get(it);
965 if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
966 _show_delete_processing_popup();
968 Eina_List *delete_item_list = NULL;
969 it = elm_genlist_first_item_get(m_history_genlist);
970 int remain_count = 0;
971 Browser_History_DB::history_item *item = NULL;
974 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
975 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
977 delete_item_list = eina_list_append(delete_item_list, it);
981 it = elm_genlist_item_next_get(it);
984 int count = eina_list_count(delete_item_list);
985 for (int i = 0; i < count; i++) {
986 it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
987 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
988 /* Delete history item */
989 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
991 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
993 delete_item_list = eina_list_next(delete_item_list);
995 for(int index = 0 ; index < m_history_list.size() ; index++) {
996 if (m_history_list[index]->id == item->id) {
997 delete m_history_list[index];
998 m_history_list.erase(m_history_list.begin() + index);
1002 elm_object_item_del(it);
1004 eina_list_free(delete_item_list);
1006 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
1008 _delete_date_only_label_genlist_item();
1010 if (remain_count == 0) {
1011 elm_box_unpack_all(m_content_box);
1012 elm_genlist_clear(m_history_genlist);
1013 evas_object_hide(m_history_genlist);
1015 if (m_edit_mode_select_all_layout) {
1016 evas_object_del(m_edit_mode_select_all_layout);
1017 m_edit_mode_select_all_layout = NULL;
1019 if (m_edit_mode_select_all_check_button) {
1020 evas_object_del(m_edit_mode_select_all_check_button);
1021 m_edit_mode_select_all_check_button = NULL;
1024 m_no_history_label = elm_label_add(m_searchbar_layout);
1025 if (!m_no_history_label) {
1026 BROWSER_LOGE("elm_label_add failed");
1030 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1031 elm_object_text_set(m_no_history_label, text.c_str());
1032 evas_object_show(m_no_history_label);
1033 elm_box_pack_start(m_content_box, m_no_history_label);
1035 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1036 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1037 BROWSER_LOGE("_set_controlbar_type failed");
1039 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1042 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1046 void Browser_History_Layout::_reload_history_genlist(void)
1048 Elm_Object_Item *it = NULL;
1049 while (it = elm_genlist_first_item_get(m_history_genlist))
1050 elm_object_item_del(it);
1052 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1053 if (m_history_list[i])
1054 delete m_history_list[i];
1056 elm_box_unpack_all(m_content_box);
1057 m_history_list.clear();
1059 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1060 if (m_history_date_label_list[i])
1061 free(m_history_date_label_list[i]);
1063 m_history_date_label_list.clear();
1065 Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1067 BROWSER_LOGE("get_history_list failed");
1069 unsigned int history_count = m_history_list.size();
1070 BROWSER_LOGD("history_count=%d", history_count);
1073 for(int i = 0 ; i < history_count; i++) {
1074 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1075 m_history_list[i]->user_data = (void *)this;
1076 if (m_last_date != date) {
1078 char *labe_item = strdup(m_history_list[i]->date.c_str());
1080 BROWSER_LOGE("strdup failed");
1083 m_history_date_label_list.push_back(labe_item);
1084 it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1085 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1087 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1089 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1090 ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1093 if (m_no_history_label) {
1094 evas_object_del(m_no_history_label);
1095 m_no_history_label = NULL;
1098 if (m_edit_mode_select_all_check_button) {
1099 evas_object_del(m_edit_mode_select_all_check_button);
1100 m_edit_mode_select_all_check_button = NULL;
1103 if (m_edit_mode_select_all_layout) {
1104 evas_object_del(m_edit_mode_select_all_layout);
1105 m_edit_mode_select_all_layout = NULL;
1108 if (m_history_list.size() == 0) {
1109 evas_object_hide(m_history_genlist);
1111 m_no_history_label = elm_label_add(m_searchbar_layout);
1112 if (!m_no_history_label) {
1113 BROWSER_LOGE("elm_label_add failed");
1117 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1118 elm_object_text_set(m_no_history_label, text.c_str());
1119 evas_object_show(m_no_history_label);
1120 elm_box_pack_start(m_content_box, m_no_history_label);
1122 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1123 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1124 BROWSER_LOGE("_set_controlbar_type failed");
1125 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1127 elm_box_pack_start(m_content_box, m_history_genlist);
1128 evas_object_show(m_history_genlist);
1130 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1131 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1135 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1137 BROWSER_LOGD("[%s]", __func__);
1138 elm_object_style_set(m_bg, "default");
1140 m_searchbar_layout = elm_layout_add(m_navi_bar);
1141 if (!m_searchbar_layout) {
1142 BROWSER_LOGE("elm_layout_add failed");
1146 _enable_searchbar_layout(EINA_TRUE);
1148 evas_object_show(m_searchbar_layout);
1150 m_content_box = elm_box_add(m_searchbar_layout);
1151 if (!m_content_box) {
1152 BROWSER_LOGE("elm_box_add failed");
1156 m_history_genlist = _create_history_genlist();
1157 if (!m_history_genlist) {
1158 BROWSER_LOGE("_create_history_genlist failed");
1162 m_history_genlist_item_class.decorate_item_style = "mode/slide3";
1163 m_history_genlist_item_class.item_style = "2text.2icon.4";
1164 m_history_genlist_item_class.decorate_all_item_style = "edit_default";
1165 m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1166 m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1167 m_history_genlist_item_class.func.state_get = NULL;
1168 m_history_genlist_item_class.func.del = NULL;
1170 m_history_group_title_class.item_style = "grouptitle";
1171 m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1172 m_history_group_title_class.func.content_get = NULL;
1173 m_history_group_title_class.func.state_get = NULL;
1174 m_history_group_title_class.func.del = NULL;
1176 _reload_history_genlist();
1178 evas_object_show(m_content_box);
1179 elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1184 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1186 BROWSER_LOGD("[%s]", __func__);
1188 m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1189 if (!m_delete_confirm_popup) {
1190 BROWSER_LOGE("elm_popup_add failed");
1194 evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1195 elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1197 Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1198 elm_object_text_set(ok_button, BR_STRING_YES);
1199 elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1201 Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1202 elm_object_text_set(cancel_button, BR_STRING_NO);
1203 elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1204 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1205 m_delete_confirm_popup);
1207 evas_object_show(m_delete_confirm_popup);
1212 #if defined(GENLIST_SWEEP)
1213 void Browser_History_Layout::__sweep_right_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1215 BROWSER_LOGD("[%s]", __func__);
1216 if (!data || elm_genlist_decorate_mode_get(obj))
1219 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_TRUE);
1220 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_NONE);
1223 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1224 if (history_layout->m_current_sweep_item)
1225 elm_genlist_item_select_mode_set(history_layout->m_current_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1226 history_layout->m_current_sweep_item = (Elm_Object_Item *)event_info;
1229 void Browser_History_Layout::__sweep_cancel_genlist_cb(void *data,
1230 Evas_Object *obj, void *event_info)
1232 BROWSER_LOGD("[%s]", __func__);
1237 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1238 Elm_Object_Item *it = (Elm_Object_Item*)elm_genlist_decorated_item_get(obj);
1240 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1241 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1243 if (it == history_layout->m_current_sweep_item)
1244 history_layout->m_current_sweep_item = NULL;
1248 void Browser_History_Layout::__sweep_left_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1250 BROWSER_LOGD("[%s]", __func__);
1251 if (!data || elm_genlist_decorate_mode_get(obj))
1254 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_FALSE);
1255 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
1258 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1259 history_layout->m_current_sweep_item = NULL;
1263 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1268 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1272 char *mark_up = NULL;
1274 if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1275 || !strncmp(part, "elm.base.text", strlen("elm.base.text"))
1276 || !strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")))
1278 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1280 } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))
1281 || !strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2"))) {
1282 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1289 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1294 char *date_label = (char *)data;
1296 if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1298 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1300 sscanf(date_label, "%d-%d-%d",
1301 &date.year, &date.month, &date.day);
1302 // BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1304 struct tm *time_info;
1306 time_info = localtime(&raw_time);
1308 // BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1309 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1310 day_gap = time_info->tm_mday - date.day;
1312 time_info->tm_year = date.year - 1900;
1313 time_info->tm_mon = date.month - 1;
1315 time_info->tm_mday = date.day;
1319 strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1320 else if (day_gap == 1)
1321 strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1323 strftime (buffer, 40, "%a, %b %d %Y", time_info);
1324 return strdup(buffer);
1329 void Browser_History_Layout::__slide_add_to_bookmark_button_clicked_cb(void *data, Evas_Object *obj,
1332 BROWSER_LOGD("[%s]", __func__);
1336 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1337 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1339 /* If add to bookmark is excuted in searched list, remove the searched list. */
1340 Evas_Object *searchbar = NULL;
1341 searchbar = edje_object_part_external_object_get(elm_layout_edje_get(history_layout->m_searchbar_layout),
1343 br_elm_searchbar_text_set(searchbar, "");
1345 if (!m_data_manager->create_add_to_bookmark_view(item->title, item->url)) {
1346 BROWSER_LOGE("create_add_to_bookmark_view failed");
1350 if (!m_data_manager->get_add_to_bookmark_view()->init()) {
1351 BROWSER_LOGE("get_add_to_bookmark_view()->init() failed");
1352 m_data_manager->destroy_add_to_bookmark_view();
1357 void Browser_History_Layout::__slide_share_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1359 BROWSER_LOGD("[%s]", __func__);
1363 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1364 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1365 if (!history_layout->_show_share_popup(item->url.c_str()))
1366 BROWSER_LOGE("_show_share_popup failed");
1369 void Browser_History_Layout::_delete_history_item_by_slide_button(Browser_History_DB::history_item *item)
1371 BROWSER_LOGD("[%s]", __func__);
1372 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1374 int ret = EINA_TRUE;
1375 ret = m_data_manager->get_history_db()->delete_history(item->id);
1377 BROWSER_LOGE("m_data_manager->get_history_db()->delete_history failed");
1381 elm_object_item_del(history_layout->m_current_sweep_item);
1383 /* If the item is deleted in searched list, then delete it from original history genlist also. */
1384 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1386 Browser_History_DB::history_item *item_data = NULL;
1387 item_data = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1388 if (item_data && (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
1389 if (item_data->id == item->id) {
1390 elm_object_item_del(it);
1394 it = elm_genlist_item_next_get(it);
1397 for(int i = 0 ; i < history_layout->m_history_list.size() ; i++) {
1398 if (history_layout->m_history_list[i]->id == item->id) {
1399 delete history_layout->m_history_list[i];
1400 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + i);
1405 if (history_layout->m_history_list.size() == 0) {
1406 history_layout->_reload_history_genlist();
1409 history_layout->_delete_date_only_label_genlist_item();
1411 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1414 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1417 BROWSER_LOGD("event_info = %d", (int)event_info);
1422 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1424 if (history_layout->m_delete_confirm_popup) {
1425 evas_object_del(history_layout->m_delete_confirm_popup);
1426 history_layout->m_delete_confirm_popup = NULL;
1429 history_layout->_delete_selected_history();
1431 if (history_layout->m_history_list.size() < BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
1432 history_layout->_set_edit_mode(EINA_FALSE);
1436 void Browser_History_Layout::__delete_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1439 BROWSER_LOGD("event_info = %d", (int)event_info);
1444 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1445 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1446 if (history_layout->m_delete_confirm_popup) {
1447 evas_object_del(history_layout->m_delete_confirm_popup);
1448 history_layout->m_delete_confirm_popup = NULL;
1451 history_layout->_delete_history_item_by_slide_button(item);
1454 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1457 BROWSER_LOGD("event_info = %d", (int)event_info);
1462 Evas_Object *popup = (Evas_Object *)data;
1463 evas_object_del(popup);
1466 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1468 BROWSER_LOGD("[%s]", __func__);
1470 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1471 /* Remove date only label item */
1473 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1474 Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1475 if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1477 it = elm_genlist_item_next_get(it);
1478 elm_object_item_del(tmp_it);
1482 it = elm_genlist_item_next_get(it);
1486 void Browser_History_Layout::__slide_delete_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1488 BROWSER_LOGD("[%s]", __func__);
1492 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1493 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1495 Evas_Object *ok_button = history_layout->_show_delete_confirm_popup();
1497 evas_object_smart_callback_add(ok_button, "clicked",
1498 __delete_confirm_response_by_slide_button_cb, item);
1501 void Browser_History_Layout::__bookmark_on_off_icon_clicked_cb(void* data, Evas* evas, Evas_Object* obj, void* ev)
1503 BROWSER_LOGD("[%s]", __func__);
1504 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1505 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1507 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_TRUE;
1509 int bookmark_id = -1;
1510 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), &bookmark_id)) {
1511 evas_object_image_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL);
1512 m_data_manager->get_bookmark_view()->delete_bookmark_item(bookmark_id);
1514 evas_object_image_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL);
1515 m_data_manager->get_bookmark_view()->append_bookmark_item(item->title.c_str(), item->url.c_str());
1519 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1524 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1525 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1526 if (!history_layout)
1529 if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
1530 Evas_Object *favicon = NULL;
1531 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1535 Evas_Object *default_favicon = elm_icon_add(obj);
1536 if (!default_favicon) {
1537 BROWSER_LOGE("elm_icon_add is failed");
1540 elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1541 evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1542 return default_favicon;
1544 } else if (!strncmp(part, "elm.icon.2", strlen("elm.icon.2"))) {
1545 Evas_Object *bookmark_icon = evas_object_image_add(evas_object_evas_get(obj));
1546 evas_object_image_load_size_set(bookmark_icon, 64 * elm_scale_get(), 64 * elm_scale_get());
1547 evas_object_image_fill_set(bookmark_icon, 0, 0, 64 * elm_scale_get(), 64 * elm_scale_get());
1549 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), NULL))
1550 evas_object_image_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL);
1552 evas_object_image_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL);
1554 evas_object_propagate_events_set(bookmark_icon, EINA_FALSE);
1555 evas_object_repeat_events_set(bookmark_icon, EINA_FALSE);
1557 evas_object_event_callback_add(bookmark_icon, EVAS_CALLBACK_MOUSE_DOWN,
1558 __bookmark_on_off_icon_clicked_cb, item);
1560 return bookmark_icon;
1561 } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1562 if (elm_genlist_decorate_mode_get(obj)) {
1563 Evas_Object *check_button = elm_check_add(obj);
1564 if (!check_button) {
1565 BROWSER_LOGE("elm_check_add is failed");
1568 elm_check_state_pointer_set(check_button, &(item->is_delete));
1569 elm_check_state_set(check_button, item->is_delete);
1570 evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1571 return check_button;
1573 } else if (!strncmp(part, "elm.slide.swallow.1", strlen("elm.slide.swallow.1"))) {
1574 Evas_Object *button = elm_button_add(obj);
1576 LOGD("elm_button_add() is failed.");
1580 elm_object_style_set(button, "sweep/multiline");
1581 elm_object_text_set(button, BR_STRING_SHARE);
1582 evas_object_smart_callback_add(button, "clicked", __slide_share_button_clicked_cb, item);
1584 } else if (!strncmp(part, "elm.slide.swallow.2", strlen("elm.slide.swallow.2"))) {
1585 Evas_Object *button = elm_button_add(obj);
1587 LOGD("elm_button_add() is failed.");
1590 elm_object_style_set(button, "sweep/multiline");
1591 elm_object_text_set(button, BR_STRING_ADD_TO_BOOKMARKS);
1592 evas_object_smart_callback_add(button, "clicked", __slide_add_to_bookmark_button_clicked_cb, item);
1594 } else if (!strncmp(part, "elm.slide.swallow.3", strlen("elm.slide.swallow.3"))) {
1595 Evas_Object *button = elm_button_add(obj);
1597 LOGD("elm_button_add() is failed.");
1600 elm_object_style_set(button, "sweep/multiline");
1601 elm_object_text_set(button, BR_STRING_DELETE);
1602 evas_object_smart_callback_add(button, "clicked", __slide_delete_button_clicked_cb, item);
1609 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1611 BROWSER_LOGD("[%s]", __func__);
1614 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1615 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1616 int selected_count = 0;
1617 int total_count = 0;
1618 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1620 Browser_History_DB::history_item *item = NULL;
1621 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1623 /* Ignore the date label. */
1624 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1626 if (item->is_delete)
1629 it = elm_genlist_item_next_get(it);
1632 if (total_count == selected_count)
1633 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1635 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1637 history_layout->_show_selection_info();
1640 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1642 BROWSER_LOGD("[%s]", __func__);
1643 Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1645 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1646 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1648 #if defined(GENLIST_SWEEP)
1649 evas_object_smart_callback_add(genlist, "drag,start,right", __sweep_right_genlist_cb, this);
1650 evas_object_smart_callback_add(genlist, "drag,start,left", __sweep_left_genlist_cb, this);
1651 evas_object_smart_callback_add(genlist, "drag,start,up", __sweep_cancel_genlist_cb, this);
1652 evas_object_smart_callback_add(genlist, "drag,start,down", __sweep_cancel_genlist_cb, this);