File indexing completed on 2024-04-28 03:56:27

0001 /*
0002     SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef RESULTSSTREAM_H
0008 #define RESULTSSTREAM_H
0009 
0010 #include <QObject>
0011 
0012 #include "enginebase.h"
0013 #include "provider.h"
0014 
0015 #include "knewstuffcore_export.h"
0016 
0017 namespace KNSCore
0018 {
0019 class ResultsStreamPrivate;
0020 /**
0021  * The ResultsStream is returned by EngineBase::search. It is used to communicate
0022  * the different entries in response to a request using the signal @m entriesFound.
0023  *
0024  * Initially the stream will communicate the entries part of the page as specified
0025  * in the request. Further pages can be requested using @m fetchMore.
0026  *
0027  * Once we have reached the end of the requested stream, the object shall emit
0028  * @m finished and delete itself.
0029  *
0030  * @since 6.0
0031  */
0032 class KNEWSTUFFCORE_EXPORT ResultsStream : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     ~ResultsStream() override;
0037 
0038     /// Issues the search, make sure all signals are connected before calling
0039     void fetch();
0040 
0041     /// Increments the requested page and issues another search
0042     void fetchMore();
0043 
0044 Q_SIGNALS:
0045     void entriesFound(const KNSCore::Entry::List &entries);
0046     void finished();
0047 
0048 private:
0049     friend class EngineBase;
0050     ResultsStream(const Provider::SearchRequest &request, EngineBase *base);
0051     void finish();
0052 
0053     std::unique_ptr<ResultsStreamPrivate> d;
0054 };
0055 
0056 }
0057 
0058 #endif // RESULTSSTREAM_H