#ifndef SEARCHCONTROLLER_H #define SEARCHCONTROLLER_H #include #include #include "data-queue.h" #include "common-defines.h" //todo: url parser? namespace UkuiSearch { class UkuiSearchTask; class ResultItem; class SearchControllerPrivate; /* *搜索控制,用于传递搜索条件,搜索唯一ID,以及管理队列等。 */ class SearchController { friend class SearchControllerPrivate; public: explicit SearchController(std::shared_ptr parent = nullptr); SearchController(SearchController &) = delete; SearchController &operator =(const SearchController &) = delete; ~SearchController(); DataQueue* refreshDataqueue(); size_t refreshSearchId(); DataQueue* initDataQueue(); void stop(); void addSearchDir(QString &path); void setRecurse(bool recurse = true); void addKeyword(QString &keyword); void setActiveKeywordSegmentation(bool active); void addFileLabel(QString &label); void setOnlySearchFile(bool onlySearchFile); void setOnlySearchDir(bool onlySearchDir); void setSearchOnlineApps(bool searchOnlineApps); //以上方法插件请不要调用 //以下方法插件可以调用 size_t getCurrentSearchId(); DataQueue* getDataQueue(); ResultDataTypes getResultDataType(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(); void setPagination(unsigned int first, unsigned int maxResults); unsigned int first() const; unsigned int maxResults() const; bool setResultDataType(SearchType searchType, ResultDataTypes dataType); bool setCustomResultDataType(QString customSearchType, QStringList dataType); private: std::shared_ptr m_parent = nullptr; SearchControllerPrivate *d = nullptr; }; } #endif // SEARCHCONTROLLER_H