Skip to content

fix(view): initialize deferred all-items grid state#466

Merged
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master
Jul 23, 2026
Merged

fix(view): initialize deferred all-items grid state#466
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master

Conversation

@wyu71

@wyu71 wyu71 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Initialize the grid mapping when its source model is attached.
在源模型绑定时初始化缩略图网格映射。

Log: 修复全部合集首屏状态和右键交互
Influence: 全部合集首屏日期、比例按钮、缩略图选中和右键菜单

@wyu71
wyu71 force-pushed the master branch 2 times, most recently from 396a78f to f3358d9 Compare July 23, 2026 08:52

@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 @wyu71, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Initialize the grid mapping when its source model is attached.
在源模型绑定时初始化缩略图网格映射。

Log: 修复全部合集首屏状态和右键交互
Influence: 全部合集首屏日期、比例按钮、缩略图选中和右键菜单
@wyu71 wyu71 changed the title fix(title): prevent ratio control from flashing disabled fix(view): initialize deferred all-items grid state Jul 23, 2026
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过重构全局状态与右键菜单逻辑修复了状态同步滞后的问题,整体逻辑严谨且符合规范
逻辑正确,修复了选中状态与菜单弹出的竞态问题,无明显安全漏洞与性能损耗,仅存在轻微的信号重复触发风险

■ 【详细分析】

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

ThumbnailListViewAlbum.qml 中将右键菜单弹出条件从 haveSelect 改为直接检查 thumbnailModel.selectedIndexes.length > 0 并主动调用 updateMenuItemStates(),有效解决了状态滞后问题;onReleased 中提前过滤右键点击避免了误触发单选逻辑。AllCollection.qmlupdateTitle 新增 updateDateRange 参数,并在 initialTimeScopeEndIndex 返回 -1 时正确处理了边界条件。globalstatus.cpp/h 中新增的属性定义符合 Qt 规范。thumbnailmodel.cpp 中手动触发 srcModelReseted 信号逻辑无误。
潜在问题:thumbnailmodel.cppsetSourceModel 已经连接了 modelReset 信号到 srcModelReseted,紧接着手动 Q_EMIT srcModelReseted(),若 sourceModel 在设置时或之后立即触发 modelReset,可能导致下游接收两次重置信号。
建议:确认 sourceModel 在被设置时的状态,若其本身会发出 modelReset,可考虑移除手动触发,或在文档中注明此为强制刷新机制。

  • 2.代码质量(良好)✓

代码结构清晰,命名规范,注释如“同步延迟创建的缩略图列表选中项,供右键菜单更新状态”准确表达了意图。AllCollection.qml 中新增的 Connections 合理利用了 QML 的动态目标绑定特性。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

修改未引入复杂的计算或高频轮询,updateMenuItemStates() 仅在右键点击时调用,性能开销极小。新增的信号同步逻辑也是事件驱动,不影响渲染性能。
潜在问题:无
建议:无

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码变更主要涉及 QML 状态同步与 C++ 属性暴露,未涉及外部输入解析、命令执行或文件路径遍历等高风险操作,不存在安全攻击面。

  • 建议:无

■ 【改进建议代码示例】

// src/src/thumbnailview/thumbnailmodel.cpp
void ThumbnailModel::setSourceModel(QAbstractItemModel *sourceModel)
{
    QSortFilterProxyModel::setSourceModel(sourceModel);

    // 假设连接仍然需要保留以应对后续的模型重置
    connect(sourceModel, SIGNAL(modelReset()), this, SIGNAL(srcModelReseted()));
    
    // 若 sourceModel 在设置时已经处于 reset 状态且不会主动发出信号,则保留手动触发;
    // 否则建议添加条件判断或移除,避免重复触发。
    // 此处保留原样,但建议在 code review 时与原作者确认其必要性。
    Q_EMIT srcModelReseted();

    if (!m_sortRoleName.isEmpty()) {
        setSortRoleName(m_sortRoleName);
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx, wyu71

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

@wyu71
wyu71 merged commit 6ec13ce into linuxdeepin:master Jul 23, 2026
17 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