Skip to content

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Jul 22, 2025

此提交旨在为后续切换组合模型做准备,是原重构分支包含的部分变更.

注意:TaskManager::WinTitleRole 的 roleName 和 "globals.h" 定义的名称不同(isActive / active)。暂未确认修改为 MODEL_ACTIVE 是否会对 QML 一侧产生影响。

Summary by Sourcery

Refactor model role definitions to use TaskManager constants and global macros, remove the duplicate enum in AbstractWindow, and streamline header inclusions.

Enhancements:

  • Centralize model role usage by replacing AbstractWindow::Roles with TaskManager role constants and MODEL_* name macros
  • Remove the obsolete Roles enum and Q_ENUM declaration from AbstractWindow

Chores:

  • Add required headers to AbstractWindowMonitor and forward-declare it in TaskManager instead of including the header

@BLumia BLumia requested a review from 18202781743 July 22, 2025 09:51
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia

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
Copy link

sourcery-ai bot commented Jul 22, 2025

Reviewer's Guide

This PR consolidates role definitions by replacing the AbstractWindow enum with TaskManager role constants, updating roleNames mappings, data switch statements, dataChanged signals, and adjusting includes and forward declarations to prepare for combined-model integration.

Class diagram for role constant refactoring in AbstractWindow and TaskManager

classDiagram
    class AbstractWindow {
        <<QObject>>
        +~AbstractWindow()
        +uint32_t id() = 0
        +uint32_t pid() = 0
        +QString identity() = 0
        +QIcon icon() = 0
        +QString title() = 0
        +bool isActive() = 0
        +bool shouldSkip() = 0
        +signals:
        +void pidChanged()
        +void identityChanged()
        +void iconChanged()
        +void titleChanged()
        +void isActiveChanged()
        +void shouldSkipChanged()
    }
    class TaskManager {
        <<DContainment, AbstractTaskManagerInterface>>
        +static const int WinIdRole
        +static const int PidRole
        +static const int IdentityRole
        +static const int WinIconRole
        +static const int WinTitleRole
        +static const int ActiveRole
        +static const int ShouldSkipRole
    }
    class AbstractWindowMonitor {
        <<QAbstractListModel>>
        +QHash<int, QByteArray> roleNames() const
        +int rowCount(const QModelIndex &parent) const
        +QVariant data(const QModelIndex &index, int role = TaskManager::WinIdRole) const
        +void trackWindow(AbstractWindow* window)
        +void destroyWindow(AbstractWindow * window)
        -QList<AbstractWindow*> m_trackedWindows
    }
    AbstractWindowMonitor --> AbstractWindow : tracks
    AbstractWindowMonitor ..> TaskManager : uses role constants
    TaskManager <|.. AbstractTaskManagerInterface
    TaskManager <|.. DContainment
Loading

File-Level Changes

Change Details Files
Use TaskManager-defined roles throughout AbstractWindowMonitor
  • Replaced roleNames entries to use TaskManager:: and MODEL_* constants
  • Updated data() switch cases to reference TaskManager:: values
  • Adjusted Q_EMIT dataChanged calls to emit TaskManager:: instead of AbstractWindow roles
  • Changed default role parameter in data() signature to TaskManager::WinIdRole
abstractwindowmonitor.cpp
abstractwindowmonitor.h
Remove redundant Roles enum from AbstractWindow
  • Deleted the enum Roles declaration
  • Removed Q_ENUM(Roles) macro
abstractwindow.h
Adjust includes and forward declarations for TaskManager integration
  • Added globals.h and taskmanager.h includes in AbstractWindowMonitor
  • Removed abstractwindowmonitor.h include in taskmanager.h and added forward declaration
  • Organized header dependencies to decouple modules
abstractwindowmonitor.cpp
abstractwindowmonitor.h
taskmanager.h

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

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


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.

此提交旨在为后续切换组合模型做准备,是原重构分支包含的部分变更.

Log:
@BLumia BLumia force-pushed the taskmanager-roles branch from e4e8b71 to cb20075 Compare July 22, 2025 12:39
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • 枚举 RolesAbstractWindow 类中被移除,但在 AbstractWindowMonitorabstractwindowmonitor.h 文件中仍然使用了这些枚举值,可能会导致编译错误。
  • AbstractWindowMonitor 类的 roleNames 方法中,使用了 TaskManager 类中的枚举值,但 TaskManager 类并没有包含 AbstractWindowMonitor.h 文件,这可能导致编译错误。
  • AbstractWindowMonitor 类的 data 方法中,使用了 TaskManager 类中的枚举值,但 TaskManager 类并没有包含 AbstractWindowMonitor.h 文件,这可能导致编译错误。
  • AbstractWindowMonitor 类的 trackWindow 方法中,使用了 TaskManager 类中的枚举值,但 TaskManager 类并没有包含 AbstractWindowMonitor.h 文件,这可能导致编译错误。
  • AbstractWindowMonitor 类的 data 方法中,使用了 TaskManager 类中的枚举值,但 TaskManager 类并没有包含 AbstractWindowMonitor.h 文件,这可能导致编译错误。

是否建议立即修改:

  • 需要立即修复 AbstractWindowMonitorabstractwindowmonitor.h 文件中的编译错误,确保使用正确的枚举值。
  • 需要检查 TaskManager 类是否应该包含 AbstractWindowMonitor.h 文件,并相应地调整包含关系,以避免未来的编译错误。
  • 需要确保所有使用 TaskManager 类中的枚举值的地方都正确地引用了 TaskManager 类,以避免潜在的运行时错误。

@BLumia BLumia merged commit 35b90c9 into linuxdeepin:master Jul 22, 2025
7 of 10 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