-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplListMenu.cpp
More file actions
56 lines (48 loc) · 910 Bytes
/
Copy pathApplListMenu.cpp
File metadata and controls
56 lines (48 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "ApplListMenu.hpp"
using namespace sf;
using namespace std;
using namespace nlohmann;
ApplListMenu::ApplListMenu(string data_file_name) :
data_file_name(data_file_name),
search_text_box(Sprite())
{
}
void ApplListMenu::save_data_to_file()
{
json appl_data = {};
ofstream file(data_file_name);
for (auto appl : all_applications)
{
json data;
appl.get_data(data);
appl_data.push_back(data);
}
file << appl_data;
}
void ApplListMenu::get_data_from_file()
{
all_applications.clear();
ifstream file(data_file_name);
if (!file)
{
cout << "Can't open the file " << data_file_name;
abort();
}
json appl_data = {};
file >> appl_data;
for (int i = 0; !appl_data[i].empty(); i++)
{
Application appl;
appl.set_data(appl_data[i]);
all_applications.push_back(appl);
}
}
void ApplListMenu::add_appl()
{
}
void ApplListMenu::delete_appl()
{
}
void ApplListMenu::search()
{
}