Add update of GenlistItem fields when text and description are changed
[profile/mobile/apps/native/accessibility-setting.git] / src / UpdateSwitchPage.hpp
1 /*
2  * Copyright 2018 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 UPDATE_SWITCH_PAGE_HPP
18 #define UPDATE_SWITCH_PAGE_HPP
19
20 #include "ActionPage.hpp"
21 #include "AppContext.hpp"
22 #include "Entry.hpp"
23 #include "Genlist.hpp"
24 #include "Layout.hpp"
25
26 /**
27  * View allowing to edit existing mapping between switches and activities
28  *
29  * @param ad global context of application
30  * @param config_item object containing information about update
31  *
32  * TODO:
33  *  replace classical callbacks with lambda expressions
34  */
35 class UpdateSwitchPage
36 {
37         public:
38         UpdateSwitchPage(UniversalSwitchConfigurationItem *config_item);
39         void attachActionCallback(UniversalSwitchCb cb, void *cbData);
40
41         private:
42         static void onActionUpdate(const std::string &action, void *user_data);
43         void createUpdateAccessoriesSwitchPage();
44         Genlist *createGenlist(Widget *parent, std::string title);
45         void updateSwitchAction();
46         static void updateSwitchChooseAction(const std::string &action, void *user_data);
47
48         AppContext &context_;
49         UniversalSwitchCb switch_updated_cb = nullptr;
50         void *switch_updated_cb_data = nullptr;
51         UniversalSwitchConfigurationItem config_item_to_update_;
52         std::unique_ptr<ActionPage> actionPage_;
53         Elm_Object_Item *save_object_item = nullptr;
54         Genlist *updateAccessoriesActionGenlist_ = nullptr;
55         Layout *layout_ = nullptr;
56         Entry *entry_ = nullptr;
57 };
58
59 #endif