2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
18 #include "UrlHistoryList.h"
19 #include "GenlistManager.h"
20 #include "BrowserLogger.h"
21 #include "../QuickAccess.h"
23 namespace tizen_browser {
26 UrlHistoryList::UrlHistoryList(QuickAccess* quickAccess) :
27 m_layout(nullptr), m_quickAccess(quickAccess)
29 m_edjFilePath = EDJE_DIR;
30 m_edjFilePath.append("QuickAccess/UrlHistoryList.edj");
31 m_genlistListManager = make_shared<GenlistManager>();
32 m_genlistListManager->signalItemSelected.connect(
33 boost::bind(&UrlHistoryList::onListItemSelect, this, _1));
34 m_genlistListManager->signalWidgetFocused.connect(
35 boost::bind(&UrlHistoryList::onListWidgetFocused, this));
36 m_genlistListManager->signalWidgetUnfocused.connect(
37 boost::bind(&UrlHistoryList::onListWidgetUnfocused, this));
40 UrlHistoryList::~UrlHistoryList()
44 Evas_Object* UrlHistoryList::getLayout()
49 void UrlHistoryList::createLayout(Evas_Object* parentLayout)
51 m_layout = elm_layout_add(parentLayout);
52 elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list");
54 Evas_Object* widgetList = m_genlistListManager->createWidget(m_layout);
57 void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl,
58 shared_ptr<services::HistoryItemVector> matchedEntries)
60 editedUrlStatesHelper.changeState(true);
62 if (matchedEntries->size() == 0) {
63 m_genlistListManager->hideWidgetPretty();
65 Evas_Object* widgetList = m_genlistListManager->getWidget();
66 elm_object_part_content_set(m_layout, "list_swallow", widgetList);
67 m_genlistListManager->showWidget(editedUrl, matchedEntries);
68 evas_object_show(widgetList);
72 void UrlHistoryList::onURLEntryEdited()
74 editedUrlStatesHelper.changeState(false);
75 if (editedUrlStatesHelper.getCurrentState()
76 == EditedUrlState::EDITED_OTHER_FIRST) {
77 m_genlistListManager->hideWidgetPretty();
79 // in this situation scroll will not work, it has to be hidden instantly
80 m_genlistListManager->hideWidgetInstant();
84 void UrlHistoryList::onMouseClick()
86 m_genlistListManager->onMouseClick();
89 void UrlHistoryList::onListItemSelect(std::string content)
91 openURLInNewTab(make_shared < services::HistoryItem > (content),
92 m_quickAccess->isDesktopMode());
95 void UrlHistoryList::onListWidgetFocused()
97 // will be used soon: in a proper focus-chain solution
100 void UrlHistoryList::onListWidgetUnfocused()
102 // will be used soon: in a proper focus-chain solution
105 }/* namespace base_ui */
106 } /* namespace tizen_browser */