2021-12-28 15:56:41 +08:00
|
|
|
#ifndef SEARCHCONTROLLERPRIVATE_H
|
|
|
|
#define SEARCHCONTROLLERPRIVATE_H
|
|
|
|
|
|
|
|
#include <QMutex>
|
2022-06-14 20:46:36 +08:00
|
|
|
#include <QMap>
|
2021-12-28 15:56:41 +08:00
|
|
|
#include "search-controller.h"
|
|
|
|
namespace UkuiSearch {
|
|
|
|
|
|
|
|
class SearchControllerPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SearchControllerPrivate(SearchController *parent);
|
|
|
|
~SearchControllerPrivate();
|
|
|
|
size_t refreshSearchId();
|
|
|
|
DataQueue<ResultItem>* refreshDataqueue();
|
|
|
|
DataQueue<ResultItem>* initDataQueue();
|
|
|
|
|
|
|
|
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-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();
|
|
|
|
void stop();
|
|
|
|
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
|
|
|
|
2022-06-13 13:38:47 +08:00
|
|
|
bool setResultDataType(SearchType searchType, ResultDataTypes dataType);
|
|
|
|
bool setCustomResultDataType(QString customSearchType, QStringList dataType);
|
|
|
|
|
2022-03-25 09:40:56 +08:00
|
|
|
/**
|
|
|
|
* @brief 分页选项
|
|
|
|
* @param first 指定起始位置
|
|
|
|
* @param maxResults 每次搜索结果集的数量
|
|
|
|
*/
|
|
|
|
void setPagination(unsigned int first, unsigned int maxResults);
|
|
|
|
unsigned int first() const;
|
|
|
|
unsigned int maxResults() const;
|
2021-12-28 15:56:41 +08:00
|
|
|
|
|
|
|
private:
|
2022-01-11 16:20:40 +08:00
|
|
|
void copyData();
|
2022-01-12 18:01:59 +08:00
|
|
|
//TODO: 这里是否可以改为字节对齐的写法?
|
2022-02-16 18:13:59 +08:00
|
|
|
// DataQueue<ResultItem>* m_dataQueue = nullptr ;
|
2022-06-13 13:38:47 +08:00
|
|
|
std::shared_ptr<DataQueue<ResultItem>> m_sharedDataQueue = nullptr;
|
2021-12-28 15:56:41 +08:00
|
|
|
size_t m_searchId = 0;
|
|
|
|
QMutex m_searchIdMutex;
|
2022-01-11 16:20:40 +08:00
|
|
|
SearchController *q = nullptr;
|
|
|
|
std::shared_ptr<SearchController> m_formerController = nullptr;
|
2021-12-28 15:56:41 +08:00
|
|
|
|
|
|
|
QStringList m_keywords;
|
|
|
|
QStringList m_searchDirs;
|
|
|
|
QStringList m_FileLabels;
|
|
|
|
bool m_recurse = true;
|
|
|
|
bool m_activeKeywordSegmentation = false;
|
2022-01-11 16:20:40 +08:00
|
|
|
bool m_onlySearchFile = false;
|
|
|
|
bool m_onlySearchDir = false;
|
2022-06-13 13:38:47 +08:00
|
|
|
bool m_searchOnlineApps = false;
|
2021-12-28 15:56:41 +08:00
|
|
|
|
2022-03-25 09:40:56 +08:00
|
|
|
unsigned int m_first = 0;
|
|
|
|
unsigned int m_maxResults = 100; //默认取100条结果
|
2022-06-13 13:38:47 +08:00
|
|
|
|
|
|
|
QMap<SearchType, ResultDataTypes> m_searchType2ResultDataType;
|
|
|
|
QMap<QString, QStringList> m_customSearchType2ResultDataType;
|
2021-12-28 15:56:41 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SEARCHCONTROLLERPRIVATE_H
|