| 1 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | // SPDX-FileCopyrightText: 2009 Jeremy Whiting <jpwhiting@kde.org> |
| 3 | // SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org> |
| 4 | // SPDX-FileCopyrightText: 2021 Dan Leinir Turthra Jensen <admin@leinir.dk> |
| 5 | // SPDX-FileCopyrightText: 2024 Harald Sitter <sitter@kde.org> |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <QString> |
| 10 | |
| 11 | #include "knewstuffcore_export.h" |
| 12 | #include "searchrequest.h" |
| 13 | |
| 14 | namespace KNSCore |
| 15 | { |
| 16 | |
| 17 | class SearchPresetPrivate; |
| 18 | |
| 19 | /** |
| 20 | * Describes a search request that may come from the provider. |
| 21 | * This is used by the OPDS provider to handle the different urls. |
| 22 | * @since 6.9 |
| 23 | */ |
| 24 | class KNEWSTUFFCORE_EXPORT SearchPreset |
| 25 | { |
| 26 | public: |
| 27 | /** |
| 28 | * @brief The SearchPresetTypes enum |
| 29 | * the preset type enum is a helper to identify the kind of label and icon |
| 30 | * the search preset should have if none are found. |
| 31 | * @since 6.9 |
| 32 | */ |
| 33 | enum class Type { |
| 34 | NoPresetType = 0, |
| 35 | GoBack, ///< preset representing the previous search. |
| 36 | Root, ///< preset indicating a root directory. |
| 37 | Start, ///< preset indicating the first entry. |
| 38 | Popular, ///< preset indicating popular items. |
| 39 | Featured, ///< preset for featured items. |
| 40 | Recommended, ///< preset for recommended. This may be customized by the server per user. |
| 41 | Shelf, ///< preset indicating previously acquired items. |
| 42 | Subscription, ///< preset indicating items that the user is subscribed to. |
| 43 | New, ///< preset indicating new items. |
| 44 | FolderUp, ///< preset indicating going up in the search result hierarchy. |
| 45 | AllEntries, ///< preset indicating all possible entries, such as a crawlable list. Might be intense to load. |
| 46 | }; |
| 47 | |
| 48 | [[nodiscard]] SearchRequest request() const; |
| 49 | [[nodiscard]] QString displayName() const; |
| 50 | [[nodiscard]] QString iconName() const; |
| 51 | [[nodiscard]] Type type() const; |
| 52 | [[nodiscard]] QString providerId() const; // not all providers can handle all search requests. |
| 53 | |
| 54 | private: |
| 55 | friend class OPDSProviderPrivate; |
| 56 | SearchPreset(SearchPresetPrivate *dptr); |
| 57 | std::shared_ptr<SearchPresetPrivate> d; |
| 58 | }; |
| 59 | |
| 60 | } // namespace KNSCore |
| 61 | |