change message list data struct

This commit is contained in:
zhangzihao 2020-12-25 20:08:26 +08:00
parent f06e9e3614
commit 0a48b42a84
5 changed files with 26 additions and 8 deletions

View File

@ -103,7 +103,7 @@ void IndexGenerator::HandlePathList(QStringList *pathlist)
auto info = new QFileInfo(list->at(i)); auto info = new QFileInfo(list->at(i));
//提取文件名并用空格分割,同时去除'.' //提取文件名并用空格分割,同时去除'.'
QString filename = info->fileName(); QString filename = info->fileName();
QString index_test = filename.replace(".","").replace(""," "); QString index_test = filename.replace(".","").replace("+", "%2B").replace(""," ");
QString pinyin_test = chineseCharactersToPinyin::find(filename.replace(".", "")).replace("", " "); QString pinyin_test = chineseCharactersToPinyin::find(filename.replace(".", "")).replace("", " ");

View File

@ -4,12 +4,16 @@ HEADERS += \
$$PWD/chinesecharacterstopinyin.h \ $$PWD/chinesecharacterstopinyin.h \
$$PWD/index-generator.h \ $$PWD/index-generator.h \
$$PWD/inotify-manager.h \ \ $$PWD/inotify-manager.h \ \
$$PWD/messagelist-manager.h $$PWD/inotify.h \
$$PWD/messagelist-manager.h \
$$PWD/traverse_bfs.h
SOURCES += \ SOURCES += \
$$PWD/chinesecharacterstopinyin.cpp \ $$PWD/chinesecharacterstopinyin.cpp \
$$PWD/index-generator.cpp \ $$PWD/index-generator.cpp \
$$PWD/inotify-manager.cpp \ $$PWD/inotify-manager.cpp \
$$PWD/inotify.cpp \
$$PWD/messagelist-manager.cpp \ $$PWD/messagelist-manager.cpp \
$$PWD/test-Inotify-Manager.cpp $$PWD/test-Inotify-Manager.cpp \
$$PWD/traverse_bfs.cpp

View File

@ -27,8 +27,8 @@ MessageListManager::~MessageListManager(){
this->indexGeneratorThread = nullptr; this->indexGeneratorThread = nullptr;
} }
void MessageListManager::AddMessage(const QString& path){ void MessageListManager::AddMessage(const QVector<QString>& pathVec){
this->messageList->append(path); this->messageList->append(pathVec);
if (static_cast<size_t>(this->messageList->length()) >= this->length){ if (static_cast<size_t>(this->messageList->length()) >= this->length){
this->SendMessage(); this->SendMessage();
} }

View File

@ -11,13 +11,15 @@ public:
explicit MessageListManager(); explicit MessageListManager();
~MessageListManager(); ~MessageListManager();
void AddMessage(const QString&); void AddMessage(const QVector<QString>&);
bool SendMessage(); bool SendMessage();
bool SendDeleteMessage(); bool SendDeleteMessage();
void SetAutoSendMessageLength(const size_t&); void SetAutoSendMessageLength(const size_t&);
private: private:
QStringList* messageList; // QStringList* messageList;
QList<QVector<QString>>* messageList;
size_t length = 0; size_t length = 0;
IndexGenerator* ig; IndexGenerator* ig;
QThread* indexGeneratorThread; QThread* indexGeneratorThread;

View File

@ -3,6 +3,7 @@
#include "src/mainwindow.h" #include "src/mainwindow.h"
#include "inotify-manager.h" #include "inotify-manager.h"
#include "chinesecharacterstopinyin.h" #include "chinesecharacterstopinyin.h"
#include "inotify.h"
void testTraverse(void){ void testTraverse(void){
/*-------------Inotify Test Start---------------*/ /*-------------Inotify Test Start---------------*/
@ -18,13 +19,24 @@ void testTraverse(void){
/*-------------PinyinSearch Test Start---------------*/ /*-------------PinyinSearch Test Start---------------*/
QTime t1 = QTime::currentTime(); QTime t1 = QTime::currentTime();
QString test("gongzuo"); QString test("test");
qDebug() << IndexGenerator::IndexSearch(test); qDebug() << IndexGenerator::IndexSearch(test);
QTime t2 = QTime::currentTime(); QTime t2 = QTime::currentTime();
qDebug() << t1; qDebug() << t1;
qDebug() << t2; qDebug() << t2;
/*-------------PinyinSearch Test End-----------------*/ /*-------------PinyinSearch Test End-----------------*/
/*-------------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-----------------*/
exit(0); exit(0);