diff --git a/index/document.cpp b/index/document.cpp index 1b3c804..f6ea7aa 100644 --- a/index/document.cpp +++ b/index/document.cpp @@ -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) diff --git a/index/inotify.cpp b/index/inotify.cpp index 4b158bc..e975bd9 100644 --- a/index/inotify.cpp +++ b/index/inotify.cpp @@ -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; } @@ -42,7 +47,12 @@ void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){ } // else{ // this->mlm->AddMessage(QVector() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(bool((fileInfo.isDir())))); -// } + // } +} + +void InotifyManagerRefact::SendRestMessage() +{ + this->mlm->SendMessage(); } bool InotifyManagerRefact::AddWatch(const QString &path){ @@ -142,9 +152,9 @@ void InotifyManagerRefact::run(){ } // else { //这里调用删除索引 - this->mlm->AddMessage(QVector() << 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() << 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)); // } } /*--------------------------------*/ diff --git a/index/inotify.h b/index/inotify.h index 398ffdb..427be65 100644 --- a/index/inotify.h +++ b/index/inotify.h @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 781c073..413ac3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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"); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7237700..1c62eef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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);