bb7d20f137db6b0bb5e9ee01103acb7a29b9e6af
[apps/web/download-manager.git] / src / include / download-manager-view.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  *    http://www.tizenopensource.org/license
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 /**
18  * @file        download-manager-view.h
19  * @author      Jungki Kwak (jungki.kwak@samsung.com)
20  * @brief       Download UI View manager
21  */
22
23 #ifndef DOWNLOAD_MANAGER_VIEW_H
24 #define DOWNLOAD_MANAGER_VIEW_H
25
26 #include <Elementary.h>
27 #include <libintl.h>
28
29 #include <vector>
30 #include "download-manager-common.h"
31 #include "download-manager-viewItem.h"
32 #include "download-manager-dateTime.h"
33
34 enum {
35         POPUP_EVENT_EXIT = 0,
36         POPUP_EVENT_ERR,
37 };
38
39 class DownloadView {
40 public:
41         static DownloadView& getInstance(void) {
42                 static DownloadView inst;
43                 return inst;
44         }
45
46         Evas_Object *create(void);
47         void destroy(void);
48         void createView(void);
49         void activateWindow(void);
50 #ifndef _TIZEN_PUBLIC
51         void rotateWindow(int angle);
52 #endif
53         void show(void);
54         void hide(void);
55
56         void attachViewItem(ViewItem *viewItem);
57         void detachViewItem(ViewItem *viewItem);
58
59         void changedRegion(void);
60         void showErrPopup(string &desc);
61         void update();
62         void update(ViewItem *viewItem);
63         void update(Elm_Object_Item *glItem);
64         void showViewItem(int id, const char *title);
65         void playContent(int id, const char *title);
66         void handleChangedAllCheckedState(void);
67         void handleCheckedState(void);
68         bool isGenlistEditMode(void);
69         void handleGenlistGroupItem(int type);
70 #ifndef _TIZEN_PUBLIC
71         void setSweepedItem(ViewItem *item) { m_sweepedItem = item; }
72         ViewItem *sweepedItem(void) { return m_sweepedItem; }
73 #endif
74         void moveRetryItem(ViewItem *viewItem);
75         static char *getGenlistGroupLabelCB(void *data, Evas_Object *obj,
76                 const char *part);
77
78 private:
79         static void showNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event);
80         static void hideNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event);
81 #ifndef _TIZEN_PUBLIC
82         static void sweepRightCB(void *data, Evas_Object *obj, void *event_info);
83         static void sweepLeftCB(void *data, Evas_Object *obj, void *event_info);
84 #endif
85         static void backBtnCB(void *data, Evas_Object *obj, void *event_info);
86         static void cbItemDeleteCB(void *data, Evas_Object *obj, void *event_info);
87         static void cbItemCancelCB(void *data, Evas_Object *obj, void *event_info);
88         static void selectAllClickedCB(void *data, Evas *evas, Evas_Object *obj,
89                 void *event_info);
90         static void selectAllChangedCB(void *data, Evas_Object *obj,
91                 void *event_info);
92         static void genlistClickCB(void *data, Evas_Object *obj, void *event_info);
93         static void cancelClickCB(void *data, Evas_Object *obj, void *event_info);
94         static void errPopupResponseCB(void *data, Evas_Object *obj, void *event_info);
95
96 private:
97         DownloadView();
98         ~DownloadView();
99
100         inline void destroyEvasObj(Evas_Object *e) { if(e) evas_object_del(e); e = NULL;}
101         void setTheme(void);
102         void setIndicator(Evas_Object *window);
103         Evas_Object *createWindow(const char *windowName);
104         Evas_Object *createBackground(Evas_Object *window);
105         Evas_Object *createLayout(Evas_Object *parent);
106         void createTheme(void);
107         void createNaviBar(void);
108         void createBackBtn(void);
109         void createControlBar(void);
110         void createBox(void);
111         void createList(void);
112
113         void removeTheme(void);
114
115         void addViewItemToGenlist(ViewItem *viewItem);
116         void createGenlistItem(ViewItem *viewItem);
117         void showEmptyView(void);
118         void hideEmptyView(void);
119
120         void removePopup(void);
121         void showGenlistEditMode(void);
122         void hideGenlistEditMode(void);
123 #ifndef _TIZEN_PUBLIC
124         void cancelSweepEvent(void);
125 #endif
126         void createSelectAllLayout(void);
127         void changeAllCheckedValue(void);
128         void destroyCheckedItem(void);
129         void showNotifyInfo(int type, int selectedCount);
130         void destroyNotifyInfo(void);
131         void createNotifyInfo(void);
132
133         DateGroup *getDateGroupObj(int type);
134         Elm_Object_Item *getGenlistGroupItem(int type);
135         int getGenlistGroupCount(int type);
136         void setGenlistGroupItem(int type, Elm_Object_Item *item);
137         void increaseGenlistGroupCount(int type);
138         void handleUpdateDateGroupType(ViewItem *viewItem);
139         void cleanGenlistData();
140         char *getGenlistGroupLabel(void *data, Evas_Object *obj, const char *part);
141 #ifndef _TIZEN_PUBLIC
142         ViewItem *findViewItemForGenlistItem(Elm_Object_Item *glItem);
143 #endif
144
145         Evas_Object *eoWindow;
146         Evas_Object *eoBackground;
147         Evas_Object *eoLayout;
148         Elm_Theme *eoTheme;
149
150         Evas_Object *eoEmptyNoContent;
151         Evas_Object *eoNaviBar;
152         Elm_Object_Item *eoNaviBarItem;
153         Evas_Object *eoBackBtn;
154         Evas_Object *eoControlBar;
155         Elm_Object_Item *eoCbItemDelete;
156         Elm_Object_Item *eoCbItemCancel;
157         Elm_Object_Item *eoCbItemEmpty;
158         Evas_Object *eoBoxLayout;
159         Evas_Object *eoBox;
160         Evas_Object *eoDldList;
161         Evas_Object *eoPopup;
162         Evas_Object *eoSelectAllLayout;
163         Evas_Object *eoAllCheckedBox;
164         Evas_Object *eoNotifyInfo;
165         Evas_Object *eoNotifyInfoLayout;
166         Elm_Genlist_Item_Class dldGenlistGroupStyle;
167         Eina_Bool m_allChecked;
168 #ifndef _TIZEN_PUBLIC
169         ViewItem *m_sweepedItem;
170 #endif
171
172         int m_viewItemCount;
173         DateGroup m_today;
174         DateGroup m_yesterday;
175         DateGroup m_previousDay;
176 };
177
178 #endif /* DOWNLOAD_MANAGER_VIEW_H */