Skip to content

refactor: centralize category name localization to C++ model - #787

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-appFoldersForTask
Open

refactor: centralize category name localization to C++ model#787
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-appFoldersForTask

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Move the category name mapping logic from multiple QML files into the C+

  • ItemArrangementProxyModel to reduce code duplication and fix potential string localization issues. This ensures consistent category display names across all views.

Log: Optimize category name processing logic

Influence:

  1. Verify that app category names display correctly in folder grid and list views
  2. Test category names in windowed mode (Alphabetical and Category sorting)
  3. Check that folder popups show correct category names
  4. Verify no untranslated "internal/category/" strings appear in the UI
  5. Ensure localized strings still support proper translation
  6. Test the dock launcher applet's folder interactions

refactor: 将分类名称本地化逻辑集中到 C++ 模型中

将多个 QML 文件中的分类名称映射逻辑移到 C++ 的 ItemArrangementProxyModel 中,减少代码重复并修复潜在的字符串本地化问题。这确保了所有视图中分类显示
名称的一致性。

Log: 优化分类名称处理逻辑

Influence:

  1. 验证文件夹网格和列表视图中应用分类名称显示正确
  2. 测试窗口模式下(按字母排序和按分类排序)的分类名称
  3. 检查文件夹弹出窗口显示正确的分类名称
  4. 确保界面中不会出现未翻译的 "internal/category/" 字符串
  5. 确认本地化字符串仍支持正常翻译
  6. 测试 dock 启动器控件的文件夹交互功能

PMS: TASK-392671

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wjyrich
wjyrich force-pushed the feat-appFoldersForTask branch from f50f5fb to ff79779 Compare July 27, 2026 02:55

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @wjyrich, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Move the category name mapping logic from multiple QML files into the C+
+ ItemArrangementProxyModel to reduce code duplication and fix potential
string localization issues. This ensures consistent category display
names across all views.

Log: Optimize category name processing logic

Influence:
1. Verify that app category names display correctly in folder grid and
list views
2. Test category names in windowed mode (Alphabetical and Category
sorting)
3. Check that folder popups show correct category names
4. Verify no untranslated "internal/category/" strings appear in the UI
5. Ensure localized strings still support proper translation
6. Test the dock launcher applet's folder interactions

refactor: 将分类名称本地化逻辑集中到 C++ 模型中

将多个 QML 文件中的分类名称映射逻辑移到 C++ 的 ItemArrangementProxyModel
中,减少代码重复并修复潜在的字符串本地化问题。这确保了所有视图中分类显示
名称的一致性。

Log: 优化分类名称处理逻辑

Influence:
1. 验证文件夹网格和列表视图中应用分类名称显示正确
2. 测试窗口模式下(按字母排序和按分类排序)的分类名称
3. 检查文件夹弹出窗口显示正确的分类名称
4. 确保界面中不会出现未翻译的 "internal/category/" 字符串
5. 确认本地化字符串仍支持正常翻译
6. 测试 dock 启动器控件的文件夹交互功能

PMS: TASK-392671
@wjyrich
wjyrich force-pushed the feat-appFoldersForTask branch from ff79779 to 94c56a9 Compare July 27, 2026 03:01
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码实现了将分类名称翻译逻辑统一下沉至C++模型层的重构,消除了QML端的重复代码并修复了本地化问题
逻辑正确且重构质量高,无安全漏洞,未扣分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

代码在ItemArrangementProxyModel::localizedFolderName中正确使用QStringViewsliced进行字符串截取与转换,在LauncherItem::groupDisplayName中通过model.match安全获取数据,folderByIdfolderItems均进行了空指针检查
潜在问题:无
建议:无

  • 2.代码质量(优秀)✓

重构将散落在Main.qmllauncheritem.qml中的getCategoryName函数统一下沉至C++层,大幅减少了代码重复,提高了可维护性。新增函数命名规范,const修饰使用得当
潜在问题:无
建议:无

  • 3.代码性能(良好)✓

groupDisplayName使用model.match进行线性查找,对于分组数量较少的场景性能开销可忽略;groupItemDetails直接通过folderById获取列表,效率较高
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码主要涉及字符串处理与模型数据查询,未引入外部输入直接参与系统命令或SQL操作,不存在命令注入或路径遍历等风险

  • 建议:无

■ 【改进建议代码示例】

// 代码质量优秀,无需额外修复

@BLumia BLumia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

与此 PR 无直接相关性:dde-shell 之前有预留文件夹的支持并且应该也预留了配置迁移的支持,之前的计划是 dde-launchpad 接 dde-shell 的 dde-apps 组件,两边共用同一套模型,数据也维持一份(不需要两边同步)。可以回顾下那个方案?(见 dde-shell 的 appgroup.{cpp,h},以及关联的代码)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants