-
Notifications
You must be signed in to change notification settings - Fork 44
/
dialog.h
164 lines (129 loc) · 5.29 KB
/
dialog.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QFile>
//网络相关头文件
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkConfigurationManager>
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QSslSocket>
#include <QDesktopServices>
//JSON相关头文件
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QTreeWidgetItem>
#include "qjsonvalue.h"
#include "qcustomplot.h"
#include "about.h"
#include "rumor.h"
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
bool isNetWorkOnline();
int dataParse(QByteArray str);
int readFromFile(QString filename);
int getNum(QJsonObject obj, int *num_confirm, int *num_suspect, int *num_dead, int *num_heal);
int getDay(QString date);
int getTotalAddData(QJsonObject chinaTotal, QJsonObject chinaAdd);
void chinaDayListParse(QJsonArray chinaDayListObj);
void chinaDayAddListParse(QJsonArray chinaDayAddListObj);
void disInfo(QString info);
QVector<double> QStringToDouble(QVector<QString> str, uint16_t len);
double getMaxVaule(QVector<double> dub1, QVector<double> dub2);
//参数是double
void widgetDrawLine(QCustomPlot *widget, QVector<QString> date,
QVector<double> data1Dub, QVector<double> data2Dub);
void widgetDrawLine(QCustomPlot *widget, QString chartName, QString name1, QString name2,
QColor clr1, QColor clr2, QVector<QString> date,
QVector<double> data1, QVector<double> data2);
void dataAddTree(QJsonObject province_obj);
void countryTreeParse(QJsonArray areaTree_obj);
void disTip(QMouseEvent *event, QCustomPlot *widget, QVector<QString> date);
void chinaTreeParse(QJsonObject chinaTree);
void articleParse(QJsonArray arr);
void wigetAddGraph(QCustomPlot *widget);
void wigetSetColor(QCustomPlot *widget, QColor clr1, QColor clr2);
QString rgbToStyle(QColor rbg);
void setSelectStyle(int id);
void parseAddSwitch(QJsonObject sw_obj);
void showAddData(QString key, int num, QLabel *lbe);
private slots:
void on_btn_update_clicked();
void httpReadyRead(); //有可用数据
void httpFinished(); //完成下载
// void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void widget_chart_event(QMouseEvent*);
void update();
void anchorClickedSlot(const QUrl& url);
void drawCharts(int id);
void on_btn_about_clicked();
void closeEvent(QCloseEvent *win);
void on_btn_rumor_clicked();
void on_btn_chkUpdate_clicked();
private:
Ui::Dialog *ui;
QNetworkAccessManager *manager;
QNetworkReply *reply;
QUrl url;
QFile *file;
QString filename;
QString verison = "v1.2";
//腾讯,最新接口有新闻,添加了病死率和治愈率
QString data1_Api = "http://view.inews.qq.com/g2/getOnsInfo?name=disease_h5&_="; //时间戳可以不添加
QString data2_Api = "https://view.inews.qq.com/g2/getOnsInfo?name=disease_other&_="; //时间戳可以不添加
//2020_02_10:添加最新动态新闻键值,大小116KB
//网易api,目前还没新闻,和腾讯非常相似
// QString dataApi = "https://c.m.163.com/ug/api/wuhan/app/data/list-total?t=";
// QString newsApi = "http://api.tianapi.com/txapi/ncov/index?key=964dc226dd5b57e892e6199735b6c55f";
uint8_t selAPI = 1;
bool dat1_parse_ok = true;
int clickId = 0;
uint8_t updateTime = 5; //默认5分钟更新一次
QString newsHtmlFileName = "html_news.txt";
QColor clr1_1 = QColor(0, 93, 255);
QColor clr1_2 = QColor(237, 160, 70);
QColor clr2_1 = QColor(245, 60, 60);
QColor clr2_2 = QColor(36, 200, 200);
QColor clr3_1 = QColor(33, 144, 5);
QColor clr3_2 = QColor(135, 135, 139);
QColor clr4_1 = QColor(33, 144, 5);
QColor clr4_2 = QColor(245, 60, 60);
QVector<QString> AddDate; //新增从1.20
QVector<double> AddConfirmDub; //新增确诊
QVector<double> AddSuspectDub; //新增疑似
QVector<double> AddDeadDub; //新增死亡
QVector<double> AddHealDub; //新增治愈
QVector<QString> TotalDate; //累计从1.13
QVector<double> TotalConfirmDub; //累计确诊
QVector<double> TotalSuspectDub; //累计疑似
QVector<double> TotalDeadDub; //累计死亡
QVector<double> TotalHealDub; //累计治愈
QVector<double> chinaDayListHealRate; //累计治愈率,从1.20开始
QVector<double> chinaDayListDeadRate; //累计死亡率,从1.20开始
QVector<QString> RateDate; //从1.20日开始
QMap<QString, bool> AddSwitchMap; //保存键值对
about ab_win;
rumor rm_win;
};
class ncovPerson
{
public:
int confirm; //确诊
int suspect; //疑似
int heal; //治愈
int dead; //死亡
QString deadRate; //死亡率
QString healRate; //治愈率
bool isUpdated; //国家数据中, 是否更新
QString date; //历史数据中包含日期
};
#endif // DIALOG_H