2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "browser-add-to-bookmark-view.h"
20 #include "browser-view.h"
21 #include "browser-history-layout.h"
23 Date::Date() : day(0), month(0), year(0) {}
25 Date::Date(Date &date)
28 this->month = date.month;
29 this->year = date.year;
32 void Date::operator=(Date &date)
35 this->month = date.month;
36 this->year = date.year;
39 bool Date::operator==(Date &date)
41 return (this->day == date.day && this->month == date.month && this->year == date.year);
44 bool Date::operator!=(Date &date)
46 return (this->day != date.day || this->month != date.month || this->year != date.year);
49 Browser_History_Layout::Browser_History_Layout(void)
50 : m_history_genlist(NULL)
51 ,m_edit_mode_select_all_layout(NULL)
52 ,m_edit_mode_select_all_check_button(NULL)
54 ,m_no_history_label(NULL)
55 ,m_current_sweep_item(NULL)
56 ,m_processing_popup_timer(NULL)
59 ,m_total_item_count(0)
60 ,m_processing_popup(NULL)
61 ,m_processing_popup_layout(NULL)
62 ,m_processing_progress_bar(NULL)
63 ,m_select_all_check_value(EINA_FALSE)
64 ,m_searchbar_layout(NULL)
65 ,m_searched_history_genlist(NULL)
66 ,m_no_content_search_result(NULL)
68 ,m_delete_confirm_popup(NULL)
69 ,m_is_bookmark_on_off_icon_clicked(EINA_FALSE)
71 BROWSER_LOGD("[%s]", __func__);
74 Browser_History_Layout::~Browser_History_Layout(void)
76 BROWSER_LOGD("[%s]", __func__);
79 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
80 if (m_history_list[i])
81 delete m_history_list[i];
83 m_history_list.clear();
85 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
86 if (m_history_date_label_list[i])
87 free(m_history_date_label_list[i]);
89 m_history_date_label_list.clear();
91 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
92 if (m_searched_history_date_label_list[i])
93 free(m_searched_history_date_label_list[i]);
95 m_searched_history_date_label_list.clear();
97 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
98 if (m_searched_history_item_list[i])
99 delete m_searched_history_item_list[i];
101 m_searched_history_item_list.clear();
103 if (m_delete_confirm_popup)
104 evas_object_del(m_delete_confirm_popup);
108 Eina_Bool Browser_History_Layout::init(void)
110 BROWSER_LOGD("[%s]", __func__);
111 return _create_main_layout();
114 Eina_Bool Browser_History_Layout::_show_searched_history(const char *search_text)
116 BROWSER_LOGD("search_text = [%s]", search_text);
118 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
119 if (m_searched_history_item_list[i])
120 delete m_searched_history_item_list[i];
122 m_searched_history_item_list.clear();
124 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
125 if (m_searched_history_date_label_list[i])
126 free(m_searched_history_date_label_list[i]);
128 m_searched_history_date_label_list.clear();
130 if (!search_text || !strlen(search_text)) {
131 if (m_searched_history_genlist || m_no_content_search_result) {
132 elm_box_unpack_all(m_content_box);
133 elm_box_pack_start(m_content_box, m_history_genlist);
134 evas_object_show(m_history_genlist);
136 if (m_searched_history_genlist) {
137 evas_object_del(m_searched_history_genlist);
138 m_searched_history_genlist = NULL;
141 if (m_no_content_search_result) {
142 evas_object_del(m_no_content_search_result);
143 m_no_content_search_result = NULL;
146 if (m_history_list.size() == 0) {
147 if (m_no_history_label) {
148 elm_box_unpack_all(m_content_box);
149 elm_box_pack_start(m_content_box, m_no_history_label);
157 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
159 Browser_History_DB::history_item *item = NULL;
160 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
161 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
162 if (item->url.find(search_text) != string::npos || item->title.find(search_text) != string::npos) {
163 Browser_History_DB::history_item *searched_item = NULL;
164 searched_item = new(nothrow) Browser_History_DB::history_item;
165 searched_item->id = item->id;
166 searched_item->url = item->url;
167 searched_item->title = item->title;
168 searched_item->date = item->date;
169 searched_item->is_delete = item->is_delete;
170 searched_item->user_data = item->user_data;
171 m_searched_history_item_list.push_back(searched_item);
174 it = elm_genlist_item_next_get(it);
177 if (m_searched_history_item_list.size()) {
178 if (m_no_content_search_result) {
179 evas_object_del(m_no_content_search_result);
180 m_no_content_search_result = NULL;
183 if (!m_searched_history_genlist) {
184 m_searched_history_genlist = _create_history_genlist();
185 if (!m_searched_history_genlist) {
186 BROWSER_LOGE("_create_history_genlist failed");
191 elm_genlist_clear(m_searched_history_genlist);
195 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++) {
196 sscanf(m_searched_history_item_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
197 m_searched_history_item_list[i]->user_data = (void *)this;
198 if (last_date != date) {
200 char *labe_item = strdup(m_searched_history_item_list[i]->date.c_str());
202 BROWSER_LOGE("strdup failed");
205 m_searched_history_date_label_list.push_back(labe_item);
206 it = elm_genlist_item_append(m_searched_history_genlist, &m_history_group_title_class,
207 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
209 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
211 elm_genlist_item_append(m_searched_history_genlist, &m_history_genlist_item_class,
212 m_searched_history_item_list[i], it, ELM_GENLIST_ITEM_NONE,
213 __history_item_clicked_cb, this);
216 elm_box_unpack_all(m_content_box);
217 evas_object_hide(m_history_genlist);
218 elm_box_pack_start(m_content_box, m_searched_history_genlist);
219 evas_object_show(m_searched_history_genlist);
221 BROWSER_LOGD("show no content");
222 if (m_no_content_search_result)
223 evas_object_del(m_no_content_search_result);
224 m_no_content_search_result = elm_layout_add(m_content_box);
225 if (!m_no_content_search_result) {
226 BROWSER_LOGE("elm_layout_add failed");
229 elm_layout_theme_set(m_no_content_search_result, "layout", "nocontents", "search");
230 elm_object_part_text_set(m_no_content_search_result, "elm.text", BR_STRING_NO_SEARCH_RESULT);
231 evas_object_size_hint_weight_set(m_no_content_search_result, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
232 evas_object_size_hint_align_set(m_no_content_search_result, EVAS_HINT_FILL, EVAS_HINT_FILL);
234 if (m_searched_history_genlist) {
235 evas_object_del(m_searched_history_genlist);
236 m_searched_history_genlist = NULL;
239 elm_box_unpack_all(m_content_box);
240 evas_object_hide(m_history_genlist);
241 elm_box_pack_start(m_content_box, m_no_content_search_result);
242 evas_object_show(m_no_content_search_result);
248 void Browser_History_Layout::__search_delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
250 const char *search_text = elm_entry_entry_get(obj);
251 BROWSER_LOGD("search_text=[%s]", search_text);
253 if (!data || !search_text)
256 char *utf8_text = elm_entry_markup_to_utf8(search_text);
260 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
261 if (!elm_entry_is_empty(obj))
262 elm_object_signal_emit(history_layout->m_searchbar, "elm,state,guidetext,hide", "elm");
263 if (!history_layout->_show_searched_history(utf8_text))
264 BROWSER_LOGE("_show_searched_history failed");
269 void Browser_History_Layout::_enable_searchbar_layout(Eina_Bool enable)
272 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "searchbar_base");
275 m_searchbar = br_elm_searchbar_add(m_searchbar_layout);
277 BROWSER_LOGD("br_elm_searchbar_add failed");
280 elm_object_part_content_set(m_searchbar_layout, "searchbar", m_searchbar);
281 evas_object_show(m_searchbar);
283 elm_object_signal_emit(m_searchbar_layout, "elm,state,show,searchbar", "elm");
285 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
286 elm_entry_input_panel_layout_set(searchbar_entry, ELM_INPUT_PANEL_LAYOUT_URL);
288 evas_object_smart_callback_add(searchbar_entry, "changed", __search_delay_changed_cb, this);
290 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
291 if (m_searched_history_item_list[i])
292 delete m_searched_history_item_list[i];
294 m_searched_history_item_list.clear();
296 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
297 if (m_searched_history_date_label_list[i])
298 free(m_searched_history_date_label_list[i]);
300 m_searched_history_date_label_list.clear();
302 if (m_searched_history_genlist || m_no_content_search_result) {
303 elm_box_unpack_all(m_content_box);
304 elm_box_pack_start(m_content_box, m_history_genlist);
305 evas_object_show(m_history_genlist);
307 if (m_searched_history_genlist) {
308 evas_object_del(m_searched_history_genlist);
309 m_searched_history_genlist = NULL;
312 if (m_no_content_search_result) {
313 evas_object_del(m_no_content_search_result);
314 m_no_content_search_result = NULL;
319 elm_object_part_content_unset(m_searchbar_layout, "searchbar");
320 evas_object_hide(m_searchbar);
323 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
324 evas_object_smart_callback_del(searchbar_entry, "changed", __search_delay_changed_cb);
326 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "noindicator");
330 void Browser_History_Layout::_set_edit_mode(Eina_Bool edit_mode)
332 BROWSER_LOGD("[%s]", __func__);
333 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
337 _enable_searchbar_layout(!edit_mode);
340 elm_object_style_set(m_bg, "edit_mode");
342 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
343 if (!m_edit_mode_select_all_layout) {
344 BROWSER_LOGE("elm_layout_add failed");
347 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
348 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
349 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
350 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
351 __edit_mode_select_all_clicked_cb, this);
353 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
354 if (!m_edit_mode_select_all_check_button) {
355 BROWSER_LOGE("elm_layout_add failed");
358 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
359 __edit_mode_select_all_check_changed_cb, this);
360 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
362 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
363 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
365 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
366 evas_object_show(m_edit_mode_select_all_layout);
368 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
369 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
371 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
373 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
374 BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
376 if (m_edit_mode_select_all_layout) {
377 elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
378 evas_object_del(m_edit_mode_select_all_layout);
379 m_edit_mode_select_all_layout = NULL;
381 if (m_edit_mode_select_all_check_button) {
382 evas_object_del(m_edit_mode_select_all_check_button);
383 m_edit_mode_select_all_check_button = NULL;
385 if (m_no_history_label) {
386 evas_object_del(m_no_history_label);
387 m_no_history_label = NULL;
390 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
391 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
392 BROWSER_LOGE("_set_controlbar_type failed");
394 Elm_Object_Item *it = NULL;
395 Browser_History_DB::history_item *item = NULL;
396 it = elm_genlist_first_item_get(m_history_genlist);
398 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
399 item->is_delete = EINA_FALSE;
400 it = elm_genlist_item_next_get(it);
403 elm_object_style_set(m_bg, "default");
404 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
405 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
407 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
409 if (m_history_list.size() == 0) {
410 elm_box_unpack_all(m_content_box);
411 elm_genlist_clear(m_history_genlist);
412 evas_object_hide(m_history_genlist);
414 if (m_edit_mode_select_all_layout) {
415 evas_object_del(m_edit_mode_select_all_layout);
416 m_edit_mode_select_all_layout = NULL;
418 if (m_edit_mode_select_all_check_button) {
419 evas_object_del(m_edit_mode_select_all_check_button);
420 m_edit_mode_select_all_check_button = NULL;
423 m_no_history_label = elm_label_add(m_searchbar_layout);
424 if (!m_no_history_label) {
425 BROWSER_LOGE("elm_label_add failed");
429 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
430 elm_object_text_set(m_no_history_label, text.c_str());
431 evas_object_show(m_no_history_label);
432 elm_box_pack_start(m_content_box, m_no_history_label);
434 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
439 void Browser_History_Layout::_show_selection_info(void)
441 BROWSER_LOGD("[%s]", __func__);
442 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
443 int selected_count = 0;
446 Browser_History_DB::history_item *item = NULL;
447 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
448 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
453 it = elm_genlist_item_next_get(it);
456 if (selected_count == 0) {
457 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
461 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
463 if (selected_count == 1) {
464 show_notify_popup(BR_STRING_ONE_ITEM_SELECTED, 0, EINA_TRUE);
465 } else if (selected_count > 1) {
466 char *small_popup_text = NULL;
467 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 1;
469 small_popup_text = (char *)malloc(string_len * sizeof(char));
470 memset(small_popup_text, 0x00, string_len);
472 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
473 show_notify_popup(small_popup_text, 0, EINA_TRUE);
475 if (small_popup_text)
476 free(small_popup_text);
477 small_popup_text = 0x00;
481 void Browser_History_Layout::_show_delete_processing_popup(void)
483 BROWSER_LOGD("[%s]", __func__);
484 if (m_processing_popup)
485 evas_object_del(m_processing_popup);
487 m_processing_popup = elm_popup_add(m_searchbar_layout);
488 if (!m_processing_popup) {
489 BROWSER_LOGE("elm_popup_add failed");
493 if (m_processing_popup_layout)
494 evas_object_del(m_processing_popup_layout);
495 m_processing_popup_layout = elm_layout_add(m_processing_popup);
496 if (!m_processing_popup_layout) {
497 BROWSER_LOGE("elm_layout_add failed");
500 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
501 "browser/popup_center_progressview")) {
502 BROWSER_LOGE("elm_layout_file_set failed");
505 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
507 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
508 elm_object_style_set(m_processing_progress_bar, "list_progress");
509 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
510 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
511 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
512 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
514 if (m_processing_popup_timer)
515 ecore_timer_del(m_processing_popup_timer);
517 m_processed_count = 0;
518 m_processed_it = elm_genlist_last_item_get(m_history_genlist);
520 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
521 m_total_item_count = 0;
523 Browser_History_DB::history_item *item = NULL;
524 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
525 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
527 m_total_item_count++;
529 it = elm_genlist_item_next_get(it);
532 m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
533 evas_object_show(m_processing_progress_bar);
535 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
536 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
537 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
538 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
540 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
542 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
543 if (!cancel_button) {
544 BROWSER_LOGE("elm_button_add failed");
547 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
548 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
549 evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
551 evas_object_show(m_processing_popup);
554 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
556 BROWSER_LOGD("[%s]", __func__);
560 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
562 evas_object_del(history_layout->m_processing_popup);
564 history_layout->m_processing_progress_bar = NULL;
565 history_layout->m_processed_it = NULL;
567 if (history_layout->m_processing_popup_timer) {
568 ecore_timer_del(history_layout->m_processing_popup_timer);
569 history_layout->m_processing_popup_timer = NULL;
572 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
574 if (history_layout->m_history_list.size() == 0) {
575 elm_box_unpack_all(history_layout->m_content_box);
576 elm_genlist_clear(history_layout->m_history_genlist);
577 evas_object_hide(history_layout->m_history_genlist);
579 if (history_layout->m_edit_mode_select_all_layout) {
580 evas_object_del(history_layout->m_edit_mode_select_all_layout);
581 history_layout->m_edit_mode_select_all_layout = NULL;
583 if (history_layout->m_edit_mode_select_all_check_button) {
584 evas_object_del(history_layout->m_edit_mode_select_all_check_button);
585 history_layout->m_edit_mode_select_all_check_button = NULL;
588 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
589 if (!history_layout->m_no_history_label) {
590 BROWSER_LOGE("elm_label_add failed");
594 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
595 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
596 evas_object_show(history_layout->m_no_history_label);
597 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
599 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
600 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
601 BROWSER_LOGE("_set_controlbar_type failed");
603 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
607 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
609 BROWSER_LOGD("[%s]", __func__);
611 return ECORE_CALLBACK_CANCEL;
613 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
614 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
616 Eina_Bool check_value = history_layout->m_select_all_check_value;
618 double value = elm_progressbar_value_get(progress_bar);
620 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
622 history_layout->m_processing_popup_timer = NULL;
623 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
625 return ECORE_CALLBACK_CANCEL;
628 while (history_layout->m_processed_it) {
629 Browser_History_DB::history_item *item = NULL;
630 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
633 && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
634 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
635 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
636 if (history_layout->m_history_list[index]->id == item->id) {
637 delete history_layout->m_history_list[index];
638 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
642 history_layout->m_processed_count++;
643 Elm_Object_Item *it = history_layout->m_processed_it;
644 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
645 elm_object_item_del(it);
646 elm_genlist_realized_items_update(history_layout->m_history_genlist);
648 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
650 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
652 if (history_layout->m_processed_count % 20 == 0)
656 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
657 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
659 char progress_text[20] = {0, };
660 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
661 history_layout->m_processed_count, history_layout->m_total_item_count);
663 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
664 "elm.text.right", progress_text);
666 return ECORE_CALLBACK_RENEW;
669 void Browser_History_Layout::_show_select_processing_popup(void)
671 BROWSER_LOGD("[%s]", __func__);
672 if (m_processing_popup)
673 evas_object_del(m_processing_popup);
675 m_processing_popup = elm_popup_add(m_searchbar_layout);
676 if (!m_processing_popup) {
677 BROWSER_LOGE("elm_popup_add failed");
681 if (m_processing_popup_layout)
682 evas_object_del(m_processing_popup_layout);
683 m_processing_popup_layout = elm_layout_add(m_processing_popup);
684 if (!m_processing_popup_layout) {
685 BROWSER_LOGE("elm_layout_add failed");
688 if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
689 "browser/popup_center_progressview")) {
690 BROWSER_LOGE("elm_layout_file_set failed");
693 evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
695 m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
696 elm_object_style_set(m_processing_progress_bar, "list_progress");
697 elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
698 evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
699 evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
700 elm_progressbar_value_set(m_processing_progress_bar, 0.0);
702 if (m_processing_popup_timer)
703 ecore_timer_del(m_processing_popup_timer);
705 m_processed_count = 0;
706 m_processed_it = elm_genlist_first_item_get(m_history_genlist);
708 m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
709 evas_object_show(m_processing_progress_bar);
711 elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
712 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
713 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
714 edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
716 elm_object_content_set(m_processing_popup, m_processing_popup_layout);
718 Evas_Object *cancel_button = elm_button_add(m_processing_popup);
719 if (!cancel_button) {
720 BROWSER_LOGE("elm_button_add failed");
723 elm_object_text_set(cancel_button, BR_STRING_CANCEL);
724 elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
725 evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
727 evas_object_show(m_processing_popup);
729 Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
730 m_select_all_check_value = check_value;
733 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
736 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
738 BROWSER_LOGD("[%s]", __func__);
742 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
744 evas_object_del(history_layout->m_processing_popup);
746 history_layout->m_processing_progress_bar = NULL;
747 history_layout->m_processed_it = NULL;
749 if (history_layout->m_processing_popup_timer) {
750 ecore_timer_del(history_layout->m_processing_popup_timer);
751 history_layout->m_processing_popup_timer = NULL;
754 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
757 Browser_History_DB::history_item *item = NULL;
758 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
760 if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
763 it = elm_genlist_item_next_get(it);
766 history_layout->_delete_date_only_label_genlist_item();
769 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
771 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
774 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
777 return ECORE_CALLBACK_CANCEL;
779 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
780 Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
782 Eina_Bool check_value = history_layout->m_select_all_check_value;
784 double value = elm_progressbar_value_get(progress_bar);
786 __select_processing_popup_response_cb(history_layout, NULL, NULL);
788 history_layout->m_processing_popup_timer = NULL;
789 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
790 history_layout->_show_selection_info();
792 return ECORE_CALLBACK_CANCEL;
795 while (history_layout->m_processed_it) {
796 Browser_History_DB::history_item *item = NULL;
797 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
798 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
799 item->is_delete = !check_value;
800 elm_genlist_item_update(history_layout->m_processed_it);
801 history_layout->m_processed_count++;
803 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
805 if (history_layout->m_processed_count % 30 == 0)
809 elm_progressbar_value_set(history_layout->m_processing_progress_bar,
810 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
812 char progress_text[20] = {0, };
813 snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
814 history_layout->m_processed_count, history_layout->m_history_list.size());
816 edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
817 "elm.text.right", progress_text);
819 return ECORE_CALLBACK_RENEW;
822 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
823 Evas_Object *obj, void *event_info)
825 BROWSER_LOGD("[%s]", __func__);
829 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
830 Eina_Bool value = elm_check_state_get(obj);
832 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
833 elm_check_state_set(obj, !value);
834 history_layout->_show_select_processing_popup();
836 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
838 Browser_History_DB::history_item *item = NULL;
839 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
841 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
842 item->is_delete = value;
843 elm_genlist_item_update(it);
846 it = elm_genlist_item_next_get(it);
849 history_layout->_show_selection_info();
853 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
854 Evas_Object *obj, void *event_info)
859 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
861 if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
862 history_layout->_show_select_processing_popup();
864 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
865 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
867 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
869 Browser_History_DB::history_item *item = NULL;
870 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
872 /* Ignore the date label. */
873 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
874 item->is_delete = !value;
875 elm_genlist_item_update(it);
878 it = elm_genlist_item_next_get(it);
881 history_layout->_show_selection_info();
885 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
887 BROWSER_LOGD("[%s]", __func__);
891 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
893 if (history_layout->m_is_bookmark_on_off_icon_clicked) {
894 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_FALSE;
895 Elm_Object_Item *selected_item = (Elm_Object_Item *)eventInfo;
896 elm_genlist_item_selected_set(selected_item, EINA_FALSE);
900 Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
901 Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
904 if (!elm_genlist_decorate_mode_get(obj)) {
905 /* calculate the index of the selected item */
906 while (index_item != seleted_item) {
907 /* Do not count date label item */
908 if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
911 index_item = elm_genlist_item_next_get(index_item);
914 const char *selected_url = NULL;
915 if (history_layout->m_searched_history_genlist == obj)
916 selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
918 selected_url = history_layout->m_history_list[index]->url.c_str();
920 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
922 Browser_History_DB::history_item *item = NULL;
923 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
924 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
925 item->is_delete = !(item->is_delete);
926 elm_genlist_item_update(seleted_item);
928 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
930 int selected_count = 0;
932 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
934 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
935 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
940 it = elm_genlist_item_next_get(it);
943 if (selected_count == total_count)
944 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
946 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
948 history_layout->_show_selection_info();
952 void Browser_History_Layout::_delete_selected_history(void)
954 BROWSER_LOGD("[%s]", __func__);
956 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
957 int delete_item_count = 0;
958 Browser_History_DB::history_item *item = NULL;
960 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
961 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
964 it = elm_genlist_item_next_get(it);
967 if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
968 _show_delete_processing_popup();
970 Eina_List *delete_item_list = NULL;
971 it = elm_genlist_first_item_get(m_history_genlist);
972 int remain_count = 0;
973 Browser_History_DB::history_item *item = NULL;
976 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
977 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
979 delete_item_list = eina_list_append(delete_item_list, it);
983 it = elm_genlist_item_next_get(it);
986 int count = eina_list_count(delete_item_list);
987 for (int i = 0; i < count; i++) {
988 it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
989 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
990 /* Delete history item */
991 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
993 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
995 delete_item_list = eina_list_next(delete_item_list);
997 for(int index = 0 ; index < m_history_list.size() ; index++) {
998 if (m_history_list[index]->id == item->id) {
999 delete m_history_list[index];
1000 m_history_list.erase(m_history_list.begin() + index);
1004 elm_object_item_del(it);
1006 eina_list_free(delete_item_list);
1008 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
1010 _delete_date_only_label_genlist_item();
1012 if (remain_count == 0) {
1013 elm_box_unpack_all(m_content_box);
1014 elm_genlist_clear(m_history_genlist);
1015 evas_object_hide(m_history_genlist);
1017 if (m_edit_mode_select_all_layout) {
1018 evas_object_del(m_edit_mode_select_all_layout);
1019 m_edit_mode_select_all_layout = NULL;
1021 if (m_edit_mode_select_all_check_button) {
1022 evas_object_del(m_edit_mode_select_all_check_button);
1023 m_edit_mode_select_all_check_button = NULL;
1026 m_no_history_label = elm_label_add(m_searchbar_layout);
1027 if (!m_no_history_label) {
1028 BROWSER_LOGE("elm_label_add failed");
1032 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1033 elm_object_text_set(m_no_history_label, text.c_str());
1034 evas_object_show(m_no_history_label);
1035 elm_box_pack_start(m_content_box, m_no_history_label);
1037 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1038 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1039 BROWSER_LOGE("_set_controlbar_type failed");
1041 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1044 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1048 void Browser_History_Layout::_reload_history_genlist(void)
1050 Elm_Object_Item *it = NULL;
1051 while (it = elm_genlist_first_item_get(m_history_genlist))
1052 elm_object_item_del(it);
1054 for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1055 if (m_history_list[i])
1056 delete m_history_list[i];
1058 elm_box_unpack_all(m_content_box);
1059 m_history_list.clear();
1061 for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1062 if (m_history_date_label_list[i])
1063 free(m_history_date_label_list[i]);
1065 m_history_date_label_list.clear();
1067 Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1069 BROWSER_LOGE("get_history_list failed");
1071 unsigned int history_count = m_history_list.size();
1072 BROWSER_LOGD("history_count=%d", history_count);
1075 for(int i = 0 ; i < history_count; i++) {
1076 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1077 m_history_list[i]->user_data = (void *)this;
1078 if (m_last_date != date) {
1080 char *labe_item = strdup(m_history_list[i]->date.c_str());
1082 BROWSER_LOGE("strdup failed");
1085 m_history_date_label_list.push_back(labe_item);
1086 it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1087 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1089 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1091 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1092 ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1095 if (m_no_history_label) {
1096 evas_object_del(m_no_history_label);
1097 m_no_history_label = NULL;
1100 if (m_edit_mode_select_all_check_button) {
1101 evas_object_del(m_edit_mode_select_all_check_button);
1102 m_edit_mode_select_all_check_button = NULL;
1105 if (m_edit_mode_select_all_layout) {
1106 evas_object_del(m_edit_mode_select_all_layout);
1107 m_edit_mode_select_all_layout = NULL;
1110 if (m_history_list.size() == 0) {
1111 evas_object_hide(m_history_genlist);
1113 m_no_history_label = elm_label_add(m_searchbar_layout);
1114 if (!m_no_history_label) {
1115 BROWSER_LOGE("elm_label_add failed");
1119 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1120 elm_object_text_set(m_no_history_label, text.c_str());
1121 evas_object_show(m_no_history_label);
1122 elm_box_pack_start(m_content_box, m_no_history_label);
1124 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1125 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1126 BROWSER_LOGE("_set_controlbar_type failed");
1127 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1129 elm_box_pack_start(m_content_box, m_history_genlist);
1130 evas_object_show(m_history_genlist);
1132 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1133 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1137 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1139 BROWSER_LOGD("[%s]", __func__);
1140 elm_object_style_set(m_bg, "default");
1142 m_searchbar_layout = elm_layout_add(m_navi_bar);
1143 if (!m_searchbar_layout) {
1144 BROWSER_LOGE("elm_layout_add failed");
1148 _enable_searchbar_layout(EINA_TRUE);
1150 evas_object_show(m_searchbar_layout);
1152 m_content_box = elm_box_add(m_searchbar_layout);
1153 if (!m_content_box) {
1154 BROWSER_LOGE("elm_box_add failed");
1158 m_history_genlist = _create_history_genlist();
1159 if (!m_history_genlist) {
1160 BROWSER_LOGE("_create_history_genlist failed");
1164 m_history_genlist_item_class.decorate_item_style = "mode/slide3";
1165 m_history_genlist_item_class.item_style = "2text.2icon.4";
1166 m_history_genlist_item_class.decorate_all_item_style = "edit_default";
1167 m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1168 m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1169 m_history_genlist_item_class.func.state_get = NULL;
1170 m_history_genlist_item_class.func.del = NULL;
1172 m_history_group_title_class.item_style = "grouptitle";
1173 m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1174 m_history_group_title_class.func.content_get = NULL;
1175 m_history_group_title_class.func.state_get = NULL;
1176 m_history_group_title_class.func.del = NULL;
1178 _reload_history_genlist();
1180 evas_object_show(m_content_box);
1181 elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1186 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1188 BROWSER_LOGD("[%s]", __func__);
1190 m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1191 if (!m_delete_confirm_popup) {
1192 BROWSER_LOGE("elm_popup_add failed");
1196 evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1197 elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1199 Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1200 elm_object_text_set(ok_button, BR_STRING_YES);
1201 elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1203 Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1204 elm_object_text_set(cancel_button, BR_STRING_NO);
1205 elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1206 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1207 m_delete_confirm_popup);
1209 evas_object_show(m_delete_confirm_popup);
1214 #if defined(GENLIST_SWEEP)
1215 void Browser_History_Layout::__sweep_right_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1217 BROWSER_LOGD("[%s]", __func__);
1218 if (!data || elm_genlist_decorate_mode_get(obj))
1221 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_TRUE);
1222 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_NONE);
1225 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1226 if (history_layout->m_current_sweep_item)
1227 elm_genlist_item_select_mode_set(history_layout->m_current_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1228 history_layout->m_current_sweep_item = (Elm_Object_Item *)event_info;
1231 void Browser_History_Layout::__sweep_cancel_genlist_cb(void *data,
1232 Evas_Object *obj, void *event_info)
1234 BROWSER_LOGD("[%s]", __func__);
1239 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1240 Elm_Object_Item *it = (Elm_Object_Item*)elm_genlist_decorated_item_get(obj);
1242 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1243 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1245 if (it == history_layout->m_current_sweep_item)
1246 history_layout->m_current_sweep_item = NULL;
1250 void Browser_History_Layout::__sweep_left_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1252 BROWSER_LOGD("[%s]", __func__);
1253 if (!data || elm_genlist_decorate_mode_get(obj))
1256 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_FALSE);
1257 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
1260 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1261 history_layout->m_current_sweep_item = NULL;
1265 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1270 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1274 char *mark_up = NULL;
1276 if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1277 || !strncmp(part, "elm.base.text", strlen("elm.base.text"))
1278 || !strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")))
1280 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1282 } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))
1283 || !strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2"))) {
1284 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1291 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1296 char *date_label = (char *)data;
1298 if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1300 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1302 sscanf(date_label, "%d-%d-%d",
1303 &date.year, &date.month, &date.day);
1304 // BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1306 struct tm *time_info;
1308 time_info = localtime(&raw_time);
1310 // BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1311 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1312 day_gap = time_info->tm_mday - date.day;
1314 time_info->tm_year = date.year - 1900;
1315 time_info->tm_mon = date.month - 1;
1317 time_info->tm_mday = date.day;
1321 strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1322 else if (day_gap == 1)
1323 strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1325 strftime (buffer, 40, "%a, %b %d %Y", time_info);
1326 return strdup(buffer);
1331 void Browser_History_Layout::__slide_add_to_bookmark_button_clicked_cb(void *data, Evas_Object *obj,
1334 BROWSER_LOGD("[%s]", __func__);
1338 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1339 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1341 /* If add to bookmark is excuted in searched list, remove the searched list. */
1342 Evas_Object *searchbar = NULL;
1343 searchbar = edje_object_part_external_object_get(elm_layout_edje_get(history_layout->m_searchbar_layout),
1345 br_elm_searchbar_text_set(searchbar, "");
1347 if (!m_data_manager->create_add_to_bookmark_view(item->title, item->url)) {
1348 BROWSER_LOGE("create_add_to_bookmark_view failed");
1352 if (!m_data_manager->get_add_to_bookmark_view()->init()) {
1353 BROWSER_LOGE("get_add_to_bookmark_view()->init() failed");
1354 m_data_manager->destroy_add_to_bookmark_view();
1359 void Browser_History_Layout::__slide_share_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1361 BROWSER_LOGD("[%s]", __func__);
1365 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1366 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1367 if (!history_layout->_show_share_popup(item->url.c_str()))
1368 BROWSER_LOGE("_show_share_popup failed");
1371 void Browser_History_Layout::_delete_history_item_by_slide_button(Browser_History_DB::history_item *item)
1373 BROWSER_LOGD("[%s]", __func__);
1374 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1376 int ret = EINA_TRUE;
1377 ret = m_data_manager->get_history_db()->delete_history(item->id);
1379 BROWSER_LOGE("m_data_manager->get_history_db()->delete_history failed");
1383 elm_object_item_del(history_layout->m_current_sweep_item);
1385 /* If the item is deleted in searched list, then delete it from original history genlist also. */
1386 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1388 Browser_History_DB::history_item *item_data = NULL;
1389 item_data = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1390 if (item_data && (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
1391 if (item_data->id == item->id) {
1392 elm_object_item_del(it);
1396 it = elm_genlist_item_next_get(it);
1399 for(int i = 0 ; i < history_layout->m_history_list.size() ; i++) {
1400 if (history_layout->m_history_list[i]->id == item->id) {
1401 delete history_layout->m_history_list[i];
1402 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + i);
1407 if (history_layout->m_history_list.size() == 0) {
1408 history_layout->_reload_history_genlist();
1411 history_layout->_delete_date_only_label_genlist_item();
1413 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1416 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1419 BROWSER_LOGD("event_info = %d", (int)event_info);
1424 Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1426 if (history_layout->m_delete_confirm_popup) {
1427 evas_object_del(history_layout->m_delete_confirm_popup);
1428 history_layout->m_delete_confirm_popup = NULL;
1431 history_layout->_delete_selected_history();
1433 if (history_layout->m_history_list.size() < BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
1434 history_layout->_set_edit_mode(EINA_FALSE);
1438 void Browser_History_Layout::__delete_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1441 BROWSER_LOGD("event_info = %d", (int)event_info);
1446 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1447 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1448 if (history_layout->m_delete_confirm_popup) {
1449 evas_object_del(history_layout->m_delete_confirm_popup);
1450 history_layout->m_delete_confirm_popup = NULL;
1453 history_layout->_delete_history_item_by_slide_button(item);
1456 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1459 BROWSER_LOGD("event_info = %d", (int)event_info);
1464 Evas_Object *popup = (Evas_Object *)data;
1465 evas_object_del(popup);
1468 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1470 BROWSER_LOGD("[%s]", __func__);
1472 Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1473 /* Remove date only label item */
1475 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1476 Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1477 if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1479 it = elm_genlist_item_next_get(it);
1480 elm_object_item_del(tmp_it);
1484 it = elm_genlist_item_next_get(it);
1488 void Browser_History_Layout::__slide_delete_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1490 BROWSER_LOGD("[%s]", __func__);
1494 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1495 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1497 Evas_Object *ok_button = history_layout->_show_delete_confirm_popup();
1499 evas_object_smart_callback_add(ok_button, "clicked",
1500 __delete_confirm_response_by_slide_button_cb, item);
1503 void Browser_History_Layout::__bookmark_on_off_icon_clicked_cb(void* data, Evas* evas, Evas_Object* obj, void* ev)
1505 BROWSER_LOGD("[%s]", __func__);
1506 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1507 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1509 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_TRUE;
1511 int bookmark_id = -1;
1512 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), &bookmark_id)) {
1513 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1514 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1516 m_data_manager->get_bookmark_view()->delete_bookmark_item(bookmark_id);
1518 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1519 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1521 m_data_manager->get_bookmark_view()->append_bookmark_item(item->title.c_str(), item->url.c_str());
1525 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1530 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1531 Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1532 if (!history_layout)
1535 if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
1536 Evas_Object *favicon = NULL;
1537 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1541 Evas_Object *default_favicon = elm_icon_add(obj);
1542 if (!default_favicon) {
1543 BROWSER_LOGE("elm_icon_add is failed");
1546 elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1547 evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1548 return default_favicon;
1550 } else if (!strncmp(part, "elm.icon.2", strlen("elm.icon.2"))) {
1551 Evas_Object *bookmark_icon = elm_icon_add(obj);
1552 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), NULL)) {
1553 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1554 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1558 if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1559 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1563 evas_object_size_hint_aspect_set(bookmark_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1564 evas_object_propagate_events_set(bookmark_icon, EINA_FALSE);
1565 evas_object_repeat_events_set(bookmark_icon, EINA_FALSE);
1567 evas_object_event_callback_add(bookmark_icon, EVAS_CALLBACK_MOUSE_DOWN,
1568 __bookmark_on_off_icon_clicked_cb, item);
1570 return bookmark_icon;
1571 } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1572 if (elm_genlist_decorate_mode_get(obj)) {
1573 Evas_Object *check_button = elm_check_add(obj);
1574 if (!check_button) {
1575 BROWSER_LOGE("elm_check_add is failed");
1578 elm_check_state_pointer_set(check_button, &(item->is_delete));
1579 elm_check_state_set(check_button, item->is_delete);
1580 evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1581 return check_button;
1583 } else if (!strncmp(part, "elm.slide.swallow.1", strlen("elm.slide.swallow.1"))) {
1584 Evas_Object *button = elm_button_add(obj);
1586 LOGD("elm_button_add() is failed.");
1590 elm_object_style_set(button, "sweep/multiline");
1591 elm_object_text_set(button, BR_STRING_SHARE);
1592 evas_object_smart_callback_add(button, "clicked", __slide_share_button_clicked_cb, item);
1594 } else if (!strncmp(part, "elm.slide.swallow.2", strlen("elm.slide.swallow.2"))) {
1595 Evas_Object *button = elm_button_add(obj);
1597 LOGD("elm_button_add() is failed.");
1600 elm_object_style_set(button, "sweep/multiline");
1601 elm_object_text_set(button, BR_STRING_ADD_TO_BOOKMARKS);
1602 evas_object_smart_callback_add(button, "clicked", __slide_add_to_bookmark_button_clicked_cb, item);
1604 } else if (!strncmp(part, "elm.slide.swallow.3", strlen("elm.slide.swallow.3"))) {
1605 Evas_Object *button = elm_button_add(obj);
1607 LOGD("elm_button_add() is failed.");
1610 elm_object_style_set(button, "sweep/multiline");
1611 elm_object_text_set(button, BR_STRING_DELETE);
1612 evas_object_smart_callback_add(button, "clicked", __slide_delete_button_clicked_cb, item);
1619 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1621 BROWSER_LOGD("[%s]", __func__);
1624 Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1625 Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1626 int selected_count = 0;
1627 int total_count = 0;
1628 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1630 Browser_History_DB::history_item *item = NULL;
1631 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1633 /* Ignore the date label. */
1634 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1636 if (item->is_delete)
1639 it = elm_genlist_item_next_get(it);
1642 if (total_count == selected_count)
1643 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1645 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1647 history_layout->_show_selection_info();
1650 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1652 BROWSER_LOGD("[%s]", __func__);
1653 Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1655 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1656 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1658 #if defined(GENLIST_SWEEP)
1659 evas_object_smart_callback_add(genlist, "drag,start,right", __sweep_right_genlist_cb, this);
1660 evas_object_smart_callback_add(genlist, "drag,start,left", __sweep_left_genlist_cb, this);
1661 evas_object_smart_callback_add(genlist, "drag,start,up", __sweep_cancel_genlist_cb, this);
1662 evas_object_smart_callback_add(genlist, "drag,start,down", __sweep_cancel_genlist_cb, this);