fix(frontend&searchPlugin):增加资源类型,最佳匹配中每种资源类型只显示1种
This commit is contained in:
parent
ca260caf1d
commit
a1f11218d9
|
@ -97,6 +97,12 @@ const bool &BestListModel::isExpanded()
|
|||
|
||||
void BestListModel::appendInfo(const QString &pluginId, const SearchPluginIface::ResultInfo &info)
|
||||
{
|
||||
|
||||
if (m_resourceTypes.contains(info.resourceType)) {
|
||||
return;
|
||||
} else {
|
||||
m_resourceTypes.append(info.resourceType);
|
||||
}
|
||||
if (m_pluginIdList.contains(pluginId)) {
|
||||
if (info.actionKey == m_items.at(m_pluginIdList.lastIndexOf(pluginId))->info().actionKey) {
|
||||
return;
|
||||
|
@ -186,7 +192,7 @@ void BestListModel::startSearch(const QString &keyword)
|
|||
if (!m_items.isEmpty()) {
|
||||
this->beginResetModel();
|
||||
m_pluginIdList.clear();
|
||||
m_pluginActionKeyList.clear();
|
||||
m_resourceTypes.clear();
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
this->endResetModel();
|
||||
|
|
|
@ -61,7 +61,7 @@ Q_SIGNALS:
|
|||
private:
|
||||
QVector<OneResult *> m_items;
|
||||
QVector<QString> m_pluginIdList;
|
||||
QVector<QString> m_pluginActionKeyList;
|
||||
QVector<QString> m_resourceTypes;
|
||||
bool m_isExpanded = false;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ void AppSearchPlugin::run()
|
|||
|
||||
ri.name = data.value(SearchProperty::SearchResultProperty::ApplicationLocalName).toString();
|
||||
ri.toolTip = ri.name;
|
||||
ri.resourceType = QStringLiteral("app");
|
||||
ri.icon = IconLoader::loadIconXdg(data.value(SearchProperty::SearchResultProperty::ApplicationIconName).toString(), QIcon(":/res/icons/unknown.svg"));
|
||||
SearchPluginIface::DescriptionInfo description;
|
||||
description.key = QString(tr("Application Description:"));
|
||||
|
|
|
@ -67,6 +67,7 @@ bool SearchManager::creatResultInfo(SearchPluginIface::ResultInfo &ri, const QSt
|
|||
ri.icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString(), false);
|
||||
ri.name = info.fileName().replace("\r", " ").replace("\n", " ");
|
||||
ri.toolTip = info.fileName();
|
||||
ri.resourceType = QStringLiteral("file");
|
||||
ri.description = QVector<SearchPluginIface::DescriptionInfo>() \
|
||||
<< SearchPluginIface::DescriptionInfo{tr("Path:"), path} \
|
||||
<< SearchPluginIface::DescriptionInfo{tr("Modified time:"), info.lastModified().toString("yyyy/MM/dd hh:mm:ss")};
|
||||
|
|
|
@ -238,6 +238,7 @@ void NoteSearch::run() {
|
|||
IconLoader::loadIconQt("kylin-notebook", QIcon(":/res/icons/desktop.png")),
|
||||
name.replace("\r", " ").replace("\n", " "),
|
||||
name,
|
||||
QStringLiteral("ukui-note"),
|
||||
QVector<SearchPluginIface::DescriptionInfo>() << SearchPluginIface::DescriptionInfo {
|
||||
key : QString(tr("Note Description:")),
|
||||
value : str.at(0)
|
||||
|
|
|
@ -21,9 +21,10 @@
|
|||
#define SEARCHPLUGINIFACE_H
|
||||
#define SearchPluginIface_iid "org.ukui.ukui-search.plugin-iface.SearchPluginInterface"
|
||||
/**
|
||||
* changelog:1.3.0 增加resourceType
|
||||
* changelog:1.2.0 增加toolTip
|
||||
*/
|
||||
#define SEARCH_PLUGIN_IFACE_VERSION "1.2.0"
|
||||
#define SEARCH_PLUGIN_IFACE_VERSION "1.3.0"
|
||||
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
|
@ -59,21 +60,24 @@ public:
|
|||
*/
|
||||
struct ResultInfo
|
||||
{
|
||||
QIcon icon;
|
||||
QString name;
|
||||
QString toolTip;
|
||||
QVector<DescriptionInfo> description;
|
||||
QString actionKey;
|
||||
QIcon icon; //要显示的图标
|
||||
QString name; //要显示的名称
|
||||
QString toolTip; //要先显示的tooltip
|
||||
QVector<DescriptionInfo> description; //详情页中使用的描述
|
||||
QString actionKey; //执行action时的key
|
||||
QString resourceType; //资源类型,可定义,例如“file, app”
|
||||
int type;
|
||||
ResultInfo(const QIcon &iconToSet = QIcon(),
|
||||
explicit ResultInfo(const QIcon &iconToSet = QIcon(),
|
||||
const QString &nameToSet = QString(),
|
||||
const QString &toolTipToSet = QString(),
|
||||
const QString &resourceTypeToSet = QString(),
|
||||
const QVector<DescriptionInfo> &descriptionToSet = QVector<DescriptionInfo>(),
|
||||
const QString &actionKeyToSet = QString(),
|
||||
const int &typeToSet = 0) {
|
||||
icon = iconToSet;
|
||||
name = nameToSet;
|
||||
toolTip = toolTipToSet;
|
||||
resourceType = resourceTypeToSet;
|
||||
description = descriptionToSet;
|
||||
actionKey = actionKeyToSet;
|
||||
type = typeToSet;
|
||||
|
|
|
@ -477,6 +477,7 @@ void SettingsMatch::createResultInfo(SearchPluginIface::ResultInfo &resultInfo,
|
|||
resultInfo.name.prepend(ql.language() == QLocale::English ? topInfo.at(0) : topInfo.at(1));
|
||||
}
|
||||
resultInfo.toolTip = resultInfo.name;
|
||||
resultInfo.resourceType = QStringLiteral("setting");
|
||||
resultInfo.icon = FileUtils::getSettingIcon();
|
||||
resultInfo.actionKey = path.section("/", 1, 1);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ void UkuiSearch::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue<UkuiS
|
|||
m_keyWord = keyword;
|
||||
ResultInfo resultInfo;
|
||||
resultInfo.name = m_keyWord.replace("\r", " ").replace("\n", " ");
|
||||
resultInfo.name = m_keyWord;
|
||||
resultInfo.toolTip = m_keyWord;
|
||||
resultInfo.resourceType = QStringLiteral("web");
|
||||
resultInfo.type = 0;
|
||||
|
||||
QIcon appIcon;
|
||||
|
|
Loading…
Reference in New Issue