Tulip  5.4.0
Large graphs analysis and drawing
FileDownloader.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 ///@cond DOXYGEN_HIDDEN
21 
22 #ifndef FILEDOWNLOADER_H
23 #define FILEDOWNLOADER_H
24 
25 #include <tulip/tulipconf.h>
26 
27 #include <QObject>
28 #include <QByteArray>
29 #include <QNetworkAccessManager>
30 #include <QNetworkRequest>
31 #include <QNetworkReply>
32 
33 namespace tlp {
34 
35 /**
36  * @brief Helper class to download the content of a file referenced by an url
37  **/
38 class TLP_QT_SCOPE FileDownloader : public QObject {
39 
40  Q_OBJECT
41 
42 public:
43  FileDownloader();
44 
45  /**
46  * Synchronously download the content of a file referenced by an url
47  * and returns it as a raw byte array.
48  *
49  */
50  const QByteArray &download(const QUrl &url);
51 
52 signals:
53 
54  void downloaded();
55 
56 private slots:
57 
58  void fileDownloaded(QNetworkReply *pReply);
59 
60 private:
61  QNetworkAccessManager _webCtrl;
62  QByteArray _downloadedData;
63 };
64 } // namespace tlp
65 
66 #endif // FILEDOWNLOADER_H
67 
68 ///@endcond