1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-24 06:23:54 +00:00
openmw/apps/opencs/model/doc/operation.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
1.8 KiB
C++
Raw Normal View History

#ifndef CSM_DOC_OPERATION_H
#define CSM_DOC_OPERATION_H
2012-12-08 14:25:50 +00:00
#include <chrono>
#include <optional>
2022-10-19 17:02:00 +00:00
#include <utility>
2012-12-08 16:53:45 +00:00
#include <vector>
#include <QObject>
2012-12-08 14:25:50 +00:00
#include "messages.hpp"
#include "state.hpp"
2022-10-09 10:39:43 +00:00
class QTimer;
namespace CSMDoc
2012-12-08 14:25:50 +00:00
{
2012-12-08 16:53:45 +00:00
class Stage;
class Operation : public QObject
2012-12-08 14:25:50 +00:00
{
Q_OBJECT
2012-12-08 16:53:45 +00:00
State mType;
2012-12-08 16:53:45 +00:00
std::vector<std::pair<Stage*, int>> mStages; // stage, number of steps
std::vector<std::pair<Stage*, int>>::iterator mCurrentStage;
int mCurrentStep;
int mCurrentStepTotal;
int mTotalSteps;
int mOrdered;
bool mFinalAlways;
bool mError;
bool mConnected;
QTimer* mTimer;
2012-12-08 16:53:45 +00:00
bool mPrepared;
Message::Severity mDefaultSeverity;
std::optional<std::chrono::steady_clock::time_point> mStart;
2012-12-08 14:25:50 +00:00
void prepareStages();
2022-09-22 18:26:05 +00:00
public:
Operation(State type, bool ordered, bool finalAlways = false);
///< \param ordered Stages must be executed in the given order.
/// \param finalAlways Execute last stage even if an error occurred during earlier stages.
2012-12-08 14:25:50 +00:00
2012-12-08 16:53:45 +00:00
virtual ~Operation();
void appendStage(Stage* stage);
///< The ownership of \a stage is transferred to *this.
///
/// \attention Do no call this function while this Operation is running.
/// \attention Do no call this function while this Operation is running.
void setDefaultSeverity(Message::Severity severity);
bool hasError() const;
2012-12-08 14:25:50 +00:00
signals:
void progress(int current, int max, int type);
void reportMessage(const CSMDoc::Message& message, int type);
void done(int type, bool failed);
2013-09-15 09:35:12 +00:00
2012-12-08 14:25:50 +00:00
public slots:
void abort();
void run();
2012-12-08 14:25:50 +00:00
private slots:
2013-09-15 07:32:20 +00:00
void executeStage();
2013-09-15 09:35:12 +00:00
protected slots:
virtual void operationDone();
2012-12-08 14:25:50 +00:00
};
}
#endif