File indexing completed on 2024-05-12 13:51:43
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Ismael Asensio <isma.af@mgmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef DOLPHINQUERY_H 0008 #define DOLPHINQUERY_H 0009 0010 #include "dolphin_export.h" 0011 0012 #include <QString> 0013 #include <QUrl> 0014 0015 /** 0016 * @brief Simple query model that parses a Baloo search Url and extracts its 0017 * separate components to be displayed on dolphin search box. 0018 */ 0019 class DolphinQuery 0020 { 0021 public: 0022 /** Parses the components of @p searchUrl for the supported schemes */ 0023 static DolphinQuery fromSearchUrl(const QUrl &searchUrl); 0024 /** Checks whether the DolphinQuery supports the given @p urlScheme */ 0025 static bool supportsScheme(const QString &urlScheme); 0026 0027 /** @return the \a searchUrl passed to Baloo::Query::fromSearchUrl() */ 0028 QUrl searchUrl() const; 0029 /** @return the user text part of the query, to be shown in the searchbar */ 0030 QString text() const; 0031 /** @return the first of Baloo::Query::types(), or an empty string */ 0032 QString type() const; 0033 /** @return a list of the search terms of the Baloo::Query that act as a filter, 0034 * such as \"rating>= <i>value<i>\" or \"modified>= <i>date<i>\"*/ 0035 QStringList searchTerms() const; 0036 /** @return Baloo::Query::includeFolder(), that is, the initial directory 0037 * for the query or an empty string if its a global search" */ 0038 QString includeFolder() const; 0039 /** @return whether the query includes search in file content */ 0040 bool hasContentSearch() const; 0041 /** @return whether the query includes a filter by fileName */ 0042 bool hasFileName() const; 0043 0044 private: 0045 /** Calls Baloo::Query::fromSearchUrl() on the current searchUrl 0046 * and parses the result to extract its separate components */ 0047 void parseBalooQuery(); 0048 0049 private: 0050 QUrl m_searchUrl; 0051 QString m_searchText; 0052 QString m_fileType; 0053 QStringList m_searchTerms; 0054 QString m_includeFolder; 0055 bool m_hasContentSearch = false; 0056 bool m_hasFileName = false; 0057 }; 0058 0059 #endif //DOLPHINQUERY_H