Skip to content

fix: use system locale for QCollator to enable numeric sorting in dock plugin - #3440

Open
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dock-plugin-numeric-sort
Open

MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dock-plugin-numeric-sort

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

缺陷说明

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 digitCollator(QLocale::c());
+        QCollator digitCollator{QLocale()};

将 QCollator 的 locale 由 QLocale::c()(C/POSIX locale)改为系统默认 locale QLocale(),使 setNumericMode(true) 在 ICU 实现下正常生效;使用花括号初始化避免 C++ most vexing parse。CJK 段使用的显式中文 locale 未改动。仅此一处改动(+1/-1)。

验证情况

  • UT 验证:27/27 用例通过(含 3 个原 SKIP 用例),覆盖率 100% 行/函数
  • 负向对照:回退为 QLocale::c() 后 3 个用例 FAILED,确认缺陷存在且修复有效
  • 编译验证:GCC 12.3.0 + Qt 6.8.0 编译通过

Log: fix dock plugin numeric sorting
Bug: https://github.com/linuxdeepin/dde-control-center

Summary by Sourcery

Bug Fixes:

  • Restore numeric sorting for digit-prefixed Dock plugin names by using the system locale with numeric collation.

…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
@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

@deepin-ci-robot

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes 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 sorting

flowchart 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"]
Loading

File-Level Changes

Change Details Files
Switch numeric-name sorting to a system-locale QCollator so ICU numeric mode is honored, while preserving case-insensitive comparison and the existing CJK sorting path.
  • Replace the C/POSIX locale with the default system locale.
  • Use brace initialization for the collator.
  • Keep numeric mode and case-insensitive settings unchanged.
src/plugin-dock/operation/dockpluginsortproxymodel.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.106
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3497

@deepin-bot

deepin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.107
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3503

@deepin-bot

deepin-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.109
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3545

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants