Skip to content

fix: fix blank area in security update log details view#312

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
xionglinlin:master
Jun 26, 2026
Merged

fix: fix blank area in security update log details view#312
mhduiy merged 1 commit into
linuxdeepin:masterfrom
xionglinlin:master

Conversation

@xionglinlin

Copy link
Copy Markdown
Contributor
  1. Remove the dependency on getDetailInfos Q_INVOKABLE method by exposing DetailInfos and Expanded roles directly in the model
  2. Add setExpanded Q_INVOKABLE method to the model to properly manage the expanded state
  3. Sync data efficiently using syncData which avoids unnecessary beginResetModel/endResetModel when the pointer list hasn't changed
  4. Simplify the QML view to use model.expanded and model.detailInfos directly from the model roles
  5. Move the showDetails property from local state to model-backed state to persist expansion correctly when data refreshes
  6. Use the model's setExpanded method when clicking "View More" or "Collapse" buttons
  7. Add setExpanded/isExpanded methods to UpdateItemInfo to persist the expanded state per item
  8. Fix the issue where the "View More" button was incorrectly visible due to stale local state
  9. Replace clearAllData+addUpdateData pattern with syncData to prevent unnecessary model reset when only the selected state changes

Log: Fixed security update log details display with proper expansion state management

Influence:

  1. Verify "View More" button appears correctly for security update items with detail logs
  2. Click "View More" and verify the detail information displays correctly
  3. Click "Collapse" and verify the details hide properly
  4. Verify the expanded state persists when other updates or UI refreshes occur
  5. Verify the "View More" button shows for items without details and does not expand to avoid blank areas
  6. Test that checking/unchecking update items does not cause the list to scroll or collapse details
  7. Verify the detail content displays correctly for both security updates and regular updates

fix: 修复安全更新日志详情页出现空白区域问题

  1. 通过直接暴露 DetailInfos 和 Expanded 角色到模型中,移除对 getDetailInfos Q_INVOKABLE 方法的依赖
  2. 在模型中添加 setExpanded Q_INVOKABLE 方法来正确管理展开状态
  3. 使用 syncData 方法高效同步数据,避免在指针列表未变化时触发不必要的 beginResetModel/endResetModel
  4. 简化 QML 视图,直接使用模型角色 model.expanded 和 model.detailInfos
  5. 将 showDetails 属性从本地状态迁移到模型支持的存储,以在数据刷新时正确 保持展开状态
  6. 点击"查看详情"或"收起"按钮时,使用模型的 setExpanded 方法
  7. 在 UpdateItemInfo 中添加 setExpanded/isExpanded 方法,以持久化每个项 目的展开状态
  8. 修复由于本地状态过期导致"查看详情"按钮显示异常的问题
  9. 使用 syncData 替代 clearAllData+addUpdateData 模式,防止仅在选中状态 变化时触发不必要的模型重置

Log: 修复安全更新日志详情显示问题,改进展开状态管理

Influence:

  1. 验证安全更新项目在有详情日志时正确显示"查看详情"按钮
  2. 点击"查看详情"后验证详情信息正确显示
  3. 点击"收起"后验证详情正确隐藏
  4. 验证在其他更新或UI刷新时展开状态保持不变
  5. 验证无详情项目不显示"查看详情"按钮,避免出现空白区域
  6. 测试勾选/取消勾选更新项目时,不会导致列表滚动或详情折叠
  7. 验证详情内容在安全更新和普通更新中都能正确显示

PMS: BUG-367683
Change-Id: I383dadacaf4217e28e25b32e7ce55aebaf32506c

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

Sorry @xionglinlin, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

1. Remove the dependency on getDetailInfos Q_INVOKABLE method by
exposing DetailInfos and Expanded roles directly in the model
2. Add setExpanded Q_INVOKABLE method to the model to properly manage
the expanded state
3. Sync data efficiently using syncData which avoids unnecessary
beginResetModel/endResetModel when the pointer list hasn't changed
4. Simplify the QML view to use model.expanded and model.detailInfos
directly from the model roles
5. Move the showDetails property from local state to model-backed state
to persist expansion correctly when data refreshes
6. Use the model's setExpanded method when clicking "View More" or
"Collapse" buttons
7. Add setExpanded/isExpanded methods to UpdateItemInfo to persist the
expanded state per item
8. Fix the issue where the "View More" button was incorrectly visible
due to stale local state
9. Replace clearAllData+addUpdateData pattern with syncData to prevent
unnecessary model reset when only the selected state changes

Log: Fixed security update log details display with proper expansion
state management

Influence:
1. Verify "View More" button appears correctly for security update items
with detail logs
2. Click "View More" and verify the detail information displays
correctly
3. Click "Collapse" and verify the details hide properly
4. Verify the expanded state persists when other updates or UI refreshes
occur
5. Verify the "View More" button shows for items without details and
does not expand to avoid blank areas
6. Test that checking/unchecking update items does not cause the list to
scroll or collapse details
7. Verify the detail content displays correctly for both security
updates and regular updates

fix: 修复安全更新日志详情页出现空白区域问题

1. 通过直接暴露 DetailInfos 和 Expanded 角色到模型中,移除对
getDetailInfos Q_INVOKABLE 方法的依赖
2. 在模型中添加 setExpanded Q_INVOKABLE 方法来正确管理展开状态
3. 使用 syncData 方法高效同步数据,避免在指针列表未变化时触发不必要的
beginResetModel/endResetModel
4. 简化 QML 视图,直接使用模型角色 model.expanded 和 model.detailInfos
5. 将 showDetails 属性从本地状态迁移到模型支持的存储,以在数据刷新时正确
保持展开状态
6. 点击"查看详情"或"收起"按钮时,使用模型的 setExpanded 方法
7. 在 UpdateItemInfo 中添加 setExpanded/isExpanded 方法,以持久化每个项
目的展开状态
8. 修复由于本地状态过期导致"查看详情"按钮显示异常的问题
9. 使用 syncData 替代 clearAllData+addUpdateData 模式,防止仅在选中状态
变化时触发不必要的模型重置

Log: 修复安全更新日志详情显示问题,改进展开状态管理

Influence:
1. 验证安全更新项目在有详情日志时正确显示"查看详情"按钮
2. 点击"查看详情"后验证详情信息正确显示
3. 点击"收起"后验证详情正确隐藏
4. 验证在其他更新或UI刷新时展开状态保持不变
5. 验证无详情项目不显示"查看详情"按钮,避免出现空白区域
6. 测试勾选/取消勾选更新项目时,不会导致列表滚动或详情折叠
7. 验证详情内容在安全更新和普通更新中都能正确显示

PMS: BUG-367683
Change-Id: I383dadacaf4217e28e25b32e7ce55aebaf32506c
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:75分

■ 【总体评价】

代码通过指针比较和状态下沉有效解决了列表滚动跳动问题,但存在QML代码重复及Model信号频发的非安全缺陷。
逻辑基本正确但因QML颜色代码大量重复和collapseAll信号未合并扣25分。

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

syncData通过QList的operator==比较指针地址与顺序,逻辑严密;setExpanded和collapseAll边界检查完善。UpdateList.qml在Component.onDestruction中调用collapseAll()能确保状态清理,但会在整个列表组件销毁时无差别收起所有已展开项,可能在某些页面切换场景下导致非预期的状态重置。
潜在问题:组件销毁时全量收起可能导致跨页面返回时丢失展开上下文。
建议:考虑仅在特定清理时机或按需重置展开状态,而非在组件销毁时强制collapseAll。

  • 2.代码质量(一般)✕

C++侧重构干净,移除了冗余的addUpdateData和getDetailInfos方法。但QML侧存在严重的代码重复,D.DTK.themeType == D.ApplicationHelper.LightType ? Qt.rgba(0, 0, 0, 1) : Qt.rgba(1, 1, 1, 1)这段主题色判断逻辑在UpdateList.qml中出现了至少4次,严重违反DRY原则。
潜在问题:主题色硬编码且重复,后续维护需多处同步修改,极易遗漏引发UI不一致。
建议:在UpdateList.qml顶层或公共组件中提取一个只读属性如property color textColor: D.DTK.themeType === D.ApplicationHelper.LightType ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1),各Label直接引用该属性。

  • 3.代码性能(存在性能问题)✕

syncData的指针比较极大优化了勾选场景的性能。但新增的collapseAll()方法在updatelistmodel.cpp中通过for循环逐个调用emit dataChanged,当列表项较多且存在大量展开项时,会触发N次独立的视图更新,造成不必要的重绘开销。
潜在问题:循环内频繁发射dataChanged信号导致QML视图多次重绘。
建议:将collapseAll()中的多次发射合并为一次批量发射,避免循环内触发重绘。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及前端UI状态管理与Model数据同步,未引入新的外部输入处理、命令执行或权限变更逻辑,无安全风险。

  • 建议:保持当前安全的编码实践,后续若detailInfos中link字段需做更严格校验,建议在C++层面对URL协议进行白名单过滤。

■ 【改进建议代码示例】

// updatelistmodel.cpp
void UpdateListModel::collapseAll()
{
    bool hasChanged = false;
    for (int i = 0; i < m_updateLists.count(); ++i) {
        if (m_updateLists[i]->isExpanded()) {
            m_updateLists[i]->setExpanded(false);
            hasChanged = true;
        }
    }
    // 批量通知视图刷新,避免循环内多次触发重绘
    if (hasChanged && !m_updateLists.isEmpty()) {
        emit dataChanged(index(0), index(m_updateLists.count() - 1), { Expanded });
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, xionglinlin

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

@mhduiy mhduiy merged commit cd7d18e into linuxdeepin:master Jun 26, 2026
9 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