Add update of GenlistItem fields when text and description are changed
[profile/mobile/apps/native/accessibility-setting.git] / src / SwitchesPage.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 SWITCHES_PAGE_HPP
18 #define SWITCHES_PAGE_HPP
19
20 #include "AddSwitchPage.hpp"
21 #include "AppContext.hpp"
22 #include "Button.hpp"
23 #include "Genlist.hpp"
24 #include "RemoveSwitchPage.hpp"
25 #include "UpdateSwitchPage.hpp"
26
27 /**
28  * View displaying already configured switches and allowing
29  * to start configuration of new switch.
30  *
31  * @param ad global context of application
32  *
33  * TODO:
34  *  replace classical callbacks with lambda expressions
35  */
36 class SwitchesPage
37 {
38         public:
39         using back_cb = void (*)(void *ad); // TODO: probably remove
40         SwitchesPage();
41         void attachCallback(back_cb callback, void *data);
42         static void addSwitchCb(
43                 void *data,
44                 const std::string &switch_id,
45                 const std::string &switch_action,
46                 const std::string &switch_name);
47
48         private:
49         void updateSwitchesList();
50         void createSwitchesGroup();
51         static void switchUpdatedCb(
52                 void *data,
53                 const std::string &switch_id,
54                 const std::string &switch_action,
55                 const std::string &switch_name);
56         static void switchRemovedCb(
57                 void *data,
58                 const std::string &switch_id,
59                 const std::string &switch_action,
60                 const std::string &switch_name);
61
62         AppContext &context_;
63         Button *removeSwitchesPageBtn_ = nullptr;
64         back_cb universal_switch_switches_back = nullptr;
65         void *universal_switch_switches_back_data = nullptr;
66         Genlist *switches_ = nullptr;
67         std::unique_ptr<RemoveSwitchPage> removeSwitchPage_;
68         std::unique_ptr<AddSwitchPage> addSwitchPage_;
69         std::unique_ptr<UpdateSwitchPage> updateSwitchPage_;
70 };
71
72 #endif