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 #if defined(GENLIST_SWEEP)
342 br_elm_genlist_sweep_item_recover(m_history_genlist);
344 elm_object_style_set(m_bg, "edit_mode");
346 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
347 if (!m_edit_mode_select_all_layout) {
348 BROWSER_LOGE("elm_layout_add failed");
351 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
352 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
353 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
354 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
355 __edit_mode_select_all_clicked_cb, this);
357 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
358 if (!m_edit_mode_select_all_check_button) {
359 BROWSER_LOGE("elm_layout_add failed");
362 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
363 __edit_mode_select_all_check_changed_cb, this);
364 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
366 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
367 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
369 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
370 evas_object_show(m_edit_mode_select_all_layout);
372 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
373 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
375 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
377 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
378 BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
380 if (m_edit_mode_select_all_layout) {
381 elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
382 evas_object_del(m_edit_mode_select_all_layout);
383 m_edit_mode_select_all_layout = NULL;
385 if (m_edit_mode_select_all_check_button) {
386 evas_object_del(m_edit_mode_select_all_check_button);
387 m_edit_mode_select_all_check_button = NULL;
389 if (m_no_history_label) {
390 evas_object_del(m_no_history_label);
391 m_no_history_label = NULL;
394 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
395 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
396 BROWSER_LOGE("_set_controlbar_type failed");
398 Elm_Object_Item *it = NULL;
399 Browser_History_DB::history_item *item = NULL;
400 it = elm_genlist_first_item_get(m_history_genlist);
402 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
403 item->is_delete = EINA_FALSE;
404 it = elm_genlist_item_next_get(it);
407 elm_object_style_set(m_bg, "default");
408 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
409 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
411 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
413 if (m_history_list.size() == 0) {
414 elm_box_unpack_all(m_content_box);
415 elm_genlist_clear(m_history_genlist);
416 evas_object_hide(m_history_genlist);
418 if (m_edit_mode_select_all_layout) {
419 evas_object_del(m_edit_mode_select_all_layout);
420 m_edit_mode_select_all_layout = NULL;
422 if (m_edit_mode_select_all_check_button) {
423 evas_object_del(m_edit_mode_select_all_check_button);
424 m_edit_mode_select_all_check_button = NULL;
427 m_no_history_label = elm_label_add(m_searchbar_layout);
428 if (!m_no_history_label) {
429 BROWSER_LOGE("elm_label_add failed");
433 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
434 elm_object_text_set(m_no_history_label, text.c_str());
435 evas_object_show(m_no_history_label);
436 elm_box_pack_start(m_content_box, m_no_history_label);
438 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
443 void Browser_History_Layout::_show_selection_info(void)
445 BROWSER_LOGD("[%s]", __func__);
446 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
447 int selected_count = 0;
450 Browser_History_DB::history_item *item = NULL;
451 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
452 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
457 it = elm_genlist_item_next_get(it);
460 if (selected_count == 0) {
461 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
462 hide_notify_popup_layout(m_sub_main_history_layout);
465 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
467 if (selected_count == 1) {
468 show_notify_popup_layout(BR_STRING_ONE_ITEM_SELECTED, 0, m_sub_main_history_layout);
469 } else if (selected_count > 1) {
470 char *small_popup_text = NULL;
471 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 1;
473 small_popup_text = (char *)malloc(string_len * sizeof(char));
474 memset(small_popup_text, 0x00, string_len);
476 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
477 show_notify_popup_layout(small_popup_text, 0, m_sub_main_history_layout);
479 if (small_popup_text)
480 free(small_popup_text);
481 small_popup_text = 0x00;
485 void Browser_History_Layout::_show_delete_processing_popup(void)
487 BROWSER_LOGD("[%s]", __func__);
488 if (m_processing_popup)
489 evas_object_del(m_processing_popup);
491 m_processing_popup = elm_popup_add(m_searchbar_layout);
492 if (!m_processing_popup) {
493 BROWSER_LOGE("elm_popup_add failed");
497 if (m_processing_popup_layout)
498 evas_object_del(m_processing_popup_layout);
499 m_processing_popup_layout = elm_layout_add(m_processing_popup);
500 if (!m_processing_popup_layout) {
501 BROWSER_LOGE("elm_layout_add failed");
504 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
505 "browser/popup_center_progressview")) {
506 BROWSER_LOGE("elm_layout_file_set failed");
509 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
511 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
512 elm_object_style_set(m_processing_progress_bar, "list_progress");
513 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
514 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
515 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
518 if (m_processing_popup_timer)
519 ecore_timer_del(m_processing_popup_timer);
521 m_processed_count = 0;
522 m_processed_it = elm_genlist_last_item_get(m_history_genlist);
524 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
525 m_total_item_count = 0;
527 Browser_History_DB::history_item *item = NULL;
528 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
529 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
531 m_total_item_count++;
533 it = elm_genlist_item_next_get(it);
536 m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
537 evas_object_show(m_processing_progress_bar);
539 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
540 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
541 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
542 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
544 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
546 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
547 if (!cancel_button) {
548 BROWSER_LOGE("elm_button_add failed");
551 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
552 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
553 evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
555 evas_object_show(m_processing_popup);
558 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
560 BROWSER_LOGD("[%s]", __func__);
564 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
566 evas_object_del(history_layout->m_processing_popup);
568 history_layout->m_processing_progress_bar = NULL;
569 history_layout->m_processed_it = NULL;
571 if (history_layout->m_processing_popup_timer) {
572 ecore_timer_del(history_layout->m_processing_popup_timer);
573 history_layout->m_processing_popup_timer = NULL;
576 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
578 if (history_layout->m_history_list.size() == 0) {
579 elm_box_unpack_all(history_layout->m_content_box);
580 elm_genlist_clear(history_layout->m_history_genlist);
581 evas_object_hide(history_layout->m_history_genlist);
583 if (history_layout->m_edit_mode_select_all_layout) {
584 evas_object_del(history_layout->m_edit_mode_select_all_layout);
585 history_layout->m_edit_mode_select_all_layout = NULL;
587 if (history_layout->m_edit_mode_select_all_check_button) {
588 evas_object_del(history_layout->m_edit_mode_select_all_check_button);
589 history_layout->m_edit_mode_select_all_check_button = NULL;
592 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
593 if (!history_layout->m_no_history_label) {
594 BROWSER_LOGE("elm_label_add failed");
598 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
599 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
600 evas_object_show(history_layout->m_no_history_label);
601 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
603 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
604 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
605 BROWSER_LOGE("_set_controlbar_type failed");
607 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
611 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
613 BROWSER_LOGD("[%s]", __func__);
615 return ECORE_CALLBACK_CANCEL;
617 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
618 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
620 Eina_Bool check_value = history_layout->m_select_all_check_value;
622 double value = elm_progressbar_value_get(progress_bar);
624 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
626 history_layout->m_processing_popup_timer = NULL;
627 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
629 return ECORE_CALLBACK_CANCEL;
632 while (history_layout->m_processed_it) {
633 Browser_History_DB::history_item *item = NULL;
634 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
637 && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
638 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
639 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
640 if (history_layout->m_history_list[index]->id == item->id) {
641 delete history_layout->m_history_list[index];
642 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
646 history_layout->m_processed_count++;
647 Elm_Object_Item *it = history_layout->m_processed_it;
648 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
649 elm_object_item_del(it);
650 elm_genlist_realized_items_update(history_layout->m_history_genlist);
652 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
654 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
656 if (history_layout->m_processed_count % 20 == 0)
660 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
661 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
663 char progress_text[20] = {0, };
664 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
665 history_layout->m_processed_count, history_layout->m_total_item_count);
667 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
668 "elm.text.right", progress_text);
670 return ECORE_CALLBACK_RENEW;
673 void Browser_History_Layout::_show_select_processing_popup(void)
675 BROWSER_LOGD("[%s]", __func__);
676 if (m_processing_popup)
677 evas_object_del(m_processing_popup);
679 m_processing_popup = elm_popup_add(m_searchbar_layout);
680 if (!m_processing_popup) {
681 BROWSER_LOGE("elm_popup_add failed");
685 if (m_processing_popup_layout)
686 evas_object_del(m_processing_popup_layout);
687 m_processing_popup_layout = elm_layout_add(m_processing_popup);
688 if (!m_processing_popup_layout) {
689 BROWSER_LOGE("elm_layout_add failed");
692 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
693 "browser/popup_center_progressview")) {
694 BROWSER_LOGE("elm_layout_file_set failed");
697 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
699 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
700 elm_object_style_set(m_processing_progress_bar, "list_progress");
701 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
702 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
703 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
704 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
706 if (m_processing_popup_timer)
707 ecore_timer_del(m_processing_popup_timer);
709 m_processed_count = 0;
710 m_processed_it = elm_genlist_first_item_get(m_history_genlist);
712 m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
713 evas_object_show(m_processing_progress_bar);
715 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
716 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
717 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
718 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
720 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
722 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
723 if (!cancel_button) {
724 BROWSER_LOGE("elm_button_add failed");
727 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
728 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
729 evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
731 evas_object_show(m_processing_popup);
733 Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
734 m_select_all_check_value = check_value;
737 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
740 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
742 BROWSER_LOGD("[%s]", __func__);
746 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
748 evas_object_del(history_layout->m_processing_popup);
750 history_layout->m_processing_progress_bar = NULL;
751 history_layout->m_processed_it = NULL;
753 if (history_layout->m_processing_popup_timer) {
754 ecore_timer_del(history_layout->m_processing_popup_timer);
755 history_layout->m_processing_popup_timer = NULL;
758 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
761 Browser_History_DB::history_item *item = NULL;
762 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
764 if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
767 it = elm_genlist_item_next_get(it);
770 history_layout->_delete_date_only_label_genlist_item();
773 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
775 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
778 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
781 return ECORE_CALLBACK_CANCEL;
783 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
784 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
786 Eina_Bool check_value = history_layout->m_select_all_check_value;
788 double value = elm_progressbar_value_get(progress_bar);
790 __select_processing_popup_response_cb(history_layout, NULL, NULL);
792 history_layout->m_processing_popup_timer = NULL;
793 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
794 history_layout->_show_selection_info();
796 return ECORE_CALLBACK_CANCEL;
799 while (history_layout->m_processed_it) {
800 Browser_History_DB::history_item *item = NULL;
801 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
802 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
803 item->is_delete = !check_value;
804 elm_genlist_item_update(history_layout->m_processed_it);
805 history_layout->m_processed_count++;
807 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
809 if (history_layout->m_processed_count % 30 == 0)
813 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
814 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
816 char progress_text[20] = {0, };
817 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
818 history_layout->m_processed_count, history_layout->m_history_list.size());
820 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
821 "elm.text.right", progress_text);
823 return ECORE_CALLBACK_RENEW;
826 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
827 Evas_Object *obj, void *event_info)
829 BROWSER_LOGD("[%s]", __func__);
833 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
834 Eina_Bool value = elm_check_state_get(obj);
836 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
837 elm_check_state_set(obj, !value);
838 history_layout->_show_select_processing_popup();
840 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
842 Browser_History_DB::history_item *item = NULL;
843 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
845 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
846 item->is_delete = value;
847 elm_genlist_item_update(it);
850 it = elm_genlist_item_next_get(it);
853 history_layout->_show_selection_info();
857 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
858 Evas_Object *obj, void *event_info)
863 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
865 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
866 history_layout->_show_select_processing_popup();
868 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
869 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
871 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
873 Browser_History_DB::history_item *item = NULL;
874 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
876 /* Ignore the date label. */
877 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
878 item->is_delete = !value;
879 elm_genlist_item_update(it);
882 it = elm_genlist_item_next_get(it);
885 history_layout->_show_selection_info();
889 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
891 BROWSER_LOGD("[%s]", __func__);
895 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
897 if (history_layout->m_is_bookmark_on_off_icon_clicked) {
898 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_FALSE;
899 Elm_Object_Item *selected_item = (Elm_Object_Item *)eventInfo;
900 elm_genlist_item_selected_set(selected_item, EINA_FALSE);
904 Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
905 Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
908 if (!elm_genlist_decorate_mode_get(obj)) {
909 /* calculate the index of the selected item */
910 while (index_item != seleted_item) {
911 /* Do not count date label item */
912 if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
915 index_item = elm_genlist_item_next_get(index_item);
918 const char *selected_url = NULL;
919 if (history_layout->m_searched_history_genlist == obj)
920 selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
922 selected_url = history_layout->m_history_list[index]->url.c_str();
924 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
926 Browser_History_DB::history_item *item = NULL;
927 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
928 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
929 item->is_delete = !(item->is_delete);
930 elm_genlist_item_update(seleted_item);
932 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
934 int selected_count = 0;
936 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
938 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
939 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
944 it = elm_genlist_item_next_get(it);
947 if (selected_count == total_count)
948 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
950 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
952 history_layout->_show_selection_info();
956 void Browser_History_Layout::_delete_selected_history(void)
958 BROWSER_LOGD("[%s]", __func__);
960 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
961 int delete_item_count = 0;
962 Browser_History_DB::history_item *item = NULL;
964 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
965 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
968 it = elm_genlist_item_next_get(it);
971 if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
972 _show_delete_processing_popup();
974 Eina_List *delete_item_list = NULL;
975 it = elm_genlist_first_item_get(m_history_genlist);
976 int remain_count = 0;
977 Browser_History_DB::history_item *item = NULL;
980 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
981 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
983 delete_item_list = eina_list_append(delete_item_list, it);
987 it = elm_genlist_item_next_get(it);
990 int count = eina_list_count(delete_item_list);
991 for (int i = 0; i < count; i++) {
992 it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
993 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
994 /* Delete history item */
995 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
997 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
999 delete_item_list = eina_list_next(delete_item_list);
1001 for(int index = 0 ; index < m_history_list.size() ; index++) {
1002 if (m_history_list[index]->id == item->id) {
1003 delete m_history_list[index];
1004 m_history_list.erase(m_history_list.begin() + index);
1008 elm_object_item_del(it);
1010 eina_list_free(delete_item_list);
1012 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
1014 _delete_date_only_label_genlist_item();
1016 if (remain_count == 0) {
1017 elm_box_unpack_all(m_content_box);
1018 elm_genlist_clear(m_history_genlist);
1019 evas_object_hide(m_history_genlist);
1021 if (m_edit_mode_select_all_layout) {
1022 evas_object_del(m_edit_mode_select_all_layout);
1023 m_edit_mode_select_all_layout = NULL;
1025 if (m_edit_mode_select_all_check_button) {
1026 evas_object_del(m_edit_mode_select_all_check_button);
1027 m_edit_mode_select_all_check_button = NULL;
1030 m_no_history_label = elm_label_add(m_searchbar_layout);
1031 if (!m_no_history_label) {
1032 BROWSER_LOGE("elm_label_add failed");
1036 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1037 elm_object_text_set(m_no_history_label, text.c_str());
1038 evas_object_show(m_no_history_label);
1039 elm_box_pack_start(m_content_box, m_no_history_label);
1041 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1042 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1043 BROWSER_LOGE("_set_controlbar_type failed");
1045 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1048 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1052 void Browser_History_Layout::_reload_history_genlist(void)
1054 Elm_Object_Item *it = NULL;
1055 while (it = elm_genlist_first_item_get(m_history_genlist))
1056 elm_object_item_del(it);
1058 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1059 if (m_history_list[i])
1060 delete m_history_list[i];
1062 elm_box_unpack_all(m_content_box);
1063 m_history_list.clear();
1065 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1066 if (m_history_date_label_list[i])
1067 free(m_history_date_label_list[i]);
1069 m_history_date_label_list.clear();
1071 Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1073 BROWSER_LOGE("get_history_list failed");
1075 unsigned int history_count = m_history_list.size();
1076 BROWSER_LOGD("history_count=%d", history_count);
1079 for(int i = 0 ; i < history_count; i++) {
1080 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1081 m_history_list[i]->user_data = (void *)this;
1082 if (m_last_date != date) {
1084 char *labe_item = strdup(m_history_list[i]->date.c_str());
1086 BROWSER_LOGE("strdup failed");
1089 m_history_date_label_list.push_back(labe_item);
1090 it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1091 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1093 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1095 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1096 ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1099 if (m_no_history_label) {
1100 evas_object_del(m_no_history_label);
1101 m_no_history_label = NULL;
1104 if (m_edit_mode_select_all_check_button) {
1105 evas_object_del(m_edit_mode_select_all_check_button);
1106 m_edit_mode_select_all_check_button = NULL;
1109 if (m_edit_mode_select_all_layout) {
1110 evas_object_del(m_edit_mode_select_all_layout);
1111 m_edit_mode_select_all_layout = NULL;
1114 if (m_history_list.size() == 0) {
1115 evas_object_hide(m_history_genlist);
1117 m_no_history_label = elm_label_add(m_searchbar_layout);
1118 if (!m_no_history_label) {
1119 BROWSER_LOGE("elm_label_add failed");
1123 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1124 elm_object_text_set(m_no_history_label, text.c_str());
1125 evas_object_show(m_no_history_label);
1126 elm_box_pack_start(m_content_box, m_no_history_label);
1128 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1129 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1130 BROWSER_LOGE("_set_controlbar_type failed");
1131 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1133 elm_box_pack_start(m_content_box, m_history_genlist);
1134 evas_object_show(m_history_genlist);
1136 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1137 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1141 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1143 BROWSER_LOGD("[%s]", __func__);
1144 elm_object_style_set(m_bg, "default");
1146 m_sub_main_history_layout = elm_layout_add(m_navi_bar);
1147 if (!m_sub_main_history_layout) {
1148 BROWSER_LOGE("elm_layout_add failed");
1151 elm_layout_file_set(m_sub_main_history_layout,
1152 BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
1153 "browser/selectioninfo");
1154 evas_object_size_hint_weight_set(
1155 m_sub_main_history_layout,
1156 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1157 evas_object_size_hint_align_set(
1158 m_sub_main_history_layout,
1159 EVAS_HINT_FILL, EVAS_HINT_FILL);
1161 m_searchbar_layout = elm_layout_add(m_sub_main_history_layout);
1162 if (!m_searchbar_layout) {
1163 BROWSER_LOGE("elm_layout_add failed");
1167 _enable_searchbar_layout(EINA_TRUE);
1169 evas_object_show(m_searchbar_layout);
1171 m_content_box = elm_box_add(m_searchbar_layout);
1172 if (!m_content_box) {
1173 BROWSER_LOGE("elm_box_add failed");
1177 m_history_genlist = _create_history_genlist();
1178 if (!m_history_genlist) {
1179 BROWSER_LOGE("_create_history_genlist failed");
1183 m_history_genlist_item_class.decorate_item_style = "mode/slide3";
1184 m_history_genlist_item_class.item_style = "dialogue/2text.2icon.3";
1185 m_history_genlist_item_class.decorate_all_item_style = "dialogue/edit";
1186 m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1187 m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1188 m_history_genlist_item_class.func.state_get = NULL;
1189 m_history_genlist_item_class.func.del = NULL;
1191 m_history_group_title_class.item_style = "dialogue/title";
1192 m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1193 m_history_group_title_class.func.content_get = NULL;
1194 m_history_group_title_class.func.state_get = NULL;
1195 m_history_group_title_class.func.del = NULL;
1197 _reload_history_genlist();
1199 evas_object_show(m_content_box);
1200 elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1201 elm_object_part_content_set(m_sub_main_history_layout, "genlist.swallow.contents", m_searchbar_layout);
1206 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1208 BROWSER_LOGD("[%s]", __func__);
1210 m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1211 if (!m_delete_confirm_popup) {
1212 BROWSER_LOGE("elm_popup_add failed");
1216 evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1217 elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1219 Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1220 elm_object_text_set(ok_button, BR_STRING_YES);
1221 elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1223 Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1224 elm_object_text_set(cancel_button, BR_STRING_NO);
1225 elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1226 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1227 m_delete_confirm_popup);
1229 evas_object_show(m_delete_confirm_popup);
1234 #if defined(GENLIST_SWEEP)
1235 void Browser_History_Layout::__sweep_right_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1237 BROWSER_LOGD("[%s]", __func__);
1238 if (!data || elm_genlist_decorate_mode_get(obj))
1241 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_TRUE);
1242 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_NONE);
1245 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1246 if (history_layout->m_current_sweep_item)
1247 elm_genlist_item_select_mode_set(history_layout->m_current_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1248 history_layout->m_current_sweep_item = (Elm_Object_Item *)event_info;
1251 void Browser_History_Layout::__sweep_cancel_genlist_cb(void *data,
1252 Evas_Object *obj, void *event_info)
1254 BROWSER_LOGD("[%s]", __func__);
1259 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1260 Elm_Object_Item *it = (Elm_Object_Item*)elm_genlist_decorated_item_get(obj);
1262 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1263 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1265 if (it == history_layout->m_current_sweep_item)
1266 history_layout->m_current_sweep_item = NULL;
1270 void Browser_History_Layout::__sweep_left_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1272 BROWSER_LOGD("[%s]", __func__);
1273 if (!data || elm_genlist_decorate_mode_get(obj))
1276 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_FALSE);
1277 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
1280 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1281 history_layout->m_current_sweep_item = NULL;
1285 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1290 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1294 char *mark_up = NULL;
1296 if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1297 || !strncmp(part, "elm.base.text", strlen("elm.base.text"))
1298 || !strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")))
1300 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1302 } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))
1303 || !strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2"))) {
1304 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1311 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1316 char *date_label = (char *)data;
1318 if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1320 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1322 sscanf(date_label, "%d-%d-%d",
1323 &date.year, &date.month, &date.day);
1324 // BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1326 struct tm *time_info;
1328 time_info = localtime(&raw_time);
1330 // BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1331 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1332 day_gap = time_info->tm_mday - date.day;
1334 time_info->tm_year = date.year - 1900;
1335 time_info->tm_mon = date.month - 1;
1337 time_info->tm_mday = date.day;
1341 strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1342 else if (day_gap == 1)
1343 strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1345 strftime (buffer, 40, "%a, %b %d %Y", time_info);
1346 return strdup(buffer);
1351 void Browser_History_Layout::__slide_add_to_bookmark_button_clicked_cb(void *data, Evas_Object *obj,
1354 BROWSER_LOGD("[%s]", __func__);
1358 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1359 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1361 /* If add to bookmark is excuted in searched list, remove the searched list. */
1362 Evas_Object *searchbar = NULL;
1363 searchbar = edje_object_part_external_object_get(elm_layout_edje_get(history_layout->m_searchbar_layout),
1365 br_elm_searchbar_text_set(searchbar, "");
1367 if (!m_data_manager->create_add_to_bookmark_view(item->title, item->url)) {
1368 BROWSER_LOGE("create_add_to_bookmark_view failed");
1372 if (!m_data_manager->get_add_to_bookmark_view()->init()) {
1373 BROWSER_LOGE("get_add_to_bookmark_view()->init() failed");
1374 m_data_manager->destroy_add_to_bookmark_view();
1379 void Browser_History_Layout::__slide_share_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1381 BROWSER_LOGD("[%s]", __func__);
1385 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1386 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1387 if (!history_layout->_show_share_popup(item->url.c_str()))
1388 BROWSER_LOGE("_show_share_popup failed");
1391 void Browser_History_Layout::_delete_history_item_by_slide_button(Browser_History_DB::history_item *item)
1393 BROWSER_LOGD("[%s]", __func__);
1394 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1396 int ret = EINA_TRUE;
1397 ret = m_data_manager->get_history_db()->delete_history(item->id);
1399 BROWSER_LOGE("m_data_manager->get_history_db()->delete_history failed");
1403 elm_object_item_del(history_layout->m_current_sweep_item);
1405 /* If the item is deleted in searched list, then delete it from original history genlist also. */
1406 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1408 Browser_History_DB::history_item *item_data = NULL;
1409 item_data = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1410 if (item_data && (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
1411 if (item_data->id == item->id) {
1412 elm_object_item_del(it);
1416 it = elm_genlist_item_next_get(it);
1419 for(int i = 0 ; i < history_layout->m_history_list.size() ; i++) {
1420 if (history_layout->m_history_list[i]->id == item->id) {
1421 delete history_layout->m_history_list[i];
1422 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + i);
1427 if (history_layout->m_history_list.size() == 0) {
1428 history_layout->_reload_history_genlist();
1431 history_layout->_delete_date_only_label_genlist_item();
1433 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1436 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1439 BROWSER_LOGD("event_info = %d", (int)event_info);
1444 Browser_History_Layout *history_layout = (Browser_History_Layout *)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_selected_history();
1453 if (history_layout->m_history_list.size() < BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
1454 history_layout->_set_edit_mode(EINA_FALSE);
1458 void Browser_History_Layout::__delete_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1461 BROWSER_LOGD("event_info = %d", (int)event_info);
1466 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1467 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1468 if (history_layout->m_delete_confirm_popup) {
1469 evas_object_del(history_layout->m_delete_confirm_popup);
1470 history_layout->m_delete_confirm_popup = NULL;
1473 history_layout->_delete_history_item_by_slide_button(item);
1476 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1479 BROWSER_LOGD("event_info = %d", (int)event_info);
1484 Evas_Object *popup = (Evas_Object *)data;
1485 evas_object_del(popup);
1488 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1490 BROWSER_LOGD("[%s]", __func__);
1492 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1493 /* Remove date only label item */
1495 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1496 Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1497 if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1499 it = elm_genlist_item_next_get(it);
1500 elm_object_item_del(tmp_it);
1504 it = elm_genlist_item_next_get(it);
1508 void Browser_History_Layout::__slide_delete_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1510 BROWSER_LOGD("[%s]", __func__);
1514 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1515 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1517 Evas_Object *ok_button = history_layout->_show_delete_confirm_popup();
1519 evas_object_smart_callback_add(ok_button, "clicked",
1520 __delete_confirm_response_by_slide_button_cb, item);
1523 void Browser_History_Layout::__bookmark_on_off_icon_clicked_cb(void* data, Evas* evas, Evas_Object* obj, void* ev)
1525 BROWSER_LOGD("[%s]", __func__);
1526 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1527 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1529 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_TRUE;
1531 int bookmark_id = -1;
1532 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), &bookmark_id)) {
1533 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1534 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1536 m_data_manager->get_bookmark_view()->delete_bookmark_item(bookmark_id);
1538 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1539 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1541 m_data_manager->get_bookmark_view()->append_bookmark_item(item->title.c_str(), item->url.c_str());
1545 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1550 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1551 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1552 if (!history_layout)
1555 if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
1556 Evas_Object *favicon = NULL;
1557 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1561 Evas_Object *default_favicon = elm_icon_add(obj);
1562 if (!default_favicon) {
1563 BROWSER_LOGE("elm_icon_add is failed");
1566 elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1567 evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1568 return default_favicon;
1570 } else if (!strncmp(part, "elm.icon.2", strlen("elm.icon.2"))) {
1571 Evas_Object *bookmark_icon = elm_icon_add(obj);
1572 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), NULL)) {
1573 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1574 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1578 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1579 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1583 evas_object_size_hint_aspect_set(bookmark_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1584 evas_object_propagate_events_set(bookmark_icon, EINA_FALSE);
1585 evas_object_repeat_events_set(bookmark_icon, EINA_FALSE);
1587 evas_object_event_callback_add(bookmark_icon, EVAS_CALLBACK_MOUSE_DOWN,
1588 __bookmark_on_off_icon_clicked_cb, item);
1590 return bookmark_icon;
1591 } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1592 if (elm_genlist_decorate_mode_get(obj)) {
1593 Evas_Object *check_button = elm_check_add(obj);
1594 if (!check_button) {
1595 BROWSER_LOGE("elm_check_add is failed");
1598 elm_check_state_pointer_set(check_button, &(item->is_delete));
1599 elm_check_state_set(check_button, item->is_delete);
1600 evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1601 return check_button;
1603 } else if (!strncmp(part, "elm.slide.swallow.1", strlen("elm.slide.swallow.1"))) {
1604 Evas_Object *button = elm_button_add(obj);
1606 LOGD("elm_button_add() is failed.");
1610 elm_object_style_set(button, "sweep/multiline");
1611 elm_object_text_set(button, BR_STRING_SHARE);
1612 evas_object_smart_callback_add(button, "clicked", __slide_share_button_clicked_cb, item);
1614 } else if (!strncmp(part, "elm.slide.swallow.2", strlen("elm.slide.swallow.2"))) {
1615 Evas_Object *button = elm_button_add(obj);
1617 LOGD("elm_button_add() is failed.");
1620 elm_object_style_set(button, "sweep/multiline");
1621 elm_object_text_set(button, BR_STRING_ADD_TO_BOOKMARKS);
1622 evas_object_smart_callback_add(button, "clicked", __slide_add_to_bookmark_button_clicked_cb, item);
1624 } else if (!strncmp(part, "elm.slide.swallow.3", strlen("elm.slide.swallow.3"))) {
1625 Evas_Object *button = elm_button_add(obj);
1627 LOGD("elm_button_add() is failed.");
1630 elm_object_style_set(button, "sweep/multiline");
1631 elm_object_text_set(button, BR_STRING_DELETE);
1632 evas_object_smart_callback_add(button, "clicked", __slide_delete_button_clicked_cb, item);
1639 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1641 BROWSER_LOGD("[%s]", __func__);
1644 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1645 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1646 int selected_count = 0;
1647 int total_count = 0;
1648 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1650 Browser_History_DB::history_item *item = NULL;
1651 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1653 /* Ignore the date label. */
1654 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1656 if (item->is_delete)
1659 it = elm_genlist_item_next_get(it);
1662 if (total_count == selected_count)
1663 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1665 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1667 history_layout->_show_selection_info();
1670 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1672 BROWSER_LOGD("[%s]", __func__);
1673 Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1675 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1676 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1678 #if defined(GENLIST_SWEEP)
1679 evas_object_smart_callback_add(genlist, "drag,start,right", __sweep_right_genlist_cb, this);
1680 evas_object_smart_callback_add(genlist, "drag,start,left", __sweep_left_genlist_cb, this);
1681 evas_object_smart_callback_add(genlist, "drag,start,up", __sweep_cancel_genlist_cb, this);
1682 evas_object_smart_callback_add(genlist, "drag,start,down", __sweep_cancel_genlist_cb, this);