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 ResultsStreamPrivate; |
20 | /** |
21 | * The ResultsStream is returned by EngineBase::search. It is used to communicate |
22 | * the different entries in response to a request using the signal @m entriesFound. |
23 | * |
24 | * Initially the stream will communicate the entries part of the page as specified |
25 | * in the request. Further pages can be requested using @m fetchMore. |
26 | * |
27 | * Once we have reached the end of the requested stream, the object shall emit |
28 | * @m finished and delete itself. |
29 | * |
30 | * @since 6.0 |
31 | */ |
32 | class KNEWSTUFFCORE_EXPORT ResultsStream : public QObject |
33 | { |
34 | Q_OBJECT |
35 | public: |
36 | ~ResultsStream() override; |
37 | |
38 | /// Issues the search, make sure all signals are connected before calling |
39 | void fetch(); |
40 | |
41 | /// Increments the requested page and issues another search |
42 | void fetchMore(); |
43 | |
44 | Q_SIGNALS: |
45 | void entriesFound(const KNSCore::Entry::List &entries); |
46 | void finished(); |
47 | |
48 | private: |
49 | friend class EngineBase; |
50 | ResultsStream(const Provider::SearchRequest &request, EngineBase *base); |
51 | void finish(); |
52 | |
53 | std::unique_ptr<ResultsStreamPrivate> d; |
54 | }; |
55 | |
56 | } |
57 | |
58 | #endif // RESULTSSTREAM_H |
59 | |