mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-11 05:42:20 +08:00
chore:完成“更新全部”下载按钮逻辑
This commit is contained in:
parent
03c53c3977
commit
8177556e5d
@ -163,3 +163,18 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
|||||||
|
|
||||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppDelegate::startDownloadForAll() {
|
||||||
|
if (!m_model) return;
|
||||||
|
for (int row = 0; row < m_model->rowCount(); ++row) {
|
||||||
|
QModelIndex index = m_model->index(row, 0);
|
||||||
|
QString packageName = index.data(Qt::UserRole + 1).toString();
|
||||||
|
if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading)
|
||||||
|
continue; // 跳过正在下载的
|
||||||
|
QString downloadUrl = index.data(Qt::UserRole + 7).toString();
|
||||||
|
QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName);
|
||||||
|
m_downloads[packageName] = {0, true};
|
||||||
|
m_downloadManager->startDownload(packageName, downloadUrl, outputPath);
|
||||||
|
emit updateDisplay(packageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||||
const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||||
|
void startDownloadForAll(); // 新增:批量下载所有应用
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateDisplay(const QString &packageName);
|
void updateDisplay(const QString &packageName);
|
||||||
|
@ -14,6 +14,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
listView->setModel(m_model);
|
listView->setModel(m_model);
|
||||||
listView->setItemDelegate(m_delegate);
|
listView->setItemDelegate(m_delegate);
|
||||||
|
|
||||||
|
// 新增:确保 delegate 拥有 model 指针
|
||||||
|
m_delegate->setModel(m_model);
|
||||||
|
|
||||||
// 设置 QListView 填充 ui->appWidget
|
// 设置 QListView 填充 ui->appWidget
|
||||||
QVBoxLayout *layout = new QVBoxLayout(ui->appWidget);
|
QVBoxLayout *layout = new QVBoxLayout(ui->appWidget);
|
||||||
layout->addWidget(listView);
|
layout->addWidget(listView);
|
||||||
@ -27,6 +30,13 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 新增:点击“更新全部”按钮批量下载
|
||||||
|
connect(ui->updatePushButton, &QPushButton::clicked, this, [=](){
|
||||||
|
qDebug()<<"更新全部按钮被点击";
|
||||||
|
m_delegate->startDownloadForAll();
|
||||||
|
});
|
||||||
|
|
||||||
checkUpdates();
|
checkUpdates();
|
||||||
initStyle();
|
initStyle();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user