From a779a3532bcaa1ca7613a11d01d970ca2a16f7e9 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 8 Jun 2025 00:57:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E6=98=BE=E7=A4=BA=E5=8C=85=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 7 +++++-- src/applistmodel.cpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index ff2c11b..8aeac93 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -13,15 +13,18 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c QString currentVersion = index.data(Qt::UserRole + 2).toString(); QString newVersion = index.data(Qt::UserRole + 3).toString(); QString iconPath = index.data(Qt::UserRole + 4).toString(); + // 获取包大小数据 + QVariant sizeVariant = index.data(Qt::UserRole + 5); + QString size = sizeVariant.isValid() ? sizeVariant.toString() : "未知"; // 绘制图标 QIcon icon(iconPath); QRect iconRect(option.rect.x() + 10, option.rect.y() + 10, 32, 32); icon.paint(painter, iconRect); - // 绘制文本 + // 绘制文本,添加包大小信息 QRect textRect(iconRect.right() + 10, option.rect.y() + 10, option.rect.width() - iconRect.width() - 20, option.rect.height() - 20); - painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3").arg(name, currentVersion, newVersion)); + painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3\n包大小: %4").arg(name, currentVersion, newVersion, size)); } QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const diff --git a/src/applistmodel.cpp b/src/applistmodel.cpp index f18ffa3..a896b0e 100644 --- a/src/applistmodel.cpp +++ b/src/applistmodel.cpp @@ -27,6 +27,8 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const return obj["new_version"].toString(); case Qt::UserRole + 4: // 图标路径 return obj["icon"].toString(); + case Qt::UserRole + 5: // 文件大小 + return obj["size"].toVariant(); default: return QVariant(); }