File indexing completed on 2024-04-21 05:10:35

0001 /*
0002     This file is part of Akregator.
0003 
0004     SPDX-FileCopyrightText: 2004 Sashmit Bhaduri <smt@vfemail.net>
0005     SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0008 */
0009 
0010 #pragma once
0011 
0012 #include "akregator_export.h"
0013 #include <QObject>
0014 
0015 namespace Akregator
0016 {
0017 class Feed;
0018 class TreeNode;
0019 
0020 class AKREGATOR_EXPORT FetchQueue : public QObject
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     explicit FetchQueue(QObject *parent = nullptr);
0026     ~FetchQueue() override;
0027 
0028     /** returns true when no feeds are neither fetching nor queued */
0029     [[nodiscard]] bool isEmpty() const;
0030 
0031     /** adds a feed to the queue */
0032     void addFeed(Feed *f);
0033 
0034 public Q_SLOTS:
0035 
0036     /** aborts currently fetching feeds and empties the queue */
0037     void slotAbort();
0038 
0039 Q_SIGNALS:
0040 
0041     void signalStarted();
0042     void signalStopped();
0043     void fetched(Akregator::Feed *);
0044     void fetchError(Akregator::Feed *);
0045 
0046 protected:
0047     /** fetches the next feed in the queue, unless the maximum of concurrent fetches is reached */
0048     void fetchNextFeed();
0049 
0050     void feedDone(Feed *f);
0051     void connectToFeed(Feed *feed);
0052     void disconnectFromFeed(Feed *feed);
0053 
0054 protected Q_SLOTS:
0055 
0056     void slotNodeDestroyed(Akregator::TreeNode *node);
0057     void slotFeedFetched(Akregator::Feed *);
0058     void slotFetchError(Akregator::Feed *);
0059     void slotFetchAborted(Akregator::Feed *);
0060 
0061 private:
0062     QList<Feed *> m_queuedFeeds;
0063     QList<Feed *> m_fetchingFeeds;
0064 };
0065 } // namespace Akregator