Modified file search interface and index interface.

This commit is contained in:
zhangpengfei 2021-01-10 15:59:17 +08:00
parent 63f945ee17
commit 929063645b
8 changed files with 204 additions and 118 deletions

View File

@ -1,65 +1,97 @@
#include <QFileInfo> #include <QFileInfo>
#include <QDebug> #include <QDebug>
#include <QtConcurrent> #include <QtConcurrent>
#include <QThread>
#include <chinese-segmentation.h> #include <chinese-segmentation.h>
#include "file-searcher.h" #include "file-searcher.h"
#include "global-settings.h" #include "global-settings.h"
size_t FileSearcher::uniqueSymbol1 = 0;
size_t FileSearcher::uniqueSymbol2 = 0;
size_t FileSearcher::uniqueSymbol3 = 0;
QMutex FileSearcher::m_mutex1;
QMutex FileSearcher::m_mutex2;
QMutex FileSearcher::m_mutex3;
FileSearcher::FileSearcher(QObject *parent) : QObject(parent) FileSearcher::FileSearcher(QObject *parent) : QObject(parent)
{ {
} }
void FileSearcher::onKeywordSearch(QString keyword) FileSearcher::~FileSearcher()
{ {
m_search_result_file = new QQueue<QString>;
m_search_result_dir = new QQueue<QString>;
m_search_result_content = new QQueue<QPair<QString,QStringList>>;
//file
QtConcurrent::run([=](){
int begin = 0;
int num = 20;
int resultCount = 0;
while(1)
{
resultCount = keywordSearchfile(keyword,"1",1,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
begin += num;
}
});
Q_EMIT this->resultFile(m_search_result_file);
//dir
QtConcurrent::run([=](){
int begin = 0;
int num = 20;
int resultCount = 0;
while(1)
{
resultCount = keywordSearchfile(keyword,"0",1,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
begin += num;
}
});
Q_EMIT this->resultDir(m_search_result_dir);
//content
QtConcurrent::run([=](){
int begin = 0;
int num = 10;
int resultCount = 0;
while(1)
{
keywordSearchContent(keyword,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
begin += num;
}
});
Q_EMIT this->resultContent(m_search_result_content);
} }
int FileSearcher::keywordSearchfile(QString keyword, QString value, unsigned slot, int begin, int num) void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent)
{
m_search_result_file = searchResultFile;
m_search_result_dir = searchResultDir;
m_search_result_content = searchResultContent;
m_mutex1.lock();
++uniqueSymbol1;
m_mutex1.unlock();
m_mutex2.lock();
++uniqueSymbol2;
m_mutex2.unlock();
m_mutex3.lock();
++uniqueSymbol3;
m_mutex3.unlock();
//file
QtConcurrent::run([&, uniqueSymbol1](){
if(!m_search_result_file->isEmpty())
m_search_result_file->clear();
int begin = 0;
int num = 5;
int resultCount = 0;
int total = 0;
while(total<20)
{
resultCount = keywordSearchfile(uniqueSymbol1,keyword,"0",1,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
total += resultCount;
begin += num;
}
});
// Q_EMIT this->resultFile(m_search_result_file);
//dir
QtConcurrent::run([&, uniqueSymbol2](){
if(!m_search_result_dir->isEmpty())
m_search_result_dir->clear();
int begin = 0;
int num = 5;
int resultCount = 0;
int total = 0;
while(total<20)
{
resultCount = keywordSearchfile(uniqueSymbol2,keyword,"1",1,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
total += resultCount;
begin += num;
}
});
// Q_EMIT this->resultDir(m_search_result_dir);
//content
QtConcurrent::run([&, uniqueSymbol3](){
if(!m_search_result_content->isEmpty())
m_search_result_content->clear();
int begin = 0;
int num = 5;
int resultCount = 0;
int total = 0;
while(total<20)
{
keywordSearchContent(uniqueSymbol3,keyword,begin,num);
if(resultCount == 0 || resultCount == -1)
break;
total += resultCount;
begin += num;
}
});
// Q_EMIT this->resultContent(m_search_result_content);
}
int FileSearcher::keywordSearchfile(size_t uniqueSymbol, QString keyword, QString value, unsigned slot, int begin, int num)
{ {
try try
{ {
@ -86,7 +118,7 @@ int FileSearcher::keywordSearchfile(QString keyword, QString value, unsigned slo
Xapian::MSet result = enquire.get_mset(begin, begin+num); Xapian::MSet result = enquire.get_mset(begin, begin+num);
int resultCount = static_cast<int>(result.get_matches_estimated()); int resultCount = static_cast<int>(result.get_matches_estimated());
qDebug()<< "find results count=" <<resultCount; qDebug()<< "find results count=" <<resultCount;
getResult(result,value); getResult(uniqueSymbol, result, value);
qDebug()<< "--search finish--"; qDebug()<< "--search finish--";
return resultCount; return resultCount;
@ -99,7 +131,7 @@ int FileSearcher::keywordSearchfile(QString keyword, QString value, unsigned slo
} }
} }
int FileSearcher::keywordSearchContent(QString keyword, int begin, int num) int FileSearcher::keywordSearchContent(size_t uniqueSymbol, QString keyword, int begin, int num)
{ {
try try
{ {
@ -135,7 +167,7 @@ int FileSearcher::keywordSearchContent(QString keyword, int begin, int num)
int resultCount = static_cast<int>(result.get_matches_estimated()); int resultCount = static_cast<int>(result.get_matches_estimated());
qDebug()<< "find results count=" <<resultCount; qDebug()<< "find results count=" <<resultCount;
getContentResult(result,words); getContentResult(uniqueSymbol, result, words);
qDebug()<< "--content search finish--"; qDebug()<< "--content search finish--";
return resultCount; return resultCount;
@ -177,7 +209,7 @@ Xapian::Query FileSearcher::creatQueryForContentSearch(QString keyword, Xapian::
} }
QStringList FileSearcher::getResult(Xapian::MSet &result, QString value) QStringList FileSearcher::getResult(size_t uniqueSymbol, Xapian::MSet &result, QString value)
{ {
//QStringList *pathTobeDelete = new QStringList; //QStringList *pathTobeDelete = new QStringList;
//Delete those path doc which is not already exist. //Delete those path doc which is not already exist.
@ -197,9 +229,9 @@ QStringList FileSearcher::getResult(Xapian::MSet &result, QString value)
if(isBlocked(path)) if(isBlocked(path))
continue; continue;
QFileInfo *info = new QFileInfo(path); QFileInfo info(path);
if(!info->exists()) if(!info.exists())
{ {
// pathTobeDelete->append(QString::fromStdString(data)); // pathTobeDelete->append(QString::fromStdString(data));
qDebug()<<path<<"is not exist!!"; qDebug()<<path<<"is not exist!!";
@ -209,10 +241,31 @@ QStringList FileSearcher::getResult(Xapian::MSet &result, QString value)
switch (value.toInt()) switch (value.toInt())
{ {
case 1: case 1:
m_search_result_dir->enqueue(path); m_mutex1.lock();
if(uniqueSymbol == FileSearcher::uniqueSymbol1)
{
m_search_result_dir->enqueue(path);
m_mutex1.unlock();
}
else
{
m_mutex1.unlock();
exit(0);
}
break; break;
case 0: case 0:
m_search_result_file->enqueue(path); m_mutex2.lock();
if(uniqueSymbol == FileSearcher::uniqueSymbol2)
{
m_search_result_file->enqueue(path);
m_mutex2.unlock();
}
else
{
m_mutex2.unlock();
exit(0);
}
break; break;
default: default:
break; break;
@ -226,7 +279,7 @@ QStringList FileSearcher::getResult(Xapian::MSet &result, QString value)
return searchResult; return searchResult;
} }
QMap<QString,QStringList> FileSearcher::getContentResult(Xapian::MSet &result, std::string &keyWord) QMap<QString,QStringList> FileSearcher::getContentResult(size_t uniqueSymbol, Xapian::MSet &result, std::string &keyWord)
{ {
//QStringList *pathTobeDelete = new QStringList; //QStringList *pathTobeDelete = new QStringList;
//Delete those path doc which is not already exist. //Delete those path doc which is not already exist.
@ -251,9 +304,9 @@ QMap<QString,QStringList> FileSearcher::getContentResult(Xapian::MSet &result, s
if(isBlocked(path)) if(isBlocked(path))
continue; continue;
QFileInfo *info = new QFileInfo(path); QFileInfo info(path);
if(!info->exists()) if(!info.exists())
{ {
// pathTobeDelete->append(QString::fromStdString(data)); // pathTobeDelete->append(QString::fromStdString(data));
qDebug()<<path<<"is not exist!!"; qDebug()<<path<<"is not exist!!";
@ -272,7 +325,17 @@ QMap<QString,QStringList> FileSearcher::getContentResult(Xapian::MSet &result, s
snippets.append(snippet); snippets.append(snippet);
++count; ++count;
} }
m_search_result_content->enqueue(qMakePair(path,snippets)); m_mutex3.lock();
if(uniqueSymbol == FileSearcher::uniqueSymbol3)
{
m_search_result_content->enqueue(qMakePair(path,snippets));
m_mutex3.unlock();
}
else
{
m_mutex3.unlock();
exit(0);
}
searchResult.insert(path,snippets); searchResult.insert(path,snippets);
qDebug()<< "path="<< path << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent; qDebug()<< "path="<< path << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent;
} }

View File

@ -8,6 +8,7 @@
#include <QMap> #include <QMap>
#include <QQueue> #include <QQueue>
#include <QPair> #include <QPair>
#include <QMutex>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString() #define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString() #define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString()
@ -17,17 +18,18 @@ class FileSearcher : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit FileSearcher(QObject *parent = nullptr); explicit FileSearcher(QObject *parent = nullptr);
~FileSearcher();
public Q_SLOTS: public Q_SLOTS:
void onKeywordSearch(QString keyword); void onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent);
Q_SIGNALS: Q_SIGNALS:
void resultFile(QQueue<QString> *); void resultFile(QQueue<QString> *);
void resultDir(QQueue<QString> *); void resultDir(QQueue<QString> *);
void resultContent(QQueue<QPair<QString,QStringList>> *); void resultContent(QQueue<QPair<QString,QStringList>> *);
private: private:
int keywordSearchfile(QString keyword, QString value,unsigned slot = 1,int begin = 0, int num = 20); int keywordSearchfile(size_t uniqueSymbol, QString keyword, QString value,unsigned slot = 1,int begin = 0, int num = 20);
int keywordSearchContent(QString keyword, int begin = 0, int num = 20); int keywordSearchContent(size_t uniqueSymbol, QString keyword, int begin = 0, int num = 20);
/** /**
* @brief FileSearcher::creatQueryForFileSearch * @brief FileSearcher::creatQueryForFileSearch
@ -39,14 +41,21 @@ private:
Xapian::Query creatQueryForFileSearch(QString keyword, Xapian::Database &db); Xapian::Query creatQueryForFileSearch(QString keyword, Xapian::Database &db);
Xapian::Query creatQueryForContentSearch(QString keyword, Xapian::Database &db); Xapian::Query creatQueryForContentSearch(QString keyword, Xapian::Database &db);
QStringList getResult(Xapian::MSet &result, QString value); QStringList getResult(size_t uniqueSymbol, Xapian::MSet &result, QString value);
QMap<QString,QStringList> getContentResult(Xapian::MSet &result,std::string &keyWord); QMap<QString,QStringList> getContentResult(size_t uniqueSymbol, Xapian::MSet &result,std::string &keyWord);
bool isBlocked(QString &path); bool isBlocked(QString &path);
QQueue<QString> *m_search_result_file = nullptr; QQueue<QString> *m_search_result_file = nullptr;
QQueue<QString> *m_search_result_dir = nullptr; QQueue<QString> *m_search_result_dir = nullptr;
QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr; QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr;
bool m_searching = false;
static size_t uniqueSymbol1;
static size_t uniqueSymbol2;
static size_t uniqueSymbol3;
static QMutex m_mutex1;
static QMutex m_mutex2;
static QMutex m_mutex3;
}; };
#endif // FILESEARCHER_H #endif // FILESEARCHER_H

View File

@ -38,7 +38,7 @@ void FileTypeFilter::Test(){
// this->result = new QList<QString>(); // this->result = new QList<QString>();
// this->result->append(QString("/home/zpf/桌面/DOCX 文档(1).docx")); // this->result->append(QString("/home/zpf/桌面/DOCX 文档(1).docx"));
ig->creatAllIndex(this->result); // ig->creatAllIndex(this->result);
} }

View File

@ -17,9 +17,11 @@ using namespace std;
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString() #define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString()
static IndexGenerator *global_instance = nullptr; static IndexGenerator *global_instance = nullptr;
QMutex IndexGenerator::m_mutex;
IndexGenerator *IndexGenerator::getInstance(bool rebuild) IndexGenerator *IndexGenerator::getInstance(bool rebuild)
{ {
QMutexLocker locker(&m_mutex);
if (!global_instance) { if (!global_instance) {
global_instance = new IndexGenerator(rebuild); global_instance = new IndexGenerator(rebuild);
} }
@ -32,7 +34,7 @@ bool IndexGenerator::setIndexdataPath()
} }
//文件名索引 //文件名索引
bool IndexGenerator::creatAllIndex(QList<QVector<QString> > *messageList) bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
{ {
HandlePathList(messageList); HandlePathList(messageList);
try try
@ -69,7 +71,7 @@ bool IndexGenerator::creatAllIndex(QList<QVector<QString> > *messageList)
return true; return true;
} }
//文件内容索引 //文件内容索引
bool IndexGenerator::creatAllIndex(QList<QString> *messageList) bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
{ {
HandlePathList(messageList); HandlePathList(messageList);
try try
@ -152,7 +154,7 @@ void IndexGenerator::insertIntoContentDatabase(Document doc)
return; return;
} }
void IndexGenerator::HandlePathList(QList<QVector<QString>> *messageList) void IndexGenerator::HandlePathList(QQueue<QVector<QString>> *messageList)
{ {
qDebug()<<"Begin HandlePathList!"; qDebug()<<"Begin HandlePathList!";
qDebug()<<messageList->size(); qDebug()<<messageList->size();
@ -169,7 +171,7 @@ void IndexGenerator::HandlePathList(QList<QVector<QString>> *messageList)
return; return;
} }
void IndexGenerator::HandlePathList(QList<QString> *messageList) void IndexGenerator::HandlePathList(QQueue<QString> *messageList)
{ {
qDebug()<<"Begin HandlePathList for content index!"; qDebug()<<"Begin HandlePathList for content index!";
qDebug()<<messageList->size(); qDebug()<<messageList->size();

View File

@ -7,6 +7,8 @@
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QMutex>
#include <QQueue>
#include "document.h" #include "document.h"
#include "file-reader.h" #include "file-reader.h"
@ -24,16 +26,17 @@ Q_SIGNALS:
void transactionFinished(); void transactionFinished();
void searchFinish(); void searchFinish();
public Q_SLOTS: public Q_SLOTS:
bool creatAllIndex(QList<QVector<QString>> *messageList); bool creatAllIndex(QQueue<QVector<QString>> *messageList);
bool creatAllIndex(QList<QString> *messageList); bool creatAllIndex(QQueue<QString> *messageList);
bool deleteAllIndex(QStringList *pathlist); bool deleteAllIndex(QStringList *pathlist);
private: private:
explicit IndexGenerator(bool rebuild = false,QObject *parent = nullptr); explicit IndexGenerator(bool rebuild = false,QObject *parent = nullptr);
static QMutex m_mutex;
//For file name index //For file name index
void HandlePathList(QList<QVector<QString>> *messageList); void HandlePathList(QQueue<QVector<QString> > *messageList);
//For file content index //For file content index
void HandlePathList(QList<QString> *messageList); void HandlePathList(QQueue<QString> *messageList);
static Document GenerateDocument(const QVector<QString> &list); static Document GenerateDocument(const QVector<QString> &list);
static Document GenerateContentDocument(const QString &list); static Document GenerateContentDocument(const QString &list);
//add one data in database //add one data in database

View File

@ -80,8 +80,8 @@ void InotifyIndex::run(){
ssize_t numRead; ssize_t numRead;
QList<QVector<QString>>* indexList = new QList<QVector<QString>>(); QQueue<QVector<QString>>* indexQueue = new QQueue<QVector<QString>>();
QList<QString>* contentIndexList = new QList<QString>(); QQueue<QString>* contentIndexQueue = new QQueue<QString>();
for (;;) { /* Read events forever */ for (;;) { /* Read events forever */
numRead = read(m_fd, buf, BUF_LEN); numRead = read(m_fd, buf, BUF_LEN);
@ -110,14 +110,14 @@ void InotifyIndex::run(){
/*--------------------------------*/ /*--------------------------------*/
// IndexGenerator::getInstance()->creatAllIndex(QQueue<QVector<QString>>(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0"))); // IndexGenerator::getInstance()->creatAllIndex(QQueue<QVector<QString>>(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0")));
indexList->append(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0")); indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(indexList); IndexGenerator::getInstance()->creatAllIndex(indexQueue);
indexList->clear(); indexQueue->clear();
for (auto i : this->targetFileTypeVec){ for (auto i : this->targetFileTypeVec){
if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){ if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
contentIndexList->append(QString(currentPath[event->wd] + '/' + event->name)); contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
IndexGenerator::getInstance()->creatAllIndex(contentIndexList); IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
contentIndexList->clear(); contentIndexQueue->clear();
} }
} }
/*--------------------------------*/ /*--------------------------------*/
@ -134,8 +134,8 @@ void InotifyIndex::run(){
} }
} }
delete indexList; delete indexQueue;
indexList = nullptr; indexQueue = nullptr;
delete contentIndexList; delete contentIndexQueue;
contentIndexList = nullptr; contentIndexQueue = nullptr;
} }

View File

@ -92,12 +92,30 @@ int main(int argc, char *argv[])
{ {
qInstallMessageHandler(messageOutput); qInstallMessageHandler(messageOutput);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
qDebug() << "main start"; QtSingleApplication app("ukui-search", argc, argv);
FirstIndex fi("/home"); app.setQuitOnLastWindowClosed(false);
fi.start();
InotifyIndex ii("/home"); if(app.isRunning())
ii.start(); {
app.sendMessage(QApplication::arguments().length() > 1 ? QApplication::arguments().at(1) : app.applicationFilePath());
qDebug() << QObject::tr("ukui-search is already running!");
return EXIT_SUCCESS;
}/*else {
QCommandLineParser parser;
QCommandLineOption debugOption({"d", "debug"}, QObject::tr("Display debug information"));
QCommandLineOption showsearch({"s", "show"}, QObject::tr("show search widget"));
parser.addOptions({debugOption, showsearch});
parser.process(app);
}*/
// qDebug() << "main start";
// FirstIndex fi("/home");
// fi.start();
// InotifyIndex ii("/home");
// ii.start();
/*-------------ukuisearchdbus Test start-----------------*/ /*-------------ukuisearchdbus Test start-----------------*/
// UkuiSearchQDBus usQDBus; // UkuiSearchQDBus usQDBus;
// usQDBus.setInotifyMaxUserWatches(); // usQDBus.setInotifyMaxUserWatches();
@ -131,27 +149,6 @@ int main(int argc, char *argv[])
// search->onKeywordSearchContent("g,e,x"); // search->onKeywordSearchContent("g,e,x");
/*-------------文本搜索 Test End-----------------*/ /*-------------文本搜索 Test End-----------------*/
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QtSingleApplication app("ukui-search", argc, argv);
app.setQuitOnLastWindowClosed(false);
qDebug() << "main start x2";
if(app.isRunning())
{
app.sendMessage(QApplication::arguments().length() > 1 ? QApplication::arguments().at(1) : app.applicationFilePath());
qDebug() << QObject::tr("ukui-search is already running!");
return EXIT_SUCCESS;
}/*else {
QCommandLineParser parser;
QCommandLineOption debugOption({"d", "debug"}, QObject::tr("Display debug information"));
QCommandLineOption showsearch({"s", "show"}, QObject::tr("show search widget"));
parser.addOptions({debugOption, showsearch});
parser.process(app);
}*/
// 加载国际化文件 // 加载国际化文件
QTranslator translator; QTranslator translator;
try { try {
@ -164,15 +161,15 @@ int main(int argc, char *argv[])
MainWindow *w = new MainWindow; MainWindow *w = new MainWindow;
QStringList arguments = QCoreApplication::arguments(); QStringList arguments = QCoreApplication::arguments();
centerToScreen(w); centerToScreen(w);
w->show();
w->raise();
w->activateWindow();
// w->loadMainWindow();
app.setActivationWindow(w); app.setActivationWindow(w);
// if(arguments.size()>1) // if(arguments.size()>1)
// w->searchContent(arguments.at(1)); // w->searchContent(arguments.at(1));
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),w, SLOT(bootOptionsFilter(const QString&))); QObject::connect(&app, SIGNAL(messageReceived(const QString&)),w, SLOT(bootOptionsFilter(const QString&)));
// qDebug() << "main start";
// FirstIndex* fi = new FirstIndex("/home");
// fi->start();
return app.exec(); return app.exec();
} }

View File

@ -194,6 +194,8 @@ void MainWindow::bootOptionsFilter(QString opt)
if (opt == "-s" || opt == "-show") { if (opt == "-s" || opt == "-show") {
clearSearchResult(); clearSearchResult();
this->show(); this->show();
this->raise();
this->activateWindow();
} }
} }
@ -251,7 +253,17 @@ void MainWindow::searchContent(QString searchcontent){
//文件、文件夹、内容搜索 //文件、文件夹、内容搜索
FileSearcher *search = new FileSearcher(); FileSearcher *search = new FileSearcher();
connect(search, &FileSearcher::resultDir, this, [ = ](QQueue<QString> * dirQueue) { connect(search, &FileSearcher::resultDir, this, [ = ](QQueue<QString> * dirQueue) {
qWarning()<<"dirFile---"; qWarning()<<"resultDir---";
QString firstDir;
while(1)
{
if(!dirQueue->isEmpty()){
firstDir = dirQueue->at(0);
qWarning()<<"firstDir"<<firstDir;
break;
}
}
}); });
connect(search, &FileSearcher::resultFile, this, [ = ](QQueue<QString> * fileQueue) { connect(search, &FileSearcher::resultFile, this, [ = ](QQueue<QString> * fileQueue) {
qWarning()<<"resultFile---"; qWarning()<<"resultFile---";