解决全局搜索中遍历搜索不能搜索到顶层文件夹的问题

This commit is contained in:
iaom 2023-04-21 11:22:41 +08:00
parent 80320ab9f2
commit 37e3de3cee
2 changed files with 32 additions and 28 deletions

View File

@ -507,6 +507,7 @@ void DirectSearch::run() {
if (!underBlock) {
blockList.append(DirWatcher::getDirWatcher()->blackListOfDir(path));
bfs.enqueue(path);
match(QFileInfo(path));
}
}
if (bfs.isEmpty()) {
@ -540,34 +541,36 @@ void DirectSearch::run() {
}
bfs.enqueue(i.absoluteFilePath());
}
if(i.fileName().contains(m_keyword, Qt::CaseInsensitive)) {
// qWarning() << i.fileName() << m_keyword;
// if(m_searchResult->length() > 49)
// return;
if((i.isDir() && m_value == DIR_SEARCH_VALUE)) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) {
SearchManager::m_mutexDir.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) {
m_searchResult->enqueue(ri);
SearchManager::m_mutexDir.unlock();
} else {
SearchManager::m_mutexDir.unlock();
return;
}
}
} else if (i.isFile() && m_value == FILE_SEARCH_VALUE) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) {
SearchManager::m_mutexFile.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) {
m_searchResult->enqueue(ri);
SearchManager::m_mutexFile.unlock();
} else {
SearchManager::m_mutexFile.unlock();
return;
}
}
match(i);
}
}
}
void DirectSearch::match(const QFileInfo &info)
{
if(info.fileName().contains(m_keyword, Qt::CaseInsensitive)) {
if((info.isDir() && m_value == DIR_SEARCH_VALUE)) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) {
SearchManager::m_mutexDir.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) {
m_searchResult->enqueue(ri);
SearchManager::m_mutexDir.unlock();
} else {
SearchManager::m_mutexDir.unlock();
return;
}
}
} else if (info.isFile() && m_value == FILE_SEARCH_VALUE) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) {
SearchManager::m_mutexFile.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) {
m_searchResult->enqueue(ri);
SearchManager::m_mutexFile.unlock();
} else {
SearchManager::m_mutexFile.unlock();
return;
}
}
}

View File

@ -161,6 +161,7 @@ public:
protected:
void run();
private:
void match(const QFileInfo& info);
QString m_keyword;
DataQueue<SearchPluginIface::ResultInfo>* m_searchResult = nullptr;
size_t m_uniqueSymbol;