2024-01-30 14:35:04 +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 SEARCHCONTROLLER_H
|
|
|
|
|
#define SEARCHCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QStringList>
|
2022-01-11 16:20:40 +08:00
|
|
|
|
#include <memory>
|
2021-12-28 15:56:41 +08:00
|
|
|
|
#include "data-queue.h"
|
2023-03-15 16:39:38 +08:00
|
|
|
|
#include "search-result-property.h"
|
2021-12-28 15:56:41 +08:00
|
|
|
|
//todo: url parser?
|
|
|
|
|
namespace UkuiSearch {
|
|
|
|
|
class UkuiSearchTask;
|
|
|
|
|
class ResultItem;
|
|
|
|
|
class SearchControllerPrivate;
|
2022-01-12 18:01:59 +08:00
|
|
|
|
/*
|
|
|
|
|
*搜索控制,用于传递搜索条件,搜索唯一ID,以及管理队列等。
|
|
|
|
|
*/
|
2021-12-28 15:56:41 +08:00
|
|
|
|
class SearchController
|
|
|
|
|
{
|
|
|
|
|
public:
|
2023-07-06 15:27:23 +08:00
|
|
|
|
SearchController();
|
|
|
|
|
SearchController(const SearchController &other);
|
|
|
|
|
SearchController &operator=(const SearchController &other);
|
|
|
|
|
SearchController &operator=(SearchController &&other) Q_DECL_NOEXCEPT;
|
|
|
|
|
|
2021-12-28 15:56:41 +08:00
|
|
|
|
~SearchController();
|
|
|
|
|
DataQueue<ResultItem>* refreshDataqueue();
|
|
|
|
|
size_t refreshSearchId();
|
|
|
|
|
DataQueue<ResultItem>* initDataQueue();
|
2021-12-31 17:38:02 +08:00
|
|
|
|
void stop();
|
2023-03-07 17:33:08 +08:00
|
|
|
|
void addSearchDir(const QString &path);
|
2021-12-28 15:56:41 +08:00
|
|
|
|
void setRecurse(bool recurse = true);
|
2023-03-07 17:33:08 +08:00
|
|
|
|
void addKeyword(const QString &keyword);
|
2024-04-25 10:59:18 +08:00
|
|
|
|
void setMatchAllIfNoKeyword(bool matchAll);
|
2021-12-28 15:56:41 +08:00
|
|
|
|
void setActiveKeywordSegmentation(bool active);
|
2023-03-07 17:33:08 +08:00
|
|
|
|
void addFileLabel(const QString &label);
|
2022-01-11 16:20:40 +08:00
|
|
|
|
void setOnlySearchFile(bool onlySearchFile);
|
|
|
|
|
void setOnlySearchDir(bool onlySearchDir);
|
2022-06-13 13:38:47 +08:00
|
|
|
|
void setSearchOnlineApps(bool searchOnlineApps);
|
2023-07-06 15:27:23 +08:00
|
|
|
|
void setSearchHiddenFiles(bool searchHiddenFiles);
|
2023-05-19 15:15:28 +08:00
|
|
|
|
void setMaxResultNum(unsigned int maxResults);
|
|
|
|
|
void setInformNum(int num = 0);
|
2021-12-31 17:38:02 +08:00
|
|
|
|
//以上方法插件请不要调用
|
2021-12-28 15:56:41 +08:00
|
|
|
|
|
2021-12-31 17:38:02 +08:00
|
|
|
|
//以下方法插件可以调用
|
2021-12-28 15:56:41 +08:00
|
|
|
|
size_t getCurrentSearchId();
|
|
|
|
|
DataQueue<ResultItem>* getDataQueue();
|
2023-03-15 16:39:38 +08:00
|
|
|
|
SearchResultProperties getResultProperties(SearchProperty::SearchType searchType);
|
2022-06-13 13:38:47 +08:00
|
|
|
|
QStringList getCustomResultDataType(QString customSearchType);
|
2021-12-28 15:56:41 +08:00
|
|
|
|
bool beginSearchIdCheck(size_t searchId);
|
|
|
|
|
void finishSearchIdCheck();
|
2021-12-31 17:38:02 +08:00
|
|
|
|
|
2021-12-28 15:56:41 +08:00
|
|
|
|
QStringList getSearchDir();
|
|
|
|
|
bool isRecurse();
|
|
|
|
|
QStringList getKeyword();
|
2024-04-25 10:59:18 +08:00
|
|
|
|
bool getMatchAllIfNoKeyword();
|
2021-12-28 15:56:41 +08:00
|
|
|
|
bool isKeywordSegmentationActived();
|
|
|
|
|
QStringList getFileLabel();
|
2022-01-11 16:20:40 +08:00
|
|
|
|
bool isSearchFileOnly();
|
|
|
|
|
bool isSearchDirOnly();
|
2022-06-13 13:38:47 +08:00
|
|
|
|
bool isSearchOnlineApps();
|
2023-07-06 15:27:23 +08:00
|
|
|
|
bool searchHiddenFiles();
|
2022-03-25 09:40:56 +08:00
|
|
|
|
void clearAllConditions();
|
|
|
|
|
void clearKeyWords();
|
|
|
|
|
void clearSearchDir();
|
2022-04-28 15:49:51 +08:00
|
|
|
|
void clearFileLabel();
|
2022-03-25 09:40:56 +08:00
|
|
|
|
|
|
|
|
|
unsigned int maxResults() const;
|
2023-05-19 15:15:28 +08:00
|
|
|
|
int informNum() const;
|
2022-03-25 09:40:56 +08:00
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
|
bool setResultProperties(SearchProperty::SearchType searchType, UkuiSearch::SearchResultProperties searchResultProperties);
|
|
|
|
|
void setCustomResultDataType(QString customSearchType, QStringList dataType);
|
2021-12-28 15:56:41 +08:00
|
|
|
|
private:
|
2023-07-06 15:27:23 +08:00
|
|
|
|
std::shared_ptr<SearchControllerPrivate> d;
|
2022-01-11 16:20:40 +08:00
|
|
|
|
|
2021-12-28 15:56:41 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // SEARCHCONTROLLER_H
|