ukui-search/libsearch/searchinterface/ukui-search-task.h

207 lines
5.9 KiB
C
Raw Normal View History

2023-04-11 10:19:35 +08:00
/*
*
* Copyright (C) 2023, 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: iaom <zhangpengfei@kylinos.cn>
*/
2021-12-28 15:56:41 +08:00
#ifndef UKUISEARCH_H
#define UKUISEARCH_H
#include "result-item.h"
#include "data-queue.h"
#include "search-result-property.h"
2021-12-28 15:56:41 +08:00
namespace UkuiSearch {
class UkuiSearchTaskPrivate;
class UkuiSearchTask : public QObject
{
Q_OBJECT
public:
explicit UkuiSearchTask(QObject *parent = nullptr);
~UkuiSearchTask();
2024-08-19 10:57:18 +08:00
/**
* @brief init
* ,
* @return ,
*/
2021-12-28 15:56:41 +08:00
DataQueue<ResultItem>* init();
2024-08-19 10:57:18 +08:00
/**
* @brief addSearchDir
* ()
* @param path
*/
void addSearchDir(const QString &path);
2024-08-19 10:57:18 +08:00
/**
* @brief setRecurse
* (),
* @param recurse
*/
2021-12-28 15:56:41 +08:00
void setRecurse(bool recurse = true);
2024-08-19 10:57:18 +08:00
/**
* @brief addKeyword
*
* @param keyword
*/
void addKeyword(const QString &keyword);
/**
* @brief setMatchAllIfNoKeyword
2024-08-19 10:57:18 +08:00
*
* @param matchAll
*/
void setMatchAllIfNoKeyword(bool matchAll);
2024-08-19 10:57:18 +08:00
/**
* @brief addFileLabel
* peony文件标签作为搜索条件
* @param label
*/
void addFileLabel(const QString &label);
2024-08-19 10:57:18 +08:00
/**
* @brief setOnlySearchFile
* ()
* @param onlySearchFile
*/
2022-01-11 16:20:40 +08:00
void setOnlySearchFile(bool onlySearchFile);
2024-08-19 10:57:18 +08:00
/**
* @brief setOnlySearchDir
* ()
* @param onlySearchDir
*/
2022-01-11 16:20:40 +08:00
void setOnlySearchDir(bool onlySearchDir);
2024-08-19 10:57:18 +08:00
/**
* @brief setSearchOnlineApps
*
* @param searchOnlineApps
*/
2021-12-28 15:56:41 +08:00
void setSearchOnlineApps(bool searchOnlineApps);
/**
* @brief setSearchHiddenFiles
2024-08-19 10:57:18 +08:00
* ,
* @param searchHiddenFiles
*/
void setSearchHiddenFiles(bool searchHiddenFiles);
/**
2024-08-19 10:57:18 +08:00
* @brief initSearchPlugin
*
* @param searchType
* @param customSearchType searchType为Custom时,
*/
void initSearchPlugin(SearchProperty::SearchType searchType, const QString& customSearchType = QString());
/**
* @brief setResultDataType
2024-08-19 10:57:18 +08:00
* searchType的搜索结果数据类型
* @param searchType
* @param searchResultProperties
*/
bool setResultProperties(SearchProperty::SearchType searchType, SearchResultProperties searchResultProperties);
2024-08-19 10:57:18 +08:00
/**
* @brief setCustomResultDataType
* initSearchPlugin中设置的SearchType为custom时,
* @param customSearchType
* @param dataType
*/
void setCustomResultDataType(QString customSearchType, QStringList dataType);
2024-08-19 10:57:18 +08:00
/**
* @brief clearAllConditions
*
*/
void clearAllConditions();
2024-08-19 10:57:18 +08:00
/**
* @brief clearKeyWords
*
*/
void clearKeyWords();
2024-08-19 10:57:18 +08:00
/**
* @brief clearSearchDir
*
*/
void clearSearchDir();
2024-08-19 10:57:18 +08:00
/**
* @brief clearFileLabel
*
*/
void clearFileLabel();
/**
2024-08-19 10:57:18 +08:00
* @brief setMaxResultNum
*
* @param maxResults
*/
void setMaxResultNum(unsigned int maxResults = 99999999);
/**
2024-08-19 10:57:18 +08:00
* @brief setInformNum
* ,@param num时,reachInformNum信号然后重新开始计数
* @param num
*/
void setInformNum(int num);
/**
2024-08-19 10:57:18 +08:00
* @brief startSearch
*
* @param searchtype
* @param customSearchType searchType为Custom时可用
2024-08-19 10:57:18 +08:00
* @return id
*/
size_t startSearch(SearchProperty::SearchType searchtype, QString customSearchType = QString());
/**
* @brief stop
*/
2021-12-28 15:56:41 +08:00
void stop();
/**
* @brief isSearching
2024-08-19 10:57:18 +08:00
* @return true表示正在搜索,false表示未在搜索
*/
bool isSearching(SearchProperty::SearchType searchtype, QString customSearchType = {});
2021-12-28 15:56:41 +08:00
Q_SIGNALS:
2024-08-19 10:57:18 +08:00
/**
* @brief searchFinished
*
* @param searchId id
*/
2021-12-28 15:56:41 +08:00
void searchFinished(size_t searchId);
2024-08-19 10:57:18 +08:00
/**
* @brief searchError
*
* @param searchId id
* @param msg
*/
void searchError(size_t searchId, QString msg);
2024-08-19 10:57:18 +08:00
/**
* @brief reachInformNum
* setInformNum使用,
*/
void reachInformNum();
2021-12-28 15:56:41 +08:00
private:
UkuiSearchTaskPrivate* d = nullptr;
};
}
#endif // UKUISEARCH_H