ukui-search/libsearch/file-utils.h

98 lines
3.0 KiB
C
Raw Normal View History

2021-01-29 11:43:07 +08:00
/*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: zhangpengfei <zhangpengfei@kylinos.cn>
* Modified by: zhangzihao <zhangzihao@kylinos.cn>
* Modified by: zhangjiaping <zhangjiaping@kylinos.cn>
*
*/
2020-12-21 18:50:54 +08:00
#ifndef FILEUTILS_H
#define FILEUTILS_H
#include <QString>
#include <QCryptographicHash>
#include <QIcon>
#include <QMap>
2021-03-04 14:10:00 +08:00
#include <QMimeDatabase>
#include <QMimeType>
2021-03-13 14:52:20 +08:00
#include <QDir>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QUrl>
#include <QMap>
#include <QDomDocument>
#include <QQueue>
#include <quazip/quazipfile.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <quazip/quazip.h>
#include <uchardet/uchardet.h>
//#include <poppler-qt5.h>
#include <poppler/qt5/poppler-qt5.h>
2021-04-15 09:19:36 +08:00
2020-12-30 14:42:04 +08:00
#include "libsearch_global.h"
#include "gobject-template.h"
//#define INITIAL_STATE 0
//#define CREATING_INDEX 1
//#define FINISH_CREATING_INDEX 2
2021-04-08 16:11:58 +08:00
#define MAX_CONTENT_LENGTH 20480000
namespace Zeeker {
2021-04-26 15:06:47 +08:00
class LIBSEARCH_EXPORT FileUtils {
2020-12-21 18:50:54 +08:00
public:
2021-04-26 15:06:47 +08:00
static std::string makeDocUterm(QString);
static QIcon getFileIcon(const QString &, bool checkValid = true);
static QIcon getAppIcon(const QString &);
static QIcon getSettingIcon(const QString &, const bool&);
static QString getFileName(const QString &);
static QString getAppName(const QString &);
static QString getSettingName(const QString &);
//chinese character to pinyin
2020-12-29 20:18:36 +08:00
static QMap<QString, QStringList> map_chinese2pinyin;
static QString find(const QString&);
static QStringList findMultiToneWords(const QString&);
static void loadHanziTable(const QString&);
2020-12-29 20:18:36 +08:00
//parse text,docx.....
2021-03-04 14:10:00 +08:00
static QMimeType getMimetype(QString &path);
static void getDocxTextContent(QString &path, QString &textcontent);
2021-04-08 16:11:58 +08:00
static void getPptxTextContent(QString &path, QString &textcontent);
2021-04-13 14:53:55 +08:00
static void getXlsxTextContent(QString &path, QString &textcontent);
2021-04-15 09:19:36 +08:00
static void getPdfTextContent(QString &path, QString &textcontent);
static void getTxtContent(QString &path, QString &textcontent);
2021-01-10 09:23:02 +08:00
static size_t _max_index_count;
static size_t _current_index_count; //this one has been Abandoned,do not use it.
2021-01-13 18:35:48 +08:00
static unsigned short _index_status;
2020-12-29 20:18:36 +08:00
2021-04-26 15:06:47 +08:00
enum class SearchMethod { DIRECTSEARCH = 0, INDEXSEARCH = 1};
2021-04-16 15:35:54 +08:00
static SearchMethod searchMethod;
2020-12-21 18:50:54 +08:00
private:
FileUtils();
};
}
2020-12-21 18:50:54 +08:00
#endif // FILEUTILS_H