chore:显示包大小数据

This commit is contained in:
momen 2025-06-08 00:57:43 +08:00
parent 50adf55762
commit a779a3532b
2 changed files with 7 additions and 2 deletions

@ -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

@ -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();
}