perf(libsearch):更新接口注释

This commit is contained in:
iaom 2024-08-19 10:57:18 +08:00
parent b70c017829
commit ee0fe24a87
4 changed files with 219 additions and 40 deletions

View File

@ -54,40 +54,41 @@ public:
/**
* @brief ApplicationInfo::getInfo
* get the application info that meets the restrictions
* @param restrictions: The restrictions that the search results should meet(e.g. u want get the app infos whose top state is 0)
* @param properties: Each application's information should contain these properties
* @return ApplicationInfoMap: the search result
* restrictions的指定应用属性
* @param restrictions:
* @param properties:
* @return ApplicationInfoMap:
*/
ApplicationInfoMap getInfo(ApplicationProperties properties, ApplicationPropertyMap restrictions);
/**
* @brief ApplicationInfo::searchApp
* @param properties: Each application's information should contain these properties
* @param keyword: the keyword of this search for applications
* @param restrictions: The restrictions that the search results should meet(e.g. u want get the app infos whose top state is 0)
* @return ApplicationInfoMap: the search result
*
* @param properties:
* @param keyword:
* @param restrictions:
* @return ApplicationInfoMap:
*/
ApplicationInfoMap searchApp(ApplicationProperties properties, const QString &keyword, ApplicationPropertyMap restrictions);
ApplicationInfoMap searchApp(ApplicationProperties properties, const QStringList &keywords, ApplicationPropertyMap restrictions);
/**
* @brief AppInfoTable::setAppToFavorites
* set the app to favorites apps
* @param desktopFilePath: the desktop file path of app
*
* @param desktopFilePath: desktop文件路径
*/
void setAppToFavorites(const QString &desktopFilePath);
/**
* @brief AppInfoTable::removeAppFromFavorites
* remove the app from favorites apps
* @param desktopFilePath: the desktop file path of app
*
* @param desktopFilePath: desktop文件路径
*/
void removeAppFromFavorites(const QString &desktopFilePath);
/**
* this function has been deprecated, use setAppToFavorites and removeAppFromFavorites instead
* @brief AppInfoTable::setFavoritesTo
* @brief ApplicationInfo::setFavoritesTo
* set the favorites state of the app to num, you can also use to change the position of the app which is one of the Favorites Apps
* @param desktopFilePath: the desktop file path of app
* @param num: the favorites app's position(from 1). If num is 0, it will remove the app from the favorites apps
@ -95,56 +96,95 @@ public:
[[deprecated]] void setFavoritesOfApp(const QString &desktopFilePath, size_t num);
/**
* @brief AppInfoTable::setAppToTop
* @brief ApplicationInfo::setAppToTop
* set the app to top apps(default is at 1)
* @param desktopFilePath: desktop file path of app
*/
[[deprecated]] void setAppToTop(const QString &desktopFilePath);
/**
* @brief AppInfoTable::setAppTopTo
* @brief ApplicationInfo::setAppTopTo
* set the top state of the app to num, you can also use to change the position of the app which is one of the Top Apps
* @param desktopFilePath: the desktop file path of app
* @param num: the top app's position(from 1). If num is 0, it will remove the app from the top apps
*/
[[deprecated]] void setTopOfApp(const QString &desktopFilePath, size_t num);
/**
* @brief ApplicationInfo::setAppLaunchedState
* ()
* @param desktopFilePath
* @param launched
*/
void setAppLaunchedState(const QString &desktopFilePath, bool launched = true);
/**
* @brief ApplicationInfo::tranPid2DesktopFp
* find the desktop file path of the process which corresponds to the pid
* @param pid: the pid of the process which need to get its desktop file path
* @param desktopFilePath: the desktop file path of the process corresponding to pid
* @return bool:true if success,else false
* desktop文件[obsolete]
* @param pid:
* @param desktopFilePath:desktop文件
* @return bool:true;false
*/
[[deprecated]] bool tranPidToDesktopFp(int pid, QString &desktopFilePath);//obsolete
/**
* @brief ApplicationInfo::tranPid2DesktopFp
* desktop文件
* @param pid:
* @param desktopFilePath:desktop文件
* @return bool:true;false
*/
bool tranPidToDesktopFp(uint pid, QString &desktopFilePath);
/**
* @brief ApplicationInfo::desktopFilePathFromName
* find the desktop file path of the process which corresponds to the desktop file name (without .desktop)
* @param desktopFileName: the desktop file name of the process which need to get its desktop file path
* @param desktopFilePath: the desktop file path of the process corresponding to pid
* @return bool:true if success,else false
* desktop文件名 ( .desktop后缀)desktop文件的全路径
* @param desktopFileName: desktop文件名
* @param desktopFilePath: desktop文件全路径
* @return bool:true;false
*/
bool desktopFilePathFromName(const QString &desktopFileName, QString &desktopFilePath);
/**
* @brief ApplicationInfo::tranWinIdToDesktopFilePath
* find the desktop file path of the process which corresponds to the winId.
* it will find through tranPidToDesktopFp method first, and then use the winId if the desktop file can not be found by pid;
* @param winId: the winId of the process which need to get its desktop file path(Only for X)
* @param desktopFilePath: the desktop file path of the process corresponding to pid
* @return bool:true if success,else false
* id找到对应的desktop文件,x环境可用
* @param winId:ID(Only for X)
* @param desktopFilePath:desktop文件全路径
* @return bool:true;false
*/
bool tranWinIdToDesktopFilePath(const QVariant &winId, QString &desktopFilePath);
Q_SIGNALS:
/**
* ,
*/
void DBOpenFailed();
/**
* @brief ApplicationInfo::appDBItems2BUpdate
*
* @param ApplicationInfoMap:
*/
void appDBItems2BUpdate(ApplicationInfoMap);
/**
* @brief ApplicationInfo::appDBItems2BUpdate
*
* @param QStringList: (desktop文件全路径)
*/
void appDBItems2BUpdateAll(QStringList);
/**
* @brief ApplicationInfo::appDBItems2BAdd
*
* @param QStringList: (desktop文件全路径)
*/
void appDBItems2BAdd(QStringList);
/**
* @brief ApplicationInfo::appDBItems2BDelete
*
* @param QStringList: (desktop文件全路径)
*/
void appDBItems2BDelete(QStringList);
private:

View File

@ -37,12 +37,54 @@ public:
ResultItem &operator=(const ResultItem &other);
ResultItem &operator=(ResultItem &&other) Q_DECL_NOEXCEPT;
/**
* @brief setSearchId
* id,
* @param searchId
*/
void setSearchId(const size_t searchId);
/**
* @brief setItemKey
* ,
* @param itemKey
*/
void setItemKey(const QString &itemKey);
/**
* @brief getSearchId
* id
* @return id
*/
size_t getSearchId() const;
/**
* @brief getItemKey
*
*/
QString getItemKey() const;
/**
* @brief setValue
* ,
* @param property
* @param value
*/
void setValue(SearchProperty::SearchResultProperty property, const QVariant &value);
/**
* @brief getValue
*
* @param property
* @return
*/
QVariant getValue(SearchProperty::SearchResultProperty property) const;
/**
* @brief getAllValue
*
* @return map
*/
SearchResultPropertyMap getAllValue() const;
private:

View File

@ -58,6 +58,7 @@ void SearchControllerPrivate::clearAllConditions()
m_onlySearchFile = false;
m_onlySearchDir = false;
m_searchOnlineApps = false;
m_matchAllIfNoKeyword = false;
}
SearchController::SearchController(): d(new SearchControllerPrivate)

View File

@ -31,61 +31,139 @@ class UkuiSearchTask : public QObject
public:
explicit UkuiSearchTask(QObject *parent = nullptr);
~UkuiSearchTask();
/**
* @brief init
* ,
* @return ,
*/
DataQueue<ResultItem>* init();
/**
* @brief addSearchDir
* ()
* @param path
*/
void addSearchDir(const QString &path);
/**
* @brief setRecurse
* (),
* @param recurse
*/
void setRecurse(bool recurse = true);
/**
* @brief addKeyword
*
* @param keyword
*/
void addKeyword(const QString &keyword);
/**
*
* @brief setMatchAllIfNoKeyword
*
* @param matchAll
*/
void setMatchAllIfNoKeyword(bool matchAll);
/**
* @brief addFileLabel
* peony文件标签作为搜索条件
* @param label
*/
void addFileLabel(const QString &label);
/**
* @brief setOnlySearchFile
* ()
* @param onlySearchFile
*/
void setOnlySearchFile(bool onlySearchFile);
/**
* @brief setOnlySearchDir
* ()
* @param onlySearchDir
*/
void setOnlySearchDir(bool onlySearchDir);
/**
* @brief setSearchOnlineApps
*
* @param searchOnlineApps
*/
void setSearchOnlineApps(bool searchOnlineApps);
/**
*
* @brief setSearchHiddenFiles
* ,
* @param searchHiddenFiles
*/
void setSearchHiddenFiles(bool searchHiddenFiles);
/**
* @brief initSearchPlugin
* @param searchType
* @param customSearchType
* @brief initSearchPlugin
*
* @param searchType
* @param customSearchType searchType为Custom时,
*/
void initSearchPlugin(SearchProperty::SearchType searchType, const QString& customSearchType = QString());
/**
* @brief setResultDataType
* @param searchType
* @param dataType
* @return
* searchType的搜索结果数据类型
* @param searchType
* @param searchResultProperties
*/
bool setResultProperties(SearchProperty::SearchType searchType, SearchResultProperties searchResultProperties);
/**
* @brief setCustomResultDataType
* initSearchPlugin中设置的SearchType为custom时,
* @param customSearchType
* @param dataType
*/
void setCustomResultDataType(QString customSearchType, QStringList dataType);
/**
* @brief clearAllConditions
*
*/
void clearAllConditions();
/**
* @brief clearKeyWords
*
*/
void clearKeyWords();
/**
* @brief clearSearchDir
*
*/
void clearSearchDir();
/**
* @brief clearFileLabel
*
*/
void clearFileLabel();
/**
* @brief setMaxResultNum
* @brief setMaxResultNum
*
* @param maxResults
*/
void setMaxResultNum(unsigned int maxResults = 99999999);
/**
* @brief setInformNum
* @brief setInformNum
* ,@param num时,reachInformNum信号然后重新开始计数
* @param num
*/
void setInformNum(int num);
/**
* @brief startSearch
* @brief startSearch
*
* @param searchtype
* @param customSearchType searchType为Custom时可用
* @return
* @return id
*/
size_t startSearch(SearchProperty::SearchType searchtype, QString customSearchType = QString());
/**
@ -94,12 +172,30 @@ public:
void stop();
/**
* @brief isSearching
* @return true表示正在搜索,false表示未在搜索
*/
bool isSearching(SearchProperty::SearchType searchtype, QString customSearchType = {});
Q_SIGNALS:
/**
* @brief searchFinished
*
* @param searchId id
*/
void searchFinished(size_t searchId);
/**
* @brief searchError
*
* @param searchId id
* @param msg
*/
void searchError(size_t searchId, QString msg);
/**
* @brief reachInformNum
* setInformNum使用,
*/
void reachInformNum();
private: