perf(libsearch):更新接口注释
This commit is contained in:
parent
b0f888fa9d
commit
2218c36b49
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -58,6 +58,7 @@ void SearchControllerPrivate::clearAllConditions()
|
|||
m_onlySearchFile = false;
|
||||
m_onlySearchDir = false;
|
||||
m_searchOnlineApps = false;
|
||||
m_matchAllIfNoKeyword = false;
|
||||
}
|
||||
|
||||
SearchController::SearchController(): d(new SearchControllerPrivate)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue