2022-06-18 10:46:14 +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>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef FILEUTILS_H
|
|
|
|
#define FILEUTILS_H
|
|
|
|
#include <QString>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QMimeType>
|
|
|
|
#include <QLabel>
|
|
|
|
#include "libsearch_global.h"
|
|
|
|
|
|
|
|
namespace UkuiSearch {
|
|
|
|
class LIBSEARCH_EXPORT FileUtils {
|
|
|
|
public:
|
|
|
|
static QString getHtmlText(const QString &text, const QString &keyword);
|
|
|
|
static QString setAllTextBold(const QString &name);
|
|
|
|
static QString wrapData(QLabel *p_label, const QString &text);
|
2023-07-18 16:18:58 +08:00
|
|
|
static qreal horizontalAdvanceContainsKeyword(const QString &content, const QString &keyword);
|
2022-06-18 10:46:14 +08:00
|
|
|
static std::string makeDocUterm(QString path);
|
|
|
|
static QIcon getFileIcon(const QString &uri, bool checkValid = true);
|
|
|
|
static QIcon getSettingIcon();
|
|
|
|
|
|
|
|
static QString getFileName(const QString &uri);
|
|
|
|
static QString getAppName(const QString &path);
|
|
|
|
static QString getSettingName(const QString &setting);
|
|
|
|
//A is or under B
|
|
|
|
static bool isOrUnder(QString pathA, QString pathB);
|
|
|
|
static QStringList findMultiToneWords(const QString &hanzi);
|
|
|
|
|
|
|
|
//parse text,docx.....
|
2022-10-26 18:01:40 +08:00
|
|
|
static QMimeType getMimetype(const QString &path);
|
|
|
|
static void getDocxTextContent(const QString &path, QString &textcontent);
|
|
|
|
static void getPptxTextContent(const QString &path, QString &textcontent);
|
|
|
|
static void getXlsxTextContent(const QString &path, QString &textcontent);
|
|
|
|
static void getPdfTextContent(const QString &path, QString &textcontent);
|
|
|
|
static void getTxtContent(const QString &path, QString &textcontent);
|
|
|
|
static void getUOFTextContent(const QString &path, QString &textContent);
|
|
|
|
static void getUOF2TextContent(const QString &path, QString &textContent);
|
|
|
|
static void getUOF2PPTContent(const QString &path, QString &textContent);
|
|
|
|
static void getOFDTextContent(const QString &path, QString &textContent);
|
2022-06-18 10:46:14 +08:00
|
|
|
|
|
|
|
static int openFile(QString &path, bool openInDir = false);
|
|
|
|
static bool copyPath(QString &path);
|
|
|
|
static QString escapeHtml(const QString &str);
|
2023-07-27 13:59:21 +08:00
|
|
|
static QString getSnippet(const std::string &myStr, uint start, const QString &keyword);
|
2023-10-27 15:06:55 +08:00
|
|
|
static QString getSnippetWithoutKeyword(const QString &content, int lineCount);
|
2022-10-26 18:01:40 +08:00
|
|
|
static bool isOpenXMLFileEncrypted(const QString &path);
|
|
|
|
/**
|
|
|
|
* @brief isEncrypedOrUnsupport
|
|
|
|
* @param path
|
|
|
|
* @param suffix
|
|
|
|
* @return true if file(path) is not a support format for content index.
|
|
|
|
*/
|
|
|
|
static bool isEncrypedOrUnsupport(const QString &path, const QString &suffix);
|
2022-06-18 10:46:14 +08:00
|
|
|
static bool isOcrSupportSize(QString path);
|
2022-10-21 11:21:35 +08:00
|
|
|
|
2022-06-18 10:46:14 +08:00
|
|
|
private:
|
|
|
|
FileUtils();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FILEUTILS_H
|