[FIX] 🐛🐛🐛 Rest message won't be sent for index generation.

This commit is contained in:
zhangzihao 2020-12-26 10:44:37 +08:00
parent 8cc3bf4448
commit f9963f178e
5 changed files with 30 additions and 22 deletions

View File

@ -8,12 +8,12 @@ Document::Document()
Document::~Document() Document::~Document()
{ {
if(m_document) // if(m_document)
delete m_document; // delete m_document;
if(m_index_text) // if(m_index_text)
delete m_index_text; // delete m_index_text;
if(m_unique_term) // if(m_unique_term)
delete m_unique_term; // delete m_unique_term;
} }
void Document::setData(QString data) 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_Q_OVERFLOW, "IN_Q_OVERFLOW");
num2string.insert(IN_IGNORED, "IN_IGNORED"); num2string.insert(IN_IGNORED, "IN_IGNORED");
this->mlm = new MessageListManager(); this->mlm = new MessageListManager();
this->AddWatch("/home");
this->Traverse();
this->SendRestMessage();
return; return;
} }
@ -42,7 +47,12 @@ void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){
} }
// else{ // else{
// this->mlm->AddMessage(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(bool((fileInfo.isDir())))); // this->mlm->AddMessage(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(bool((fileInfo.isDir()))));
// } // }
}
void InotifyManagerRefact::SendRestMessage()
{
this->mlm->SendMessage();
} }
bool InotifyManagerRefact::AddWatch(const QString &path){ bool InotifyManagerRefact::AddWatch(const QString &path){
@ -142,9 +152,9 @@ void InotifyManagerRefact::run(){
} }
// else { // else {
//这里调用删除索引 //这里调用删除索引
this->mlm->AddMessage(QVector<QString>() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR)))); // this->mlm->AddMessage(QVector<QString>() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR))));
this->mlm->SendDeleteMessage(); // this->mlm->SendDeleteMessage();
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name)); IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
// } // }
} }
/*--------------------------------*/ /*--------------------------------*/

View File

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

View File

@ -45,16 +45,6 @@ void centerToScreen(QWidget* widget) {
int main(int argc, char *argv[]) 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>"); qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 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) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(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->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAttribute(Qt::WA_TranslucentBackground, true);