forked from foruok/stockMonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstockProvider.h
125 lines (110 loc) · 3.65 KB
/
stockProvider.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef STOCKPROVIDER_H
#define STOCKPROVIDER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QList>
#include <QTime>
#include <QByteArray>
class StockProvider;
class StockDetail
{
friend class StockProvider;
public:
StockDetail(const QByteArray & stockCode);
~StockDetail();
const bool detailAvailable() const;
const QByteArray & name() const;
const QByteArray & code() const;
const QByteArray & todayOpenPrice() const;
const QByteArray & yesterdayClosePrice() const;
const QByteArray & currentPrice() const;
const QByteArray & todayHighestPrice() const;
const QByteArray & todayLowestPrice() const;
const QByteArray & transactionStocks() const;
const QByteArray & transactionMoney() const;
const QByteArray & buyOneAmount() const;
const QByteArray & buyOnePrice() const;
const QByteArray & buyTwoAmount() const;
const QByteArray & buyTwoPrice() const;
const QByteArray & buyThreeAmount() const;
const QByteArray & buyThreePrice() const;
const QByteArray & buyFourAmount() const;
const QByteArray & buyFourPrice() const;
const QByteArray & buyFiveAmount() const;
const QByteArray & buyFivePrice() const;
const QByteArray & saleOneAmount() const;
const QByteArray & saleOnePrice() const;
const QByteArray & saleTwoAmount() const;
const QByteArray & saleTwoPrice() const;
const QByteArray & saleThreeAmount() const;
const QByteArray & saleThreePrice() const;
const QByteArray & saleFourAmount() const;
const QByteArray & saleFourPrice() const;
const QByteArray & saleFiveAmount() const;
const QByteArray & saleFivePrice() const;
const QByteArray & date() const ;
const QByteArray & time() const;
const QString rise() const;
const QString risePercent() const ;
const int riseMode() const;
const bool arriveStopWin() const;
const bool arriveStopLose() const;
void setStopWinPrice(double price);
const double stopWinPrice() const;
void setStopLosePrice(double price);
const double stopLosePrice() const;
const bool isDetailsValid() const;
const QString handoverRate() const;
protected:
QByteArray m_strCode;
QList<QByteArray> m_details;
double m_stopWinPrice;
double m_stopLosePrice;
double m_totalTransactStocks;
};
class StockProvider : public QObject
{
Q_OBJECT
public:
StockProvider(QObject * parent = 0);
~StockProvider();
bool addStock(const QByteArray & stockCode);
void removeStock(const QByteArray & stockCode);
void removeStock(int index);
StockDetail * stock(const QByteArray & stockCode);
int stockCount();
StockDetail * stockAt(int index);
int remindMode();
void setRemindMode(int mode);
void saveState();
int updateInterval() { return m_refreshInterval; }
void setUpdateInterval(int seconds);
signals:
void beginRefresh();
void refreshed();
void remind(const QString & contents);
protected slots:
void onRefreshFinished();
void onRefreshError(QNetworkReply::NetworkError code);
protected:
void timerEvent(QTimerEvent *);
void saveToFile();
void readFromFile();
void startUpdate();
void parseData(const QByteArray & data);
void updateStockDetail(const QByteArray & stockCode, const QByteArray & data);
void updateRemindContents(StockDetail * stock);
protected:
QList<StockDetail*> m_stocks;
int m_iRefreshTimer;
int m_iRefreshTimeoutTimer;
QNetworkAccessManager m_nam;
QTime m_updateElapsed;
int m_iRemindMode;
int m_refreshInterval;
QNetworkReply *m_reply;
bool m_bShouldSave;
QString m_strRemind;
};
#endif // STOCKPROVIDER_H