The source code moved from the SPIN with license changed to Flora 1.1
[apps/native/home/homescreen-efl.git] / inc / data_model.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.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 #ifndef DATA_MODEL_H_
18 #define DATA_MODEL_H_
19
20 #include <stdbool.h>
21 #include "app_mgr.h"
22 #include "tree.h"
23
24 typedef enum {
25         REPOSITION_SIDE_TO_LEFT,
26         REPOSITION_SIDE_TO_RIGHT
27 } reposition_side_t;
28
29 /**
30  * @brief gets data model of the application
31  */
32 extern Tree_node_t *data_model_get_data(void);
33
34 /**
35  * @brief gets data model for the all apps view.
36  */
37 extern Tree_node_t *data_model_get_all_apps(void);
38
39 /**
40  * @brief gets data model for the home view.
41  */
42 extern Tree_node_t *data_model_get_home(void);
43
44 /*
45  * @brief Get applications from app manager
46  */
47 extern void data_model_load_app_mgr(void);
48
49 /*
50  * @brief Get applications from database
51  */
52 extern Eina_Bool data_model_load_db(void);
53
54 /*
55  * @brief free entire memory allocated for model structure
56  * and nodes data
57  */
58 extern void data_model_free(void);
59
60 /**
61  * @brief Creates folder in the data model/
62  */
63 extern Tree_node_t *data_model_create_folder(app_item_t *node);
64
65 /**
66  * @brief Appends an item into the folder.
67  */
68 extern void data_model_append_node_to_folder(Tree_node_t *folder,
69         Tree_node_t *node);
70
71 /**
72  * @brief Removes empty pages from the all apps view in the data model.
73  */
74 extern void data_model_free_empty_pages(Tree_node_t *folder_or_some_other_root);
75
76 /*
77  * @brief Delete folder and move apps to all apps
78  */
79 extern void data_model_delete_folder(Tree_node_t *node);
80
81 /**
82  * @brief Append an newly installed application to the data model.
83  */
84 extern Tree_node_t *data_model_install_application(
85         app_mgr_item_t *app_mgr_item);
86
87 /**
88  * @brief Uninstall an application
89  */
90 extern void data_model_uninstall_application(Tree_node_t *node);
91
92 /*
93  * @brief set checked state to all icons
94  */
95 extern void data_model_check_all_apps(Tree_node_t *node, bool checked);
96
97 /**
98  * @brief returns count of checked applications in the all apps edit mode view.
99  */
100 extern int data_model_get_app_check_state(void);
101
102 /**
103  * @brief change position of an application
104  */
105 extern void data_model_reposition_item(Tree_node_t *node,
106         Tree_node_t *destinations_parent, Tree_node_t *destination,
107         reposition_side_t side, int page_limit);
108
109 /**
110  * @brief set the view type of the data models items
111  */
112 extern void data_model_set_view_mode(homescreen_view_t view);
113
114 /**
115  * @brief iterates over the whole tree and applies func_cb over each node
116  * @param node - tree node, pass NULL if You want
117  * to start from the root of the model tree
118  * @param func_cb - function to call on each node
119  * @param data - data - to be passed to func_cb
120  * @details [long description]
121  */
122 extern void data_model_iterate(Tree_node_t *node, tree_browse_cb_t func_cb,
123         void *data);
124
125 /**
126  * @brief This one takes pages abstraction into account.
127  * Iterates through pages, and it's items.
128  * @param node - tree node, pass NULL if You want
129  * to start from the root of the model tree
130  * @param item_func - function to call on each item
131  * @param page_func - function to call on each page
132  * @param data - data - to be passed to func_cb
133  */
134 extern void data_model_iterate_pages(Tree_node_t *node,
135         tree_browse_cb_t page_func, tree_browse_cb_t item_func, void *data);
136
137 /**
138  * @brief sorts in place using sort_compare_function
139  */
140 extern void data_model_sort(Eina_Compare_Cb sort_compare_function);
141
142 /**
143  * @brief Creates new page
144  * @details Creates new page node, adds it to the tree structure and
145  * returns the created page
146  * @return new page node
147  */
148 extern Tree_node_t *data_model_add_widget_page(void);
149
150 /**
151  * @brief Creates new widget and adds it to @p page
152  * @param page Page the new widget will be added to
153  * @param widget_id Created widget
154  * @param col column to put widget in
155  * @param row row to put widget in
156  * @param col_span column span of widget
157  * @param row_span row span of widget
158  * @return New widget node
159  */
160 extern Tree_node_t *data_model_add_widget(Tree_node_t *page,
161         const char *widget_id, int col, int row, int col_span, int row_span,
162         const char *content_info);
163
164 /**
165  * @brief [brief description]
166  * @details [long description]
167  */
168 extern void data_model_reposition_widget(Tree_node_t *page_node,
169         Tree_node_t *obj_node);
170
171 /**
172  * @brief [brief description]
173  * @details [long description]
174  */
175 extern void data_model_resize_widget(Tree_node_t *item_node, int col, int row,
176         int col_span, int row_span);
177
178 extern void data_model_update_content_info(Tree_node_t *item_node, const char *content_info);
179
180 /**
181  * @brief [brief description]
182  * @details [long description]
183  */
184 extern void data_model_insert_after(Tree_node_t *prev_node,
185         Tree_node_t *item_node);
186
187 /**
188  * @brief [brief description]
189  * @details [long description]
190  */
191 extern void data_model_del_item(Tree_node_t *node);
192
193 /**
194  * @brief [brief description]
195  * @details [long description]
196  */
197 extern void data_model_update_item(Tree_node_t *node);
198
199 /**
200  * @brief Unpin a repositioned node from the folder.
201  *
202  * @param folder_node Folder node pointer.
203  * @param node repositioned node pointer.
204  */
205 extern void data_model_detach_from_folder(Tree_node_t *folder_node,
206         Tree_node_t *node);
207
208
209 #endif /* DATA_MODEL_H_ */