~zeal-developers/zeal/master

« back to all changes in this revision

Viewing changes to src/zealsearchquery.h

  • Committer: Oleg Shparber
  • Date: 2015-01-12 03:51:13 UTC
  • Revision ID: git-v1:792a35241c995b7f5913ee426f4bf5aa706b43d9
Move .pro file to the top, rename zeal dir into src

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef ZEALSEARCHQUERY_H
 
2
#define ZEALSEARCHQUERY_H
 
3
 
 
4
#include <QStringList>
 
5
 
 
6
namespace Zeal {
 
7
 
 
8
/**
 
9
 * @short The search query model.
 
10
 */
 
11
class SearchQuery
 
12
{
 
13
public:
 
14
    /// Creates a search query from a string. Single separator will be
 
15
    /// used to contstruct docset filter, but separator repeated twice
 
16
    /// will be left inside coreQuery part since double semicolon is
 
17
    /// used inside qualified symbol names in popular programming
 
18
    /// languages (c++, ruby, perl, etc.).
 
19
    ///
 
20
    /// Examples:
 
21
    ///   "android:setTypeFa" #=> docsetFilters = ["android"], coreQuery = "setTypeFa"
 
22
    ///   "noprefix"          #=> docsetFilters = [], coreQuery = "noprefix"
 
23
    ///   ":find"             #=> docsetFilters = [], coreQuery = ":find"
 
24
    ///   "std::string"       #=> docsetFilters = [], coreQuery = "std::string"
 
25
    ///   "c++:std::string"   #=> docsetFilters = ["c++"], coreQuery = "std::string"
 
26
    ///
 
27
    /// Multiple docsets are supported using the ',' character:
 
28
    ///   "java,android:setTypeFa #=> docsetFilters = ["java", "android"], coreQuery = "setTypeFa"
 
29
    explicit SearchQuery(const QString &coreQuery);
 
30
 
 
31
    /// Returns true if there's a docset filter for the given query
 
32
    bool hasDocsetFilter() const;
 
33
 
 
34
    /// Returns true if the docset prefix match the ones given on query
 
35
    bool docsetPrefixMatch(const QString &docsetPrefix) const;
 
36
 
 
37
    /// Returns the docset filter raw size for the given query
 
38
    int docsetFilterSize() const;
 
39
 
 
40
    /// Returns the core query, sanitized for use in SQL queries
 
41
    QString sanitizedQuery() const;
 
42
 
 
43
    /// Returns the query with any docset prefixes removed.
 
44
    QString coreQuery() const;
 
45
 
 
46
private:
 
47
    QString m_rawDocsetFilter;
 
48
    QStringList m_docsetFilters;
 
49
    QString m_coreQuery;
 
50
};
 
51
 
 
52
} // namespace Zeal
 
53
 
 
54
#endif // ZEALSEARCHQUERY_H