Merge pull request #23 from MouseZhangZh/zzh-search

add file type filter and some classes(n…
This commit is contained in:
iaom 2020-12-28 21:23:55 +08:00 committed by GitHub
commit 84611d8043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 129 additions and 1 deletions

6
globalsettings.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "globalsettings.h"
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
{
}

16
globalsettings.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef GLOBALSETTINGS_H
#define GLOBALSETTINGS_H
#include <QObject>
class GlobalSettings : public QObject
{
Q_OBJECT
public:
explicit GlobalSettings(QObject *parent = nullptr);
Q_SIGNALS:
};
#endif // GLOBALSETTINGS_H

6
index/blockdirs.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "blockdirs.h"
BlockDirs::BlockDirs(QObject *parent) : QObject(parent)
{
}

16
index/blockdirs.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef BLOCKDIRS_H
#define BLOCKDIRS_H
#include <QObject>
class BlockDirs : public QObject
{
Q_OBJECT
public:
explicit BlockDirs(QObject *parent = nullptr);
Q_SIGNALS:
};
#endif // BLOCKDIRS_H

33
index/filetypefilter.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <QDebug>
#include "filetypefilter.h"
FileTypeFilter::FileTypeFilter(const QString& path) : Traverse_BFS(path)
{
this->result = new QVector<QString>();
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<QString>* FileTypeFilter::getTargetFileAbsolutePath(){
return this->result;
}

32
index/filetypefilter.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef FILETYPEFILTER_H
#define FILETYPEFILTER_H
#include <QObject>
#include <QMimeDatabase>
#include <QMimeType>
#include <QVector>
#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<QString>* getTargetFileAbsolutePath();
Q_SIGNALS:
private:
const QVector<QString> targetFileTypeVec ={ QString(".doc"),
QString(".docx"),
QString(".ppt"),
QString(".pptx"),
QString(".xls"),
QString(".xlsx"),
QString(".txt")};
QVector<QString>* result;
};
#endif // FILETYPEFILTER_H

View File

@ -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 \

View File

@ -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++);
}

View File

@ -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);

View File

@ -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