MainWindow: Avoid potential double path searches
This commit is contained in:
parent
c0657947b1
commit
b10c2edf05
@ -164,12 +164,22 @@ void MainWindow::lineEditReturnPressed()
|
|||||||
[&, q]()
|
[&, q]()
|
||||||
{
|
{
|
||||||
SqliteSearch searcher(db);
|
SqliteSearch searcher(db);
|
||||||
|
QVector<SearchResult> results;
|
||||||
this->contentSearchQuery = LooqsQuery::build(q, TokenType::FILTER_CONTENT_CONTAINS, true);
|
this->contentSearchQuery = LooqsQuery::build(q, TokenType::FILTER_CONTENT_CONTAINS, true);
|
||||||
|
|
||||||
LooqsQuery filesQuery = LooqsQuery::build(q, TokenType::FILTER_PATH_CONTAINS, false);
|
/* We can have a path search in contentsearch too (if given explicitly), so no need to do it twice.
|
||||||
QVector<SearchResult> results;
|
Make sure path results are listed first. */
|
||||||
results.append(searcher.search(filesQuery));
|
bool addContentSearch = this->contentSearchQuery.hasContentSearch();
|
||||||
results.append(searcher.search(this->contentSearchQuery));
|
bool addPathSearch = !this->contentSearchQuery.hasPathSearch() || !addContentSearch;
|
||||||
|
if(addPathSearch)
|
||||||
|
{
|
||||||
|
LooqsQuery filesQuery = LooqsQuery::build(q, TokenType::FILTER_PATH_CONTAINS, false);
|
||||||
|
results.append(searcher.search(filesQuery));
|
||||||
|
}
|
||||||
|
if(addContentSearch)
|
||||||
|
{
|
||||||
|
results.append(searcher.search(this->contentSearchQuery));
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
});
|
});
|
||||||
searchWatcher.setFuture(searchFuture);
|
searchWatcher.setFuture(searchFuture);
|
||||||
|
Caricamento…
Fai riferimento in un nuovo problema
Block a user