Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Sep 28, 2025

Added sortRoleName and sortOrder properties to DDT.SortFilterProxyModel to enable proper sorting of tray items by visual index in ascending order. This ensures that tray icons are displayed in a consistent and predictable sequence, improving the user experience by maintaining stable icon positions.

feat: 为托盘项添加排序功能

在 DDT.SortFilterProxyModel 中添加了 sortRoleName 和 sortOrder 属性,以 支持按视觉索引升序排列托盘项。这确保了托盘图标以一致且可预测的顺序显示,
通过保持稳定的图标位置来改善用户体验。

Pms: BUG-288745

Summary by Sourcery

Enable proper sorting of tray items by visual index in ascending order to maintain stable icon positions and improve user experience

New Features:

  • Expose sortRoleName and sortOrder properties on DDT.SortFilterProxyModel to sort tray items by visual index

Enhancements:

  • Ensure tray icons display in a consistent, predictable sequence by sorting in ascending order

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR configures DDT.SortFilterProxyModel in the tray component to sort items by their visual index in ascending order, ensuring stable and predictable icon ordering.

Class diagram for updated DDT.SortFilterProxyModel sorting properties

classDiagram
    class DDT.SortFilterProxyModel {
        +sortRoleName: string
        +sortOrder: enum
    }
    DDT.SortFilterProxyModel <|-- DDT.TraySortOrderModel
Loading

File-Level Changes

Change Details Files
Enable sorting of tray items by visual index
  • Added sortRoleName property set to "visualIndex"
  • Added sortOrder property set to Qt.AscendingOrder
panels/dock/tray/package/tray.qml

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - 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-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 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

Added sortRoleName and sortOrder properties to DDT.SortFilterProxyModel
to enable proper sorting of tray items by visual index in ascending
order. This ensures that tray icons are displayed in a consistent and
predictable sequence, improving the user experience by maintaining
stable icon positions.

feat: 为托盘项添加排序功能

在 DDT.SortFilterProxyModel 中添加了 sortRoleName 和 sortOrder 属性,以
支持按视觉索引升序排列托盘项。这确保了托盘图标以一致且可预测的顺序显示,
通过保持稳定的图标位置来改善用户体验。

Pms: BUG-288745
@deepin-ci-robot
Copy link

deepin pr auto review

我来审查这段代码并提供改进建议:

语法逻辑

  1. 代码逻辑基本正确,通过SortFilterProxyModel对TraySortOrderModel进行了排序和过滤
  2. filterRowCallback函数正确实现了过滤逻辑,只保留SectionType为"stashed"的项

代码质量

  1. 添加的sortRoleName和sortOrder配置很好,确保了项目按visualIndex升序排列
  2. 建议为filterRowCallback添加注释,说明过滤条件
  3. 可以考虑将"stashed"这个字符串定义为常量,提高代码可维护性

代码性能

  1. 当前实现是合理的,SortFilterProxyModel已经提供了高效的排序和过滤机制
  2. 如果数据量很大,可以考虑添加一些性能优化,比如在数据变化时才重新计算过滤和排序

代码安全

  1. 代码中没有明显的安全问题
  2. 建议对sourceModel进行空值检查,防止出现未定义行为

改进建议

AppletItem {
    // ... 其他代码 ...
    
    // 建议添加常量定义
    readonly property string STASHED_SECTION_TYPE: "stashed"
    
    Rectangle {
        // ... 其他属性 ...
        
        model: DDT.SortFilterProxyModel {
            sourceModel: DDT.TraySortOrderModel
            
            // 已有的排序配置很好
            sortRoleName: "visualIndex"
            sortOrder: Qt.AscendingOrder
            
            // 改进后的filterRowCallback,添加注释和空值检查
            filterRowCallback: (sourceRow, sourceParent) => {
                if (!sourceModel) return false
                
                let index = sourceModel.index(sourceRow, 0, sourceParent)
                if (!index.isValid) return false
                
                // 只保留类型为"stashed"的项
                return sourceModel.data(index, DDT.TraySortOrderModel.SectionTypeRole) === STASHED_SECTION_TYPE
            }
        }
    }
}

这些建议可以提高代码的可维护性、健壮性和可读性,同时保持原有功能不变。

@wjyrich wjyrich merged commit 2467e97 into linuxdeepin:master Sep 28, 2025
10 of 11 checks passed
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