Merge pull request #13 from MouseZhangZh/zzh-search

[FIX] 🐛🐛🐛 Rest message won't be sent for index generation.
This commit is contained in:
iaom 2020-12-26 11:05:45 +08:00 committed by GitHub
commit 05eb521213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 22 deletions

View File

@ -8,12 +8,12 @@ Document::Document()
Document::~Document()
{
if(m_document)
delete m_document;
if(m_index_text)
delete m_index_text;
if(m_unique_term)
delete m_unique_term;
// if(m_document)
// delete m_document;
// if(m_index_text)
// delete m_index_text;
// if(m_unique_term)
// delete m_unique_term;
}
void Document::setData(QString data)

View File

@ -23,6 +23,11 @@ InotifyManagerRefact::InotifyManagerRefact(const QString& path) : Traverse_BFS(p
num2string.insert(IN_Q_OVERFLOW, "IN_Q_OVERFLOW");
num2string.insert(IN_IGNORED, "IN_IGNORED");
this->mlm = new MessageListManager();
this->AddWatch("/home");
this->Traverse();
this->SendRestMessage();
return;
}
@ -45,6 +50,11 @@ void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){
// }
}
void InotifyManagerRefact::SendRestMessage()
{
this->mlm->SendMessage();
}
bool InotifyManagerRefact::AddWatch(const QString &path){
//m_fd = inotify_init();
// qDebug() << "m_fd: " <<m_fd;
@ -142,9 +152,9 @@ void InotifyManagerRefact::run(){
}
// else {
//这里调用删除索引
this->mlm->AddMessage(QVector<QString>() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR))));
this->mlm->SendDeleteMessage();
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
// this->mlm->AddMessage(QVector<QString>() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR))));
// this->mlm->SendDeleteMessage();
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
// }
}
/*--------------------------------*/

View File

@ -19,6 +19,7 @@ public:
bool AddWatch(const QString&);
bool RemoveWatch(const QString&);
virtual void DoSomething(const QFileInfo &) final;
void SendRestMessage();
Q_SIGNALS:
protected:
void run() override;

View File

@ -45,16 +45,6 @@ void centerToScreen(QWidget* widget) {
int main(int argc, char *argv[])
{
/*-------------InotyifyRefact Test Start---------------*/
QTime t1 = QTime::currentTime();
InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
imr->AddWatch("/home");
imr->setPath("/home");
imr->Traverse();
QTime t2 = QTime::currentTime();
qDebug() << t1;
qDebug() << t2;
/*-------------InotyifyRefact Test End-----------------*/
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

View File

@ -46,8 +46,15 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
//testBackServe
//testTraverse();
/*-------------InotyifyRefact Test Start---------------*/
QTime t1 = QTime::currentTime();
InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
imr->start();
QTime t2 = QTime::currentTime();
qDebug() << t1;
qDebug() << t2;
/*-------------InotyifyRefact Test End-----------------*/
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);