Fix: [Memory] The memory list not show.#546
Fix: [Memory] The memory list not show.#546deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
Conversation
-- code logic error. -- Not judge the speciall platform success. Log: fix issue Bug:
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes the memory list visibility issue by correcting platform detection logic across multiple components—replacing raw specialComType checks with Common::isHwPlatform(), refactoring table update/resizing conditions, and updating EDIDParser to use a named constant with clearer string formatting. Sequence diagram for memory list visibility update in PageMultiInfosequenceDiagram
participant PageMultiInfo
participant Common
participant mp_Table
participant mp_Label
PageMultiInfo->>Common: isHwPlatform()
alt isHwPlatform() == true
PageMultiInfo->>mp_Label: text()
alt text is "Storage" or "Memory" or "Monitor"
PageMultiInfo->>mp_Table: setVisible(false)
PageMultiInfo->>mp_Table: setFixedHeight(0)
else text is other
PageMultiInfo->>mp_Table: setVisible(true)
PageMultiInfo->>mp_Table: setFixedHeight(TABLE_HEIGHT)
PageMultiInfo->>mp_Table: updateTable(...)
end
else isHwPlatform() == false
PageMultiInfo->>mp_Table: setVisible(true)
PageMultiInfo->>mp_Table: setFixedHeight(TABLE_HEIGHT)
PageMultiInfo->>mp_Table: updateTable(...)
end
Class diagram for updated platform detection logicclassDiagram
class Common {
+specialComType : int
+kSpecialType7 : int
+isHwPlatform() : bool
}
class PageMultiInfo {
+updateInfo(lst : QList<DeviceBaseInfo*>)
+resizeEvent(e : QResizeEvent*)
-mp_Table
-mp_Label
-m_deviceList
-m_menuControlList
}
class DeviceMonitor {
+setInfoFromHwinfo(mapInfo : QMap<QString, QString>)
+available() : bool
+subTitle() : QString
-m_DisplayInput
-m_ScreenSize
-m_MainScreen
-m_SupportResolution
-m_Name
}
class DeviceCpu {
+setInfoFromDmidecode(mapInfo : QMap<QString, QString>)
-m_Name
}
class EDIDParser {
+parseScreenSize()
+parseMonitorName()
-m_Width
-m_Height
-m_ScreenSize
}
Common <|-- PageMultiInfo
Common <|-- DeviceMonitor
Common <|-- DeviceCpu
Common <|-- EDIDParser
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The nested if/else branches in resizeEvent introduce a lot of duplicated updateTable calls—consider extracting the common logic or inverting the conditions to simplify and DRY up the code.
- Repeated string comparisons against mp_Label->text() for "Storage", "Memory", and "Monitor" could be consolidated into a helper function or constant set to reduce literal duplication and improve clarity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The nested if/else branches in resizeEvent introduce a lot of duplicated updateTable calls—consider extracting the common logic or inverting the conditions to simplify and DRY up the code.
- Repeated string comparisons against mp_Label->text() for "Storage", "Memory", and "Monitor" could be consolidated into a helper function or constant set to reduce literal duplication and improve clarity.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review我来对这个diff进行代码审查:
a) 代码安全方面:
b) 代码质量方面:
c) 代码性能方面:
d) 具体修改建议: // Common.h 中建议添加
enum class SpecialType {
Normal = 0,
Type7 = 7
// 其他特殊类型...
};
class Common {
public:
static bool isHwPlatform() {
return specialComType > static_cast<int>(SpecialType::Normal);
}
static bool isSpecialType7() {
return specialComType == static_cast<int>(SpecialType::Type7);
}
};
// EDIDParser.cpp 中修改
void EDIDParser::parseScreenSize()
{
// ... 其他代码 ...
if (Common::isSpecialType7()) {
m_Width = 296;
m_Height = 197;
}
double inch = calculateScreenInch();
int precision = Common::isSpecialType7() ? 0 : 1;
m_ScreenSize = formatScreenSize(inch, precision);
}
private:
double calculateScreenInch() {
return sqrt((m_Width / 2.54) * (m_Width / 2.54) +
(m_Height / 2.54) * (m_Height / 2.54))/10;
}
QString formatScreenSize(double inch, int precision) {
return QString("%1 %2(%3mm×%4mm)")
.arg(QString::number(inch, '0', precision))
.arg(QObject::tr("inch"))
.arg(m_Width)
.arg(m_Height);
}
这些改进可以提高代码的可维护性、可读性和安全性,同时保持代码的性能。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
29ffb3d
into
linuxdeepin:develop/eagle
-- code logic error.
-- Not judge the speciall platform success.
Log: fix issue
Bug:
Summary by Sourcery
Replace ad-hoc numeric specialComType checks with a unified isHwPlatform() method to correctly control display logic for memory, storage, and monitor tables and fix the memory list not showing on hardware platforms.
Bug Fixes:
Enhancements: