Merge pull request #23 from MouseZhangZh/zzh-search
✨✨✨add file type filter and some classes(n…
This commit is contained in:
commit
84611d8043
|
@ -0,0 +1,6 @@
|
||||||
|
#include "globalsettings.h"
|
||||||
|
|
||||||
|
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "blockdirs.h"
|
||||||
|
|
||||||
|
BlockDirs::BlockDirs(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
|
@ -2,7 +2,9 @@ INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
# $$PWD/chinesecharacterstopinyin.h \
|
# $$PWD/chinesecharacterstopinyin.h \
|
||||||
|
$$PWD/blockdirs.h \
|
||||||
$$PWD/document.h \
|
$$PWD/document.h \
|
||||||
|
$$PWD/filetypefilter.h \
|
||||||
$$PWD/index-generator.h \
|
$$PWD/index-generator.h \
|
||||||
# $$PWD/inotify-manager.h \
|
# $$PWD/inotify-manager.h \
|
||||||
$$PWD/inotify.h \
|
$$PWD/inotify.h \
|
||||||
|
@ -14,7 +16,9 @@ HEADERS += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
# $$PWD/chinesecharacterstopinyin.cpp \
|
# $$PWD/chinesecharacterstopinyin.cpp \
|
||||||
|
$$PWD/blockdirs.cpp \
|
||||||
$$PWD/document.cpp \
|
$$PWD/document.cpp \
|
||||||
|
$$PWD/filetypefilter.cpp \
|
||||||
$$PWD/index-generator.cpp \
|
$$PWD/index-generator.cpp \
|
||||||
# $$PWD/inotify-manager.cpp \
|
# $$PWD/inotify-manager.cpp \
|
||||||
$$PWD/inotify.cpp \
|
$$PWD/inotify.cpp \
|
||||||
|
|
|
@ -85,7 +85,7 @@ bool InotifyManagerRefact::RemoveWatch(const QString &path){
|
||||||
qDebug() << i.value();
|
qDebug() << i.value();
|
||||||
/*--------------------------------*/
|
/*--------------------------------*/
|
||||||
//在此调用删除索引
|
//在此调用删除索引
|
||||||
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(path));
|
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(path));
|
||||||
/*--------------------------------*/
|
/*--------------------------------*/
|
||||||
currentPath.erase(i++);
|
currentPath.erase(i++);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "index-generator.h"
|
#include "index-generator.h"
|
||||||
//#include "inotify-manager.h"
|
//#include "inotify-manager.h"
|
||||||
#include "inotify.h"
|
#include "inotify.h"
|
||||||
|
#include "filetypefilter.h"
|
||||||
#include "file-searcher.h"
|
#include "file-searcher.h"
|
||||||
|
|
||||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
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) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(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->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
this->setAutoFillBackground(false);
|
this->setAutoFillBackground(false);
|
||||||
|
|
|
@ -32,10 +32,12 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
file-utils.h \
|
file-utils.h \
|
||||||
|
globalsettings.h \
|
||||||
gobject-template.h \
|
gobject-template.h \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
file-utils.cpp \
|
file-utils.cpp \
|
||||||
|
globalsettings.cpp \
|
||||||
gobject-template.cpp \
|
gobject-template.cpp \
|
||||||
|
|
||||||
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xrandr xtst
|
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xrandr xtst
|
||||||
|
|
Loading…
Reference in New Issue