修改判斷搜索對象的邏輯

This commit is contained in:
hewenfei 2022-03-30 14:46:59 +08:00
parent 777b5c06ef
commit 50bee43617
1 changed files with 5 additions and 5 deletions

View File

@ -89,17 +89,17 @@ void FileSearchWorker::run()
Xapian::Query FileSearchWorker::creatQueryForFileSearch() { Xapian::Query FileSearchWorker::creatQueryForFileSearch() {
Xapian::Query fileOrDir = Xapian::Query::MatchAll; Xapian::Query fileOrDir = Xapian::Query::MatchAll;
if (!m_searchController->isSearchDirOnly() || !m_searchController->isSearchFileOnly()) { if (m_searchController->isSearchDirOnly() && m_searchController->isSearchFileOnly()) {
//同时指定'只搜索目录'和'只搜索文件',那麼拒絕搜索
return {};
} else {
if (m_searchController->isSearchDirOnly()) { if (m_searchController->isSearchDirOnly()) {
fileOrDir = Xapian::Query(Xapian::Query::OP_VALUE_RANGE, 1, "1", "1"); fileOrDir = Xapian::Query(Xapian::Query::OP_VALUE_RANGE, 1, "1", "1");
} else if (m_searchController->isSearchFileOnly()) { } else if (m_searchController->isSearchFileOnly()) {
fileOrDir = Xapian::Query(Xapian::Query::OP_VALUE_RANGE, 1, "0", "0"); fileOrDir = Xapian::Query(Xapian::Query::OP_VALUE_RANGE, 1, "0", "0");
} }
} else {
//同时指定只搜索目录和只搜索文件。。。
return {};
} }
std::vector<Xapian::Query> queries; std::vector<Xapian::Query> queries;