forked from openkylin/ukui-search
✨✨✨add file type filter and some classes(not completed)
This commit is contained in:
parent
b4d3ee033d
commit
c0ac3492c8
|
@ -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 += \
|
||||
# $$PWD/chinesecharacterstopinyin.h \
|
||||
$$PWD/blockdirs.h \
|
||||
$$PWD/document.h \
|
||||
$$PWD/filetypefilter.h \
|
||||
$$PWD/index-generator.h \
|
||||
# $$PWD/inotify-manager.h \
|
||||
$$PWD/inotify.h \
|
||||
|
@ -13,7 +15,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 \
|
||||
|
|
|
@ -83,7 +83,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++);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "index-generator.h"
|
||||
//#include "inotify-manager.h"
|
||||
#include "inotify.h"
|
||||
#include "filetypefilter.h"
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
/**
|
||||
|
@ -46,15 +47,16 @@ 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;
|
||||
// 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);
|
||||
|
|
|
@ -31,10 +31,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
|
||||
|
|
Loading…
Reference in New Issue