Line data Source code
1 : #ifndef BATCHFEEDDISCOVERY_H
2 : #define BATCHFEEDDISCOVERY_H
3 :
4 : #include "../models/FeedItem.h"
5 : #include "../models/ListModel.h"
6 : #include "FeedDiscovery.h"
7 : #include "../FangObject.h"
8 :
9 : #include <QObject>
10 : #include <QMap>
11 : #include <QQueue>
12 :
13 : /*!
14 : \brief Calls FeedDiscovery on a bunch of feeds at once in a list.
15 :
16 : Each FeedItem will have IsUpdating and HasError set:
17 : IsUpdating: The feed discovery is in progress
18 : IsError: The feed discovery completed with an error
19 :
20 : If both are false at the time done() is emitted, you're hella
21 : ready to rock and roll!
22 : */
23 : class BatchFeedDiscovery : public FangObject
24 : {
25 : Q_OBJECT
26 : public:
27 : explicit BatchFeedDiscovery(QObject *parent = nullptr);
28 :
29 : signals:
30 :
31 : /*!
32 : \brief Completion signal.
33 : */
34 : void done();
35 :
36 : public slots:
37 :
38 : /*!
39 : \brief Checks an entire feed list.
40 : */
41 : void checkFeedList(ListModel* feedList, int maxConcurrent = 3);
42 :
43 : /*!
44 : \return The list of feeds you asked me to check? Here they are.
45 : */
46 1 : inline ListModel* getFeedList() { return feedList; }
47 :
48 : protected slots:
49 :
50 : void onFeedDiscoveryFinished(FeedDiscovery* discovery);
51 :
52 : void runDiscovery(FeedDiscovery* discovery, FeedItem* item);
53 :
54 : protected:
55 : /*!
56 : \brief Creates a FeedDiscovery instance. Virtual to allow mocking in tests.
57 : */
58 : virtual FeedDiscovery* createFeedDiscovery();
59 :
60 : ListModel* feedList;
61 : QQueue<FeedItem*> queue;
62 : QMap<FeedDiscovery*, FeedItem*> lookup;
63 : };
64 :
65 : #endif // BATCHFEEDDISCOVERY_H
|