Unify ProgressCallbacks to a Common::ProgressCallback

This commit is contained in:
Pengfei
2021-06-28 22:50:16 +08:00
parent 5a4bf7daff
commit 2575e7fdde
15 changed files with 69 additions and 46 deletions
+2 -1
View File
@@ -7,6 +7,7 @@
#include <atomic>
#include <functional>
#include <QThread>
#include "common/progress_callback.h"
#include "core/importer.h"
class MultiJob : public QThread {
@@ -14,7 +15,7 @@ class MultiJob : public QThread {
public:
using ExecuteFunc = std::function<bool(Core::SDMCImporter&, const Core::ContentSpecifier&,
const Core::SDMCImporter::ProgressCallback&)>;
const Common::ProgressCallback&)>;
using DeleteFunc = std::function<void(Core::SDMCImporter&, const Core::ContentSpecifier&)>;
using AbortFunc = std::function<void(Core::SDMCImporter&)>;
+2 -2
View File
@@ -7,6 +7,7 @@
#include <functional>
#include <QThread>
#include "common/common_types.h"
#include "common/progress_callback.h"
/**
* Lightweight wrapper around QThread, for easy use with progressive jobs.
@@ -15,8 +16,7 @@ class SimpleJob : public QThread {
Q_OBJECT
public:
using ProgressCallback = std::function<void(std::size_t, std::size_t)>;
using ExecuteFunc = std::function<bool(const ProgressCallback&)>;
using ExecuteFunc = std::function<bool(const Common::ProgressCallback&)>;
using AbortFunc = std::function<void()>;
explicit SimpleJob(QObject* parent, ExecuteFunc execute, AbortFunc abort);
+5 -4
View File
@@ -21,6 +21,7 @@
#include <QtConcurrent/QtConcurrentRun>
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/progress_callback.h"
#include "common/scope_exit.h"
#include "frontend/helpers/multi_job.h"
#include "frontend/helpers/simple_job.h"
@@ -726,7 +727,7 @@ void ImportDialog::StartDumpingCXISingle(const Core::ContentSpecifier& specifier
auto* job = new SimpleJob(
this,
[this, specifier, path](const SimpleJob::ProgressCallback& callback) {
[this, specifier, path](const Common::ProgressCallback& callback) {
if (!importer.DumpCXI(specifier, path.toStdString(), callback)) {
FileUtil::Delete(path.toStdString());
return false;
@@ -789,7 +790,7 @@ void ImportDialog::StartBatchDumpingCXI() {
auto* job = new MultiJob(
this, importer, std::move(to_import),
[path](Core::SDMCImporter& importer, const Core::ContentSpecifier& specifier,
const Core::SDMCImporter::ProgressCallback& callback) {
const Common::ProgressCallback& callback) {
return importer.DumpCXI(specifier, path.toStdString() + GetCXIFileName(specifier),
callback);
},
@@ -812,7 +813,7 @@ void ImportDialog::StartBuildingCIASingle(const Core::ContentSpecifier& specifie
auto* job = new SimpleJob(
this,
[this, specifier, path](const SimpleJob::ProgressCallback& callback) {
[this, specifier, path](const Common::ProgressCallback& callback) {
if (!importer.BuildCIA(specifier, path.toStdString(), callback)) {
FileUtil::Delete(path.toStdString());
return false;
@@ -878,7 +879,7 @@ void ImportDialog::StartBatchBuildingCIA() {
auto* job = new MultiJob(
this, importer, std::move(to_import),
[path](Core::SDMCImporter& importer, const Core::ContentSpecifier& specifier,
const Core::SDMCImporter::ProgressCallback& callback) {
const Common::ProgressCallback& callback) {
return importer.BuildCIA(specifier, path.toStdString() + GetCIAFileName(specifier),
callback);
},