Skip to content

Conversation

@GongHeng2017
Copy link
Contributor

@GongHeng2017 GongHeng2017 commented Jul 23, 2025

-- Add extra information display logic.

Log: add feature for GPU.
Task: https://pms.uniontech.com/task-view-378987.html

Summary by Sourcery

Introduce dynamic GPU extra information handling by parsing a new 'Version' field and aggregating all unrecognized GPU attributes into a generic extra info map which is appended to the device details list.

New Features:

  • Support GPU version attribute in custom info parsing
  • Collect and display arbitrary extra GPU properties beyond the standard fields

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 23, 2025

Reviewer's Guide

Introduces handling of GPU version and dynamic extra GPU attributes by refactoring info parsing to collect unknown keys into a new map and appending them to the display list.

Entity relationship diagram for GPU info attributes and extra info

erDiagram
    DEVICE_GPU {
        string Name
        string Vendor
        string Model
        string Version
        string Graphics_Memory
    }
    EXTRA_INFO {
        string Key
        string Value
    }
    DEVICE_GPU ||--o{ EXTRA_INFO : has
Loading

Class diagram for updated DeviceGpu class with extra info handling

classDiagram
    class DeviceGpu {
        - QString m_Model
        - QString m_GraphicsMemory
        - QString m_Version
        - QMap<QString, QString> m_extraInfo
        + void setGpuInfo(const QMap<QString, QString> &mapInfo)
        + void setGpuInfoByCustom(const QMap<QString, QString> &mapInfo)
        + void loadOtherDeviceInfo()
        + void loadTableData()
        - void appendExtraInfoToOtherInfo()
    }
    DeviceGpu --|> DeviceBaseInfo
Loading

File-Level Changes

Change Details Files
Refactored GPU info parsing to support Version and extra attributes
  • Replaced multiple setAttribute calls with a loop over mapInfo entries
  • Added branch to assign "Version" to m_Version
  • Stored unrecognized keys and values in m_extraInfo
  • Updated header comment to include Version field
deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp
Added logic to append extra GPU info to display list
  • Implemented appendExtraInfoToOtherInfo() to filter and append m_extraInfo entries
  • Invoked appendExtraInfoToOtherInfo() in loadOtherDeviceInfo()
deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp
Extended DeviceGpu class to store and expose extra info
  • Declared private appendExtraInfoToOtherInfo() in header
  • Added QMap<QString, QString> m_extraInfo member
deepin-devicemanager/src/DeviceManager/DeviceGpu.h
Updated server utility to include GPU version key
  • Added kVersion constant to customgpuinfo main.cpp
  • Updated comment header to list Version field
deepin-devicemanager-server/customgpuinfo/main.cpp

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

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码注释

    • main.cppDeviceGpu.cpp中,注释应该使用中文,但是注释的格式和内容应该保持一致。例如,main.cpp中的注释使用了中文括号,而DeviceGpu.cpp中的注释使用了英文括号。建议统一注释格式。
  2. 代码重复

    • DeviceGpu::setGpuInfoByCustom函数中,使用了for循环来遍历mapInfo,并使用if-else语句来设置不同的属性。这种做法可能会导致代码难以维护,如果以后需要添加新的属性,需要修改循环和条件判断。建议使用switch语句或者std::map来简化代码。
  3. 性能优化

    • DeviceGpu::appendExtraInfoToOtherInfo函数中,使用了auto iter = m_extraInfo.begin();来遍历m_extraInfo。如果m_extraInfo非常大,这可能会导致性能问题。建议使用QMap::const_iterator来代替auto,并使用QMap::constBegin()QMap::constEnd()来获取迭代器。
  4. 代码可读性

    • DeviceGpu::setGpuInfoByCustom函数中,if-else语句的缩进不一致,建议统一缩进格式,以提高代码的可读性。
  5. 代码安全

    • DeviceGpu::setGpuInfoByCustom函数中,没有对mapInfo中的值进行任何验证。如果mapInfo中的值来自不可信的源,可能会导致安全问题。建议在设置属性之前,对值进行验证。
  6. 代码风格

    • DeviceGpu::setGpuInfoByCustom函数中,else if语句的else关键字后面没有空格,建议添加空格以提高代码的可读性。
  7. 代码维护

    • DeviceGpu.h中,m_extraInfo的声明应该放在类的私有部分,而不是公有部分。这样,其他类只能通过DeviceGpu的公有接口来访问m_extraInfo,提高了代码的安全性。

综上所述,建议对代码进行重构,以提高代码的可读性、可维护性和安全性。

@deepin-ci-robot
Copy link

[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

-- Add extra information display logic.

Log: add feature for GPU.
Task: https://pms.uniontech.com/task-view-378987.html
@GongHeng2017 GongHeng2017 force-pushed the 202507222031-eagle-feat branch from 8b3e354 to a8e0fda Compare July 23, 2025 02:17
@GongHeng2017
Copy link
Contributor Author

/forcemerge

@deepin-bot deepin-bot bot merged commit 19f6a31 into linuxdeepin:develop/eagle Jul 23, 2025
16 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