Skip to content

Conversation

@caixr23
Copy link
Contributor

@caixr23 caixr23 commented Dec 29, 2025

When adding a wireless device item, the code creates a WirelessOtherItem but its expanded state was not properly initialized. This caused the item to appear in an inconsistent state when first displayed. The fix explicitly sets the expanded state to true using the updateexpanded(true) method immediately after creating the WirelessOtherItem to ensure proper visual representation.

Influence:

  1. Test adding new wireless devices to verify they display correctly
  2. Check that wireless other items appear in expanded state by default
  3. Verify that child items under wireless other items are visible
  4. Test collapsing and expanding functionality still works properly

fix: 初始化无线其他项的展开状态

当添加无线设备项时,代码创建了WirelessOtherItem但其展开状态未正
确初始化。这导致项目首次显示时处于不一致的状态。修复方案在创建
WirelessOtherItem后立即使用updateexpanded(true)方法显式设置展开状态为 true,确保正确的视觉表示。

Influence:

  1. 测试添加新无线设备以验证其正确显示
  2. 检查无线其他项是否默认显示为展开状态
  3. 验证无线其他项下的子项是否可见
  4. 测试折叠和展开功能是否正常工作

PMS: BUG-287223

Summary by Sourcery

Bug Fixes:

  • Initialize the expanded state of newly created wireless "other" items so that they are expanded and display their child items on first render.

@caixr23 caixr23 requested a review from mhduiy December 29, 2025 07:03
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 29, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures newly created WirelessOtherItem instances for wireless devices start in an expanded state to maintain consistent initial UI behavior, while preserving existing add/collapse/expand flows.

Sequence diagram for initializing WirelessOtherItem expanded state on add

sequenceDiagram
    actor User
    participant UIWirelessView
    participant NetManagerPrivate
    participant NetWirelessOtherItemPrivate
    participant WirelessMineItem
    participant WirelessHiddenItem

    User->>UIWirelessView: AddWirelessDevice
    UIWirelessView->>NetManagerPrivate: onItemAdded(parentID, WirelessDeviceItem)

    NetManagerPrivate->>WirelessMineItem: create WirelessMineItem
    NetManagerPrivate->>NetManagerPrivate: addItem(WirelessMineItem, nullptr)

    NetManagerPrivate->>NetWirelessOtherItemPrivate: create WirelessOtherItem
    NetManagerPrivate->>NetWirelessOtherItemPrivate: updateexpanded(true)
    NetManagerPrivate->>NetManagerPrivate: addItem(WirelessOtherItem, WirelessDeviceItem)

    NetManagerPrivate->>WirelessHiddenItem: create WirelessHiddenItem
    NetManagerPrivate->>NetManagerPrivate: addItem(WirelessHiddenItem, WirelessOtherItem)

    NetManagerPrivate-->>UIWirelessView: WirelessDevice subtree added
    UIWirelessView-->>User: WirelessOtherItem visible expanded with children
Loading

Updated class diagram for NetManagerPrivate and NetWirelessOtherItemPrivate

classDiagram
    class NetManagerPrivate {
        +void onItemAdded(QString parentID, NetItemPrivate item)
        +void addItem(NetItemPrivate item, NetItemPrivate parent)
        -map~int,int~ m_deviceCount
    }

    class NetItemPrivate {
        +QString id()
    }

    class NetWirelessOtherItemPrivate {
        +void updateexpanded(bool expanded)
    }

    class WirelessMineItem {
    }

    class WirelessHiddenItem {
    }

    NetManagerPrivate --> NetItemPrivate : uses
    NetManagerPrivate --> NetWirelessOtherItemPrivate : creates
    NetManagerPrivate --> WirelessMineItem : creates
    NetManagerPrivate --> WirelessHiddenItem : creates
    NetWirelessOtherItemPrivate --> NetItemPrivate : inherits
Loading

File-Level Changes

Change Details Files
Initialize WirelessOtherItem instances in an expanded state immediately after creation to fix inconsistent initial UI display.
  • Call the expanded-state update method with a true argument right after creating a WirelessOtherItem instance for a wireless device item
  • Keep the existing sequence of adding the 'other' item under the wireless device and then adding its hidden child item unchanged
net-view/operation/netmanager.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

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码差异进行审查:

  1. 语法逻辑:
  • 代码语法正确,新增的一行 otherItem->updateexpanded(true); 符合 C++ 语法规范。
  • 从上下文看,这是在处理无线设备添加时的逻辑,设置其他网络项的展开状态是合理的。
  1. 代码质量:
  • 函数命名 updateexpanded 不符合驼峰命名法,建议改为 updateExpanded 更规范。
  • 缺少对 otherItem 指针的有效性检查,虽然在当前上下文中不太可能为空,但为了代码健壮性,建议添加空指针检查。
  1. 代码性能:
  • 这行代码的性能影响很小,只是设置一个布尔值,不会对性能造成明显影响。
  1. 代码安全:
  • 建议在调用 updateexpanded 前添加空指针检查:
if (otherItem) {
    otherItem->updateexpanded(true);
}

改进建议:

  1. 将函数名改为更规范的驼峰命名法
  2. 添加空指针检查以提高代码健壮性
  3. 建议在代码注释中说明为什么需要默认展开其他网络项,以便其他开发者理解设计意图

修改后的代码建议:

NetWirelessOtherItemPrivate *otherItem = NetItemNew(WirelessOtherItem, item->id() + ":Other");
if (otherItem) {
    // 默认展开其他网络项,方便用户查看可用网络
    otherItem->updateExpanded(true);
}
addItem(otherItem, item);

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 - I've left some high level feedback:

  • Since WirelessOtherItem should always start expanded, consider moving the updateexpanded(true) call into the WirelessOtherItem (or its private) initialization logic so callers don’t need to remember to manually set this state and to keep the invariant encapsulated in the class itself.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `WirelessOtherItem` should always start expanded, consider moving the `updateexpanded(true)` call into the `WirelessOtherItem` (or its private) initialization logic so callers don’t need to remember to manually set this state and to keep the invariant encapsulated in the class itself.

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: caixr23, mhduiy, robertkill

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

When adding a wireless device item, the code creates a WirelessOtherItem
but its expanded state was not properly initialized. This caused
the item to appear in an inconsistent state when first displayed.
The fix explicitly sets the expanded state to true using the
updateexpanded(true) method immediately after creating the
WirelessOtherItem to ensure proper visual representation.

Influence:
1. Test adding new wireless devices to verify they display correctly
2. Check that wireless other items appear in expanded state by default
3. Verify that child items under wireless other items are visible
4. Test collapsing and expanding functionality still works properly

fix: 初始化无线其他项的展开状态

当添加无线设备项时,代码创建了WirelessOtherItem但其展开状态未正
确初始化。这导致项目首次显示时处于不一致的状态。修复方案在创建
WirelessOtherItem后立即使用updateexpanded(true)方法显式设置展开状态为
true,确保正确的视觉表示。

Influence:
1. 测试添加新无线设备以验证其正确显示
2. 检查无线其他项是否默认显示为展开状态
3. 验证无线其他项下的子项是否可见
4. 测试折叠和展开功能是否正常工作

PMS: BUG-287223
@caixr23 caixr23 merged commit 3c098b1 into linuxdeepin:master Dec 30, 2025
13 of 18 checks passed
@caixr23 caixr23 deleted the BUG-287223 branch December 30, 2025 02:41
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