Skip to content

feat: improve PageMultiInfo CPU header info display and device genera…#634

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eagle-20260325from
GongHeng2017:202604011133-tmp-dev-feat
Apr 1, 2026
Merged

feat: improve PageMultiInfo CPU header info display and device genera…#634
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eagle-20260325from
GongHeng2017:202604011133-tmp-dev-feat

Conversation

@GongHeng2017
Copy link
Copy Markdown
Contributor

@GongHeng2017 GongHeng2017 commented Apr 1, 2026

…tion

  • Update PageMultiInfo to use scroll area container layout for CPU header detail widgets
  • Add/adjust accessor usage for header info in CPU page
  • Refactor scroll area content resizing and visibility behavior
  • Update DeviceGenerator logic and declarations (internal feature updates)
  • Keep UI behavior consistent with latest header info widget layout

Log: add feature for cpu info show.
Task: https://pms.uniontech.com/task-view-387697.html

Summary by Sourcery

Add a scrollable CPU header information section to the multi-info page and populate it using computed CPU summary data from the device generator.

New Features:

  • Display CPU header information above the table on the CPU page using a dedicated scrollable container.
  • Compute and expose summarized CPU attributes (model, vendor, architecture, cores, threads, caches) for use in the UI header section.

Enhancements:

  • Adjust PageMultiInfo layout to integrate the optional CPU header area while keeping existing table and detail views intact.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 1, 2026

Reviewer's Guide

Adds a CPU-specific header info scroll area to PageMultiInfo and computes CPU header metadata during device generation so the CPU page can display rich, scrollable summary information while keeping layout and visibility behavior consistent with other pages.

Sequence diagram for CPU header info generation and display

sequenceDiagram
    participant DeviceGenerator
    participant DeviceManager
    participant PageMultiInfo
    participant DeviceCpu
    participant HeaderInfoTableWidget

    DeviceGenerator->>DeviceGenerator: generatorCpuDevice()
    loop For_each_cpu_in_lsCpu
        DeviceGenerator->>DeviceManager: addCpuDevice(device)
    end
    alt At_least_one_cpu
        DeviceGenerator->>DeviceGenerator: calAndSetCpuHeaderInfo(firstProcessorInfo, coreNum, logicalNum)
        DeviceGenerator->>DeviceManager: setCpuHeaderInfo(cpuHeaderInfo)
    end

    PageMultiInfo->>PageMultiInfo: updateInfo(lst)
    PageMultiInfo->>DeviceCpu: dynamic_cast from lst.at(0)
    alt Is_cpu_page
        PageMultiInfo->>DeviceManager: getCpuHeaderInfo(headerInfo)
        PageMultiInfo->>PageMultiInfo: clearLayout(mp_HeaderInfoWidgetLay)
        loop For_each_headerInfo_group
            PageMultiInfo->>HeaderInfoTableWidget: new HeaderInfoTableWidget(mp_HeaderInfoWidget)
            PageMultiInfo->>HeaderInfoTableWidget: updateData(headerInfoGroup)
            PageMultiInfo->>PageMultiInfo: mp_HeaderInfoWidgetLay->addWidget(headerWidget)
        end
        PageMultiInfo->>PageMultiInfo: configure mp_HeaderInfoWidget (height, resize, visible true)
    else Not_cpu_page
        PageMultiInfo->>PageMultiInfo: mp_HeaderInfoWidget->setVisible(false)
        PageMultiInfo->>PageMultiInfo: mp_HeaderInfoWidget->setMaximumHeight(0)
    end
Loading

Updated class diagram for CPU header info flow

classDiagram
    class DeviceGenerator {
        +generatorCpuDevice() void
        -calAndSetCpuHeaderInfo(firstProcessorInfo QMap~QString_QString~, coreNum int, logicalNum int) void
        -m_ListBusID QStringList
    }

    class DeviceManager {
        +instance() DeviceManager*
        +addCpuDevice(device DeviceBaseInfo*) void
        +setCpuHeaderInfo(cpuHeaderInfo QList~QList~QPair~QString_QString~~~~) void
        +getCpuHeaderInfo(headerInfo QList~QList~QPair~QString_QString~~~~&) void
    }

    class PageMultiInfo {
        +PageMultiInfo(parent QWidget*)
        +~PageMultiInfo()
        +updateInfo(lst QList~DeviceBaseInfo*~&) void
        +initWidgets() void
        -clearLayout(layout QLayout*) void
        -mp_Label DLabel*
        -mp_HeaderInfoWidget DScrollArea*
        -mp_HeaderInfoContainer DWidget*
        -mp_HeaderInfoWidgetLay QVBoxLayout*
        -mp_Table PageTableHeader*
        -mp_Detail PageDetail*
        -m_lstDevice QList~DeviceBaseInfo*~
        -m_deviceList QList~QStringList~
        -m_menuControlList QList~QStringList~
    }

    class DeviceBaseInfo {
        <<abstract>>
    }

    class DeviceCpu {
    }

    class HeaderInfoTableWidget {
        +HeaderInfoTableWidget(parent QWidget*)
        +updateData(data QList~QPair~QString_QString~~&) void
    }

    class PageTableHeader {
    }

    class PageDetail {
    }

    class DScrollArea {
    }

    class DWidget {
    }

    class DLabel {
    }

    class QVBoxLayout {
    }

    class QLayout {
    }

    DeviceGenerator --> DeviceManager : uses
    DeviceGenerator ..> DeviceBaseInfo : creates
    DeviceGenerator ..> DeviceCpu

    PageMultiInfo --> DScrollArea : composition
    PageMultiInfo --> DWidget : composition
    PageMultiInfo --> QVBoxLayout : composition
    PageMultiInfo --> PageTableHeader : composition
    PageMultiInfo --> PageDetail : composition
    PageMultiInfo --> DLabel : composition

    PageMultiInfo ..> DeviceCpu : dynamic_cast
    PageMultiInfo ..> DeviceManager : getCpuHeaderInfo
    PageMultiInfo ..> HeaderInfoTableWidget : creates

    DeviceCpu --|> DeviceBaseInfo

    QVBoxLayout --|> QLayout
Loading

File-Level Changes

Change Details Files
Introduce a scrollable CPU header info area in PageMultiInfo and manage its lifecycle and visibility based on whether the current device is a CPU.
  • Add DScrollArea-based header info widget, container, and layout members to PageMultiInfo, initializing them in the constructor and cleaning them up in the destructor.
  • Update initWidgets to insert the header info scroll area between the page label and the table, configure scroll policies, size constraints, margins, and size policies, and rename the main layout variable for clarity.
  • In updateInfo, detect CPU pages via dynamic_cast, fetch precomputed header info from DeviceManager, rebuild HeaderInfoTableWidget children inside the header layout, configure scroll area height/visibility, and hide/collapse the header area for non-CPU pages.
  • Add a clearLayout helper method to safely delete all widgets in a given layout using deleteLater on contained widgets.
deepin-devicemanager/src/Page/PageMultiInfo.cpp
deepin-devicemanager/src/Page/PageMultiInfo.h
Compute and store CPU header metadata during device generation so it can be consumed by the CPU page header widgets.
  • Extend generatorCpuDevice to call a new calAndSetCpuHeaderInfo helper after creating CPU devices, using the first processor entry and core/logical counts.
  • Implement calAndSetCpuHeaderInfo to assemble localized key/value pairs for model, vendor, architecture, core count, threads per core, and aggregated cache sizes using Common::formatTotalCache, then pass this structured list to DeviceManager::setCpuHeaderInfo.
  • Declare calAndSetCpuHeaderInfo as a private helper in DeviceGenerator to keep CPU header calculation encapsulated.
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.h
Miscellaneous housekeeping updates for licensing headers and includes needed by the new CPU header feature.
  • Update SPDX copyright ranges to 2022 - 2026 in touched source and header files.
  • Include headerinfotablewidget.h and DeviceCpu.h in PageMultiInfo.cpp to support the new CPU header widgets and CPU type detection.
  • Move QVBoxLayout include into the header and add DScrollArea include to support the new layout and scroll area members.
deepin-devicemanager/src/Page/PageMultiInfo.cpp
deepin-devicemanager/src/Page/PageMultiInfo.h
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.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
Copy Markdown

@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 found 1 issue, and left some high level feedback:

  • The clearLayout helper is declared as a slot and only clears direct widgets (ignores nested sub-layouts); consider making it a private non-slot utility and handling item->layout() recursively to avoid leaking or orphaning nested layout content if the container ever becomes more complex.
  • In calAndSetCpuHeaderInfo, the thread count calculation logicalNum / coreNum with a fallback of 2 when coreNum == 0 may produce misleading values (e.g., when logicalNum is 0 or inconsistent); it would be safer to explicitly guard against invalid or zero values and choose a neutral default such as 1 or an empty field instead of hardcoding 2.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `clearLayout` helper is declared as a slot and only clears direct widgets (ignores nested sub-layouts); consider making it a private non-slot utility and handling `item->layout()` recursively to avoid leaking or orphaning nested layout content if the container ever becomes more complex.
- In `calAndSetCpuHeaderInfo`, the thread count calculation `logicalNum / coreNum` with a fallback of `2` when `coreNum == 0` may produce misleading values (e.g., when `logicalNum` is 0 or inconsistent); it would be safer to explicitly guard against invalid or zero values and choose a neutral default such as 1 or an empty field instead of hardcoding 2.

## Individual Comments

### Comment 1
<location path="deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp" line_range="1298-1307" />
<code_context>
+            QPair<QString, QString> totalL1dCache(tr("L1i cache"), strTotalL1iCache);
</code_context>
<issue_to_address>
**nitpick:** Using the same variable name totalL1dCache for different cache levels reduces readability and is error-prone.

Please rename each variable to reflect its specific cache level (e.g. totalL1iCache, totalL2Cache, totalL3Cache) so the logic is self‑documenting and less prone to copy‑paste errors.
</issue_to_address>

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.

@GongHeng2017 GongHeng2017 force-pushed the 202604011133-tmp-dev-feat branch 2 times, most recently from 4d78d2c to e94a488 Compare April 1, 2026 06:39
…tion

- Update PageMultiInfo to use scroll area container layout for CPU header detail widgets
- Add/adjust accessor usage for header info in CPU page
- Refactor scroll area content resizing and visibility behavior
- Update DeviceGenerator logic and declarations (internal feature updates)
- Keep UI behavior consistent with latest header info widget layout

Log: add feature for cpu info show.
Task: https://pms.uniontech.com/task-view-387697.html
@GongHeng2017 GongHeng2017 force-pushed the 202604011133-tmp-dev-feat branch from e94a488 to 6c51615 Compare April 1, 2026 06:41
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, max-lvs

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

@GongHeng2017
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot bot commented Apr 1, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 37f5c80 into linuxdeepin:develop/eagle-20260325 Apr 1, 2026
20 of 22 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