diff --git a/globalsettings.cpp b/globalsettings.cpp new file mode 100644 index 0000000..1b0f10a --- /dev/null +++ b/globalsettings.cpp @@ -0,0 +1,6 @@ +#include "globalsettings.h" + +GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent) +{ + +} diff --git a/globalsettings.h b/globalsettings.h new file mode 100644 index 0000000..c10c0c9 --- /dev/null +++ b/globalsettings.h @@ -0,0 +1,16 @@ +#ifndef GLOBALSETTINGS_H +#define GLOBALSETTINGS_H + +#include + +class GlobalSettings : public QObject +{ + Q_OBJECT +public: + explicit GlobalSettings(QObject *parent = nullptr); + +Q_SIGNALS: + +}; + +#endif // GLOBALSETTINGS_H diff --git a/index/blockdirs.cpp b/index/blockdirs.cpp new file mode 100644 index 0000000..49fc5da --- /dev/null +++ b/index/blockdirs.cpp @@ -0,0 +1,6 @@ +#include "blockdirs.h" + +BlockDirs::BlockDirs(QObject *parent) : QObject(parent) +{ + +} diff --git a/index/blockdirs.h b/index/blockdirs.h new file mode 100644 index 0000000..b0a1d20 --- /dev/null +++ b/index/blockdirs.h @@ -0,0 +1,16 @@ +#ifndef BLOCKDIRS_H +#define BLOCKDIRS_H + +#include + +class BlockDirs : public QObject +{ + Q_OBJECT +public: + explicit BlockDirs(QObject *parent = nullptr); + +Q_SIGNALS: + +}; + +#endif // BLOCKDIRS_H diff --git a/index/filetypefilter.cpp b/index/filetypefilter.cpp new file mode 100644 index 0000000..e5e104d --- /dev/null +++ b/index/filetypefilter.cpp @@ -0,0 +1,33 @@ +#include +#include "filetypefilter.h" + +FileTypeFilter::FileTypeFilter(const QString& path) : Traverse_BFS(path) +{ + this->result = new QVector(); + this->Traverse(); +} + +FileTypeFilter::~FileTypeFilter() +{ + delete this->result; + this->result = nullptr; +} + +void FileTypeFilter::DoSomething(const QFileInfo& fileInfo){ +// QMimeDatabase qmd; +// QMimeType qmt; +// qmt = qmd.mimeTypeForFile(fileInfo.fileName()); +// qDebug() << qmt.preferredSuffix(); + for (auto i : this->targetFileTypeVec){ + if (fileInfo.fileName().endsWith(i)){ +// qDebug() << fileInfo.fileName(); + this->result->append(fileInfo.absoluteFilePath()); + } + } + +} + +QVector* FileTypeFilter::getTargetFileAbsolutePath(){ + return this->result; +} + diff --git a/index/filetypefilter.h b/index/filetypefilter.h new file mode 100644 index 0000000..4d28227 --- /dev/null +++ b/index/filetypefilter.h @@ -0,0 +1,32 @@ +#ifndef FILETYPEFILTER_H +#define FILETYPEFILTER_H + +#include +#include +#include +#include +#include "traverse_bfs.h" + +class FileTypeFilter : public QObject, public Traverse_BFS +{ + Q_OBJECT +public: + explicit FileTypeFilter(const QString&); + ~FileTypeFilter(); + virtual void DoSomething(const QFileInfo&) final; + QVector* getTargetFileAbsolutePath(); + +Q_SIGNALS: +private: + const QVector targetFileTypeVec ={ QString(".doc"), + QString(".docx"), + QString(".ppt"), + QString(".pptx"), + QString(".xls"), + QString(".xlsx"), + QString(".txt")}; + QVector* result; + +}; + +#endif // FILETYPEFILTER_H diff --git a/index/index.pri b/index/index.pri index bab7f9c..96b2aba 100644 --- a/index/index.pri +++ b/index/index.pri @@ -2,7 +2,9 @@ INCLUDEPATH += $$PWD HEADERS += \ # $$PWD/chinesecharacterstopinyin.h \ + $$PWD/blockdirs.h \ $$PWD/document.h \ + $$PWD/filetypefilter.h \ $$PWD/index-generator.h \ # $$PWD/inotify-manager.h \ $$PWD/inotify.h \ @@ -14,7 +16,9 @@ HEADERS += \ SOURCES += \ # $$PWD/chinesecharacterstopinyin.cpp \ + $$PWD/blockdirs.cpp \ $$PWD/document.cpp \ + $$PWD/filetypefilter.cpp \ $$PWD/index-generator.cpp \ # $$PWD/inotify-manager.cpp \ $$PWD/inotify.cpp \ diff --git a/index/inotify.cpp b/index/inotify.cpp index 974adb8..f6e7b2d 100644 --- a/index/inotify.cpp +++ b/index/inotify.cpp @@ -85,7 +85,7 @@ bool InotifyManagerRefact::RemoveWatch(const QString &path){ qDebug() << i.value(); /*--------------------------------*/ //在此调用删除索引 -// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(path)); + IndexGenerator::getInstance()->deleteAllIndex(new QStringList(path)); /*--------------------------------*/ currentPath.erase(i++); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 646e189..37f1211 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -36,6 +36,7 @@ #include "index-generator.h" //#include "inotify-manager.h" #include "inotify.h" +#include "filetypefilter.h" #include "file-searcher.h" extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); @@ -49,6 +50,18 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + FileTypeFilter* ftf = new FileTypeFilter("/home"); + ftf->getTargetFileAbsolutePath(); + + /*-------------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); this->setAutoFillBackground(false); diff --git a/ukui-search.pro b/ukui-search.pro index ea03398..190b9ed 100644 --- a/ukui-search.pro +++ b/ukui-search.pro @@ -32,10 +32,12 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin HEADERS += \ file-utils.h \ + globalsettings.h \ gobject-template.h \ SOURCES += \ file-utils.cpp \ + globalsettings.cpp \ gobject-template.cpp \ PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xrandr xtst