Blame view

LiveChat/FeiTalk/common/downloadfile.h 1.21 KB
9f17d59e   陈明泉   no message
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
  /*
  * @file doanlowdfile.h
  * @author 袁爱玲
  * @version 0.1
  * @date 2014.1.26
  * @details 下载资源
  * @history
  */
  #ifndef DOWNLOADFILE_H
  #define DOWNLOADFILE_H
  
  #include <QObject>
  #include <QNetworkReply>
  #include <QFile>
  
  
  struct downFile{
      QUrl url;
      QString filename;
      int fid;
  };
  
  class IDownloadFile : public QObject
  {
      Q_OBJECT
  public:
      IDownloadFile();
      void cancelDownload();
      void downloadFile(QUrl url,QString filename,int fid);
      static IDownloadFile *Instance();
      void addDownloadFile(QUrl url,QString filename,int fid);
  
  public slots:
      void httpReadyRead();
      void httpFinished();
      void errorReturn(QNetworkReply::NetworkError);
      void startDownload();
  
  signals:
      void writeok(int);
      void downloadError(int);
      void startDownloadFile();
6e10e93e   陈明泉   no message
43
      void downloadFileEnd();
9f17d59e   陈明泉   no message
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  
  private:
      QUrl url;
      QNetworkAccessManager qnam;
      QNetworkReply *reply;
      QFile *file;
      int httpGetId;
      int fid;
      bool httpRequestAborted;
      QMap<int,QString> downfileMap;//下载的文件
  public:
      QString filename;
      QString d_type;
      static IDownloadFile *m_downloadFile;
      int downloadNum;
      struct downFile downFileMsg[20];
      bool downloadFlag;
  };
  
  #endif // DOWNLOADFILE_H