mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 21:32:05 +08:00
update:显示进度条
This commit is contained in:
@@ -1,35 +1,31 @@
|
||||
#ifndef APPDELEGATE_H
|
||||
#define APPDELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QPainter>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
// 前向声明 DownloadManager 类
|
||||
class DownloadManager;
|
||||
#include <QHash>
|
||||
#include "downloadmanager.h"
|
||||
|
||||
class AppDelegate : public QStyledItemDelegate
|
||||
{
|
||||
struct DownloadInfo {
|
||||
int progress = 0;
|
||||
bool isDownloading = false;
|
||||
};
|
||||
|
||||
class AppDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppDelegate(QObject *parent = nullptr);
|
||||
|
||||
// 重写方法
|
||||
void setModel(QAbstractItemModel *model);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||
|
||||
signals:
|
||||
void updateDisplay(); // 声明更新显示的信号
|
||||
void updateDisplay(const QString &packageName);
|
||||
|
||||
private:
|
||||
struct DownloadInfo {
|
||||
int progress = 0;
|
||||
bool isDownloading = false;
|
||||
};
|
||||
QHash<QString, DownloadInfo> m_downloads; // 使用包名作为键的下载状态
|
||||
DownloadManager *m_downloadManager;
|
||||
|
||||
QHash<QString, DownloadInfo> m_downloads;
|
||||
QAbstractItemModel *m_model = nullptr;
|
||||
};
|
||||
|
||||
#endif // APPDELEGATE_H
|
||||
|
||||
Reference in New Issue
Block a user