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"
|
2022-06-13 13:38:47 +08:00
|
|
|
|
#include "common-defines.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
|
|
|
|
|
{
|
|
|
|
|
friend class SearchControllerPrivate;
|
|
|
|
|
public:
|
2022-01-11 16:20:40 +08:00
|
|
|
|
explicit SearchController(std::shared_ptr<SearchController> parent = nullptr);
|
2022-01-24 09:44:42 +08:00
|
|
|
|
SearchController(SearchController &) = delete;
|
|
|
|
|
SearchController &operator =(const SearchController &) = delete;
|
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();
|
2021-12-28 15:56:41 +08:00
|
|
|
|
|
|
|
|
|
void addSearchDir(QString &path);
|
|
|
|
|
void setRecurse(bool recurse = true);
|
|
|
|
|
void addKeyword(QString &keyword);
|
|
|
|
|
void setActiveKeywordSegmentation(bool active);
|
|
|
|
|
void addFileLabel(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);
|
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();
|
2022-06-13 13:38:47 +08:00
|
|
|
|
ResultDataTypes getResultDataType(SearchType searchType);
|
|
|
|
|
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();
|
|
|
|
|
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();
|
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
|
|
|
|
|
|
|
|
|
void setPagination(unsigned int first, unsigned int maxResults);
|
|
|
|
|
unsigned int first() const;
|
|
|
|
|
unsigned int maxResults() const;
|
|
|
|
|
|
2022-06-13 13:38:47 +08:00
|
|
|
|
bool setResultDataType(SearchType searchType, ResultDataTypes dataType);
|
|
|
|
|
bool setCustomResultDataType(QString customSearchType, QStringList dataType);
|
2021-12-28 15:56:41 +08:00
|
|
|
|
private:
|
2022-01-11 16:20:40 +08:00
|
|
|
|
std::shared_ptr<SearchController> m_parent = nullptr;
|
|
|
|
|
SearchControllerPrivate *d = nullptr;
|
|
|
|
|
|
2021-12-28 15:56:41 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // SEARCHCONTROLLER_H
|