Using UrlHistoryList do display history list (on urientry edition).
[profile/tv/apps/web/browser.git] / services / QuickAccess / QuickAccess.h
1 /*
2  * Copyright (c) 2014 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 #ifndef QUICKACCESS_H
18 #define QUICKACCESS_H
19
20 #include <Evas.h>
21 #include <boost/signals2/signal.hpp>
22
23 #include "AbstractUIComponent.h"
24 #include "AbstractService.h"
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
27 #include "services/HistoryService/HistoryItem.h"
28 #include "BookmarkItem.h"
29 #include "DetailPopup.h"
30
31 namespace tizen_browser{
32 namespace base_ui{
33
34 class UrlHistoryList;
35 typedef std::shared_ptr<UrlHistoryList> UrlHistoryPtr;
36
37 //TODO: This class name is not revelant to what this class actually does.
38 //Rename this class and file to "QuickAccessUI".
39 class BROWSER_EXPORT QuickAccess
40         : public tizen_browser::core::AbstractService
41 {
42 public:
43     QuickAccess();
44     ~QuickAccess();
45     void init(Evas_Object *main_layout);
46     Evas_Object* getContent();
47     void showMostVisited(std::shared_ptr<services::HistoryItemVector> vec);
48     void showBookmarks(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > vec);
49     void hideUI();
50     void showUI();
51     virtual std::string getName();
52     void openDetailPopup(std::shared_ptr<services::HistoryItem> currItem, std::shared_ptr<services::HistoryItemVector> prevItems);
53     bool isDesktopMode() const;
54     void setDesktopMode(bool mode);
55     DetailPopup & getDetailPopup();
56     UrlHistoryPtr getUrlHistoryList();
57     void backButtonClicked();
58     inline bool isMostVisitedActive() const;
59     void refreshFocusChain();
60
61     boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, int)> mostVisitedTileClicked;
62     boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURLInNewTab;
63     boost::signals2::signal<void ()> mostVisitedClicked;
64     boost::signals2::signal<void ()> bookmarkClicked;
65     boost::signals2::signal<void ()> bookmarkManagerClicked;
66
67     static const int MAX_THUMBNAIL_WIDTH;
68     static const int MAX_THUMBNAIL_HEIGHT;
69
70 private:
71     void createItemClasses();
72     void addHistoryItem(std::shared_ptr<services::HistoryItem>);
73     void addHistoryItems(std::shared_ptr<services::HistoryItemVector>);
74     void addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem>);
75     void addBookmarkItems(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >);
76     void clearHistoryGenlist();
77     void clearBookmarkGengrid();
78     Evas_Object* createBookmarkGengrid(Evas_Object *parent);
79     void showHistory();
80     void showBookmarks();
81
82     Evas_Object* createQuickAccessLayout(Evas_Object *parent);
83     Evas_Object* createMostVisitedView(Evas_Object *parent);
84     Evas_Object* createBookmarksView(Evas_Object *parent);
85     Evas_Object* createBottomButton(Evas_Object *parent);
86     Evas_Object* createTopButtons(Evas_Object *parent);
87     Evas_Object* createUrlHistoryListLayout(Evas_Object *parent);
88
89     static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part);
90     static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part);
91     static void _thumbBookmarkClicked(void * data, Evas_Object * obj, void * event_info);
92     static void _thumbHistoryClicked(void * data, Evas_Object * obj, void * event_info);
93     void setEmptyView(bool empty);
94     void showNoHistoryLabel();
95
96     static void _mostVisited_clicked(void * data, Evas_Object * obj, void * event_info);
97     static void _bookmark_clicked(void * data, Evas_Object * obj, void * event_info);
98     static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info);
99
100     Evas_Object *m_parent;
101     Evas_Object *m_layout;
102     Evas_Object *m_bookmarksView;
103     Evas_Object *m_mostVisitedView;
104     Evas_Object *m_bookmarksButton;
105     Evas_Object *m_mostVisitedButton;
106     Evas_Object *m_bookmarkGengrid;
107     Evas_Object *m_bookmarkManagerButton;
108     bool m_after_history_thumb;
109     std::vector<Evas_Object *> m_tiles;
110     Eina_List* m_parentFocusChain;
111
112     UrlHistoryPtr m_urlHistoryList;
113     Evas_Object* m_urlHistoryListLayout;
114
115     Elm_Gengrid_Item_Class * m_bookmark_item_class;
116     DetailPopup m_detailPopup;
117     services::HistoryItemVector m_historyItems;
118     bool m_gengridSetup;
119     std::string edjFilePath;
120     std::string edjFilePathUrlHistoryList;
121     bool m_desktopMode;
122
123     static const int MAX_TILES_NUMBER;
124     static const int BIG_TILE_INDEX;
125     static const int TOP_RIGHT_TILE_INDEX;
126     static const int BOTTOM_RIGHT_TILE_INDEX;
127     static const std::vector<std::string> TILES_NAMES;
128 };
129
130 }
131 }
132
133 #endif // QUICKACCESS_H