forked from MatsuriDayo/nekoray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabase.hpp
62 lines (38 loc) · 1.54 KB
/
Database.hpp
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
57
58
59
60
61
62
#pragma once
#include "main/NekoGui.hpp"
#include "ProxyEntity.hpp"
#include "Group.hpp"
namespace NekoGui {
class ProfileManager : private JsonStore {
public:
// JsonStore
// order -> id
QList<int> groupsTabOrder;
// Manager
std::map<int, std::shared_ptr<ProxyEntity>> profiles;
std::map<int, std::shared_ptr<Group>> groups;
ProfileManager();
// LoadManager Reset and loads profiles & groups
void LoadManager();
void SaveManager();
[[nodiscard]] static std::shared_ptr<ProxyEntity> NewProxyEntity(const QString &type);
[[nodiscard]] static std::shared_ptr<Group> NewGroup();
bool AddProfile(const std::shared_ptr<ProxyEntity> &ent, int gid = -1);
void DeleteProfile(int id);
void MoveProfile(const std::shared_ptr<ProxyEntity> &ent, int gid);
std::shared_ptr<ProxyEntity> GetProfile(int id);
bool AddGroup(const std::shared_ptr<Group> &ent);
void DeleteGroup(int gid);
std::shared_ptr<Group> GetGroup(int id);
std::shared_ptr<Group> CurrentGroup();
private:
// sort by id
QList<int> profilesIdOrder;
QList<int> groupsIdOrder;
[[nodiscard]] int NewProfileID() const;
[[nodiscard]] int NewGroupID() const;
static std::shared_ptr<ProxyEntity> LoadProxyEntity(const QString &jsonPath);
static std::shared_ptr<Group> LoadGroup(const QString &jsonPath);
};
extern ProfileManager *profileManager;
} // namespace NekoGui