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