1 | /* |
2 | SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez <aleixpol@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-or-later |
5 | */ |
6 | |
7 | #ifndef RESULTSSTREAM_H |
8 | #define RESULTSSTREAM_H |
9 | |
10 | #include <QObject> |
11 | |
12 | #include "enginebase.h" |
13 | #include "provider.h" |
14 | |
15 | #include "knewstuffcore_export.h" |
16 | |
17 | namespace KNSCore |
18 | { |
19 | class SearchRequest; |
20 | class ResultsStreamPrivate; |
21 | /*! |
22 | * \class KNSCore::ResultsStream |
23 | * \inmodule KNewStuffCore |
24 | * |
25 | * \brief The ResultsStream is returned by EngineBase::search. It is used to communicate |
26 | * the different entries in response to a request using the signal \c entriesFound. |
27 | * |
28 | * Initially the stream will communicate the entries part of the page as specified |
29 | * in the request. Further pages can be requested using \c fetchMore. |
30 | * |
31 | * Once we have reached the end of the requested stream, the object shall emit |
32 | * \c finished and delete itself. |
33 | * |
34 | * \since 6.0 |
35 | */ |
36 | class KNEWSTUFFCORE_EXPORT ResultsStream : public QObject |
37 | { |
38 | Q_OBJECT |
39 | public: |
40 | ~ResultsStream() override; |
41 | |
42 | /// Issues the search, make sure all signals are connected before calling |
43 | void fetch(); |
44 | |
45 | /// Increments the requested page and issues another search |
46 | void fetchMore(); |
47 | |
48 | Q_SIGNALS: |
49 | void entriesFound(const KNSCore::Entry::List &entries); |
50 | void finished(); |
51 | |
52 | private: |
53 | friend class EngineBase; |
54 | #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(6, 9) |
55 | /// @deprecated since 6.9 Use SearchRequest constructor |
56 | KNEWSTUFFCORE_DEPRECATED_VERSION(6, 9, "Use SearchRequest constructor" ) |
57 | ResultsStream(const Provider::SearchRequest &request, EngineBase *base); |
58 | #endif |
59 | /** |
60 | * @param request The search request to be issued |
61 | * @param base The engine issuing the request |
62 | * @since 6.9 |
63 | */ |
64 | ResultsStream(const SearchRequest &request, EngineBase *base); |
65 | void finish(); |
66 | |
67 | std::unique_ptr<ResultsStreamPrivate> d; |
68 | }; |
69 | |
70 | } |
71 | |
72 | #endif // RESULTSSTREAM_H |
73 | |