kylin-weather/model/datarequest.h

43 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef DATAREQUEST_H
#define DATAREQUEST_H
#include <QObject>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QDebug>
#include <QByteArray>
#include <QTimer>
#include <QEventLoop>
#include <QJsonParseError>
#include "controller/core/errorreact.h"
#include "global/corevar.h"
class DataRequest : public QObject
{
Q_OBJECT
public:
explicit DataRequest(QObject *parent = nullptr);
~DataRequest();
void dataRequest(const QString &cityId); //主界面城市数据请求
void dataRequestLeftAndRight(const QString &cityIdList);//主界面左右城市数据请求
void dataRequestCollect(const QString &cityIdList); //收藏城市数据请求
private:
QNetworkAccessManager *m_networkManager = nullptr;
void dataReply(); //主界面城市网络返回
void dataReplyCollect(); //收藏界面网络返回
bool m_requsetWay = false; //默认为false请求数据的方式true代表是从搜索列表请求false为其他
QTimer m_timer; //当前城市的定时器
QTimer m_timerLAndR; //左侧城市的定时器
QTimer m_timerColl; //收藏的定时器
QNetworkReply *m_reply = nullptr; //主界面城市网络reply
QNetworkReply *m_replyLAndR = nullptr; //主界面左边城市网络reply
QNetworkReply *m_replyCollect = nullptr; //收藏城市界面网络reply
bool timeOut(QTimer *timer, QNetworkReply *reply, QEventLoop *eventloop); //主界面超时函数
signals:
void sigSendLAndRData(QByteArray dataBa); //主界面左边城市数据
void sendData(QByteArray dataBa); //主界面城市数据
void sendCollData(QByteArray dataBa); //收藏城市数据
};
#endif // DATAREQUEST_H