Line data Source code
1 : #ifndef IMAGEGRABBER_H
2 : #define IMAGEGRABBER_H
3 :
4 : #include <QObject>
5 : #include <QImage>
6 : #include <QList>
7 : #include <QUrl>
8 : #include <QMap>
9 :
10 : #include "../network/FangNetworkAccessManager.h"
11 : #include "../FangObject.h"
12 :
13 : class ImageGrabber : public FangObject
14 : {
15 : Q_OBJECT
16 : public:
17 : explicit ImageGrabber(QObject *parent = nullptr);
18 :
19 : signals:
20 : /**
21 : * @brief Called when all images are found.
22 : */
23 : void finished();
24 :
25 : public slots:
26 :
27 : /**
28 : * @brief Fetch a group of remote images.
29 : * @param urls
30 : */
31 : void fetchUrls(const QList<QUrl> &urls);
32 :
33 : /**
34 : * @brief Fetch a remote image.
35 : * @param url
36 : */
37 : void fetchUrl(const QUrl &url);
38 :
39 3 : inline QMap<QUrl, QImage>* getResults() { return &results; }
40 :
41 : private slots:
42 : void onRequestFinished(QNetworkReply *reply);
43 :
44 : void checkCompletion();
45 :
46 : void checkUrl(const QUrl &url);
47 :
48 : private:
49 : FangNetworkAccessManager manager;
50 : QList<QUrl> urlsToCheck;
51 : QMap<QUrl, QImage> results;
52 : };
53 :
54 : #endif // IMAGEGRABBER_H
|