Tulip  5.2.1
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  * @brief Helper class to download the content of a file referenced by an url
16  **/
17 class TLP_QT_SCOPE FileDownloader : public QObject {
18 
19  Q_OBJECT
20 
21 public:
23 
24  /**
25  * Synchronously download the content of a file referenced by an url
26  * and returns it as a raw byte array.
27  *
28  */
29  const QByteArray &download(const QUrl &url);
30 
31 signals:
32 
33  void downloaded();
34 
35 private slots:
36 
37  void fileDownloaded(QNetworkReply *pReply);
38 
39 private:
40  QNetworkAccessManager _webCtrl;
41  QByteArray _downloadedData;
42 };
43 } // namespace tlp
44 
45 #endif // FILEDOWNLOADER_H
Helper class to download the content of a file referenced by an url.