Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -1950,3 +1950,13 @@
device->setFrequencyIsCur(flag);
}
}

void DeviceManager::setCpuHeaderInfo(const QList<QList<QPair<QString, QString> > > &info)

Check warning on line 1954 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setCpuHeaderInfo' is never used.

Check warning on line 1954 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'setCpuHeaderInfo' is never used.
{
m_ListCpuHeaderInfo = info;
}

void DeviceManager::getCpuHeaderInfo(QList<QList<QPair<QString, QString> > > &info) const

Check warning on line 1959 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getCpuHeaderInfo' is never used.

Check warning on line 1959 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'getCpuHeaderInfo' is never used.
{
info = m_ListCpuHeaderInfo;
}
7 changes: 5 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -631,6 +630,9 @@ class DeviceManager : public QObject
*/
void setCpuFrequencyIsCur(const bool &flag);

void setCpuHeaderInfo(const QList<QList<QPair<QString, QString>>> &info);
void getCpuHeaderInfo(QList<QList<QPair<QString, QString>>> &info) const;

protected:
DeviceManager();
~DeviceManager();
Expand Down Expand Up @@ -669,6 +671,7 @@ class DeviceManager : public QObject

static int m_CurrentXlsRow; //<! xlsx表格当前行
QStringList m_networkDriver; //网络驱动
QList<QList<QPair<QString, QString>>> m_ListCpuHeaderInfo; // 所有物理CPU个体的头部信息
};

#endif // DEVICEMANAGER_H
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Page/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DWIDGET_USE_NAMESPACE
using namespace DDLog;
// 主界面需要的一些宏定义
#define INIT_WIDTH 1000 // 窗口的初始化宽度
#define INIT_HEIGHT 720 // 窗口的初始化高度
#define INIT_HEIGHT 802 // 窗口的初始化高度
#define MIN_WIDTH 680 // 窗口的最小宽度
#define MIN_HEIGHT 300 // 窗口的最小高度

Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/Widget/headerinfotablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
initUI();
}

void HeaderInfoTableWidget::updateData(const QList<QPair<QString, QString>> &data)

Check warning on line 26 in deepin-devicemanager/src/Widget/headerinfotablewidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'updateData' is never used.

Check warning on line 26 in deepin-devicemanager/src/Widget/headerinfotablewidget.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'updateData' is never used.
{
clear();
resetTableContents();
int nRow = data.size();
setRowCount(nRow);

Expand Down Expand Up @@ -118,7 +118,7 @@
painter.drawLine(vline);
}

void HeaderInfoTableWidget::clear()
void HeaderInfoTableWidget::resetTableContents()
{
DTableWidget::clear();
setRowCount(0);
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Widget/headerinfotablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HeaderInfoTableWidget : public DTK_WIDGET_NAMESPACE::DTableWidget

private:
void initUI();
void clear();
void resetTableContents();
class HeaderInfoDelegate *m_delegate = nullptr;
};

Expand Down
62 changes: 62 additions & 0 deletions deepin-devicemanager/src/commonfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,65 @@
}
return outPut;
}

QString Common::formatTotalCache(const QString &perThreadCache, int coreCount)

Check warning on line 243 in deepin-devicemanager/src/commonfunction.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'formatTotalCache' is never used.

Check warning on line 243 in deepin-devicemanager/src/commonfunction.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'formatTotalCache' is never used.
{
// 1. 清理并分离数字与单位
QString s = perThreadCache.trimmed();
if (s.isEmpty())
return QString();

int i = s.length() - 1;
while (i >= 0 && !s[i].isDigit() && s[i] != '.')
--i;

QString numStr = s.left(i + 1);
QString unitStr = s.mid(i + 1).toUpper();

bool ok;
double num = numStr.toDouble(&ok);
if (!ok)
return QString();

// 2. 将单核/单线程缓存转换为 KiB
double perCoreKiB = 0.0;
if (unitStr.startsWith("K") || unitStr == "KB" || unitStr == "KIB") {
perCoreKiB = num;
} else if (unitStr.startsWith("M") || unitStr == "MB" || unitStr == "MIB") {
perCoreKiB = num * 1024.0;
} else if (unitStr.startsWith("G") || unitStr == "GB" || unitStr == "GIB") {
perCoreKiB = num * 1024.0 * 1024.0;
} else if (unitStr.startsWith("T") || unitStr == "TB" || unitStr == "TIB") {
perCoreKiB = num * 1024.0 * 1024.0 * 1024.0;
} else if (unitStr.isEmpty() || unitStr == "B") {
// 无单位或纯字节,视为字节并转为 KiB
perCoreKiB = num / 1024.0;
} else {
// 未知单位,按原数值当作 KiB 处理
perCoreKiB = num;
}

double totalKiB = perCoreKiB * coreCount;

// 3. 选择最合适的单位并格式化数值
double value;
QString unit;
if (totalKiB >= 1024.0 * 1024.0) {
value = totalKiB / (1024.0 * 1024.0);
unit = "GiB";
} else if (totalKiB >= 1024.0) {
value = totalKiB / 1024.0;
unit = "MiB";
} else {
value = totalKiB;
unit = "KiB";
}

// 4. 数值显示:若为整数则无小数位,否则保留一位小数
double intPart;
if (std::abs(std::modf(value, &intPart)) < 1e-6) {
return QString::number(static_cast<long long>(value)) + " " + unit;
} else {
return QString::number(value, 'f', 1) + " " + unit;
}
}
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/commonfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ class Common
static SpecialCpuType curCpuType;

static QByteArray executeClientCmd(const QString& cmd, const QStringList& args = QStringList(), const QString& workPath = QString(), int msecsWaiting = 30000);

static QString formatTotalCache(const QString& perThreadCache, int coreCount);
};
#endif // COMMONFUNCTION_H
Loading