Tulip  5.0.0
Large graphs analysis and drawing
FileDownloader.h
1 #ifndef FILEDOWNLOADER_H
2 #define FILEDOWNLOADER_H
3 
4 #include <tulip/tulipconf.h>
5 
6 #include <QObject>
7 #include <QByteArray>
8 #include <QNetworkAccessManager>
9 #include <QNetworkRequest>
10 #include <QNetworkReply>
11 
12 namespace tlp {
13 
14 
15 /**
16  * @brief Helper class to download the content of a file referenced by an url
17  **/
18 class TLP_QT_SCOPE FileDownloader : public QObject {
19 
20  Q_OBJECT
21 
22 public:
23 
25 
26  /**
27  * Synchronously download the content of a file referenced by an url
28  * and returns it as a raw byte array.
29  *
30  */
31  const QByteArray &download(const QUrl &url);
32 
33 signals:
34 
35  void downloaded();
36 
37 private slots:
38 
39  void fileDownloaded(QNetworkReply* pReply);
40 
41 private:
42 
43  QNetworkAccessManager _webCtrl;
44  QByteArray _downloadedData;
45 
46 };
47 
48 }
49 
50 #endif // FILEDOWNLOADER_H
Helper class to download the content of a file referenced by an url.