解决文件搜索插件判断索引状态有误的问题和文件图标获取失败的问题
This commit is contained in:
parent
4a98056c06
commit
308b9b642f
|
@ -41,7 +41,7 @@ FileIndexerConfig *FileIndexerConfig::getInstance()
|
||||||
return global_intance;
|
return global_intance;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileIndexerConfig::FileIndexerConfig(QObject *parent) \
|
FileIndexerConfig::FileIndexerConfig(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_dirWatcher(DirWatcher::getDirWatcher())
|
m_dirWatcher(DirWatcher::getDirWatcher())
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,7 +147,7 @@ bool FileContentSearchWorker::execSearch()
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FilePath, path);
|
resultItem.setValue(SearchProperty::SearchResultProperty::FilePath, path);
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(path).name());
|
resultItem.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()).name());
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FileName, path.section("/", -1));
|
resultItem.setValue(SearchProperty::SearchResultProperty::FileName, path.section("/", -1));
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
#include <QUrl>
|
||||||
#include "index-status-recorder.h"
|
#include "index-status-recorder.h"
|
||||||
#include "dir-watcher.h"
|
#include "dir-watcher.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -92,21 +93,29 @@ void FileSearchWorker::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finished = true;
|
bool finished = true;
|
||||||
bool indexed = !DirWatcher::getDirWatcher()->currentIndexableDir().isEmpty();
|
bool indexed = true;
|
||||||
qDebug() << DirWatcher::getDirWatcher()->currentIndexableDir();
|
|
||||||
for(const QString &dir : DirWatcher::getDirWatcher()->currentIndexableDir()) {
|
QStringList indexedDir = DirWatcher::getDirWatcher()->currentIndexableDir();
|
||||||
|
if(!indexedDir.isEmpty() && IndexStatusRecorder::getInstance()->indexDatabaseEnable()) {
|
||||||
for(const QString &path : m_searchController->getSearchDir()) {
|
for(const QString &path : m_searchController->getSearchDir()) {
|
||||||
if(!FileUtils::isOrUnder(path, dir)) {
|
bool pathIndexed = false;
|
||||||
|
for(const QString &dir : indexedDir) {
|
||||||
|
if(FileUtils::isOrUnder(path, dir)) {
|
||||||
|
pathIndexed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!pathIndexed) {
|
||||||
indexed = false;
|
indexed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!indexed) {
|
} else {
|
||||||
break;
|
indexed = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 还需要判断是否为不能建立索引的目录
|
//TODO 还需要判断是否为不能建立索引的目录
|
||||||
if (IndexStatusRecorder::getInstance()->indexDatabaseEnable() && indexed) {
|
if (indexed) {
|
||||||
qDebug() << "index ready";
|
qDebug() << "index ready";
|
||||||
finished = searchWithIndex();
|
finished = searchWithIndex();
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,7 +185,7 @@ bool FileSearchWorker::searchWithIndex()
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FilePath, path);
|
resultItem.setValue(SearchProperty::SearchResultProperty::FilePath, path);
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(path).name());
|
resultItem.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()).name());
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
||||||
resultItem.setValue(SearchProperty::SearchResultProperty::FileName, path.section("/", -1));
|
resultItem.setValue(SearchProperty::SearchResultProperty::FileName, path.section("/", -1));
|
||||||
|
@ -278,7 +287,7 @@ bool FileSearchWorker::directSearch()
|
||||||
ri.setValue(SearchProperty::SearchResultProperty::FilePath, fileInfo.absoluteFilePath());
|
ri.setValue(SearchProperty::SearchResultProperty::FilePath, fileInfo.absoluteFilePath());
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileIconName)) {
|
||||||
ri.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(fileInfo.absoluteFilePath()).name());
|
ri.setValue(SearchProperty::SearchResultProperty::FileIconName, FileUtils::getFileIcon(QUrl::fromLocalFile(fileInfo.absoluteFilePath()).toString()).name());
|
||||||
}
|
}
|
||||||
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
if(properties.contains(SearchProperty::SearchResultProperty::FileName)) {
|
||||||
ri.setValue(SearchProperty::SearchResultProperty::FileName, fileInfo.fileName());
|
ri.setValue(SearchProperty::SearchResultProperty::FileName, fileInfo.fileName());
|
||||||
|
|
Loading…
Reference in New Issue