diff --git a/frontend/model/best-list-model.cpp b/frontend/model/best-list-model.cpp index 8fd7a82..3d4e743 100644 --- a/frontend/model/best-list-model.cpp +++ b/frontend/model/best-list-model.cpp @@ -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(); diff --git a/frontend/model/best-list-model.h b/frontend/model/best-list-model.h index dc745fb..a11c1fa 100644 --- a/frontend/model/best-list-model.h +++ b/frontend/model/best-list-model.h @@ -61,7 +61,7 @@ Q_SIGNALS: private: QVector m_items; QVector m_pluginIdList; - QVector m_pluginActionKeyList; + QVector m_resourceTypes; bool m_isExpanded = false; }; } diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index 1df092d..e2bc217 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -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:")); diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index ba3c7da..e5953fb 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -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{tr("Path:"), path} \ << SearchPluginIface::DescriptionInfo{tr("Modified time:"), info.lastModified().toString("yyyy/MM/dd hh:mm:ss")}; diff --git a/libsearch/notesearch/note-search-plugin.cpp b/libsearch/notesearch/note-search-plugin.cpp index 0d39aef..2d927bb 100644 --- a/libsearch/notesearch/note-search-plugin.cpp +++ b/libsearch/notesearch/note-search-plugin.cpp @@ -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 { key : QString(tr("Note Description:")), value : str.at(0) diff --git a/libsearch/plugininterface/search-plugin-iface.h b/libsearch/plugininterface/search-plugin-iface.h index 96c1eba..c9c3aef 100644 --- a/libsearch/plugininterface/search-plugin-iface.h +++ b/libsearch/plugininterface/search-plugin-iface.h @@ -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 #include @@ -59,21 +60,24 @@ public: */ struct ResultInfo { - QIcon icon; - QString name; - QString toolTip; - QVector description; - QString actionKey; + QIcon icon; //要显示的图标 + QString name; //要显示的名称 + QString toolTip; //要先显示的tooltip + QVector 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 &descriptionToSet = QVector(), const QString &actionKeyToSet = QString(), const int &typeToSet = 0) { icon = iconToSet; name = nameToSet; toolTip = toolTipToSet; + resourceType = resourceTypeToSet; description = descriptionToSet; actionKey = actionKeyToSet; type = typeToSet; diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index 8cf7306..2697893 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -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); } diff --git a/libsearch/websearch/web-search-plugin.cpp b/libsearch/websearch/web-search-plugin.cpp index 3f2a802..c89411d 100644 --- a/libsearch/websearch/web-search-plugin.cpp +++ b/libsearch/websearch/web-search-plugin.cpp @@ -68,7 +68,8 @@ void UkuiSearch::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue