This repository has been archived by the owner on Apr 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffer_info.h
94 lines (67 loc) · 1.66 KB
/
offer_info.h
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
#ifndef OFFER_INFO_H
#define OFFER_INFO_H
#include <QDateTime>
class QXmlStreamReader;
class QXmlStreamWriter;
class offer_info
{
public:
enum class type
{
buy,
sell
};
enum class state
{
open,
cancelled,
finished,
expired
};
public:
offer_info() = default;
offer_info(qlonglong id);
offer_info(qlonglong id, const offer_info& offer);
offer_info(QXmlStreamReader& xml);
void from(const offer_info& offer);
qlonglong id() const;
type target() const;
void set_target(type target);
state status() const;
void set_staus(state status);
qlonglong item_id() const;
void set_item_id(qlonglong id);
int amount() const;
void add_amount(int amount);
void sub_amount(int amount);
void set_amount(int amount);
int price() const;
void set_price(int price);
int total_price() const;
int fee() const;
void set_fee(int fee);
int total_fee() const;
void add_total_fee(int fee);
void set_total_fee(int total);
bool flag() const;
void set_flag(bool flag);
void toggle_flag();
QDateTime expires() const;
void set_expires(const QDateTime& expires);
void refresh();
bool operator==(const offer_info& r) const;
void read_from_xml(QXmlStreamReader& xml);
void append_to_xml(QXmlStreamWriter& xml);
protected:
qlonglong m_id = -1;
type m_target = type::buy;
state m_status = state::open;
qlonglong m_item_id = 0;
int m_amount = 0;
int m_price = 0;
int m_fee = 0;
int m_total_fee = 0;
bool m_flag = false;
QDateTime m_expires;
};
#endif // OFFER_INFO_H