-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd_account.cpp
94 lines (81 loc) · 2.81 KB
/
d_account.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "d_account.h"
D_Account::D_Account(int idx, const QString& name, const QString& type,
const QString& api, const QString& secret, bool selected,
bool connected, const QString& status, const QString& balance, QObject *parent)
: _idx(idx), _name(name), _type(type), _api(api), _secret(secret),
_selected(selected), _connected(connected), _status(status), _balance(balance), QObject{parent}
{}
D_Account::D_Account(const QVariantMap &map, QObject *parent) : QObject(parent)
{
_idx = map.value("id").toInt();
_name = map.value("name").toString();
_type = map.value("type").toString();
_api = map.value("api").toString();
_secret = map.value("secret").toString();
_selected = map.value("selected", false).toBool();
_connected = map.value("connected", false).toBool();
_status = map.value("status", "Invalid").toString();
_balance = map.value("balance", 0.00).toString();
}
void D_Account::setid(int idx)
{
if (idx != _idx) {_idx = idx; emit idChanged(); }
}
void D_Account::setName(const QString &name)
{
if (name != _name) {_name = name; emit nameChanged(); }
}
void D_Account::setType(const QString &type)
{
if (type != _type) {_type = type; emit typeChanged(); }
}
void D_Account::setApi(const QString &api)
{
if (api != _api) {_api = api; emit apiChanged(); }
}
void D_Account::setSecret(const QString &secret)
{
if (secret != _secret) {_secret = secret; emit secretChanged(); }
}
void D_Account::setSelected(bool selected)
{
if (selected != _selected) {_selected = selected; emit selectedChanged(); }
}
void D_Account::setConnected(bool connected)
{
if (connected != _connected) {_connected = connected; emit connectedChanged(); }
}
void D_Account::setStatus(const QString &status)
{
if (status != _status) {_status = status; emit statusChanged(); }
}
void D_Account::setBalance(const QString &balance)
{
if (balance != _balance) {_balance = balance; emit balanceChanged(); }
}
QVariantMap D_Account::getMap()
{
QVariantMap map;
map.insert("id", _idx);
map.insert("name", _name);
map.insert("type", _type);
map.insert("api", _api);
map.insert("secret", _secret);
map.insert("selected", _selected);
map.insert("connected", _connected);
map.insert("status", _status);
map.insert("balance", _balance);
return map;
}
void D_Account::fromMap(QVariantMap map)
{
_idx = map.value("id").toInt();
_name = map.value("name").toString();
_type = map.value("type").toString();
_api = map.value("api").toString();
_secret = map.value("secret").toString();
_selected = map.value("selected", false).toBool();
_connected = map.value("connected", false).toBool();
_status = map.value("status", "Invalid").toString();
_balance = map.value("balance", 0.00).toString();
}