FOSSredder 0.5.0
Loading...
Searching...
No Matches
ExportWorkflow.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QFuture>
9#include <QFutureWatcher>
10#include <QObject>
11#include <QString>
12#include <QVariantMap>
13#include <functional>
14#include <memory>
15
19
20namespace ui::adapters {
21class ExportAdapter;
22}
23
24namespace ui {
25
29class ExportWorkflow : public QObject {
30 Q_OBJECT
31public:
32 enum Mode {
35 };
36
40 std::function<void(const core::ports::workspace::ExportLogSnapshot&)>;
41
49 explicit ExportWorkflow(
50 StateSnapshotProvider stateSnapshotProvider,
51 std::shared_ptr<ui::adapters::ExportAdapter> exportAdapter,
52 std::shared_ptr<core::ports::diagnostics::IErrorReporter> errorReporter,
53 QObject* parent = nullptr);
54
60
63 bool isRunning() const noexcept {
64 return isRunning_;
65 }
66
67 bool isPaused() const noexcept {
68 return isPaused_;
69 }
70
71 double progress() const noexcept {
72 return progress_;
73 }
74
75 QString phase() const {
76 return phase_;
77 }
78
79 QString error() const {
80 return lastError_;
81 }
82
86 int currentMode() const noexcept;
87
97 void exportDataWithPayload(int format, const QString& path,
98 bool includeFormulas, const QString& locale,
99 const QVariantMap& payload, int totalSteps = 1);
107 void cancelExport();
111 void pauseExport();
115 void resumeExport();
116
117signals:
126 void exportFinished(bool success);
131 void exportFailed(const QString& error);
132
133private slots:
135 void onExportFinished();
136
137private:
147 core::ports::exporting::ExportRequest
148 buildRequest(int format, const QString& path, bool includeFormulas,
149 const QString& locale, const QVariantMap& payload) const;
154 void publishExportLog(const core::ports::workspace::ExportLogSnapshot& log);
163 core::ports::workspace::ExportLogSnapshot
164 publishExportLogById(const QString& logId, const QString& path,
165 const QString& status, const QString& message);
171 void finishExport(bool success, const QString& outputPath = QString());
175 void finishCanceled();
180 core::ports::workspace::WorkspaceSnapshot stateSnapshot() const;
181 struct ExportControlState;
182
183 StateSnapshotProvider stateSnapshotProvider_;
184 ExportLogSink exportLogSink_;
185 std::shared_ptr<ui::adapters::ExportAdapter> exportAdapter_;
186 std::shared_ptr<core::ports::diagnostics::IErrorReporter> errorReporter_;
187 std::shared_ptr<ExportControlState> exportControl_;
188 QFuture<core::ports::exporting::ExportResult> exportFuture_;
189 QFutureWatcher<core::ports::exporting::ExportResult> exportWatcher_;
190 bool isRunning_ = false;
191 bool isPaused_ = false;
192 bool cancelRequested_ = false;
193 double progress_ = 0.0;
194 QString phase_;
195 int totalSteps_ = 1;
196 int completedSteps_ = 0;
197 QString activeExportLogId_;
198 QString activeExportPath_;
199 QString lastError_;
200};
201
202} // namespace ui
Declares the export execution result port contract.
Declares the structured diagnostics reporting port.
Immutable workspace read-model snapshot exposed through workspace ports.
void exportDataWithPayload(int format, const QString &path, bool includeFormulas, const QString &locale, const QVariantMap &payload, int totalSteps=1)
Starts an export using a QML selection payload.
void exportFailed(const QString &error)
Emitted when an export failed.
int currentMode() const noexcept
Returns the current export workflow mode.
void setExportLogSink(ExportLogSink sink)
Sets the sink used to save export logs through workspace commands.
void pauseExport()
Pauses the running export.
std::function< void(const core::ports::workspace::ExportLogSnapshot &)> ExportLogSink
QString error() const
Returns current export error text.
void clearActiveExportLog()
Clears the active export log selection.
void cancelExport()
Requests cancellation of the running export.
ExportWorkflow(StateSnapshotProvider stateSnapshotProvider, std::shared_ptr< ui::adapters::ExportAdapter > exportAdapter, std::shared_ptr< core::ports::diagnostics::IErrorReporter > errorReporter, QObject *parent=nullptr)
Creates an export workflow backed by a snapshot provider and runner.
bool isRunning() const noexcept
Reports whether an export is running.
bool isPaused() const noexcept
Reports whether the export is paused.
void stateChanged()
Emitted when export workflow state changed.
QString phase() const
Returns current export phase text.
std::function< core::ports::workspace::WorkspaceSnapshot()> StateSnapshotProvider
void exportFinished(bool success)
Emitted when an export finished or stopped.
double progress() const noexcept
Returns export progress.
void resumeExport()
Resumes the paused export.