Feat: add CPU header info storage and cache size formatting#633
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eagle-20260325from Apr 1, 2026
Conversation
- Add DeviceManager CPU header info getters/setters and storage member - Adjust main window initial height to 802 - Rename HeaderInfoTableWidget clear() to resetTableContents() - Add Common::formatTotalCache for converting per-thread cache to total cache and formatting with KiB/MiB/GiB units - Update SPDX year range in DeviceManager files Log: add feature for cpu info show Task: https://pms.uniontech.com/task-view-387697.html
Reviewer's GuideImplements CPU header info storage on DeviceManager, introduces a reusable cache-size formatting helper, and performs a few small UI and metadata tweaks (window height, header table reset naming, SPDX year range). Class diagram for updated DeviceManager, Common, and HeaderInfoTableWidgetclassDiagram
class Common {
+SpecialCpuType curCpuType
+QByteArray executeClientCmd(cmd, args, workPath, msecsWaiting)
+QString formatTotalCache(perThreadCache, coreCount)
}
class DeviceManager {
+setCpuFrequencyIsCur(flag)
+setCpuHeaderInfo(info)
+getCpuHeaderInfo(info) const
-m_CurrentXlsRow : int
-m_networkDriver : QStringList
-m_ListCpuHeaderInfo : QList~QList~QPair~QString, QString~~~~
}
class HeaderInfoTableWidget {
-HeaderInfoDelegate m_delegate
+HeaderInfoTableWidget(parent)
+updateData(data)
-initUI()
-resetTableContents()
}
DeviceManager ..> QList : uses
DeviceManager ..> QPair : uses
DeviceManager ..> QString : uses
Common ..> QString : uses
HeaderInfoTableWidget --|> DTableWidget
Flow diagram for Common::formatTotalCache cache size formattingflowchart TD
A_start[Start formatTotalCache] --> B_trim[Trim perThreadCache to s]
B_trim --> C_empty{s is empty?}
C_empty -- Yes --> Z_returnEmpty[Return empty QString]
C_empty -- No --> D_scan[Scan from end to find last digit or '.' index i]
D_scan --> E_numUnit["Split into numStr and unitStr (uppercased)"]
E_numUnit --> F_parseNum[Parse numStr to double num]
F_parseNum --> G_ok{Parse ok?}
G_ok -- No --> Z_returnEmpty
G_ok -- Yes --> H_unitToKiB[Convert per core cache to perCoreKiB]
H_unitToKiB --> H1_unitCheck{unitStr type}
H1_unitCheck -- K/KiB/KB --> H1_k[perCoreKiB = num]
H1_unitCheck -- M/MiB/MB --> H1_m[perCoreKiB = num * 1024]
H1_unitCheck -- G/GiB/GB --> H1_g[perCoreKiB = num * 1024 * 1024]
H1_unitCheck -- T/TiB/TB --> H1_t[perCoreKiB = num * 1024 * 1024 * 1024]
H1_unitCheck -- empty or B --> H1_b[perCoreKiB = num / 1024]
H1_unitCheck -- other --> H1_other[perCoreKiB = num]
H1_k --> I_total
H1_m --> I_total
H1_g --> I_total
H1_t --> I_total
H1_b --> I_total
H1_other --> I_total
I_total[Compute totalKiB = perCoreKiB * coreCount] --> J_pickUnit{totalKiB >= 1024^2?}
J_pickUnit -- Yes --> J_gib[value = totalKiB / 1024^2; unit = GiB]
J_pickUnit -- No --> K_pickMiB{totalKiB >= 1024?}
K_pickMiB -- Yes --> K_mib[value = totalKiB / 1024; unit = MiB]
K_pickMiB -- No --> K_kib[value = totalKiB; unit = KiB]
J_gib --> L_intCheck
K_mib --> L_intCheck
K_kib --> L_intCheck
L_intCheck[Check if value is integer using modf] --> M_isInt{Is integer?}
M_isInt -- Yes --> N_int[Return integer string + space + unit]
M_isInt -- No --> O_frac[Return value with 1 decimal + space + unit]
N_int --> P_end[End]
O_frac --> P_end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In Common::formatTotalCache, consider validating/corectly guarding against non-positive coreCount values (e.g., <= 0) to avoid misleading results like negative or zero total cache.
- The unit parsing in Common::formatTotalCache treats unknown units as KiB, which may hide input errors; consider either returning an empty string or logging/flagging unrecognized units instead of silently assuming KiB.
- DeviceManager::getCpuHeaderInfo currently uses an out-parameter and copies the entire QList; consider returning a const reference or value directly to simplify the API and potentially reduce unnecessary copying.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In Common::formatTotalCache, consider validating/corectly guarding against non-positive coreCount values (e.g., <= 0) to avoid misleading results like negative or zero total cache.
- The unit parsing in Common::formatTotalCache treats unknown units as KiB, which may hide input errors; consider either returning an empty string or logging/flagging unrecognized units instead of silently assuming KiB.
- DeviceManager::getCpuHeaderInfo currently uses an out-parameter and copies the entire QList; consider returning a const reference or value directly to simplify the API and potentially reduce unnecessary copying.
## Individual Comments
### Comment 1
<location path="deepin-devicemanager/src/commonfunction.cpp" line_range="243-252" />
<code_context>
+QString Common::formatTotalCache(const QString &perThreadCache, int coreCount)
</code_context>
<issue_to_address>
**issue:** Guard against non-positive coreCount to avoid misleading results.
For `coreCount <= 0`, `totalKiB` becomes 0 or negative and still formats as a valid cache size. Please either early-return a sentinel (e.g., empty string) or clamp `coreCount` to at least 1 so that invalid inputs are handled explicitly and easier to detect.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
max-lvs
approved these changes
Apr 1, 2026
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
8f355a2
into
linuxdeepin:develop/eagle-20260325
19 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: add feature for cpu info show
Task: https://pms.uniontech.com/task-view-387697.html
Summary by Sourcery
Add CPU header information storage in DeviceManager and introduce a utility for formatting total CPU cache size, alongside minor UI and metadata adjustments.
New Features:
Enhancements: