75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
#ifndef SEARCHCONTROLLER_H
|
||
#define SEARCHCONTROLLER_H
|
||
|
||
#include <QStringList>
|
||
#include <memory>
|
||
#include "data-queue.h"
|
||
#include "search-result-property.h"
|
||
//todo: url parser?
|
||
namespace UkuiSearch {
|
||
class UkuiSearchTask;
|
||
class ResultItem;
|
||
class SearchControllerPrivate;
|
||
/*
|
||
*搜索控制,用于传递搜索条件,搜索唯一ID,以及管理队列等。
|
||
*/
|
||
class SearchController
|
||
{
|
||
friend class SearchControllerPrivate;
|
||
public:
|
||
explicit SearchController(std::shared_ptr<SearchController> parent = nullptr);
|
||
SearchController(SearchController &) = delete;
|
||
SearchController &operator =(const SearchController &) = delete;
|
||
~SearchController();
|
||
DataQueue<ResultItem>* refreshDataqueue();
|
||
size_t refreshSearchId();
|
||
DataQueue<ResultItem>* initDataQueue();
|
||
void stop();
|
||
|
||
void addSearchDir(const QString &path);
|
||
void setRecurse(bool recurse = true);
|
||
void addKeyword(const QString &keyword);
|
||
void setActiveKeywordSegmentation(bool active);
|
||
void addFileLabel(const QString &label);
|
||
void setOnlySearchFile(bool onlySearchFile);
|
||
void setOnlySearchDir(bool onlySearchDir);
|
||
void setSearchOnlineApps(bool searchOnlineApps);
|
||
void setMaxResultNum(unsigned int maxResults);
|
||
void setInformNum(int num = 0);
|
||
//以上方法插件请不要调用
|
||
|
||
//以下方法插件可以调用
|
||
size_t getCurrentSearchId();
|
||
DataQueue<ResultItem>* getDataQueue();
|
||
SearchResultProperties getResultProperties(SearchProperty::SearchType searchType);
|
||
QStringList getCustomResultDataType(QString customSearchType);
|
||
bool beginSearchIdCheck(size_t searchId);
|
||
void finishSearchIdCheck();
|
||
|
||
QStringList getSearchDir();
|
||
bool isRecurse();
|
||
QStringList getKeyword();
|
||
bool isKeywordSegmentationActived();
|
||
QStringList getFileLabel();
|
||
bool isSearchFileOnly();
|
||
bool isSearchDirOnly();
|
||
bool isSearchOnlineApps();
|
||
void clearAllConditions();
|
||
void clearKeyWords();
|
||
void clearSearchDir();
|
||
void clearFileLabel();
|
||
|
||
unsigned int maxResults() const;
|
||
int informNum() const;
|
||
|
||
bool setResultProperties(SearchProperty::SearchType searchType, UkuiSearch::SearchResultProperties searchResultProperties);
|
||
void setCustomResultDataType(QString customSearchType, QStringList dataType);
|
||
private:
|
||
std::shared_ptr<SearchController> m_parent = nullptr;
|
||
SearchControllerPrivate *d = nullptr;
|
||
|
||
};
|
||
}
|
||
|
||
#endif // SEARCHCONTROLLER_H
|