]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinquery.h
Apply 1 suggestion(s) to 1 file(s)
[dolphin.git] / src / search / dolphinquery.h
1 /*
2 * SPDX-FileCopyrightText: 2019 Ismael Asensio <isma.af@mgmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINQUERY_H
8 #define DOLPHINQUERY_H
9
10 #include "dolphin_export.h"
11
12 #include <QString>
13 #include <QUrl>
14
15 /**
16 * @brief Simple query model that parses a Baloo search Url and extracts its
17 * separate components to be displayed on dolphin search box.
18 */
19 class DolphinQuery
20 {
21 public:
22 /** Parses the components of @p searchUrl for the supported schemes */
23 static DolphinQuery fromSearchUrl(const QUrl &searchUrl);
24 /** Checks whether the DolphinQuery supports the given @p urlScheme */
25 static bool supportsScheme(const QString &urlScheme);
26
27 /** @return the \a searchUrl passed to Baloo::Query::fromSearchUrl() */
28 QUrl searchUrl() const;
29 /** @return the user text part of the query, to be shown in the searchbar */
30 QString text() const;
31 /** @return the first of Baloo::Query::types(), or an empty string */
32 QString type() const;
33 /** @return a list of the search terms of the Baloo::Query that act as a filter,
34 * such as \"rating>= <i>value<i>\" or \"modified>= <i>date<i>\"*/
35 QStringList searchTerms() const;
36 /** @return Baloo::Query::includeFolder(), that is, the initial directory
37 * for the query or an empty string if its a global search" */
38 QString includeFolder() const;
39 /** @return whether the query includes search in file content */
40 bool hasContentSearch() const;
41 /** @return whether the query includes a filter by fileName */
42 bool hasFileName() const;
43
44 private:
45 /** Calls Baloo::Query::fromSearchUrl() on the current searchUrl
46 * and parses the result to extract its separate components */
47 void parseBalooQuery();
48
49 private:
50 QUrl m_searchUrl;
51 QString m_searchText;
52 QString m_fileType;
53 QStringList m_searchTerms;
54 QString m_includeFolder;
55 bool m_hasContentSearch = false;
56 bool m_hasFileName = false;
57 };
58
59 #endif //DOLPHINQUERY_H