Changeset View
Changeset View
Standalone View
Standalone View
src/search/dolphinquery.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 48 | { | |||
---|---|---|---|---|---|
49 | DolphinQuery model; | 49 | DolphinQuery model; | ||
50 | model.m_searchUrl = searchUrl; | 50 | model.m_searchUrl = searchUrl; | ||
51 | 51 | | |||
52 | #ifdef HAVE_BALOO | 52 | #ifdef HAVE_BALOO | ||
53 | const Baloo::Query query = Baloo::Query::fromSearchUrl(searchUrl); | 53 | const Baloo::Query query = Baloo::Query::fromSearchUrl(searchUrl); | ||
54 | 54 | | |||
55 | model.m_includeFolder = query.includeFolder(); | 55 | model.m_includeFolder = query.includeFolder(); | ||
56 | 56 | | |||
57 | model.m_searchText = query.searchString(); | | |||
58 | | ||||
59 | const QStringList types = query.types(); | 57 | const QStringList types = query.types(); | ||
60 | model.m_fileType = types.isEmpty() ? QString() : types.first(); | 58 | model.m_fileType = types.isEmpty() ? QString() : types.first(); | ||
61 | 59 | | |||
60 | QStringList textParts; | ||||
61 | | ||||
62 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | 62 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | ||
63 | foreach (const QString& subTerm, subTerms) { | 63 | foreach (const QString& subTerm, subTerms) { | ||
64 | QString value; | ||||
64 | if (subTerm.startsWith(QLatin1String("filename:"))) { | 65 | if (subTerm.startsWith(QLatin1String("filename:"))) { | ||
65 | const QString value = subTerm.mid(9); | 66 | value = subTerm.mid(9); | ||
66 | model.m_searchText = value; | 67 | model.m_hasFileName = true; | ||
67 | } else if (isSearchTerm(subTerm)) { | 68 | } else if (isSearchTerm(subTerm)) { | ||
68 | model.m_searchTerms << subTerm; | 69 | model.m_searchTerms << subTerm; | ||
70 | continue; | ||||
71 | } else if (subTerm == QLatin1String("AND") && subTerm != subTerms.at(0) && subTerm != subTerms.back()) { | ||||
72 | continue; | ||||
73 | } else { | ||||
74 | value = subTerm; | ||||
75 | } | ||||
76 | | ||||
77 | if (!value.isEmpty() && value.at(0) == QLatin1Char('"')) { | ||||
78 | value = value.mid(1); | ||||
79 | } | ||||
80 | if (!value.isEmpty() && value.back() == QLatin1Char('"')) { | ||||
81 | value = value.mid(0, value.size() - 1); | ||||
82 | } | ||||
83 | if (!value.isEmpty()) { | ||||
84 | textParts << value; | ||||
69 | } | 85 | } | ||
70 | } | 86 | } | ||
87 | | ||||
88 | model.m_searchText = textParts.join(QLatin1Char(' ')); | ||||
89 | | ||||
71 | #endif | 90 | #endif | ||
72 | return model; | 91 | return model; | ||
73 | } | 92 | } | ||
74 | 93 | | |||
75 | QUrl DolphinQuery::searchUrl() const | 94 | QUrl DolphinQuery::searchUrl() const | ||
76 | { | 95 | { | ||
77 | return m_searchUrl; | 96 | return m_searchUrl; | ||
78 | } | 97 | } | ||
Show All 12 Lines | |||||
91 | { | 110 | { | ||
92 | return m_searchTerms; | 111 | return m_searchTerms; | ||
93 | } | 112 | } | ||
94 | 113 | | |||
95 | QString DolphinQuery::includeFolder() const | 114 | QString DolphinQuery::includeFolder() const | ||
96 | { | 115 | { | ||
97 | return m_includeFolder; | 116 | return m_includeFolder; | ||
98 | } | 117 | } | ||
118 | | ||||
119 | bool DolphinQuery::isContentSearch() const | ||||
120 | { | ||||
121 | return !m_hasFileName; | ||||
122 | } |