1 | // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
2 | // SPDX-FileCopyrightText: 2024 Harald Sitter <sitter@kde.org> |
3 | |
4 | #pragma once |
5 | |
6 | #include "provider.h" |
7 | #include "searchrequest.h" |
8 | |
9 | namespace KNSCore |
10 | { |
11 | |
12 | struct SearchRequestPrivate { |
13 | KNSCore::SortMode sortMode; |
14 | KNSCore::Filter filter; |
15 | QString searchTerm; |
16 | QStringList categories; |
17 | int page; |
18 | int pageSize; |
19 | quint64 id; |
20 | |
21 | [[nodiscard]] QString hashForRequest() const |
22 | { |
23 | return QString::number((int)sortMode) + QLatin1Char(',') + searchTerm + QLatin1Char(',') + categories.join(sep: QLatin1Char('-')) + QLatin1Char(',') |
24 | + QString::number(page) + QLatin1Char(',') + QString::number(pageSize); |
25 | } |
26 | |
27 | bool operator==(const SearchRequestPrivate &other) const |
28 | { |
29 | return id == other.id; |
30 | } |
31 | |
32 | [[nodiscard]] static quint64 searchRequestId() |
33 | { |
34 | static quint64 id = 0; |
35 | return id++; |
36 | } |
37 | }; |
38 | |
39 | KNSCore::SearchRequest searchRequestFromLegacy(const KNSCore::Provider::SearchRequest &request); |
40 | |
41 | } // namespace KNSCore |
42 | |