149 lines
5.3 KiB
Diff
149 lines
5.3 KiB
Diff
From 71520f1092cf973bbb63306b141b2d5c3f141d98 Mon Sep 17 00:00:00 2001
|
|
From: liuxinhao <liuxinhao@kylinsec.com.cn>
|
|
Date: Fri, 19 Apr 2024 10:44:44 +0800
|
|
Subject: [PATCH 7/7] fix(network): Crash caused by mismatch between registered
|
|
search terms and actual content
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
- 修复网络插件注册的搜索项和实际内容对应不上导致的崩溃
|
|
|
|
Closes #35252
|
|
---
|
|
lib/plugin-framework/category-manager.cpp | 8 +++++
|
|
.../network/src/plugin/network-subitem.cpp | 33 +++++++------------
|
|
src/search-edit/search-model.cpp | 11 ++++---
|
|
3 files changed, 26 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/lib/plugin-framework/category-manager.cpp b/lib/plugin-framework/category-manager.cpp
|
|
index 96eb696..a01a2ac 100644
|
|
--- a/lib/plugin-framework/category-manager.cpp
|
|
+++ b/lib/plugin-framework/category-manager.cpp
|
|
@@ -288,6 +288,9 @@ void CategoryManager::removeSubItem(const QString& categoryID, Plugin* plugin, c
|
|
}
|
|
}
|
|
|
|
+/**
|
|
+ * NOTE: 该方法为插件调用触发,主面板处理子功能项目信息发生变化
|
|
+*/
|
|
void CategoryManager::handlePluginSubItemInfoChanged(const QString& subiemID)
|
|
{
|
|
Plugin* plugin = qobject_cast<Plugin*>(sender());
|
|
@@ -301,11 +304,16 @@ void CategoryManager::handlePluginSubItemInfoChanged(const QString& subiemID)
|
|
{
|
|
QString categoryID = cacheItem.categoryID;
|
|
Category* category = m_categorysMap[categoryID];
|
|
+ // 发出主分类子功能项信息变化信号,感兴趣类通过该方法
|
|
+ // 重新加载该主分类下子功能项的信息,例如搜索项
|
|
emit category->subItemInfoChanged(subiemID);
|
|
}
|
|
}
|
|
}
|
|
|
|
+/**
|
|
+ * NOTE: 该方法为插件调用触发,主面板处理子功能变更,更新二级分类
|
|
+*/
|
|
void CategoryManager::handlePluginSubItemChanged()
|
|
{
|
|
Plugin* plugin = qobject_cast<Plugin*>(sender());
|
|
diff --git a/plugins/network/src/plugin/network-subitem.cpp b/plugins/network/src/plugin/network-subitem.cpp
|
|
index 03456d8..b896ba4 100644
|
|
--- a/plugins/network/src/plugin/network-subitem.cpp
|
|
+++ b/plugins/network/src/plugin/network-subitem.cpp
|
|
@@ -116,40 +116,29 @@ void NetworkSubItem::handleSubItemsChanged()
|
|
m_interface->handlePluginSubItemInfoChanged(getID());
|
|
}
|
|
|
|
+//TODO:
|
|
+//1.用翻译文本做Key后续得改
|
|
+//2.这些文本存在多次拷贝,后续改到一处,避免后续改动不全出问题
|
|
QStringList NetworkSubItem::subItemsList()
|
|
{
|
|
QStringList subItemsList;
|
|
auto wiredList = NetworkUtils::getManagedDeviceList(NetworkManager::Device::Ethernet);
|
|
auto wirelessList = NetworkUtils::getManagedDeviceList(NetworkManager::Device::Wifi);
|
|
- for (int i = 0; i < wiredList.count(); i++)
|
|
+
|
|
+ if (!wiredList.isEmpty())
|
|
{
|
|
- QString subItemName = tr("Wired Network %1");
|
|
- QString subItemNameStr = subItemName.arg(i + 1);
|
|
- if (wiredList.count() == 1)
|
|
- {
|
|
- QString name = tr("Wired Network");
|
|
- subItemsList << name;
|
|
- }
|
|
- else
|
|
- subItemsList << subItemNameStr;
|
|
+ QString name = tr("Wired Network");
|
|
+ subItemsList << name;
|
|
}
|
|
|
|
- for (int i = 0; i < wirelessList.count(); i++)
|
|
+ if( !wirelessList.isEmpty() )
|
|
{
|
|
- QString subItemName = tr("Wireless Network %1");
|
|
- QString subItemNameStr = subItemName.arg(i + 1);
|
|
-
|
|
- if (wirelessList.count() == 1)
|
|
- {
|
|
- QString name = tr("Wireless Network");
|
|
- subItemsList << name;
|
|
- }
|
|
- else
|
|
- subItemsList << subItemNameStr;
|
|
+ QString name = tr("Wireless Network");
|
|
+ subItemsList << name;
|
|
}
|
|
|
|
subItemsList << tr("VPN");
|
|
subItemsList << tr("Network Details");
|
|
|
|
return subItemsList;
|
|
-}
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/search-edit/search-model.cpp b/src/search-edit/search-model.cpp
|
|
index 6afcffe..618342b 100644
|
|
--- a/src/search-edit/search-model.cpp
|
|
+++ b/src/search-edit/search-model.cpp
|
|
@@ -50,13 +50,14 @@ void SearchModel::loadSearchModel()
|
|
QString categoryID = category->getID();
|
|
|
|
auto subitems = category->getSubItems();
|
|
-
|
|
- if(subitems.size() > 0)
|
|
+ if( subitems.size() == 0 )
|
|
{
|
|
- // 添加分类搜索项
|
|
- appendItem(categoryName, categoryID, subitems.at(0)->getID());
|
|
+ continue;
|
|
}
|
|
|
|
+ // 添加分类搜索项
|
|
+ appendItem(categoryName, categoryID, subitems.at(0)->getID());
|
|
+
|
|
/**
|
|
* NOTE: 分类下单个子功能项应不添加搜索项
|
|
* 避免 显示设置分类下显示设置子功能项,构成"显示设置->显示设置"这种搜索项
|
|
@@ -77,6 +78,7 @@ void SearchModel::loadSearchModel()
|
|
{
|
|
QString subItemSearchKey = QString("%1 -> %2").arg(categoryName).arg(subitemName);
|
|
appendItem(subItemSearchKey, categoryID, subitemID);
|
|
+
|
|
subItemPrefix = subItemSearchKey;
|
|
}
|
|
else
|
|
@@ -89,6 +91,7 @@ void SearchModel::loadSearchModel()
|
|
{
|
|
QString searchName = searchItem.first;
|
|
QString searchKey = searchItem.second;
|
|
+
|
|
QString searchText = QString("%1 -> %2").arg(subItemPrefix).arg(searchName);
|
|
appendItem(searchText, categoryID, subitemID, searchKey);
|
|
}
|
|
--
|
|
2.33.0
|
|
|