fix: use system locale for QCollator to enable numeric sorting in dock plugin - #3440
MyLeeJiEun wants to merge 1 commit into
Conversation
…k plugin QCollator constructed with QLocale::c() (C/POSIX locale) does not support numeric mode under the ICU implementation, causing setNumericMode(true) to be silently ignored. This results in dock plugin names starting with digits being sorted lexicographically instead of numerically (e.g. "10" sorted before "2"). Replace QLocale::c() with the system default locale QLocale() so that setNumericMode(true) takes effect. Use brace initialization to avoid the C++ most vexing parse with GCC. Log: fix dock plugin numeric sorting Bug: https://github.com/linuxdeepin/dde-control-center
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MyLeeJiEun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @MyLeeJiEun. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes Dock plugin natural sorting for names beginning with digits by using the system locale instead of QLocale::c(), enabling QCollator numeric mode under the current ICU implementation. Flow diagram for Dock plugin numeric sortingflowchart TD
A["Dock plugin compares names"] --> B{"Names begin with digits?"}
B -->|Yes| C["Create QCollator with QLocale()"]
C --> D["setNumericMode(true)"]
D --> E["Compare using natural numeric order"]
B -->|No| F["Use existing string-group sorting"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
TAG Bot New tag: 6.1.106 |
|
TAG Bot New tag: 6.1.107 |
|
TAG Bot New tag: 6.1.109 |
缺陷说明
src/plugin-dock/operation/dockpluginsortproxymodel.cpp第 51 行使用QCollator digitCollator(QLocale::c())构造排序器。QLocale::c()对应 C/POSIX locale,在当前 ICU 实现下不支持 numeric mode,导致setNumericMode(true)被静默忽略,Dock 插件中以数字开头的名称按字典序而非数值序排列(如"10"排在"2"之前)。修改内容
将
QCollator的 locale 由QLocale::c()(C/POSIX locale)改为系统默认 localeQLocale(),使setNumericMode(true)在 ICU 实现下正常生效;使用花括号初始化避免 C++ most vexing parse。CJK 段使用的显式中文 locale 未改动。仅此一处改动(+1/-1)。验证情况
QLocale::c()后 3 个用例 FAILED,确认缺陷存在且修复有效Log: fix dock plugin numeric sorting
Bug: https://github.com/linuxdeepin/dde-control-center
Summary by Sourcery
Bug Fixes: