Skip to content

feat: add package name search configuration#594

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-addsearch-package
Jul 4, 2025
Merged

feat: add package name search configuration#594
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-addsearch-package

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 4, 2025

Copy link
Copy Markdown
Contributor
  1. Added new DConfig setting "searchPackage" to control package name search functionality
  2. Implemented package name search in SearchFilterProxyModel when enabled
  3. Added DConfig monitoring to dynamically update search behavior when setting changes
  4. Package name search includes exact match, starts with, and contains matching
  5. Added desktopId comparison in calculateWeight method for package name matching

The changes allow users to enable/disable package name searching through DConfig, providing more flexible search options. This is particularly useful for technical users who may want to search applications by their package names.

feat: 添加包名搜索配置功能

  1. 新增 DConfig 设置项 "searchPackage" 用于控制包名搜索功能
  2. 在 SearchFilterProxyModel 中实现包名搜索功能(当启用时)
  3. 添加 DConfig 监听以动态更新搜索行为
  4. 包名搜索支持精确匹配、开头匹配和包含匹配
  5. 在 calculateWeight 方法中添加 desktopId 比较用于包名匹配

这些改动允许用户通过 DConfig 启用/禁用包名搜索功能,提供更灵活的搜索选
项。对于技术用户来说特别有用,他们可能希望通过包名来搜索应用程序。

Summary by Sourcery

Enable users to search applications by package name by adding a DConfig-controlled switch and matching logic in SearchFilterProxyModel

New Features:

  • Add DConfig setting searchPackage to toggle package name search
  • Extend SearchFilterProxyModel to include desktopId-based matching (exact, prefix, substring) when enabled
  • Monitor DConfig changes to dynamically update search behavior

@sourcery-ai

sourcery-ai Bot commented Jul 4, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR integrates a new DConfig-based toggle to enable or disable package name searching globally and extends the existing SearchFilterProxyModel to dynamically react to configuration changes and weight matches against the app’s desktopId when enabled.

Sequence diagram for dynamic update of search behavior via DConfig

sequenceDiagram
    participant User
    participant DConfig
    participant SearchFilterProxyModel

    User->>DConfig: Change "searchPackage" setting
    DConfig-->>SearchFilterProxyModel: valueChanged("searchPackage")
    SearchFilterProxyModel->>DConfig: value("searchPackage", false)
    SearchFilterProxyModel->>SearchFilterProxyModel: Update m_searchPackageEnabled
    SearchFilterProxyModel->>SearchFilterProxyModel: invalidateFilter()
Loading

File-Level Changes

Change Details Files
Integrate DConfig for package search configuration
  • Include DConfig header
  • Declare m_dconfig and m_searchPackageEnabled in the proxy model
  • Initialize DConfig instance and load initial searchPackage value
  • Assert configuration validity
src/models/searchfilterproxymodel.cpp
src/models/searchfilterproxymodel.h
Add dynamic config listener to update search behavior
  • Connect DConfig::valueChanged to update m_searchPackageEnabled
  • Log config updates via qDebug
  • Call invalidateFilter() to reapply filters immediately
src/models/searchfilterproxymodel.cpp
Extend weight calculation with desktopId matching
  • Retrieve desktopId from model roles
  • Normalize and lowercase desktopId
  • Append exact/start/contains match functions when package search is enabled
src/models/searchfilterproxymodel.cpp
Expose searchPackage setting in JSON schema
  • Add searchPackage key to org.deepin.ds.launchpad.json configuration
src/models/org.deepin.ds.launchpad.json

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 @wjyrich - I've reviewed your changes - here's some feedback:

  • Pass this as the parent in DConfig::create to ensure the DConfig instance is properly cleaned up instead of leaking.
  • Move m_dconfig and m_searchPackageEnabled into a private section in the header to avoid exposing internal state.
  • Extract the desktopId search clauses out of calculateWeight into a helper method to keep the weight logic more focused.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Pass `this` as the parent in DConfig::create to ensure the DConfig instance is properly cleaned up instead of leaking.
- Move m_dconfig and m_searchPackageEnabled into a private section in the header to avoid exposing internal state.
- Extract the desktopId search clauses out of calculateWeight into a helper method to keep the weight logic more focused.

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.

@wjyrich wjyrich force-pushed the feat-addsearch-package branch 2 times, most recently from d4586aa to 80cabf6 Compare July 4, 2025 08:29
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • searchfilterproxymodel.cpp中,m_dconfig的初始化应该放在构造函数的初始化列表中,以提高代码的可读性和性能。
  • Q_ASSERT_X用于检查配置文件的有效性,这是一个好的做法,但是应该确保在所有可能的情况下都有相应的错误处理机制。
  • calculateWeight函数中,desktopIdLower变量被创建但未在注释中说明其用途,应该添加注释来解释其作用。
  • m_searchPackageEnabled变量在配置变化时被更新,但是没有检查配置值是否真的发生了变化,直接更新可能会导致不必要的性能开销。
  • qDebug用于在配置变化时输出日志,这在调试阶段是合适的,但是在生产环境中应该避免使用qDebug,或者至少应该提供一种方式来启用或禁用这种日志输出。

是否建议立即修改:

BLumia
BLumia previously approved these changes Jul 4, 2025

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

一个可选建议

Comment thread src/models/org.deepin.ds.launchpad.json Outdated
1. Added new DConfig setting "searchPackage" to control package name
search functionality
2. Implemented package name search in SearchFilterProxyModel when
enabled
3. Added DConfig monitoring to dynamically update search behavior when
setting changes
4. Package name search includes exact match, starts with, and contains
matching
5. Added desktopId comparison in calculateWeight method for package
name matching

The changes allow users to enable/disable package name searching through
DConfig, providing more flexible search options. This is particularly
useful for technical users who may want to search applications by their
package names.

feat: 添加包名搜索配置功能

1. 新增 DConfig 设置项 "searchPackage" 用于控制包名搜索功能
2. 在 SearchFilterProxyModel 中实现包名搜索功能(当启用时)
3. 添加 DConfig 监听以动态更新搜索行为
4. 包名搜索支持精确匹配、开头匹配和包含匹配
5. 在 calculateWeight 方法中添加 desktopId 比较用于包名匹配

这些改动允许用户通过 DConfig 启用/禁用包名搜索功能,提供更灵活的搜索选
项。对于技术用户来说特别有用,他们可能希望通过包名来搜索应用程序。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, 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 commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 4, 2025

Copy link
Copy Markdown

This pr force merged! (status: behind)

@deepin-bot deepin-bot Bot merged commit 8ba54e2 into linuxdeepin:master Jul 4, 2025
6 of 8 checks passed
"description": "Whether to allow the search for Desktop ID during the search.",
"description[zh_CN]": "在搜索时候是否允许搜索Desktop ID。",
"permissions": "readwrite",
"visibility": "private"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

visibility为private,表明它是私有的配置,仅当前应用设置,你这个之后可能由dde-control-center改写吧,是不是应该是public的,

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.

4 participants