Skip to content

refactor: delegate folder management to dde-shell shared model - #832

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-folders
Open

wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-folders

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
  1. Replace ItemArrangementProxyModel's own folder/pagination/persistence logic with a thin presentation adapter backed by the dde-apps shared folder model through QMetaObject::invokeMethod
  2. Remove ItemsPage usage from the item arrangement model and simplify ItemsPageModel to track only page count from the adapter
  3. Add folderApplicationBackend property and wire appGroupModel from the dde-apps applet into ItemArrangementProxyModel::setFolderModel in LauncherItem
  4. Allow dock/undock operations on internal folder IDs (except internal/ folders/0) in DesktopIntegration and AppItemMenu
  5. Bump dde-shell dependency to >> 2.0.60
  6. Stop compiling itemspage.cpp in production; keep legacy ItemsPage sources only for the legacy test target
  7. Add itemarrangementproxytest covering model identity, forwarding, provider lifetime, and role queries

Log: Launcher folders are now managed by the shared dde-apps model, enabling folders to be sent to and removed from the dock

Influence:

  1. Verify launcher folder display, paging and icon previews still work after the refactor
  2. Create, rename and delete folders and confirm changes persist across restarts
  3. Drag and drop apps between folders, pages and the top level, including joining/creating folders
  4. Send folder entries (internal/folders/N) to the dock and remove them again
  5. Confirm that internal/folders/0 cannot be added to the dock and the menu item stays disabled for it
  6. Verify app installation/removal updates folder contents and page counts without crashes
  7. Run the new itemarrangementproxytest and the existing test suite
  8. Check that older saved item-arrangement.ini data migrates or is ignored gracefully

refactor: 将文件夹管理委托给 dde-shell 共享模型

  1. 移除 ItemArrangementProxyModel 自有的文件夹、分页和持久化逻辑,改为 通过 QMetaObject::invokeMethod 调用 dde-apps 共享文件夹模型的轻量展示适 配层
  2. 从排列模型中移除 ItemsPage 依赖,并将 ItemsPageModel 简化为仅跟踪适配 层的页数
  3. 在 LauncherItem 中新增 folderApplicationBackend 属性,并将 dde-apps applet 的 appGroupModel 接入 ItemArrangementProxyModel::setFolderModel
  4. 在 DesktopIntegration 和 AppItemMenu 中允许对内部文件夹 ID(internal/ folders/0 除外)执行停靠/取消停靠操作
  5. 将 dde-shell 依赖版本提升至 >> 2.0.60
  6. 生产构建不再编译 itemspage.cpp,仅保留 ItemsPage 源码供旧测试目标使用
  7. 新增 itemarrangementproxytest,覆盖模型身份、转发、提供者生命周期和角 色查询

Log: 启动器文件夹改由 dde-apps 共享模型管理,支持将文件夹发送到任务栏或
从任务栏移除

Influence:

  1. 验证重构后启动器文件夹的显示、分页和图标预览功能正常
  2. 创建、重命名和删除文件夹,确认重启后更改仍然保留
  3. 测试应用在文件夹、页面和顶层之间的拖放,包括合并和创建文件夹
  4. 将文件夹项(internal/folders/N)发送到任务栏并再次移除
  5. 确认 internal/folders/0 无法添加到任务栏且其菜单项保持禁用
  6. 验证应用安装/卸载后文件夹内容和页数更新且不崩溃
  7. 运行新增的 itemarrangementproxytest 及现有测试套件
  8. 检查旧的 item-arrangement.ini 数据能否正常迁移或被安全忽略

PMS: TASK-397247 TASK-396759

Summary by Sourcery

Delegate launcher folder management to the shared dde-apps model while retaining the launcher’s presentation and integration interfaces.

New Features:

  • Enable docking and undocking launcher folders, excluding the reserved root folder.

Bug Fixes:

  • Expose and preserve autostart state through desktop integration.

Enhancements:

  • Delegate folder arrangement, pagination, persistence, naming, icon previews, and drag-and-drop operations to the shared dde-apps folder model through a lightweight adapter.
  • Simplify page tracking to consume page counts from the arrangement adapter and remove production dependence on the legacy ItemsPage implementation.

Build:

  • Stop compiling legacy ItemsPage sources in production while retaining them for the legacy test target.
  • Update the dde-shell dependency requirement to version 2.0.60 or newer.

Tests:

  • Add adapter coverage for model identity, role forwarding, folder-provider lifetime, pagination, mutations, and icon/name queries.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

This refactor makes dde-apps the owner of launcher folder arrangement, pagination, persistence, and mutations, while dde-shell exposes a thin adapter that integrates the shared model with launcher presentation and docking behavior.

Sequence diagram for folder arrangement forwarding

sequenceDiagram
    participant View as Launcher view
    participant Adapter as ItemArrangementProxyModel
    participant FolderModel as dde-apps shared folder model
    participant Apps as AppsModel

    View->>Adapter: commitDndOperation(dragId, dropId, op, pageHint)
    Adapter->>FolderModel: rearrange(dragId, dropId, op, pageHint)
    FolderModel-->>Adapter: arrangementChanged()
    Adapter->>Adapter: refreshArrangement()
    Adapter-->>View: dataChanged and page-count signals

    FolderModel-->>Adapter: folderInfo(id)
    Adapter-->>View: folder icons and position roles
Loading

Sequence diagram for folder docking

sequenceDiagram
    actor User
    participant Menu as AppItemMenu
    participant Desktop as DesktopIntegration
    participant Dock as Dock integration

    User->>Menu: Trigger dock menu
    Menu->>Desktop: isDockedApp(desktopId)
    Desktop->>Dock: isDocked(desktopId)
    Dock-->>Desktop: dock state
    Desktop-->>Menu: dock state
    User->>Menu: Trigger send or remove
    Menu->>Desktop: sendToDock(desktopId) or removeFromDock(desktopId)
    Desktop->>Dock: sendToDock(desktopId) or removeFromDock(desktopId)
Loading

File-Level Changes

Change Details Files
Replace locally owned folder arrangement and persistence with a presentation adapter over the dde-apps shared model.
  • Convert the arrangement model to a list model combining AppsModel rows with dynamically discovered folder IDs.
  • Forward folder queries and mutations through QMetaObject::invokeMethod.
  • Preserve model updates, folder filtering, icon previews, positions, and page-count notifications.
src/models/itemarrangementproxymodel.cpp
src/models/itemarrangementproxymodel.h
Wire the shared folder provider into the launcher and simplify page tracking.
  • Expose DesktopIntegration as the folder application backend.
  • Pass the dde-apps appGroupModel to the arrangement adapter.
  • Track only the adapter's top-level page count in ItemsPageModel.
  • Remove production compilation of ItemsPage while retaining it for legacy tests.
shell-launcher-applet/launcheritem.cpp
shell-launcher-applet/launcheritem.h
src/models/itemspagemodel.cpp
src/models/itemspagemodel.h
src/models/CMakeLists.txt
tests/CMakeLists.txt
Enable docking and undocking of supported internal folder entries.
  • Route internal folder IDs directly to dock integration.
  • Keep internal/folders/0 excluded while allowing other internal folders through the menu.
desktopintegration.cpp
qml/AppItemMenu.qml
Add adapter-focused regression coverage and update the dde-shell dependency.
  • Test folder filtering, identity, role forwarding, mutation forwarding, persistent indexes, page counts, provider destruction, and icon/name queries.
  • Raise the dde-shell build dependency to the shared-model version.
tests/itemarrangementproxytest.cpp
debian/control

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 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

1. Replace ItemArrangementProxyModel's own folder/pagination/persistence
logic with a thin presentation adapter backed by the dde-apps shared
folder model through QMetaObject::invokeMethod
2. Remove ItemsPage usage from the item arrangement model and simplify
ItemsPageModel to track only page count from the adapter
3. Add folderApplicationBackend property and wire appGroupModel from
the dde-apps applet into ItemArrangementProxyModel::setFolderModel in
LauncherItem
4. Allow dock/undock operations on internal folder IDs (except internal/
folders/0) in DesktopIntegration and AppItemMenu
5. Bump dde-shell dependency to >> 2.0.60
6. Stop compiling itemspage.cpp in production; keep legacy ItemsPage
sources only for the legacy test target
7. Add itemarrangementproxytest covering model identity, forwarding,
provider lifetime, and role queries

Log: Launcher folders are now managed by the shared dde-apps model,
enabling folders to be sent to and removed from the dock

Influence:
1. Verify launcher folder display, paging and icon previews still work
after the refactor
2. Create, rename and delete folders and confirm changes persist across
restarts
3. Drag and drop apps between folders, pages and the top level,
including joining/creating folders
4. Send folder entries (internal/folders/N) to the dock and remove them
again
5. Confirm that internal/folders/0 cannot be added to the dock and the
menu item stays disabled for it
6. Verify app installation/removal updates folder contents and page
counts without crashes
7. Run the new itemarrangementproxytest and the existing test suite
8. Check that older saved item-arrangement.ini data migrates or is
ignored gracefully

refactor: 将文件夹管理委托给 dde-shell 共享模型

1. 移除 ItemArrangementProxyModel 自有的文件夹、分页和持久化逻辑,改为
通过 QMetaObject::invokeMethod 调用 dde-apps 共享文件夹模型的轻量展示适
配层
2. 从排列模型中移除 ItemsPage 依赖,并将 ItemsPageModel 简化为仅跟踪适配
层的页数
3. 在 LauncherItem 中新增 folderApplicationBackend 属性,并将 dde-apps
applet 的 appGroupModel 接入 ItemArrangementProxyModel::setFolderModel
4. 在 DesktopIntegration 和 AppItemMenu 中允许对内部文件夹 ID(internal/
folders/0 除外)执行停靠/取消停靠操作
5. 将 dde-shell 依赖版本提升至 >> 2.0.60
6. 生产构建不再编译 itemspage.cpp,仅保留 ItemsPage 源码供旧测试目标使用
7. 新增 itemarrangementproxytest,覆盖模型身份、转发、提供者生命周期和角
色查询

Log: 启动器文件夹改由 dde-apps 共享模型管理,支持将文件夹发送到任务栏或
从任务栏移除

Influence:
1. 验证重构后启动器文件夹的显示、分页和图标预览功能正常
2. 创建、重命名和删除文件夹,确认重启后更改仍然保留
3. 测试应用在文件夹、页面和顶层之间的拖放,包括合并和创建文件夹
4. 将文件夹项(internal/folders/N)发送到任务栏并再次移除
5. 确认 internal/folders/0 无法添加到任务栏且其菜单项保持禁用
6. 验证应用安装/卸载后文件夹内容和页数更新且不崩溃
7. 运行新增的 itemarrangementproxytest 及现有测试套件
8. 检查旧的 item-arrangement.ini 数据能否正常迁移或被安全忽略

PMS: TASK-397247 TASK-396759
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 96 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交是一个重构,将文件夹管理逻辑从 dde-launchpad 内部实现委托到 dde-shell 共享模型。 ItemArrangementProxyModel 从 QConcatenateTablesProxyModel(内含 ItemsPage 管理和 QSettings 持久化) 简化为一个轻量的 QAbstractListModel 适配器,通过 QMetaObject::invokeMethod 将所有操作委托给外部模型。 代码删除了约360行复杂逻辑,新增了完善的单元测试。四维度均通过,无安全漏洞,代码质量显著提升。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议在 dataChanged 信号连接中增加 role 过滤,仅在相关 role(如 DesktopIdRole、IconNameRole)变化时触发 refreshArrangement()', '建议对 match() 返回空列表的情况增加 qCWarning 日志,便于调试']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议为 rebuildFolders()、data() 等关键方法增加注释,说明委托模式和行偏移计算逻辑', '建议将 internal/folders/ 前缀检查提取为辅助函数,减少 desktopintegration.cpp 中的重复', '建议在后续提交中修正 creatEmptyPage 拼写错误']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['可考虑在 setFolderModel 时缓存 folder id 到 name 的映射,避免 data() 中每次 match() 查找', '建议 dataChanged 连接增加 role 过滤参数,减少不必要的 refreshArrangement() 调用']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 建议优化:在构造函数中为 dataChanged 连接增加 role 过滤
// 修改前:
connect(&apps, &QAbstractItemModel::dataChanged, this, [this] { refreshArrangement(); });

// 修改后:仅在相关 role 变化时刷新
connect(&apps, &QAbstractItemModel::dataChanged, this, [this](const QModelIndex &, const QModelIndex &, const QList<int> &roles) {
    if (roles.isEmpty() ||
        roles.contains(AppsModel::DesktopIdRole) ||
        roles.contains(AppsModel::IconNameRole) ||
        roles.contains(AppsModel::NameRole)) {
        refreshArrangement();
    }
});

本报告由 AI 代码审查工具自动生成

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.

2 participants