Adding UrlHistoryList class and other classes managing display of 'URL from history'
[profile/tv/apps/web/browser.git] / services / QuickAccess / UrlHistoryList / UrlHistoryList.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <Elementary.h>
18 #include "UrlHistoryList.h"
19 #include "GenlistManager.h"
20
21 #include "BrowserLogger.h"
22
23 namespace tizen_browser
24 {
25 namespace base_ui
26 {
27
28 UrlHistoryList::UrlHistoryList() :
29                 m_layout(nullptr)
30 {
31         m_edjFilePath = EDJE_DIR;
32         m_edjFilePath.append("MainUI/UrlHistoryList.edj");
33         m_widgetListManager = make_shared<services::GenlistManager>();
34 }
35
36 UrlHistoryList::~UrlHistoryList()
37 {
38 }
39
40 void UrlHistoryList::show()
41 {
42         if (m_layout)
43         {
44                 evas_object_show(m_layout);
45         }
46 }
47
48 Evas_Object* UrlHistoryList::getLayout()
49 {
50         return m_layout;
51 }
52
53 void UrlHistoryList::createLayout(Evas_Object* parentLayout)
54 {
55         m_layout = elm_layout_add(parentLayout);
56         elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list");
57
58         Evas_Object* widgetList = m_widgetListManager->createWidget(m_layout);
59 }
60
61 void UrlHistoryList::onURLEntryEdit(const string& editedUrl,
62                 shared_ptr<services::HistoryItemVector> matchedEntries)
63 {
64         Evas_Object* widgetList = m_widgetListManager->getWidget();
65         if (matchedEntries->size() == 0)
66         {
67                 m_widgetListManager->hideWidget();
68         }
69         else
70         {
71                 elm_object_part_content_set(m_layout, "list_swallow", widgetList);
72                 m_widgetListManager->showWidget(editedUrl, matchedEntries);
73                 evas_object_show(widgetList);
74         }
75 }
76
77 void UrlHistoryList::onMouseClick()
78 {
79         m_widgetListManager->onMouseClick();
80 }
81
82 }/* namespace base_ui */
83 } /* namespace tizen_browser */