Files
spark-store/spark-update-tool/src/appdelegate.h
shenmo 1becfbc9be feat(迁移功能): 添加包迁移功能支持
实现从aptss到apm的包迁移功能
- 添加迁移包集合存储用户确认的迁移项
- 在数据模型中添加迁移相关字段
- 修改合并逻辑以识别迁移场景
- 添加迁移确认对话框
- 处理迁移安装时的特殊逻辑
2026-04-05 10:49:03 +08:00

75 lines
2.2 KiB
C++

#pragma once
#include <QStyledItemDelegate>
#include <QHash>
#include <QQueue>
#include <QProcess>
#include <QElapsedTimer>
#include <QTimer>
#include <QSet>
#include "downloadmanager.h"
struct DownloadInfo {
int progress = 0;
bool isDownloading = false;
bool isInstalled = false;
bool isInstalling = false;
};
class AppDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
explicit AppDelegate(QObject *parent = nullptr);
~AppDelegate();
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;
void startDownloadForAll();
void startDownloadForSelected();
// 复选框相关方法
void setSelectedPackages(const QSet<QString> &selected);
QSet<QString> getSelectedPackages() const;
void clearSelection();
// 获取下载状态信息
const QHash<QString, DownloadInfo>& getDownloads() const;
signals:
void updateDisplay(const QString &packageName);
void updateFinished(bool success); //传递是否完成更新
void ignoreApp(const QString &packageName, const QString &version); // 新增:忽略应用信号
void unignoreApp(const QString &packageName); // 新增:取消忽略应用信号
private slots:
void updateSpinner(); // 新增槽函数
private:
DownloadManager *m_downloadManager;
QHash<QString, DownloadInfo> m_downloads;
QAbstractItemModel *m_model = nullptr;
// 复选框相关成员变量
QSet<QString> m_selectedPackages;
// 迁移包集合(用户确认要迁移的包)
QSet<QString> m_migrationPackages;
QQueue<QString> m_installQueue;
bool m_isInstalling = false;
QProcess *m_installProcess = nullptr;
QString m_installingPackage;
QElapsedTimer m_spinnerTimer;
QTimer m_spinnerUpdateTimer; // 新增定时器
int m_spinnerAngle = 0; // 新增角度变量
void enqueueInstall(const QString &packageName);
void startNextInstall();
};