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_sub_main_history_layout(NULL)
65 ,m_searchbar_layout(NULL)
66 ,m_searched_history_genlist(NULL)
67 ,m_no_content_search_result(NULL)
69 ,m_delete_confirm_popup(NULL)
70 ,m_is_bookmark_on_off_icon_clicked(EINA_FALSE)
72 BROWSER_LOGD("[%s]", __func__);
75 Browser_History_Layout::~Browser_History_Layout(void)
77 BROWSER_LOGD("[%s]", __func__);
78 hide_notify_popup_layout(m_sub_main_history_layout);
80 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
81 if (m_history_list[i])
82 delete m_history_list[i];
84 m_history_list.clear();
86 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
87 if (m_history_date_label_list[i])
88 free(m_history_date_label_list[i]);
90 m_history_date_label_list.clear();
92 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
93 if (m_searched_history_date_label_list[i])
94 free(m_searched_history_date_label_list[i]);
96 m_searched_history_date_label_list.clear();
98 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
99 if (m_searched_history_item_list[i])
100 delete m_searched_history_item_list[i];
102 m_searched_history_item_list.clear();
104 if (m_delete_confirm_popup)
105 evas_object_del(m_delete_confirm_popup);
109 Eina_Bool Browser_History_Layout::init(void)
111 BROWSER_LOGD("[%s]", __func__);
112 return _create_main_layout();
115 Eina_Bool Browser_History_Layout::_show_searched_history(const char *search_text)
117 BROWSER_LOGD("search_text = [%s]", search_text);
119 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
120 if (m_searched_history_item_list[i])
121 delete m_searched_history_item_list[i];
123 m_searched_history_item_list.clear();
125 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
126 if (m_searched_history_date_label_list[i])
127 free(m_searched_history_date_label_list[i]);
129 m_searched_history_date_label_list.clear();
131 if (!search_text || !strlen(search_text)) {
132 if (m_searched_history_genlist || m_no_content_search_result) {
133 elm_box_unpack_all(m_content_box);
134 elm_box_pack_start(m_content_box, m_history_genlist);
135 evas_object_show(m_history_genlist);
137 if (m_searched_history_genlist) {
138 evas_object_del(m_searched_history_genlist);
139 m_searched_history_genlist = NULL;
142 if (m_no_content_search_result) {
143 evas_object_del(m_no_content_search_result);
144 m_no_content_search_result = NULL;
147 if (m_history_list.size() == 0) {
148 if (m_no_history_label) {
149 elm_box_unpack_all(m_content_box);
150 elm_box_pack_start(m_content_box, m_no_history_label);
158 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
160 Browser_History_DB::history_item *item = NULL;
161 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
162 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
163 if (item->url.find(search_text) != string::npos || item->title.find(search_text) != string::npos) {
164 Browser_History_DB::history_item *searched_item = NULL;
165 searched_item = new(nothrow) Browser_History_DB::history_item;
166 searched_item->id = item->id;
167 searched_item->url = item->url;
168 searched_item->title = item->title;
169 searched_item->date = item->date;
170 searched_item->is_delete = item->is_delete;
171 searched_item->user_data = item->user_data;
172 m_searched_history_item_list.push_back(searched_item);
175 it = elm_genlist_item_next_get(it);
178 if (m_searched_history_item_list.size()) {
179 if (m_no_content_search_result) {
180 evas_object_del(m_no_content_search_result);
181 m_no_content_search_result = NULL;
184 if (!m_searched_history_genlist) {
185 m_searched_history_genlist = _create_history_genlist();
186 if (!m_searched_history_genlist) {
187 BROWSER_LOGE("_create_history_genlist failed");
192 elm_genlist_clear(m_searched_history_genlist);
196 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++) {
197 sscanf(m_searched_history_item_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
198 m_searched_history_item_list[i]->user_data = (void *)this;
199 if (last_date != date) {
201 char *labe_item = strdup(m_searched_history_item_list[i]->date.c_str());
203 BROWSER_LOGE("strdup failed");
206 m_searched_history_date_label_list.push_back(labe_item);
207 it = elm_genlist_item_append(m_searched_history_genlist, &m_history_group_title_class,
208 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
210 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
212 elm_genlist_item_append(m_searched_history_genlist, &m_history_genlist_item_class,
213 m_searched_history_item_list[i], it, ELM_GENLIST_ITEM_NONE,
214 __history_item_clicked_cb, this);
217 elm_box_unpack_all(m_content_box);
218 evas_object_hide(m_history_genlist);
219 elm_box_pack_start(m_content_box, m_searched_history_genlist);
220 evas_object_show(m_searched_history_genlist);
222 BROWSER_LOGD("show no content");
223 if (m_no_content_search_result)
224 evas_object_del(m_no_content_search_result);
225 m_no_content_search_result = elm_layout_add(m_content_box);
226 if (!m_no_content_search_result) {
227 BROWSER_LOGE("elm_layout_add failed");
230 elm_layout_theme_set(m_no_content_search_result, "layout", "nocontents", "search");
231 elm_object_part_text_set(m_no_content_search_result, "elm.text", BR_STRING_NO_SEARCH_RESULT);
232 evas_object_size_hint_weight_set(m_no_content_search_result, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
233 evas_object_size_hint_align_set(m_no_content_search_result, EVAS_HINT_FILL, EVAS_HINT_FILL);
235 if (m_searched_history_genlist) {
236 evas_object_del(m_searched_history_genlist);
237 m_searched_history_genlist = NULL;
240 elm_box_unpack_all(m_content_box);
241 evas_object_hide(m_history_genlist);
242 elm_box_pack_start(m_content_box, m_no_content_search_result);
243 evas_object_show(m_no_content_search_result);
249 void Browser_History_Layout::__search_delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
251 const char *search_text = elm_entry_entry_get(obj);
252 BROWSER_LOGD("search_text=[%s]", search_text);
254 if (!data || !search_text)
257 char *utf8_text = elm_entry_markup_to_utf8(search_text);
261 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
262 if (!elm_entry_is_empty(obj))
263 elm_object_signal_emit(history_layout->m_searchbar, "elm,state,guidetext,hide", "elm");
264 if (!history_layout->_show_searched_history(utf8_text))
265 BROWSER_LOGE("_show_searched_history failed");
270 void Browser_History_Layout::_enable_searchbar_layout(Eina_Bool enable)
273 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "searchbar_base");
276 m_searchbar = br_elm_searchbar_add(m_searchbar_layout);
278 BROWSER_LOGD("br_elm_searchbar_add failed");
281 elm_object_part_content_set(m_searchbar_layout, "searchbar", m_searchbar);
282 evas_object_show(m_searchbar);
284 elm_object_signal_emit(m_searchbar_layout, "elm,state,show,searchbar", "elm");
286 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
287 elm_entry_input_panel_layout_set(searchbar_entry, ELM_INPUT_PANEL_LAYOUT_URL);
289 evas_object_smart_callback_add(searchbar_entry, "changed", __search_delay_changed_cb, this);
291 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
292 if (m_searched_history_item_list[i])
293 delete m_searched_history_item_list[i];
295 m_searched_history_item_list.clear();
297 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
298 if (m_searched_history_date_label_list[i])
299 free(m_searched_history_date_label_list[i]);
301 m_searched_history_date_label_list.clear();
303 if (m_searched_history_genlist || m_no_content_search_result) {
304 elm_box_unpack_all(m_content_box);
305 elm_box_pack_start(m_content_box, m_history_genlist);
306 evas_object_show(m_history_genlist);
308 if (m_searched_history_genlist) {
309 evas_object_del(m_searched_history_genlist);
310 m_searched_history_genlist = NULL;
313 if (m_no_content_search_result) {
314 evas_object_del(m_no_content_search_result);
315 m_no_content_search_result = NULL;
320 elm_object_part_content_unset(m_searchbar_layout, "searchbar");
321 evas_object_hide(m_searchbar);
324 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
325 evas_object_smart_callback_del(searchbar_entry, "changed", __search_delay_changed_cb);
327 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "noindicator");
331 void Browser_History_Layout::_set_edit_mode(Eina_Bool edit_mode)
333 BROWSER_LOGD("[%s]", __func__);
334 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
336 hide_notify_popup_layout(m_sub_main_history_layout);
338 _enable_searchbar_layout(!edit_mode);
341 elm_object_style_set(m_bg, "edit_mode");
343 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
344 if (!m_edit_mode_select_all_layout) {
345 BROWSER_LOGE("elm_layout_add failed");
348 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
349 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
350 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
351 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
352 __edit_mode_select_all_clicked_cb, this);
354 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
355 if (!m_edit_mode_select_all_check_button) {
356 BROWSER_LOGE("elm_layout_add failed");
359 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
360 __edit_mode_select_all_check_changed_cb, this);
361 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
363 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
364 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
366 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
367 evas_object_show(m_edit_mode_select_all_layout);
369 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
370 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
372 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
374 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
375 BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
377 if (m_edit_mode_select_all_layout) {
378 elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
379 evas_object_del(m_edit_mode_select_all_layout);
380 m_edit_mode_select_all_layout = NULL;
382 if (m_edit_mode_select_all_check_button) {
383 evas_object_del(m_edit_mode_select_all_check_button);
384 m_edit_mode_select_all_check_button = NULL;
386 if (m_no_history_label) {
387 evas_object_del(m_no_history_label);
388 m_no_history_label = NULL;
391 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
392 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
393 BROWSER_LOGE("_set_controlbar_type failed");
395 Elm_Object_Item *it = NULL;
396 Browser_History_DB::history_item *item = NULL;
397 it = elm_genlist_first_item_get(m_history_genlist);
399 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
400 item->is_delete = EINA_FALSE;
401 it = elm_genlist_item_next_get(it);
404 elm_object_style_set(m_bg, "default");
405 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
406 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
408 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
410 if (m_history_list.size() == 0) {
411 elm_box_unpack_all(m_content_box);
412 elm_genlist_clear(m_history_genlist);
413 evas_object_hide(m_history_genlist);
415 if (m_edit_mode_select_all_layout) {
416 evas_object_del(m_edit_mode_select_all_layout);
417 m_edit_mode_select_all_layout = NULL;
419 if (m_edit_mode_select_all_check_button) {
420 evas_object_del(m_edit_mode_select_all_check_button);
421 m_edit_mode_select_all_check_button = NULL;
424 m_no_history_label = elm_label_add(m_searchbar_layout);
425 if (!m_no_history_label) {
426 BROWSER_LOGE("elm_label_add failed");
430 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
431 elm_object_text_set(m_no_history_label, text.c_str());
432 evas_object_show(m_no_history_label);
433 elm_box_pack_start(m_content_box, m_no_history_label);
435 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
440 void Browser_History_Layout::_show_selection_info(void)
442 BROWSER_LOGD("[%s]", __func__);
443 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
444 int selected_count = 0;
447 Browser_History_DB::history_item *item = NULL;
448 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
449 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
454 it = elm_genlist_item_next_get(it);
457 if (selected_count == 0) {
458 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
459 hide_notify_popup_layout(m_sub_main_history_layout);
462 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
464 if (selected_count == 1) {
465 show_notify_popup_layout(BR_STRING_ONE_ITEM_SELECTED, 0, m_sub_main_history_layout);
466 } else if (selected_count > 1) {
467 char *small_popup_text = NULL;
468 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 1;
470 small_popup_text = (char *)malloc(string_len * sizeof(char));
471 memset(small_popup_text, 0x00, string_len);
473 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
474 show_notify_popup_layout(small_popup_text, 0, m_sub_main_history_layout);
476 if (small_popup_text)
477 free(small_popup_text);
478 small_popup_text = 0x00;
482 void Browser_History_Layout::_show_delete_processing_popup(void)
484 BROWSER_LOGD("[%s]", __func__);
485 if (m_processing_popup)
486 evas_object_del(m_processing_popup);
488 m_processing_popup = elm_popup_add(m_searchbar_layout);
489 if (!m_processing_popup) {
490 BROWSER_LOGE("elm_popup_add failed");
494 if (m_processing_popup_layout)
495 evas_object_del(m_processing_popup_layout);
496 m_processing_popup_layout = elm_layout_add(m_processing_popup);
497 if (!m_processing_popup_layout) {
498 BROWSER_LOGE("elm_layout_add failed");
501 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
502 "browser/popup_center_progressview")) {
503 BROWSER_LOGE("elm_layout_file_set failed");
506 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
508 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
509 elm_object_style_set(m_processing_progress_bar, "list_progress");
510 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
511 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
512 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
513 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
515 if (m_processing_popup_timer)
516 ecore_timer_del(m_processing_popup_timer);
518 m_processed_count = 0;
519 m_processed_it = elm_genlist_last_item_get(m_history_genlist);
521 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
522 m_total_item_count = 0;
524 Browser_History_DB::history_item *item = NULL;
525 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
526 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
528 m_total_item_count++;
530 it = elm_genlist_item_next_get(it);
533 m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
534 evas_object_show(m_processing_progress_bar);
536 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
537 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
538 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
539 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
541 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
543 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
544 if (!cancel_button) {
545 BROWSER_LOGE("elm_button_add failed");
548 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
549 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
550 evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
552 evas_object_show(m_processing_popup);
555 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
557 BROWSER_LOGD("[%s]", __func__);
561 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
563 evas_object_del(history_layout->m_processing_popup);
565 history_layout->m_processing_progress_bar = NULL;
566 history_layout->m_processed_it = NULL;
568 if (history_layout->m_processing_popup_timer) {
569 ecore_timer_del(history_layout->m_processing_popup_timer);
570 history_layout->m_processing_popup_timer = NULL;
573 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
575 if (history_layout->m_history_list.size() == 0) {
576 elm_box_unpack_all(history_layout->m_content_box);
577 elm_genlist_clear(history_layout->m_history_genlist);
578 evas_object_hide(history_layout->m_history_genlist);
580 if (history_layout->m_edit_mode_select_all_layout) {
581 evas_object_del(history_layout->m_edit_mode_select_all_layout);
582 history_layout->m_edit_mode_select_all_layout = NULL;
584 if (history_layout->m_edit_mode_select_all_check_button) {
585 evas_object_del(history_layout->m_edit_mode_select_all_check_button);
586 history_layout->m_edit_mode_select_all_check_button = NULL;
589 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
590 if (!history_layout->m_no_history_label) {
591 BROWSER_LOGE("elm_label_add failed");
595 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
596 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
597 evas_object_show(history_layout->m_no_history_label);
598 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
600 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
601 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
602 BROWSER_LOGE("_set_controlbar_type failed");
604 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
608 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
610 BROWSER_LOGD("[%s]", __func__);
612 return ECORE_CALLBACK_CANCEL;
614 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
615 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
617 Eina_Bool check_value = history_layout->m_select_all_check_value;
619 double value = elm_progressbar_value_get(progress_bar);
621 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
623 history_layout->m_processing_popup_timer = NULL;
624 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
626 return ECORE_CALLBACK_CANCEL;
629 while (history_layout->m_processed_it) {
630 Browser_History_DB::history_item *item = NULL;
631 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
634 && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
635 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
636 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
637 if (history_layout->m_history_list[index]->id == item->id) {
638 delete history_layout->m_history_list[index];
639 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
643 history_layout->m_processed_count++;
644 Elm_Object_Item *it = history_layout->m_processed_it;
645 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
646 elm_object_item_del(it);
647 elm_genlist_realized_items_update(history_layout->m_history_genlist);
649 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
651 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
653 if (history_layout->m_processed_count % 20 == 0)
657 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
658 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
660 char progress_text[20] = {0, };
661 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
662 history_layout->m_processed_count, history_layout->m_total_item_count);
664 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
665 "elm.text.right", progress_text);
667 return ECORE_CALLBACK_RENEW;
670 void Browser_History_Layout::_show_select_processing_popup(void)
672 BROWSER_LOGD("[%s]", __func__);
673 if (m_processing_popup)
674 evas_object_del(m_processing_popup);
676 m_processing_popup = elm_popup_add(m_searchbar_layout);
677 if (!m_processing_popup) {
678 BROWSER_LOGE("elm_popup_add failed");
682 if (m_processing_popup_layout)
683 evas_object_del(m_processing_popup_layout);
684 m_processing_popup_layout = elm_layout_add(m_processing_popup);
685 if (!m_processing_popup_layout) {
686 BROWSER_LOGE("elm_layout_add failed");
689 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
690 "browser/popup_center_progressview")) {
691 BROWSER_LOGE("elm_layout_file_set failed");
694 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
696 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
697 elm_object_style_set(m_processing_progress_bar, "list_progress");
698 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
699 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
700 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
701 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
703 if (m_processing_popup_timer)
704 ecore_timer_del(m_processing_popup_timer);
706 m_processed_count = 0;
707 m_processed_it = elm_genlist_first_item_get(m_history_genlist);
709 m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
710 evas_object_show(m_processing_progress_bar);
712 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
713 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
714 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
715 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
717 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
719 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
720 if (!cancel_button) {
721 BROWSER_LOGE("elm_button_add failed");
724 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
725 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
726 evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
728 evas_object_show(m_processing_popup);
730 Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
731 m_select_all_check_value = check_value;
734 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
737 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
739 BROWSER_LOGD("[%s]", __func__);
743 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
745 evas_object_del(history_layout->m_processing_popup);
747 history_layout->m_processing_progress_bar = NULL;
748 history_layout->m_processed_it = NULL;
750 if (history_layout->m_processing_popup_timer) {
751 ecore_timer_del(history_layout->m_processing_popup_timer);
752 history_layout->m_processing_popup_timer = NULL;
755 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
758 Browser_History_DB::history_item *item = NULL;
759 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
761 if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
764 it = elm_genlist_item_next_get(it);
767 history_layout->_delete_date_only_label_genlist_item();
770 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
772 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
775 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
778 return ECORE_CALLBACK_CANCEL;
780 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
781 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
783 Eina_Bool check_value = history_layout->m_select_all_check_value;
785 double value = elm_progressbar_value_get(progress_bar);
787 __select_processing_popup_response_cb(history_layout, NULL, NULL);
789 history_layout->m_processing_popup_timer = NULL;
790 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
791 history_layout->_show_selection_info();
793 return ECORE_CALLBACK_CANCEL;
796 while (history_layout->m_processed_it) {
797 Browser_History_DB::history_item *item = NULL;
798 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
799 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
800 item->is_delete = !check_value;
801 elm_genlist_item_update(history_layout->m_processed_it);
802 history_layout->m_processed_count++;
804 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
806 if (history_layout->m_processed_count % 30 == 0)
810 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
811 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
813 char progress_text[20] = {0, };
814 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
815 history_layout->m_processed_count, history_layout->m_history_list.size());
817 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
818 "elm.text.right", progress_text);
820 return ECORE_CALLBACK_RENEW;
823 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
824 Evas_Object *obj, void *event_info)
826 BROWSER_LOGD("[%s]", __func__);
830 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
831 Eina_Bool value = elm_check_state_get(obj);
833 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
834 elm_check_state_set(obj, !value);
835 history_layout->_show_select_processing_popup();
837 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
839 Browser_History_DB::history_item *item = NULL;
840 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
842 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
843 item->is_delete = value;
844 elm_genlist_item_update(it);
847 it = elm_genlist_item_next_get(it);
850 history_layout->_show_selection_info();
854 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
855 Evas_Object *obj, void *event_info)
860 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
862 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
863 history_layout->_show_select_processing_popup();
865 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
866 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
868 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
870 Browser_History_DB::history_item *item = NULL;
871 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
873 /* Ignore the date label. */
874 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
875 item->is_delete = !value;
876 elm_genlist_item_update(it);
879 it = elm_genlist_item_next_get(it);
882 history_layout->_show_selection_info();
886 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
888 BROWSER_LOGD("[%s]", __func__);
892 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
894 if (history_layout->m_is_bookmark_on_off_icon_clicked) {
895 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_FALSE;
896 Elm_Object_Item *selected_item = (Elm_Object_Item *)eventInfo;
897 elm_genlist_item_selected_set(selected_item, EINA_FALSE);
901 Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
902 Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
905 if (!elm_genlist_decorate_mode_get(obj)) {
906 /* calculate the index of the selected item */
907 while (index_item != seleted_item) {
908 /* Do not count date label item */
909 if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
912 index_item = elm_genlist_item_next_get(index_item);
915 const char *selected_url = NULL;
916 if (history_layout->m_searched_history_genlist == obj)
917 selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
919 selected_url = history_layout->m_history_list[index]->url.c_str();
921 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
923 Browser_History_DB::history_item *item = NULL;
924 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
925 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
926 item->is_delete = !(item->is_delete);
927 elm_genlist_item_update(seleted_item);
929 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
931 int selected_count = 0;
933 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
935 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
936 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
941 it = elm_genlist_item_next_get(it);
944 if (selected_count == total_count)
945 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
947 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
949 history_layout->_show_selection_info();
953 void Browser_History_Layout::_delete_selected_history(void)
955 BROWSER_LOGD("[%s]", __func__);
957 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
958 int delete_item_count = 0;
959 Browser_History_DB::history_item *item = NULL;
961 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
962 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
965 it = elm_genlist_item_next_get(it);
968 if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
969 _show_delete_processing_popup();
971 Eina_List *delete_item_list = NULL;
972 it = elm_genlist_first_item_get(m_history_genlist);
973 int remain_count = 0;
974 Browser_History_DB::history_item *item = NULL;
977 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
978 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
980 delete_item_list = eina_list_append(delete_item_list, it);
984 it = elm_genlist_item_next_get(it);
987 int count = eina_list_count(delete_item_list);
988 for (int i = 0; i < count; i++) {
989 it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
990 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
991 /* Delete history item */
992 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
994 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
996 delete_item_list = eina_list_next(delete_item_list);
998 for(int index = 0 ; index < m_history_list.size() ; index++) {
999 if (m_history_list[index]->id == item->id) {
1000 delete m_history_list[index];
1001 m_history_list.erase(m_history_list.begin() + index);
1005 elm_object_item_del(it);
1007 eina_list_free(delete_item_list);
1009 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
1011 _delete_date_only_label_genlist_item();
1013 if (remain_count == 0) {
1014 elm_box_unpack_all(m_content_box);
1015 elm_genlist_clear(m_history_genlist);
1016 evas_object_hide(m_history_genlist);
1018 if (m_edit_mode_select_all_layout) {
1019 evas_object_del(m_edit_mode_select_all_layout);
1020 m_edit_mode_select_all_layout = NULL;
1022 if (m_edit_mode_select_all_check_button) {
1023 evas_object_del(m_edit_mode_select_all_check_button);
1024 m_edit_mode_select_all_check_button = NULL;
1027 m_no_history_label = elm_label_add(m_searchbar_layout);
1028 if (!m_no_history_label) {
1029 BROWSER_LOGE("elm_label_add failed");
1033 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1034 elm_object_text_set(m_no_history_label, text.c_str());
1035 evas_object_show(m_no_history_label);
1036 elm_box_pack_start(m_content_box, m_no_history_label);
1038 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1039 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1040 BROWSER_LOGE("_set_controlbar_type failed");
1042 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1045 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1049 void Browser_History_Layout::_reload_history_genlist(void)
1051 Elm_Object_Item *it = NULL;
1052 while (it = elm_genlist_first_item_get(m_history_genlist))
1053 elm_object_item_del(it);
1055 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1056 if (m_history_list[i])
1057 delete m_history_list[i];
1059 elm_box_unpack_all(m_content_box);
1060 m_history_list.clear();
1062 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1063 if (m_history_date_label_list[i])
1064 free(m_history_date_label_list[i]);
1066 m_history_date_label_list.clear();
1068 Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1070 BROWSER_LOGE("get_history_list failed");
1072 unsigned int history_count = m_history_list.size();
1073 BROWSER_LOGD("history_count=%d", history_count);
1076 for(int i = 0 ; i < history_count; i++) {
1077 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1078 m_history_list[i]->user_data = (void *)this;
1079 if (m_last_date != date) {
1081 char *labe_item = strdup(m_history_list[i]->date.c_str());
1083 BROWSER_LOGE("strdup failed");
1086 m_history_date_label_list.push_back(labe_item);
1087 it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1088 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1090 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1092 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1093 ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1096 if (m_no_history_label) {
1097 evas_object_del(m_no_history_label);
1098 m_no_history_label = NULL;
1101 if (m_edit_mode_select_all_check_button) {
1102 evas_object_del(m_edit_mode_select_all_check_button);
1103 m_edit_mode_select_all_check_button = NULL;
1106 if (m_edit_mode_select_all_layout) {
1107 evas_object_del(m_edit_mode_select_all_layout);
1108 m_edit_mode_select_all_layout = NULL;
1111 if (m_history_list.size() == 0) {
1112 evas_object_hide(m_history_genlist);
1114 m_no_history_label = elm_label_add(m_searchbar_layout);
1115 if (!m_no_history_label) {
1116 BROWSER_LOGE("elm_label_add failed");
1120 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1121 elm_object_text_set(m_no_history_label, text.c_str());
1122 evas_object_show(m_no_history_label);
1123 elm_box_pack_start(m_content_box, m_no_history_label);
1125 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1126 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1127 BROWSER_LOGE("_set_controlbar_type failed");
1128 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1130 elm_box_pack_start(m_content_box, m_history_genlist);
1131 evas_object_show(m_history_genlist);
1133 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1134 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1138 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1140 BROWSER_LOGD("[%s]", __func__);
1141 elm_object_style_set(m_bg, "default");
1143 m_sub_main_history_layout = elm_layout_add(m_navi_bar);
1144 if (!m_sub_main_history_layout) {
1145 BROWSER_LOGE("elm_layout_add failed");
1148 elm_layout_file_set(m_sub_main_history_layout,
1149 BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
1150 "browser/selectioninfo");
1151 evas_object_size_hint_weight_set(
1152 m_sub_main_history_layout,
1153 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1154 evas_object_size_hint_align_set(
1155 m_sub_main_history_layout,
1156 EVAS_HINT_FILL, EVAS_HINT_FILL);
1158 m_searchbar_layout = elm_layout_add(m_sub_main_history_layout);
1159 if (!m_searchbar_layout) {
1160 BROWSER_LOGE("elm_layout_add failed");
1164 _enable_searchbar_layout(EINA_TRUE);
1166 evas_object_show(m_searchbar_layout);
1168 m_content_box = elm_box_add(m_searchbar_layout);
1169 if (!m_content_box) {
1170 BROWSER_LOGE("elm_box_add failed");
1174 m_history_genlist = _create_history_genlist();
1175 if (!m_history_genlist) {
1176 BROWSER_LOGE("_create_history_genlist failed");
1180 m_history_genlist_item_class.decorate_item_style = "mode/slide3";
1181 m_history_genlist_item_class.item_style = "2text.2icon.4";
1182 m_history_genlist_item_class.decorate_all_item_style = "edit_default";
1183 m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1184 m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1185 m_history_genlist_item_class.func.state_get = NULL;
1186 m_history_genlist_item_class.func.del = NULL;
1188 m_history_group_title_class.item_style = "grouptitle";
1189 m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1190 m_history_group_title_class.func.content_get = NULL;
1191 m_history_group_title_class.func.state_get = NULL;
1192 m_history_group_title_class.func.del = NULL;
1194 _reload_history_genlist();
1196 evas_object_show(m_content_box);
1197 elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1198 elm_object_part_content_set(m_sub_main_history_layout, "genlist.swallow.contents", m_searchbar_layout);
1203 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1205 BROWSER_LOGD("[%s]", __func__);
1207 m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1208 if (!m_delete_confirm_popup) {
1209 BROWSER_LOGE("elm_popup_add failed");
1213 evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1214 elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1216 Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1217 elm_object_text_set(ok_button, BR_STRING_YES);
1218 elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1220 Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1221 elm_object_text_set(cancel_button, BR_STRING_NO);
1222 elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1223 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1224 m_delete_confirm_popup);
1226 evas_object_show(m_delete_confirm_popup);
1231 #if defined(GENLIST_SWEEP)
1232 void Browser_History_Layout::__sweep_right_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1234 BROWSER_LOGD("[%s]", __func__);
1235 if (!data || elm_genlist_decorate_mode_get(obj))
1238 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_TRUE);
1239 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_NONE);
1242 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1243 if (history_layout->m_current_sweep_item)
1244 elm_genlist_item_select_mode_set(history_layout->m_current_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1245 history_layout->m_current_sweep_item = (Elm_Object_Item *)event_info;
1248 void Browser_History_Layout::__sweep_cancel_genlist_cb(void *data,
1249 Evas_Object *obj, void *event_info)
1251 BROWSER_LOGD("[%s]", __func__);
1256 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1257 Elm_Object_Item *it = (Elm_Object_Item*)elm_genlist_decorated_item_get(obj);
1259 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1260 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1262 if (it == history_layout->m_current_sweep_item)
1263 history_layout->m_current_sweep_item = NULL;
1267 void Browser_History_Layout::__sweep_left_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1269 BROWSER_LOGD("[%s]", __func__);
1270 if (!data || elm_genlist_decorate_mode_get(obj))
1273 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_FALSE);
1274 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
1277 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1278 history_layout->m_current_sweep_item = NULL;
1282 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1287 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1291 char *mark_up = NULL;
1293 if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1294 || !strncmp(part, "elm.base.text", strlen("elm.base.text"))
1295 || !strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")))
1297 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1299 } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))
1300 || !strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2"))) {
1301 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1308 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1313 char *date_label = (char *)data;
1315 if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1317 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1319 sscanf(date_label, "%d-%d-%d",
1320 &date.year, &date.month, &date.day);
1321 // BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1323 struct tm *time_info;
1325 time_info = localtime(&raw_time);
1327 // BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1328 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1329 day_gap = time_info->tm_mday - date.day;
1331 time_info->tm_year = date.year - 1900;
1332 time_info->tm_mon = date.month - 1;
1334 time_info->tm_mday = date.day;
1338 strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1339 else if (day_gap == 1)
1340 strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1342 strftime (buffer, 40, "%a, %b %d %Y", time_info);
1343 return strdup(buffer);
1348 void Browser_History_Layout::__slide_add_to_bookmark_button_clicked_cb(void *data, Evas_Object *obj,
1351 BROWSER_LOGD("[%s]", __func__);
1355 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1356 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1358 /* If add to bookmark is excuted in searched list, remove the searched list. */
1359 Evas_Object *searchbar = NULL;
1360 searchbar = edje_object_part_external_object_get(elm_layout_edje_get(history_layout->m_searchbar_layout),
1362 br_elm_searchbar_text_set(searchbar, "");
1364 if (!m_data_manager->create_add_to_bookmark_view(item->title, item->url)) {
1365 BROWSER_LOGE("create_add_to_bookmark_view failed");
1369 if (!m_data_manager->get_add_to_bookmark_view()->init()) {
1370 BROWSER_LOGE("get_add_to_bookmark_view()->init() failed");
1371 m_data_manager->destroy_add_to_bookmark_view();
1376 void Browser_History_Layout::__slide_share_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1378 BROWSER_LOGD("[%s]", __func__);
1382 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1383 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1384 if (!history_layout->_show_share_popup(item->url.c_str()))
1385 BROWSER_LOGE("_show_share_popup failed");
1388 void Browser_History_Layout::_delete_history_item_by_slide_button(Browser_History_DB::history_item *item)
1390 BROWSER_LOGD("[%s]", __func__);
1391 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1393 int ret = EINA_TRUE;
1394 ret = m_data_manager->get_history_db()->delete_history(item->id);
1396 BROWSER_LOGE("m_data_manager->get_history_db()->delete_history failed");
1400 elm_object_item_del(history_layout->m_current_sweep_item);
1402 /* If the item is deleted in searched list, then delete it from original history genlist also. */
1403 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1405 Browser_History_DB::history_item *item_data = NULL;
1406 item_data = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1407 if (item_data && (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
1408 if (item_data->id == item->id) {
1409 elm_object_item_del(it);
1413 it = elm_genlist_item_next_get(it);
1416 for(int i = 0 ; i < history_layout->m_history_list.size() ; i++) {
1417 if (history_layout->m_history_list[i]->id == item->id) {
1418 delete history_layout->m_history_list[i];
1419 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + i);
1424 if (history_layout->m_history_list.size() == 0) {
1425 history_layout->_reload_history_genlist();
1428 history_layout->_delete_date_only_label_genlist_item();
1430 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1433 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1436 BROWSER_LOGD("event_info = %d", (int)event_info);
1441 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1443 if (history_layout->m_delete_confirm_popup) {
1444 evas_object_del(history_layout->m_delete_confirm_popup);
1445 history_layout->m_delete_confirm_popup = NULL;
1448 history_layout->_delete_selected_history();
1450 if (history_layout->m_history_list.size() < BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
1451 history_layout->_set_edit_mode(EINA_FALSE);
1455 void Browser_History_Layout::__delete_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1458 BROWSER_LOGD("event_info = %d", (int)event_info);
1463 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1464 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1465 if (history_layout->m_delete_confirm_popup) {
1466 evas_object_del(history_layout->m_delete_confirm_popup);
1467 history_layout->m_delete_confirm_popup = NULL;
1470 history_layout->_delete_history_item_by_slide_button(item);
1473 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1476 BROWSER_LOGD("event_info = %d", (int)event_info);
1481 Evas_Object *popup = (Evas_Object *)data;
1482 evas_object_del(popup);
1485 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1487 BROWSER_LOGD("[%s]", __func__);
1489 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1490 /* Remove date only label item */
1492 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1493 Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1494 if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1496 it = elm_genlist_item_next_get(it);
1497 elm_object_item_del(tmp_it);
1501 it = elm_genlist_item_next_get(it);
1505 void Browser_History_Layout::__slide_delete_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1507 BROWSER_LOGD("[%s]", __func__);
1511 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1512 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1514 Evas_Object *ok_button = history_layout->_show_delete_confirm_popup();
1516 evas_object_smart_callback_add(ok_button, "clicked",
1517 __delete_confirm_response_by_slide_button_cb, item);
1520 void Browser_History_Layout::__bookmark_on_off_icon_clicked_cb(void* data, Evas* evas, Evas_Object* obj, void* ev)
1522 BROWSER_LOGD("[%s]", __func__);
1523 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1524 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1526 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_TRUE;
1528 int bookmark_id = -1;
1529 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), &bookmark_id)) {
1530 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1531 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1533 m_data_manager->get_bookmark_view()->delete_bookmark_item(bookmark_id);
1535 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1536 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1538 m_data_manager->get_bookmark_view()->append_bookmark_item(item->title.c_str(), item->url.c_str());
1542 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1547 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1548 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1549 if (!history_layout)
1552 if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
1553 Evas_Object *favicon = NULL;
1554 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1558 Evas_Object *default_favicon = elm_icon_add(obj);
1559 if (!default_favicon) {
1560 BROWSER_LOGE("elm_icon_add is failed");
1563 elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1564 evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1565 return default_favicon;
1567 } else if (!strncmp(part, "elm.icon.2", strlen("elm.icon.2"))) {
1568 Evas_Object *bookmark_icon = elm_icon_add(obj);
1569 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), NULL)) {
1570 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1571 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1575 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1576 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1580 evas_object_size_hint_aspect_set(bookmark_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1581 evas_object_propagate_events_set(bookmark_icon, EINA_FALSE);
1582 evas_object_repeat_events_set(bookmark_icon, EINA_FALSE);
1584 evas_object_event_callback_add(bookmark_icon, EVAS_CALLBACK_MOUSE_DOWN,
1585 __bookmark_on_off_icon_clicked_cb, item);
1587 return bookmark_icon;
1588 } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1589 if (elm_genlist_decorate_mode_get(obj)) {
1590 Evas_Object *check_button = elm_check_add(obj);
1591 if (!check_button) {
1592 BROWSER_LOGE("elm_check_add is failed");
1595 elm_check_state_pointer_set(check_button, &(item->is_delete));
1596 elm_check_state_set(check_button, item->is_delete);
1597 evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1598 return check_button;
1600 } else if (!strncmp(part, "elm.slide.swallow.1", strlen("elm.slide.swallow.1"))) {
1601 Evas_Object *button = elm_button_add(obj);
1603 LOGD("elm_button_add() is failed.");
1607 elm_object_style_set(button, "sweep/multiline");
1608 elm_object_text_set(button, BR_STRING_SHARE);
1609 evas_object_smart_callback_add(button, "clicked", __slide_share_button_clicked_cb, item);
1611 } else if (!strncmp(part, "elm.slide.swallow.2", strlen("elm.slide.swallow.2"))) {
1612 Evas_Object *button = elm_button_add(obj);
1614 LOGD("elm_button_add() is failed.");
1617 elm_object_style_set(button, "sweep/multiline");
1618 elm_object_text_set(button, BR_STRING_ADD_TO_BOOKMARKS);
1619 evas_object_smart_callback_add(button, "clicked", __slide_add_to_bookmark_button_clicked_cb, item);
1621 } else if (!strncmp(part, "elm.slide.swallow.3", strlen("elm.slide.swallow.3"))) {
1622 Evas_Object *button = elm_button_add(obj);
1624 LOGD("elm_button_add() is failed.");
1627 elm_object_style_set(button, "sweep/multiline");
1628 elm_object_text_set(button, BR_STRING_DELETE);
1629 evas_object_smart_callback_add(button, "clicked", __slide_delete_button_clicked_cb, item);
1636 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1638 BROWSER_LOGD("[%s]", __func__);
1641 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1642 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1643 int selected_count = 0;
1644 int total_count = 0;
1645 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1647 Browser_History_DB::history_item *item = NULL;
1648 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1650 /* Ignore the date label. */
1651 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1653 if (item->is_delete)
1656 it = elm_genlist_item_next_get(it);
1659 if (total_count == selected_count)
1660 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1662 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1664 history_layout->_show_selection_info();
1667 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1669 BROWSER_LOGD("[%s]", __func__);
1670 Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1672 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1673 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1675 #if defined(GENLIST_SWEEP)
1676 evas_object_smart_callback_add(genlist, "drag,start,right", __sweep_right_genlist_cb, this);
1677 evas_object_smart_callback_add(genlist, "drag,start,left", __sweep_left_genlist_cb, this);
1678 evas_object_smart_callback_add(genlist, "drag,start,up", __sweep_cancel_genlist_cb, this);
1679 evas_object_smart_callback_add(genlist, "drag,start,down", __sweep_cancel_genlist_cb, this);