ukui-search/libsearch/searchinterface/search-controller-private.h

87 lines
2.7 KiB
C++

#ifndef SEARCHCONTROLLERPRIVATE_H
#define SEARCHCONTROLLERPRIVATE_H
#include <QMutex>
#include <QMap>
#include "search-controller.h"
#include "search-result-property.h"
namespace UkuiSearch {
class SearchControllerPrivate
{
public:
explicit SearchControllerPrivate(SearchController *parent);
~SearchControllerPrivate();
size_t refreshSearchId();
DataQueue<ResultItem>* refreshDataqueue();
DataQueue<ResultItem>* initDataQueue();
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);
size_t getCurrentSearchId();
DataQueue<ResultItem>* getDataQueue();
SearchResultProperties getResultProperties(SearchProperty::SearchType searchType);
QStringList getCustomResultDataType(QString customSearchType);
bool beginSearchIdCheck(size_t searchId);
void finishSearchIdCheck();
void stop();
QStringList getSearchDir();
bool isRecurse();
QStringList getKeyword();
bool isKeywordSegmentationActived();
QStringList getFileLabel();
bool isSearchFileOnly();
bool isSearchDirOnly();
bool isSearchOnlineApps();
void clearAllConditions();
void clearKeyWords();
void clearSearchDir();
void clearFileLabel();
bool setResultProperties(SearchProperty::SearchType searchType, UkuiSearch::SearchResultProperties searchResultProperties);
void setCustomResultDataType(QString customSearchType, QStringList dataType);
/**
* @brief
* @param maxResults 每次搜索结果集的数量
*/
void setMaxResultNum(unsigned int maxResults);
void setInformNum(int num = 0);
unsigned int maxResults() const;
int informNum() const;
private:
void copyData();
std::shared_ptr<DataQueue<ResultItem>> m_sharedDataQueue = nullptr;
size_t m_searchId = 0;
QMutex m_searchIdMutex;
SearchController *q = nullptr;
std::shared_ptr<SearchController> m_formerController = nullptr;
QStringList m_keywords;
QStringList m_searchDirs;
QStringList m_FileLabels;
bool m_recurse = true;
bool m_activeKeywordSegmentation = false;
bool m_onlySearchFile = false;
bool m_onlySearchDir = false;
bool m_searchOnlineApps = false;
unsigned int m_maxResults = 100; //默认取100条结果
int m_informNum = 0;
QMap<SearchProperty::SearchType, SearchResultProperties> m_searchType2ResultProperties;
QMap<QString, QStringList> m_customSearchType2ResultDataType;
};
}
#endif // SEARCHCONTROLLERPRIVATE_H